change: use Gtk.present_window_with_time()

This commit is contained in:
aclist 2026-05-13 20:48:50 +09:00
parent 866c88fbb0
commit fb62fe285d
6 changed files with 11 additions and 20 deletions

View File

@ -17,4 +17,3 @@ class UserPrefs:
allow_updates: bool
paths: "Xdg"
use_miles: bool
foreground_cmd: str | None

View File

@ -497,3 +497,6 @@ class Controller(GObject.GObject):
def get_steam_client_name(self) -> str:
return self.mediator.options.get_client_name()
def present_window(self) -> None:
self.mediator.window.present_with_time(Gdk.CURRENT_TIME)

View File

@ -60,6 +60,7 @@ def has_cmd(cmd: str) -> bool:
return False
@deprecated("dropped in favor of Gtk native methods")
def foreground(cmd: str, pid: int) -> None:
if cmd == "wmctrl":
proc = subprocess.run(["wmctrl", "-ilp"], capture_output=True, text=True)

View File

@ -7,7 +7,7 @@ import warnings
from typing import TYPE_CHECKING
from dzgui.api.mods import remove_stale_signatures
from dzgui.const.constants import APP_NAME, FOREGROUND_CMDS
from dzgui.const.constants import APP_NAME
from dzgui.const.enum import Preferences
from dzgui.config.ipdb import get_ipdb
from dzgui.config.query import lookup
@ -142,12 +142,6 @@ def main() -> None:
local_coords = get_local_coords(XDG.ips)
use_miles = lookup(XDG.config, Preferences.DIST)
tool = None
for cmd in FOREGROUND_CMDS:
if has_cmd(cmd) is True:
tool = cmd
break
prefs = UserPrefs(
is_steam_deck=_is_steam_deck,
is_game_mode=_is_game_mode,
@ -157,7 +151,6 @@ def main() -> None:
allow_updates=allow,
paths=XDG,
use_miles=use_miles,
foreground_cmd=tool,
)
# TODO: drop allow updates
print(boot.all_ok)

View File

@ -32,7 +32,7 @@ from dzgui.const.constants import (
APPNAME_DAYZ_EXP,
)
from dzgui.const.enum import NotebookPage, Preferences
from dzgui.init.proc import foreground, is_dayz_running, is_steam_running
from dzgui.init.proc import is_dayz_running, is_steam_running
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.strings.dialogs import waiting_for_launch, waiting_for_mods
from dzgui.strings.server_mods import checkmark, resync
@ -74,7 +74,6 @@ class Prerequisites:
dayz_running: bool
steam_proc: SteamProcess
mods: list[list[str]]
foreground_cmd: str | None
game_mode: bool
@ -167,7 +166,6 @@ class ConnectionManager:
running = is_steam_running(client)
steam_proc = SteamProcess(client_name, running)
self.foreground_cmd = prefs.foreground_cmd
game_mode = prefs.is_game_mode
prereqs = Prerequisites(
@ -183,7 +181,6 @@ class ConnectionManager:
dayz_running=dayz_running,
steam_proc=steam_proc,
mods=remote_mods,
foreground_cmd=self.foreground_cmd, # TODO: change to bool
game_mode=game_mode,
)
@ -281,10 +278,9 @@ class ConnectionManager:
enqueue_mod(mod, self.appid)
time.sleep(2)
if self.foreground_cmd is not None and raise_window is True:
pid = os.getpid()
logger.info(f"Raising window with '{self.foreground_cmd}'")
foreground(self.foreground_cmd, pid)
if raise_window is True:
logger.info(f"Bringing window to foreground")
GLib.idle_add(self.controller.present_window)
for title, mod, stamp, size in self.missing_mods:
mod_path = self.workshop / mod

View File

@ -116,7 +116,7 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
visible=False,
has_tooltip=True,
sensitive=False,
tooltip_text="This option is available if wmctrl or xdotool is installed on the system",
tooltip_text="Foreground the DZGUI window after mod downloads are queued",
active=True,
)
self.button_box = Gtk.Box(
@ -303,8 +303,7 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
self.raise_window.set_visible(False)
else:
self.raise_window.set_visible(True)
if prereqs.foreground_cmd is not None:
self.raise_window.set_sensitive(True)
self.raise_window.set_sensitive(True)
pretty = number(prereqs.required_space)
suffix = f" Need to download {pretty} MiB of mod updates."