From c838746d95d4c0972d41ecafec4eb463bcaa3fd8 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 24 Jun 2018 08:28:22 +0000 Subject: [PATCH] fix some GTK3 deprecation warnings: keymaps are per-display git-svn-id: https://xpra.org/svn/Xpra/trunk@19697 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gtk_base/gtk_keyboard_helper.py | 8 +++++--- src/xpra/gtk_common/gtk_util.py | 2 -- src/xpra/gtk_common/keymap.py | 7 ++++--- src/xpra/server/gtk_server_base.py | 5 +++-- src/xpra/x11/server_keyboard_config.py | 5 +++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/xpra/client/gtk_base/gtk_keyboard_helper.py b/src/xpra/client/gtk_base/gtk_keyboard_helper.py index fe54798180..35820c75cc 100644 --- a/src/xpra/client/gtk_base/gtk_keyboard_helper.py +++ b/src/xpra/client/gtk_base/gtk_keyboard_helper.py @@ -8,7 +8,7 @@ from xpra.client.keyboard_helper import KeyboardHelper, log from xpra.gtk_common.gobject_compat import import_gdk, import_glib from xpra.gtk_common.keymap import get_gtk_keymap -from xpra.gtk_common.gtk_util import display_get_default, get_default_keymap +from xpra.gtk_common.gtk_util import display_get_default, keymap_get_for_display gdk = import_gdk() glib = import_glib() @@ -21,7 +21,8 @@ def __init__(self, *args): #(as we may be getting dozens of such events at a time) self._keymap_changing = False self._keymap_change_handler_id = None - self._keymap = get_default_keymap() + display = display_get_default() + self._keymap = keymap_get_for_display(display) self.update() if self._keymap: self._keymap_change_handler_id = self._keymap.connect("keys-changed", self.keymap_changed) @@ -31,7 +32,8 @@ def keymap_changed(self, *args): if self._keymap_change_handler_id: self._keymap.disconnect(self._keymap_change_handler_id) self._keymap_change_handler_id = None - self._keymap = get_default_keymap() + display = display_get_default() + self._keymap = keymap_get_for_display(display) if self._keymap_changing: #timer due already return diff --git a/src/xpra/gtk_common/gtk_util.py b/src/xpra/gtk_common/gtk_util.py index f5f72f778a..aeb5ce13a4 100644 --- a/src/xpra/gtk_common/gtk_util.py +++ b/src/xpra/gtk_common/gtk_util.py @@ -176,7 +176,6 @@ def gdk_cairo_context(cairo_context): def pixbuf_new_from_data(*args): args = list(args)+[None, None] return GdkPixbuf.Pixbuf.new_from_data(*args) - get_default_keymap = gdk.Keymap.get_default display_get_default = gdk.Display.get_default screen_get_default = gdk.Screen.get_default cairo_set_source_pixbuf = gdk.cairo_set_source_pixbuf @@ -430,7 +429,6 @@ def get_default_cursor(): image_new_from_pixbuf = gtk.image_new_from_pixbuf pixbuf_new_from_file = gdk.pixbuf_new_from_file pixbuf_new_from_data = gdk.pixbuf_new_from_data - get_default_keymap = gdk.keymap_get_default display_get_default = gdk.display_get_default screen_get_default = gdk.screen_get_default window_set_default_icon = gtk.window_set_default_icon diff --git a/src/xpra/gtk_common/keymap.py b/src/xpra/gtk_common/keymap.py index 6f47db8578..240b4d2f19 100755 --- a/src/xpra/gtk_common/keymap.py +++ b/src/xpra/gtk_common/keymap.py @@ -20,10 +20,11 @@ def get_gtk_keymap(ignore_keys=[None, "VoidSymbol", "0xffffff"]): by adding the keyval_name. We can also ignore some keys """ - from xpra.gtk_common.gtk_util import get_default_keymap, import_gdk, is_gtk3 + from xpra.gtk_common.gtk_util import keymap_get_for_display, display_get_default, import_gdk, is_gtk3 gdk = import_gdk() - keymap = get_default_keymap() - log("get_default_keymap()=%s, direction=%s, bidirectional layouts: %s", keymap, keymap.get_direction(), keymap.have_bidi_layouts()) + display = display_get_default() + keymap = keymap_get_for_display(display) + log("keymap_get_for_display(%s)=%s, direction=%s, bidirectional layouts: %s", display, keymap, keymap.get_direction(), keymap.have_bidi_layouts()) keycodes=[] for i in range(0, 2**8): entries = keymap.get_entries_for_keycode(i) diff --git a/src/xpra/server/gtk_server_base.py b/src/xpra/server/gtk_server_base.py index 7b7a337a1f..2de07a92f5 100644 --- a/src/xpra/server/gtk_server_base.py +++ b/src/xpra/server/gtk_server_base.py @@ -23,7 +23,7 @@ gtk_main_quit_on_fatal_exceptions_enable, gtk_main_quit_on_fatal_exceptions_disable) from xpra.server.server_base import ServerBase -from xpra.gtk_common.gtk_util import get_gtk_version_info, gtk_main, display_get_default, get_root_size, get_default_keymap +from xpra.gtk_common.gtk_util import get_gtk_version_info, gtk_main, display_get_default, get_root_size, keymap_get_for_display glib = import_glib() glib.threads_init() @@ -51,7 +51,8 @@ def __init__(self): def watch_keymap_changes(self): ### Set up keymap change notification: - keymap = get_default_keymap() + display = display_get_default() + keymap = keymap_get_for_display(display) keymap.connect("keys-changed", self._keys_changed) def signal_quit(self, signum, frame=None): diff --git a/src/xpra/x11/server_keyboard_config.py b/src/xpra/x11/server_keyboard_config.py index 4b90b40032..c2b921a8c0 100644 --- a/src/xpra/x11/server_keyboard_config.py +++ b/src/xpra/x11/server_keyboard_config.py @@ -15,7 +15,7 @@ from xpra.os_util import bytestostr from xpra.gtk_common.keymap import get_gtk_keymap from xpra.x11.gtk_x11.keys import grok_modifier_map -from xpra.gtk_common.gtk_util import get_default_keymap, display_get_default, get_default_root_window +from xpra.gtk_common.gtk_util import keymap_get_for_display, display_get_default, get_default_root_window from xpra.keyboard.mask import DEFAULT_MODIFIER_NUISANCE, DEFAULT_MODIFIER_NUISANCE_KEYNAMES, mask_to_names from xpra.server.keyboard_config_base import KeyboardConfigBase from xpra.x11.xkbhelper import do_set_keymap, set_all_keycodes, set_keycode_translation, \ @@ -173,7 +173,8 @@ def hashadd(v): def compute_modifier_keynames(self): self.keycodes_for_modifier_keynames = {} self.xkbmap_mod_nuisance = set(DEFAULT_MODIFIER_NUISANCE) - keymap = get_default_keymap() + display = display_get_default() + keymap = keymap_get_for_display(display) gdk = import_gdk() if self.keynames_for_mod: for modifier, keynames in self.keynames_for_mod.items():