Skip to content

Commit

Permalink
#1925: completely disable X11 bindings under wayland with GTK3
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@20066 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 12, 2018
1 parent d28fc58 commit 2a38fac
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 148 deletions.
4 changes: 2 additions & 2 deletions src/xpra/client/gtk3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from xpra.log import Logger
log = Logger("gtk", "client")

from xpra.os_util import OSX, POSIX
if POSIX and not OSX:
from xpra.os_util import OSX, POSIX, PYTHON2, is_Wayland
if POSIX and not OSX and (not is_Wayland() or PYTHON2):
try:
from xpra.x11.gtk3.gdk_display_source import init_gdk_display_source
init_gdk_display_source()
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
draglog = Logger("dragndrop")


from xpra.os_util import bytestostr, WIN32, OSX, POSIX, PYTHON3
from xpra.os_util import bytestostr, is_Wayland, WIN32, OSX, POSIX, PYTHON3, PYTHON2
from xpra.util import (AdHocStruct, typedict, envint, envbool, nonl, csv,
WORKSPACE_UNSET, WORKSPACE_ALL, WORKSPACE_NAMES, MOVERESIZE_DIRECTION_STRING, SOURCE_INDICATION_STRING,
MOVERESIZE_CANCEL,
Expand All @@ -58,7 +58,7 @@

CAN_SET_WORKSPACE = False
HAS_X11_BINDINGS = False
USE_X11_BINDINGS = envbool("XPRA_USE_X11_BINDINGS", True)
USE_X11_BINDINGS = envbool("XPRA_USE_X11_BINDINGS", not is_Wayland or PYTHON2)
SET_WORKSPACE = envbool("XPRA_SET_WORKSPACE", True)
if POSIX and USE_X11_BINDINGS:
try:
Expand Down
12 changes: 7 additions & 5 deletions src/xpra/client/gtk_base/gtk_keyboard_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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, keymap_get_for_display
from xpra.os_util import is_Wayland, PYTHON2
gdk = import_gdk()
glib = import_glib()

Expand Down Expand Up @@ -56,11 +57,12 @@ def do_keys_changed():
def update(self):
old_hash = self.hash
self.query_xkbmap()
try:
self.keyboard.update_modifier_map(display_get_default(), self.xkbmap_mod_meanings)
except:
log.error("error querying modifier map", exc_info=True)
log("do_keys_changed() modifier_map=%s, old hash=%s, new hash=%s", self.keyboard.modifier_map, old_hash, self.hash)
if not is_Wayland() or PYTHON2:
try:
self.keyboard.update_modifier_map(display_get_default(), self.xkbmap_mod_meanings)
except:
log.error("error querying modifier map", exc_info=True)
log("update() modifier_map=%s, old hash=%s, new hash=%s", self.keyboard.modifier_map, old_hash, self.hash)
return old_hash!=self.hash

def get_full_keymap(self):
Expand Down
8 changes: 5 additions & 3 deletions src/xpra/client/mixins/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ def get_caps(self):

self._last_screen_settings = self.get_screen_settings()
root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h, _, _ = self._last_screen_settings
caps["desktop_size"] = self.cp(u_root_w, u_root_h)
caps["desktops"] = ndesktops
caps["desktop.names"] = desktop_names
if u_root_w and u_root_h:
caps["desktop_size"] = self.cp(u_root_w, u_root_h)
if ndesktops:
caps["desktops"] = ndesktops
caps["desktop.names"] = desktop_names

ss = self.get_screen_sizes()
self._current_screen_sizes = ss
Expand Down
13 changes: 7 additions & 6 deletions src/xpra/clipboard/clipboard_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from xpra.gtk_common.gtk_util import GetClipboard, selection_owner_set, selection_add_target, selectiondata_get_selection, selectiondata_get_target, selectiondata_get_data, selectiondata_get_data_type, selectiondata_get_format, selectiondata_set, clipboard_request_contents, PROPERTY_CHANGE_MASK
from xpra.gtk_common.nested_main import NestedMainLoop
from xpra.net.compression import Compressible
from xpra.os_util import WIN32, POSIX, monotonic_time, strtobytes, bytestostr, hexstr, get_hex_uuid
from xpra.os_util import WIN32, POSIX, PYTHON2, monotonic_time, strtobytes, bytestostr, hexstr, get_hex_uuid, is_Wayland
from xpra.util import csv, envint, envbool, repr_ellipsized, typedict
from xpra.platform.features import CLIPBOARD_GREEDY

Expand Down Expand Up @@ -614,11 +614,12 @@ def __init__(self, selection):
self._request_contents_events = 0
self._last_targets = ()

try:
from xpra.x11.gtk_x11.prop import prop_get
self.prop_get = prop_get
except ImportError:
self.prop_get = None
if not is_Wayland() or PYTHON2:
try:
from xpra.x11.gtk_x11.prop import prop_get
self.prop_get = prop_get
except ImportError:
self.prop_get = None

self._loop_uuid = ""
self._clipboard.connect("owner-change", self.do_owner_changed)
Expand Down
9 changes: 5 additions & 4 deletions src/xpra/gtk_common/gtk_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os.path
import array
from xpra.util import iround
from xpra.util import iround, first_time
from xpra.os_util import strtobytes, bytestostr, WIN32
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, import_glib, import_pixbufloader, import_pango, import_cairo, import_gobject, import_pixbuf, is_gtk3
gtk = import_gtk()
Expand Down Expand Up @@ -153,9 +153,10 @@ def get_root_size():
root = get_default_root_window()
w, h = root.get_geometry()[2:4]
if w<=0 or h<=0 or w>32768 or h>32768:
log.warn("Warning: Gdk returned invalid root window dimensions: %ix%i", w, h)
w, h = 1920, 1080
log.warn(" using %ix%i instead", w, h)
if first_time("Gtk root window dimensions"):
log.warn("Warning: Gdk returned invalid root window dimensions: %ix%i", w, h)
w, h = 1920, 1080
log.warn(" using %ix%i instead", w, h)
return w, h

keymap_get_for_display = gdk.Keymap.get_for_display
Expand Down
5 changes: 5 additions & 0 deletions src/xpra/os_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ def uupdate(ustr):
except Exception as e:
pass


def is_Wayland():
return os.environ.get("WAYLAND_DISPLAY") or os.environ.get("XDG_SESSION_TYPE")=="wayland"


def is_distribution_variant(variant=b"Debian", os_file="/etc/os-release"):
if not POSIX:
return False
Expand Down
Loading

0 comments on commit 2a38fac

Please sign in to comment.