Skip to content

Commit

Permalink
fix some GTK3 deprecation warnings: keymaps are per-display
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@19697 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 24, 2018
1 parent 71d6b15 commit c838746
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/xpra/client/gtk_base/gtk_keyboard_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/xpra/gtk_common/gtk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/xpra/gtk_common/keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/server/gtk_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/x11/server_keyboard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit c838746

Please sign in to comment.