Skip to content

Commit

Permalink
add more dbus methods, including x11 specific ones
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@10740 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 5, 2015
1 parent c4af448 commit ee119ca
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 7 deletions.
27 changes: 26 additions & 1 deletion src/xpra/server/dbus_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from xpra.dbus.helper import dbus_to_native
from xpra.dbus.common import init_session_bus
from xpra.util import parse_scaling_value, from0to100
from xpra.util import parse_scaling_value, from0to100, AdHocStruct
import dbus.service

from xpra.log import Logger, add_debug_category, remove_debug_category, disable_debug_for, enable_debug_for
Expand Down Expand Up @@ -120,6 +120,31 @@ def KeyPress(self, keycode):
def KeyRelease(self, keycode):
self.server.control_command_key(keycode, press=False)

@dbus.service.method(INTERFACE)
def ClearKeysPressed(self):
self.server._clear_keys_pressed()

@dbus.service.method(INTERFACE, in_signature='ii')
def SetKeyboardRepeat(self, repeat_delay, repeat_interval):
self.server.set_keyboard_repeat(repeat_delay, repeat_interval)


@dbus.service.method(INTERFACE, in_signature='iii')
def MovePointer(self, wid, x, y):
self.server._move_pointer(wid, (x, y))

@dbus.service.method(INTERFACE, in_signature='iibiias')
def MouseClick(self, wid, button, pressed, x, y, modifiers):
packet = [wid, button, pressed, (x, y), modifiers]
self.server._process_button_action(None, packet)


@dbus.service.method(INTERFACE, in_signature='iiii')
def SetWorkarea(self, x, y, w, h):
workarea = AdHocStruct()
workarea.x, workarea.y, workarea.width, workarea.height = x, y, w, h
self.server.set_workarea(workarea)


@dbus.service.method(INTERFACE, in_signature='', out_signature='v')
def ListWindows(self):
Expand Down
11 changes: 11 additions & 0 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,4 +1239,15 @@ def root_set(p):
root_set("PULSE_SERVER")


def init_dbus_server(self):
if not self.dbus_control:
return
try:
from xpra.x11.x11_dbus_server import X11_DBUS_Server
self.dbus_server = X11_DBUS_Server(self, os.environ.get("DISPLAY", "").lstrip(":"))
except Exception as e:
log.error("Error setting up our dbus server:")
log.error(" %s", e)


gobject.type_register(XpraServer)
30 changes: 30 additions & 0 deletions src/xpra/x11/x11_dbus_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2015 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

from xpra.server.dbus_server import DBUS_Server, INTERFACE
import dbus.service

from xpra.log import Logger
log = Logger("dbus", "server")


class X11_DBUS_Server(DBUS_Server):

@dbus.service.method(INTERFACE)
def SyncVfb(self):
self.server.do_repaint_root_overlay()

@dbus.service.method(INTERFACE)
def ResetXSettings(self):
self.server.update_all_server_settings(True)

@dbus.service.method(INTERFACE, in_signature='ii')
def SetDPI(self, xdpi, ydpi):
self.server.set_dpi()

@dbus.service.method(INTERFACE, in_signature='ii', out_signature='ii')
def SetScreenSize(self, width, height):
return self.server.set_screen_size(width, height)
11 changes: 5 additions & 6 deletions src/xpra/x11/x11_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,16 +466,15 @@ def _move_pointer(self, wid, pos):
X11Keyboard.xtest_fake_motion(self.screen_number, x, y)

def _process_mouse_common(self, proto, wid, pointer, modifiers):
ss = self._server_sources.get(proto)
if ss is None:
return
pos = self.root_window.get_pointer()[:2]
if pos!=pointer:
with xswallow:
self._move_pointer(wid, pointer)
ss.make_keymask_match(modifiers)
if wid==self.get_focus():
ss.user_event()
ss = self._server_sources.get(proto)
if ss:
ss.make_keymask_match(modifiers)
if wid==self.get_focus():
ss.user_event()

def _process_button_action(self, proto, packet):
ss = self._server_sources.get(proto)
Expand Down

0 comments on commit ee119ca

Please sign in to comment.