Skip to content

Commit

Permalink
#853 desktop server
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@20762 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 22, 2018
1 parent 2abcb22 commit 57b3267
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 57 deletions.
4 changes: 3 additions & 1 deletion src/xpra/platform/xposix/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ def get_wm_name():
traylog("_NET_SUPPORTING_WM_CHECK window=%#x", xid)
wm_name = _get_X11_window_property(xid, "_NET_WM_NAME", "UTF8_STRING")
traylog("_NET_WM_NAME=%s", wm_name)
return wm_name.decode("utf-8")
if wm_name:
return wm_name.decode("utf-8")
except Exception as e:
traylog("get_wm_name()", exc_info=True)
traylog.error("Error accessing window manager information:")
traylog.error(" %s", e)
return wm_name
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def kill_dbus():
log("XShape=%s", X11Window.displayHasXShape())
app = make_server(clobber)
else:
assert starting_desktop and not PYTHON3
assert starting_desktop
app = make_desktop_server()
app.init_virtual_devices(devices)

Expand Down
3 changes: 2 additions & 1 deletion src/xpra/x11/bindings/ximage.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import absolute_import

import errno as pyerrno
from xpra.os_util import strtobytes
from libc.stdint cimport uint64_t, uintptr_t
from xpra.buffers.membuf cimport memory_as_pybuffer, object_as_buffer
from xpra.monotonic_time cimport monotonic_time
Expand Down Expand Up @@ -439,7 +440,7 @@ cdef class XImageWrapper(object):
self.rowstride = rowstride

def set_pixel_format(self, pixel_format):
assert pixel_format is not None and pixel_format in RGB_FORMATS, "invalid pixel format: %s" % pixel_format
assert pixel_format is not None and strtobytes(pixel_format) in RGB_FORMATS, "invalid pixel format: %s" % pixel_format
self.pixel_format = pixel_format

def set_pixels(self, pixels):
Expand Down
38 changes: 20 additions & 18 deletions src/xpra/x11/desktop_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# later version. See the file COPYING for details.

import os
from gtk import gdk
import gobject
import socket

from xpra.os_util import get_generic_os_name
Expand All @@ -17,16 +15,18 @@
from xpra.gtk_common.gobject_util import one_arg_signal, no_arg_signal
from xpra.gtk_common.gobject_compat import import_glib
from xpra.gtk_common.error import xswallow
from xpra.gtk_common.gtk_util import get_screen_sizes, get_root_size, get_xwindow
from xpra.x11.gtk2.models.model_stub import WindowModelStub
from xpra.x11.gtk2.gdk_bindings import (
add_catchall_receiver, #@UnresolvedImport
remove_catchall_receiver, #@UnresolvedImport
add_event_receiver, #@UnresolvedImport
init_x11_filter, #@UnresolvedImport
cleanup_x11_filter, #@UnresolvedImport
cleanup_all_event_receivers #@UnresolvedImport
)
from xpra.gtk_common.gtk_util import (
get_screen_sizes, get_root_size,
get_xwindow,
display_get_default,
)
from xpra.x11.models.model_stub import WindowModelStub
from xpra.x11.gtk_x11.gdk_bindings import (
add_catchall_receiver, remove_catchall_receiver,
add_event_receiver, #@UnresolvedImport
init_x11_filter, cleanup_x11_filter, #@UnresolvedImport
cleanup_all_event_receivers #@UnresolvedImport
)
from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
from xpra.x11.xroot_props import XRootPropWatcher
from xpra.x11.gtk_x11.window_damage import WindowDamageHandler
Expand All @@ -37,6 +37,8 @@
RandR = RandRBindings()
from xpra.x11.x11_server_base import X11ServerBase, mouselog
from xpra.gtk_common.error import xsync
from xpra.gtk_common.gobject_compat import import_gobject
gobject = import_gobject()

from xpra.log import Logger
log = Logger("server")
Expand Down Expand Up @@ -99,7 +101,7 @@ def setup(self):
screen = self.client_window.get_screen()
screen.connect("size-changed", self._screen_size_changed)
self.update_size_hints(screen)
self._depth = X11Window.get_depth(self.client_window.xid)
self._depth = X11Window.get_depth(get_xwindow(self.client_window))
self._managed = True
self._setup_done = True

Expand Down Expand Up @@ -154,7 +156,7 @@ def get_default_window_icon(self):

def get_property(self, prop):
if prop=="xid":
return int(self.client_window.xid)
return int(get_xwindow(self.client_window))
elif prop=="depth":
return self._depth
elif prop=="title":
Expand Down Expand Up @@ -286,7 +288,7 @@ def init(self, opts):
def x11_init(self):
X11ServerBase.x11_init(self)
assert init_x11_filter() is True
display = gdk.display_get_default()
display = display_get_default()
screens = display.get_n_screens()
for n in range(screens):
screen = display.get_screen(n)
Expand Down Expand Up @@ -326,11 +328,11 @@ def get_best_screen_size(self, desired_w, desired_h, bigger=False):

def configure_best_screen_size(self):
""" for the first client, honour desktop_mode_size if set """
root_w, root_h = self.root_window.get_size()
root_w, root_h = self.root_window.get_geometry()[2:4]
if not self.randr:
screenlog("configure_best_screen_size() no randr")
return root_w, root_h
sss = self._server_sources.values()
sss = tuple(self._server_sources.values())
if len(sss)!=1:
screenlog.info("screen used by %i clients:", len(sss))
return root_w, root_h
Expand Down Expand Up @@ -410,7 +412,7 @@ def make_hello(self, source):
def load_existing_windows(self):
#at present, just one window is forwarded:
#the root window covering the whole display
display = gdk.display_get_default()
display = display_get_default()
screens = display.get_n_screens()
with xsync:
for n in range(screens):
Expand Down
17 changes: 11 additions & 6 deletions src/xpra/x11/gtk_x11/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from xpra.x11.gtk_x11.window_damage import WindowDamageHandler
from xpra.gtk_common.gobject_util import one_arg_signal, AutoPropGObjectMixin
from xpra.gtk_common.gtk_util import get_xwindow
from xpra.x11.gtk_x11.gdk_bindings import (
add_event_receiver, #@UnresolvedImport
remove_event_receiver, #@UnresolvedImport
Expand Down Expand Up @@ -48,15 +49,17 @@ def __repr__(self):
xid = 0
cw = self.client_window
if cw:
xid = cw.xid
xid = get_xwindow(cw)
return "CompositeHelper(%#x)" % xid

def setup(self):
X11Window.XCompositeRedirectWindow(self.client_window.xid)
xid = get_xwindow(self.client_window)
X11Window.XCompositeRedirectWindow(xid)
WindowDamageHandler.setup(self)

def do_destroy(self, window):
trap.swallow_synced(X11Window.XCompositeUnredirectWindow, window.xid)
xid = get_xwindow(window)
trap.swallow_synced(X11Window.XCompositeUnredirectWindow, xid)
WindowDamageHandler.do_destroy(self, window)

def invalidate_pixmap(self):
Expand Down Expand Up @@ -102,11 +105,13 @@ def _set_pixmap(self):
# corral window selection masks, and those don't deserve
# clobbering. They are our friends! X is driving me
# slowly mad.
X11Window.addXSelectInput(win.xid, StructureNotifyMask)
xid = get_xwindow(win)
X11Window.addXSelectInput(xid, StructureNotifyMask)
add_event_receiver(win, self, max_receivers=-1)
listening.append(win)
win = get_parent(win)
handle = XImage.get_xcomposite_pixmap(self.client_window.xid)
xid = get_xwindow(self.client_window)
handle = XImage.get_xcomposite_pixmap(xid)
except Exception as e:
try:
self._cleanup_listening(listening)
Expand All @@ -118,7 +123,7 @@ def _set_pixmap(self):
win = self.client_window
xid = 0
if win:
xid = win.xid
xid = get_xwindow(win)
log("failed to name a window pixmap for %#x: %s", xid, e)
self._cleanup_listening(listening)
else:
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/x11/gtk_x11/gdk_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
remove_event_receiver = gdk_bindings.remove_event_receiver
add_fallback_receiver = gdk_bindings.add_fallback_receiver
remove_fallback_receiver = gdk_bindings.remove_fallback_receiver
add_catchall_receiver = gdk_bindings.add_catchall_receiver
remove_catchall_receiver = gdk_bindings.remove_catchall_receiver
get_children = gdk_bindings.get_children
init_x11_filter = gdk_bindings.init_x11_filter
cleanup_x11_filter = gdk_bindings.cleanup_x11_filter
Expand Down
28 changes: 16 additions & 12 deletions src/xpra/x11/gtk_x11/window_damage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from xpra.gtk_common.error import trap, xsync, xswallow, XError
from xpra.x11.common import Unmanageable
from xpra.gtk_common.gtk_util import get_xwindow

from xpra.x11.bindings.ximage import XImageBindings #@UnresolvedImport
XImage = XImageBindings()
Expand All @@ -40,7 +41,7 @@ class WindowDamageHandler(object):

# This may raise XError.
def __init__(self, client_window, use_xshm=USE_XSHM):
log("WindowDamageHandler.__init__(%#x, %s)", client_window.xid, use_xshm)
log("WindowDamageHandler.__init__(%#x, %s)", get_xwindow(client_window), use_xshm)
self.client_window = client_window
self._use_xshm = use_xshm
self._damage_handle = None
Expand All @@ -51,12 +52,12 @@ def __init__(self, client_window, use_xshm=USE_XSHM):
def __repr__(self):
xid = None
if self.client_window:
xid = self.client_window.xid
xid = get_xwindow(self.client_window)
return "WindowDamageHandler(%#x)" % xid

def setup(self):
self.invalidate_pixmap()
xid = self.client_window.xid
xid = get_xwindow(self.client_window)
geom = X11Window.geometry_with_border(xid)
if geom is None:
raise Unmanageable("window %#x disappeared already" % xid)
Expand All @@ -65,7 +66,7 @@ def setup(self):
add_event_receiver(self.client_window, self)

def create_damage_handle(self):
xid = self.client_window.xid
xid = get_xwindow(self.client_window)
self._damage_handle = X11Window.XDamageCreate(xid)
log("damage handle(%#x)=%#x", xid, self._damage_handle)

Expand Down Expand Up @@ -123,14 +124,17 @@ def has_xshm(self):
def get_xshm_handle(self):
if not self.has_xshm():
return None
if self._xshm_handle and self._xshm_handle.get_size()!=self.client_window.get_size():
#size has changed!
#make sure the current wrapper gets garbage collected:
self._xshm_handle.cleanup()
self._xshm_handle = None
if self._xshm_handle:
sw, sh = self._xshm_handle.get_size()
ww, wh = self.client_window.get_geometry()[2:4]
if sw!=ww or sh!=wh:
#size has changed!
#make sure the current wrapper gets garbage collected:
self._xshm_handle.cleanup()
self._xshm_handle = None
if self._xshm_handle is None:
#make a new one:
self._xshm_handle = XImage.get_XShmWrapper(self.client_window.xid)
self._xshm_handle = XImage.get_XShmWrapper(get_xwindow(self.client_window))
if self._xshm_handle is None:
#failed (may retry)
return None
Expand All @@ -147,7 +151,7 @@ def get_xshm_handle(self):
return self._xshm_handle

def _set_pixmap(self):
self._contents_handle = XImage.get_xwindow_pixmap_wrapper(self.client_window.xid)
self._contents_handle = XImage.get_xwindow_pixmap_wrapper(get_xwindow(self.client_window))

def get_contents_handle(self):
if not self.client_window:
Expand All @@ -162,7 +166,7 @@ def get_contents_handle(self):
def get_image(self, x, y, width, height):
handle = self.get_contents_handle()
if handle is None:
log("get_image(..) pixmap is None for window %#x", self.client_window.xid)
log("get_image(..) pixmap is None for window %#x", get_xwindow(self.client_window))
return None

#try XShm:
Expand Down
8 changes: 4 additions & 4 deletions src/xpra/x11/gtk_x11/wm.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _manage_client(self, gdkwindow):
l = log.warn
else:
l = log
l("Warning: failed to manage client window %#x:", gdkwindow.xid)
l("Warning: failed to manage client window %#x:", get_xwindow(gdkwindow))
l(" %s", e)
l("", exc_info=True)
with xswallow:
Expand Down Expand Up @@ -375,13 +375,13 @@ def do_xpra_client_message_event(self, event):
#so this must be a an unmapped window
frame = (0, 0, 0, 0)
with xswallow:
if not X11Window.is_override_redirect(event.window.xid):
if not X11Window.is_override_redirect(get_xwindow(event.window)):
#use the global default:
frame = prop_get(self._root, "DEFAULT_NET_FRAME_EXTENTS", ["u32"], ignore_errors=True)
if not frame:
#fallback:
frame = (0, 0, 0, 0)
framelog("_NET_REQUEST_FRAME_EXTENTS: setting _NET_FRAME_EXTENTS=%s on %#x", frame, event.window.xid)
framelog("_NET_REQUEST_FRAME_EXTENTS: setting _NET_FRAME_EXTENTS=%s on %#x", frame, get_xwindow(event.window))
prop_set(event.window, "_NET_FRAME_EXTENTS", ["u32"], frame)

def _lost_wm_selection(self, selection):
Expand Down Expand Up @@ -419,7 +419,7 @@ def do_child_configure_request_event(self, event):
return
log("do_child_configure_request_event(%s) value_mask=%s, reconfigure on withdrawn window", event, configure_bits(event.value_mask))
with xswallow:
xid = event.window.xid
xid = get_xwindow(event.window)
x, y, w, h = X11Window.getGeometry(xid)[:4]
if event.value_mask & CWX:
x = event.x
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/x11/gtk_x11/wm_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def xid(w):
if upgrading and name and name==wm_name:
log.info("found previous Xpra instance")
else:
log.warn("Warning: found an existing window manager on screen %s using window %#x: %s", i, ewmh_wm.xid, name or "unknown")
log.warn("Warning: found an existing window manager on screen %s using window %#x: %s", i, get_xwindow(ewmh_wm), name or "unknown")
if (wm_so is None or wm_so==0) and (cwm_so is None or cwm_so==0):
if FORCE_REPLACE_WM:
log.warn("XPRA_FORCE_REPLACE_WM is set, replacing it forcibly")
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/x11/gtk_x11/world_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from xpra.x11.gtk_x11.send_wm import send_wm_take_focus #@UnresolvedImport
from xpra.x11.gtk_x11.prop import prop_set
from xpra.x11.gtk_x11.gdk_bindings import x11_get_server_time
from xpra.gtk_common.gtk_util import get_default_root_window, screen_get_default
from xpra.gtk_common.gtk_util import get_default_root_window, screen_get_default, get_xwindow
from xpra.gtk_common.gobject_compat import import_gtk, import_gobject
gtk = import_gtk()
gobject = import_gobject()
Expand Down Expand Up @@ -118,7 +118,7 @@ def __init__(self, screen=screen_get_default()):
def __repr__(self):
xid = 0
if self.window:
xid = self.window.xid
xid = get_xwindow(self.window)
return "WorldWindow(%#x)" % xid

def _resize(self, *_args):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/x11/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ class CoreX11WindowModel(WindowModelStub):
"_NET_FRAME_EXTENTS", "_NET_WM_ALLOWED_ACTIONS"]

def __init__(self, client_window):
log("new window %#x", client_window.xid)
super(CoreX11WindowModel, self).__init__()
self.xid = get_xwindow(client_window)
log("new window %#x", self.xid)
self.client_window = client_window
self.client_window_saved_events = self.client_window.get_events()
self._composite = None
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,18 @@ def x11_init(self):
prop_set(root, "XPRA_SERVER", "latin1", strtobytes(XPRA_VERSION).decode())
add_event_receiver(root, self)
if self.sync_xvfb>0:
xid = get_xwindow(root)
try:
with xsync:
self.root_overlay = X11Window.XCompositeGetOverlayWindow(root.xid)
self.root_overlay = X11Window.XCompositeGetOverlayWindow(xid)
if self.root_overlay:
#ugly: API expects a window object with a ".xid"
X11WindowModel = namedtuple("X11WindowModel", "xid")
root_overlay = X11WindowModel(xid=self.root_overlay)
prop_set(root_overlay, "WM_TITLE", "latin1", u"RootOverlay")
X11Window.AllowInputPassthrough(self.root_overlay)
except Exception as e:
log("XCompositeGetOverlayWindow(%#x)", root.xid, exc_info=True)
log("XCompositeGetOverlayWindow(%#x)", xid, exc_info=True)
log.error("Error setting up xvfb synchronization:")
log.error(" %s", e)
if self.root_overlay:
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 @@ -12,7 +12,7 @@


from xpra.util import csv, nonl, envbool
from xpra.os_util import bytestostr
from xpra.os_util import bytestostr, strtobytes
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 keymap_get_for_display, display_get_default, get_default_root_window
Expand Down Expand Up @@ -484,9 +484,10 @@ def change_mask(modifiers, press, info):
failed = []
for modifier in modifiers:
modifier = bytestostr(modifier)
keynames = self.keynames_for_mod.get(modifier)
keynames = self.keynames_for_mod.get(strtobytes(modifier))
if not keynames:
log.error("Error: unknown modifier '%s'", modifier)
log.error(" known modifiers: %s", csv(self.keynames_for_mod.keys()))
continue
#find the keycodes that match the keynames for this modifier
keycodes = []
Expand Down
Loading

0 comments on commit 57b3267

Please sign in to comment.