Re: [hatari-devel] Hatari window embedding issue |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Hatari window embedding issue
- From: Jens Guenther <dbotw@xxxxxxx>
- Date: Fri, 18 Dec 2020 17:21:52 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608308513; bh=jg/d1trFxNkMNjz8Bwbg0tlfEpn06yOaZo+wznloXLk=; h=X-UI-Sender-Class:Date:From:To:Subject:In-Reply-To:References; b=VgRfZlVpb+bW3zfurFnL3zoUFPPqr5U/FjK6gum7mlXBWTkMi2ogmAguIPrOtG2y+ kVP/aN4ITeb3E6nzghW3FWdDqgPmBsf2BjMYjQTSNR6Nmh6Ks9iG8YhMInhvXBdGMt l+pffXq3xlPcFqAjVgVR4GmUYmy4eJRWO6vPCCJY=
Hi,
Eero Tamminen <oak@xxxxxxxxxxxxxx> wrote:
> Is the fixed version of Hatari first thing in your PATH?
Yes. Tested with SDL2 verions 2.0.9 (BunsenLabs) and 2.0.12 (ArcoLinux) and
both show the same behavior: "hatariui" with embedded SDL2 renderer window,
pressing F11 twice brings the black area back. But sometimes it works after
toggling the fullscreen mode several times ...
> I think most, if not all deprecation warnings
> can be fixed with APIs in that Gtk version.
OK, no more cheap excuses ... a first attempt is attached ... ;-)
Seems that changing the background color now requires CSS ... %-)
Jens
diff --git a/python-ui/hatariui.py b/python-ui/hatariui.py
index 150b8e08..83d82d49 100755
--- a/python-ui/hatariui.py
+++ b/python-ui/hatariui.py
@@ -2,7 +2,7 @@
#
# A Python Gtk UI for Hatari that can embed the Hatari emulator window.
#
-# Requires Gtk 3.x and Python GObject Introspection libraries.
+# Requires Gtk 3.x and Python GLib Introspection libraries.
#
# Copyright (C) 2008-2020 by Eero Tamminen
#
@@ -25,7 +25,7 @@ import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
-from gi.repository import GObject
+from gi.repository import GLib
from debugui import HatariDebugUI
from hatari import Hatari, HatariConfigMapping
@@ -150,7 +150,10 @@ class UICallbacks:
socket.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("black"))
socket.set_events(Gdk.EventMask.ALL_EVENTS_MASK)
# set max Hatari window size = desktop size
- self.config.set_desktop_size(Gdk.Screen.width(), Gdk.Screen.height())
+ monitor = Gdk.Display.get_default().get_primary_monitor()
+ geometry = monitor.get_geometry()
+ scale = monitor.get_scale_factor()
+ self.config.set_desktop_size(scale * geometry.width, scale * geometry.height)
# set initial embedded hatari size
width, height = self.config.get_window_size()
socket.set_size_request(width, height)
@@ -160,7 +163,7 @@ class UICallbacks:
# ------- run callback -----------
def _socket_cb(self, fd, event):
- if event != GObject.IO_IN:
+ if event != GLib.IO_IN:
# hatari process died, make sure Hatari instance notices
self.hatari.kill()
return False
@@ -177,7 +180,7 @@ class UICallbacks:
if not self.killdialog.run(self.hatari):
return
if self.io_id:
- GObject.source_remove(self.io_id)
+ GLib.source_remove(self.io_id)
args = ["--configfile"]
# whether to use Hatari config or unsaved Hatari UI config?
if self.config.is_changed():
@@ -194,8 +197,8 @@ class UICallbacks:
# get notifications of Hatari window size changes
self.hatari.enable_embed_info()
socket = self.hatari.get_control_socket().fileno()
- events = GObject.IO_IN | GObject.IO_HUP | GObject.IO_ERR
- self.io_id = GObject.io_add_watch(socket, events, self._socket_cb)
+ events = GLib.IO_IN | GLib.IO_HUP | GLib.IO_ERR
+ self.io_id = GLib.io_add_watch(socket, events, self._socket_cb)
# all keyboard events should go to Hatari window
self.hatariwin.grab_focus()
else:
@@ -215,7 +218,7 @@ class UICallbacks:
if not self.killdialog.run(self.hatari):
return True
if self.io_id:
- GObject.source_remove(self.io_id)
+ GLib.source_remove(self.io_id)
Gtk.main_quit()
if os.path.exists(self.tmpconfpath):
os.unlink(self.tmpconfpath)
@@ -661,7 +664,7 @@ class UIActions:
# ugly, Hatari socket window ID can be gotten only
# after Socket window is realized by gtk_main()
- GObject.idle_add(self.callbacks.run)
+ GLib.idle_add(self.callbacks.run)
Gtk.main()