Skip to content

Commit

Permalink
#3859 keyboard support should not require dbus
Browse files Browse the repository at this point in the history
only the gnome input source bits do
  • Loading branch information
totaam committed Jul 24, 2024
1 parent 0205881 commit 9099fee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xpra/platform/posix/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from collections.abc import Iterable, Sequence

from xpra.platform.keyboard_base import KeyboardBase
from xpra.dbus.helper import DBusHelper, native_to_dbus, dbus_to_native
from xpra.keyboard.mask import MODIFIER_MAP
from xpra.log import Logger
from xpra.util.env import first_time
Expand Down Expand Up @@ -45,6 +44,7 @@ def init_vars(self) -> None:
self.keyboard_bindings = None
self.__input_sources: dict[str, int] = {}
try:
from xpra.dbus.helper import DBusHelper
self.__dbus_helper = DBusHelper()
# we really want to catch `dbus.exceptions.DBusException` here instead:
except Exception as e:
Expand All @@ -62,6 +62,8 @@ def _store_input_sources(self, input_sources: Iterable) -> None:
self.__input_sources[layout] = index

def _dbus_gnome_shell_ism(self, method, args, callback=None) -> None:
from xpra.dbus.helper import dbus_to_native

def ok_cb(success, res) -> None:
try:
if not dbus_to_native(success):
Expand Down Expand Up @@ -96,6 +98,7 @@ def err_cb(msg) -> None:
)

def _dbus_gnome_shell_eval_ism(self, cmd, callback=None) -> None:
from xpra.dbus.helper import dbus_to_native, native_to_dbus
ism = "imports.ui.status.keyboard.getInputSourceManager()"

def ok_cb(success, res) -> None:
Expand Down Expand Up @@ -127,7 +130,9 @@ def set_platform_layout(self, layout: str) -> None:
if index is None:
log(f"asked layout ({layout}) has no corresponding registered input source")
return
self._dbus_gnome_shell_ism("Activate", [native_to_dbus(index)])
if self.__dbus_helper:
from xpra.dbus.helper import native_to_dbus
self._dbus_gnome_shell_ism("Activate", [native_to_dbus(index)])

def __repr__(self):
return "posix.Keyboard"
Expand Down

0 comments on commit 9099fee

Please sign in to comment.