def send():
     root_window = get_xwindow(root)
     window = get_xwindow(self.gdk_window())
     X11WindowBindings.sendClientMessage(root_window, window, False,
                                         event_mask, "_NET_WM_DESKTOP",
                                         workspace,
                                         const["CurrentTime"], 0, 0, 0)
Example #2
0
def raw_prop_get(target, key, etype, ignore_errors=False, raise_xerrors=False):
    def etypestr():
        return _etypestr(etype)

    if isinstance(etype, (list, tuple)):
        scalar_type = etype[0]
    else:
        scalar_type = etype
    atom = PROP_TYPES[scalar_type][1]
    try:
        buffer_size = PROP_SIZES.get(scalar_type, 64 * 1024)
        with XSyncContext():
            data = X11WindowBindings().XGetWindowProperty(
                target.get_xid(), key, atom, etype, buffer_size)
        if data is None:
            if not ignore_errors:
                log("Missing property %s (%s)", key, etype)
            return None
    except XError:
        log("prop_get%s", (target, key, etype, ignore_errors, raise_xerrors),
            exc_info=True)
        if raise_xerrors:
            raise
        log.info("Missing window %s or wrong property type %s (%s)", target,
                 key, etypestr())
        return None
    except PropertyError as e:
        log("prop_get%s", (target, key, etype, ignore_errors, raise_xerrors),
            exc_info=True)
        if not ignore_errors:
            log.info("Missing property or wrong property type %s (%s)", key,
                     etypestr())
            log.info(" %s", e)
        return None
    return data
Example #3
0
def get_x11_property(atom_name):
    from xpra.os_util import OSX, POSIX
    if not POSIX or OSX:
        return ""
    display = os.environ.get("DISPLAY")
    if not display:
        return ""
    try:
        from xpra.x11.bindings.posix_display_source import X11DisplayContext  #@UnresolvedImport
        with X11DisplayContext(display) as dc:
            from xpra.x11.bindings.window_bindings import X11WindowBindings
            X11Window = X11WindowBindings()
            root = X11Window.getDefaultRootWindow()
            log("getDefaultRootWindow()=%#x", root)
            try:
                prop = X11Window.XGetWindowProperty(root, atom_name, "STRING")
            except Exception as e:
                log("cannot get X11 property '%s': %s", atom_name, e)
                return ""
            log("XGetWindowProperty(..)=%s", prop)
            if prop:
                from xpra.x11.prop_conv import prop_decode
                v = prop_decode(dc.display, "latin1", prop)
                log("get_x11_property(%s)=%s", atom_name, v)
                return v
            return ""
    except Exception:
        log.error("Error: cannot get X11 property '%s'",
                  atom_name,
                  exc_info=True)
        log.error(" for python %s", sys.version_info)
        log.error(" xpra command=%s", sys.argv)
    return ""
Example #4
0
def main():
    window = gtk.Window(WINDOW_TOPLEVEL)
    window.set_size_request(400, 100)
    window.connect("delete_event", gtk.main_quit)
    da = gtk.DrawingArea()
    window.add(da)
    window.show_all()

    #self.selectX11FocusChange(self)
    def focus_in(_window, event):
        print("focus-in-event")

    def focus_out(_window, event):
        print("focus-out-event")

    def has_toplevel_focus(_window, event):
        print("has-toplevel-event")

    window.connect("focus-in-event", focus_in)
    window.connect("focus-out-event", focus_out)
    window.connect("notify::has-toplevel-focus", has_toplevel_focus)
    #x11 focus events:
    gdk_win = window.get_window()
    xid = get_xwindow(gdk_win)
    init_gdk_display_source()
    os.environ["XPRA_X11_DEBUG_EVENTS"] = "FocusIn,FocusOut"
    init_x11_filter()
    with xlog:
        X11WindowBindings().selectFocusChange(xid)

    gtk.main()
    return 0
Example #5
0
def main():
    from xpra.platform.gui import init as gui_init
    from xpra.platform import program_context
    from xpra.gtk_common.error import xsync
    with program_context("XSettings"):
        gui_init()
        verbose = "-v" in sys.argv or "--verbose" in sys.argv
        if verbose:
            from xpra.log import get_all_loggers
            for x in get_all_loggers():
                x.enable_debug()

        #naughty, but how else can I hook this up?
        if os.name != "posix":
            print("xsettings require a posix OS")
            return 1

        with xsync:
            from xpra.x11.bindings.posix_display_source import init_posix_display_source  #@UnresolvedImport
            init_posix_display_source()
            from xpra.x11.bindings.window_bindings import X11WindowBindings  #@UnresolvedImport
            window_bindings = X11WindowBindings()
            selection = "_XSETTINGS_S0"
            owner = window_bindings.XGetSelectionOwner(selection)
            print("owner(%s)=%#x" % (selection, owner))
            XSETTINGS = "_XSETTINGS_SETTINGS"
            if owner:
                data = window_bindings.XGetWindowProperty(
                    owner, XSETTINGS, XSETTINGS)
                serial, settings = get_settings(None, data)
                print("serial=%s" % serial)
                print("%s settings:" % len(settings))
                for s in settings:
                    print(s)
            return 0
Example #6
0
def main():
    from xpra.platform.gui import init as gui_init
    from xpra.platform import init as platform_init,clean
    try:
        platform_init("XSettings")
        gui_init()
        verbose = "-v" in sys.argv or "--verbose" in sys.argv
        if verbose:
            from xpra.log import get_all_loggers
            for x in get_all_loggers():
                x.enable_debug()

        #naughty, but how else can I hook this up?
        import os
        if os.name!="posix":
            print("xsettings require a posix OS")
            return 1

        from xpra.x11.bindings import posix_display_source  #@UnresolvedImport - takes care of hooking up the display
        assert posix_display_source
        from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
        window_bindings = X11WindowBindings()
        selection = "_XSETTINGS_S0"
        owner = window_bindings.XGetSelectionOwner(selection)
        print("owner(%s)=%#x" % (selection, owner))
        XSETTINGS = "_XSETTINGS_SETTINGS"
        data = window_bindings.XGetWindowProperty(owner, XSETTINGS, XSETTINGS)
        serial, settings = get_settings(None, data)
        print("serial=%s" % serial)
        print("%s settings:" % len(settings))
        for s in settings:
            print(s)
        return 0
    finally:
        clean()
Example #7
0
def _get_X11_root_property(name, req_type):
    try:
        X11Window = X11WindowBindings()
        root_xid = X11Window.getDefaultRootWindow()
        return _get_X11_window_property(root_xid, name, req_type)
    except Exception as e:
        log.warn("Warning: failed to get X11 root property '%s'", name)
        log.warn(" %s", e)
    return None
Example #8
0
def _get_X11_root_property(name, req_type):
    try:
        from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
        window_bindings = X11WindowBindings()
        root_xid = window_bindings.getDefaultRootWindow()
        return _get_X11_window_property(root_xid, name, req_type)
    except Exception as e:
        log.warn("failed to get X11 root property %s: %s", name, e)
    return None
Example #9
0
 def xsettings_owner(self):
     with xlog:
         from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
         X11Window = X11WindowBindings()
         owner_x = X11Window.XGetSelectionOwner(self._selection)
         log("XGetSelectionOwner(%s)=%#x", self._selection, owner_x)
         if owner_x == XNone:
             return None
         return get_pywindow(self._clipboard, owner_x)
Example #10
0
def get_wm_info():
    with xsync:
        from gi.repository import Gdk  #pylint: disable=import-outside-toplevel
        display = Gdk.Display.get_default()
        X11Window = X11WindowBindings()
        screen = display.get_default_screen()
        root = screen.get_root_window()
        info = {
            "display": display.get_name(),
            "root": root.get_xid(),
            "WM_S0": X11Window.XGetSelectionOwner(WM_S0) or 0,
            "_NEW_WM_CM_S0": X11Window.XGetSelectionOwner(_NEW_WM_CM_S0) or 0,
        }
        ewmh_xid = raw_prop_get(root,
                                "_NET_SUPPORTING_WM_CHECK",
                                "window",
                                ignore_errors=False,
                                raise_xerrors=False)
        if ewmh_xid:
            ewmh_wm = prop_get(root,
                               "_NET_SUPPORTING_WM_CHECK",
                               "window",
                               ignore_errors=True,
                               raise_xerrors=False)
            if ewmh_wm:
                info["_NET_SUPPORTING_WM_CHECK"] = ewmh_wm.get_xid()
                info["wmname"] = prop_get(ewmh_wm,
                                          "_NET_WM_NAME",
                                          "utf8",
                                          ignore_errors=True,
                                          raise_xerrors=False) or ""
            else:
                info["wmname"] = prop_get(root,
                                          "_NET_WM_NAME",
                                          "utf8",
                                          ignore_errors=True,
                                          raise_xerrors=False) or ""
        for name, prop_name, prop_type in (
            ("xpra-server-pid", "XPRA_SERVER_PID", "u32"),
            ("xpra-vfb-pid", "XPRA_XVFB_PID", "u32"),
            ("xpra-server-version", "XPRA_SERVER", "latin1"),
            ("xpra-server-mode", "XPRA_SERVER_MODE", "latin1"),
            ("dbus-address", "DBUS_SESSION_BUS_ADDRESS", "latin1"),
            ("dbus-pid", "DBUS_SESSION_BUS_PID", "u32"),
            ("dbus-window", "DBUS_SESSION_BUS_WINDOW_ID", "u32"),
        ):
            v = prop_get(root,
                         prop_name,
                         prop_type,
                         ignore_errors=True,
                         raise_xerrors=False)
            if v:
                info[name] = v
    log("get_wm_info()=%s", info)
    return info
Example #11
0
def prop_get(target, key, etype, ignore_errors=False, raise_xerrors=False):
    if isinstance(etype, (list, tuple)):
        scalar_type = etype[0]

        def etypestr():
            return "array of %s" % scalar_type
    else:
        scalar_type = etype

        def etypestr():
            return "%s" % etype

    atom = PROP_TYPES[scalar_type][1]
    try:
        buffer_size = PROP_SIZES.get(scalar_type, 64 * 1024)
        with XSyncContext():
            data = X11WindowBindings().XGetWindowProperty(
                target.get_xid(), key, atom, etype, buffer_size)
        if data is None:
            if not ignore_errors:
                log("Missing property %s (%s)", key, etype)
            return None
    except XError:
        log("prop_get%s", (target, key, etype, ignore_errors, raise_xerrors),
            exc_info=True)
        if raise_xerrors:
            raise
        log.info("Missing window %s or wrong property type %s (%s)", target,
                 key, etypestr())
        return None
    except PropertyError as e:
        log("prop_get%s", (target, key, etype, ignore_errors, raise_xerrors),
            exc_info=True)
        if not ignore_errors:
            log.info("Missing property or wrong property type %s (%s)", key,
                     etypestr())
            log.info(" %s", e)
        return None
    try:
        with XSyncContext():
            return prop_decode(target, etype, data)
    except:
        if ignore_errors:
            log("prop_get%s",
                (target, key, etype, ignore_errors, raise_xerrors),
                exc_info=True)
            return None
        log.warn("Error parsing property '%s' (%s)", key, etypestr())
        log.warn(" this may be a misbehaving application, or bug in Xpra")
        try:
            log.warn(" data length=%i", len(data))
        except TypeError:
            pass
        log.warn(" data: %r", repr_ellipsized(str(data)), exc_info=True)
        raise
Example #12
0
def make_window():
    window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
    window.set_title("Window Focus")
    window.set_size_request(640, 200)
    window.connect("delete_event", Gtk.main_quit)
    vbox = Gtk.VBox()
    N = 8
    labels = []
    font = Pango.FontDescription("sans 12")
    for _ in range(N):
        l = Gtk.Label()
        l.modify_font(font)
        labels.append(l)
    for l in labels:
        al = Gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0)
        al.add(l)
        vbox.add(al)
    window.add(vbox)
    window.show_all()
    text = deque(maxlen=N)

    def update(s):
        text.append("%s: %s" % (datetime.now(), s))
        for i, t in enumerate(text):
            labels[i].set_text(t)

    #self.selectX11FocusChange(self)
    def focus_in(_window, event):
        update("focus-in-event")

    def focus_out(_window, event):
        update("focus-out-event")

    def has_toplevel_focus(window, _event):
        update("has-toplevel-focus: %s" % window.has_toplevel_focus())

    window.connect("focus-in-event", focus_in)
    window.connect("focus-out-event", focus_out)
    window.connect("notify::has-toplevel-focus", has_toplevel_focus)
    if POSIX and not OSX:
        from xpra.gtk_common.error import xlog
        from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
        from xpra.x11.gtk_x11.gdk_bindings import init_x11_filter
        from xpra.x11.bindings.window_bindings import X11WindowBindings  #pylint: disable=no-name-in-module
        from xpra.os_util import is_Wayland
        if not is_Wayland():
            #x11 focus events:
            gdk_win = window.get_window()
            xid = gdk_win.get_xid()
            init_gdk_display_source()
            os.environ["XPRA_X11_DEBUG_EVENTS"] = "FocusIn,FocusOut"
            init_x11_filter()
            with xlog:
                X11WindowBindings().selectFocusChange(xid)
    return window
Example #13
0
 def send_net_showing_desktop(v):
     from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
     from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
     init_gdk_display_source()
     X11Window = X11WindowBindings()
     root = window.get_window().get_screen().get_root_window()
     root_xid = root.get_xid()
     SubstructureNotifyMask = constants["SubstructureNotifyMask"]
     SubstructureRedirectMask = constants["SubstructureRedirectMask"]
     event_mask = SubstructureNotifyMask | SubstructureRedirectMask
     X11Window.sendClientMessage(root_xid, root_xid, False, event_mask,
                                 "_NET_SHOWING_DESKTOP", v)
Example #14
0
def main():
    from xpra.x11.gtk2 import gdk_display_source
    assert gdk_display_source
    from xpra.x11.gtk2.gdk_bindings import init_x11_filter, add_catchall_receiver  #@UnresolvedImport
    init_x11_filter()

    root_window = gtk.gdk.get_default_root_window()
    root_window.set_events(root_window.get_events()
                           | gtk.gdk.SUBSTRUCTURE_MASK)
    r = receiver()
    add_catchall_receiver("xpra-create-event", r)
    X11WindowBindings().substructureRedirect(root_window.xid)
    gtk.main()
Example #15
0
	def close(*args):
		from xpra.x11.gtk2 import gdk_display_source
		assert gdk_display_source
		from xpra.gtk_common.gtk_util import get_xwindow
		from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
		X11Window = X11WindowBindings()
		root = window.get_window().get_screen().get_root_window()
		root_xid = get_xwindow(root)
		xwin = get_xwindow(window.get_window())
		SubstructureNotifyMask = constants["SubstructureNotifyMask"]
		SubstructureRedirectMask = constants["SubstructureRedirectMask"]
		event_mask = SubstructureNotifyMask | SubstructureRedirectMask
		now = gtk.gdk.x11_get_server_time(window.get_window())
		X11Window.sendClientMessage(root_xid, xwin, False, event_mask, "_NET_CLOSE_WINDOW", now, 1)
Example #16
0
	def moveresize_X11(self, *_args):
		new_x, new_y, new_width, new_height = self.get_new_geometry()
		from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
		init_gdk_display_source()
		from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
		X11Window = X11WindowBindings()
		root = self.get_window().get_screen().get_root_window()
		root_xid = root.xid
		xwin = self.get_window().xid
		SubstructureNotifyMask = constants["SubstructureNotifyMask"]
		SubstructureRedirectMask = constants["SubstructureRedirectMask"]
		event_mask = SubstructureNotifyMask | SubstructureRedirectMask
		X11Window.sendClientMessage(root_xid, xwin, False, event_mask, "_NET_MOVERESIZE_WINDOW",
			  1+2**8+2**9+2**10+2**11, new_x, new_y, new_width, new_height)
Example #17
0
def _get_atom(_disp, d):
    unpacked = struct.unpack(b"@L", d)[0]
    if unpacked == 0:
        log.warn("Warning: invalid zero atom value")
        return None
    with xsync:
        pyatom = X11WindowBindings().XGetAtomName(unpacked)
    if not pyatom:
        log.error("invalid atom: %s - %s", repr(d), repr(unpacked))
        return None
    if not isinstance(pyatom, str):
        #py3k:
        return pyatom.decode()
    return pyatom
Example #18
0
	def initiate(x_root, y_root, direction, button, source_indication):
		#print("initiate%s" % str((x_root, y_root, direction, button, source_indication)))
		from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
		init_gdk_display_source()
		from xpra.x11.bindings.core_bindings import X11CoreBindings					#@UnresolvedImport
		from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
		event_mask = constants["SubstructureNotifyMask"] | constants["SubstructureRedirectMask"]
		root_xid = get_root_window().get_xid()
		xwin = window.get_window().get_xid()
		X11Core = X11CoreBindings()
		X11Core.UngrabPointer()
		X11Window = X11WindowBindings()
		X11Window.sendClientMessage(root_xid, xwin, False, event_mask, "_NET_WM_MOVERESIZE",
			  x_root, y_root, direction, button, source_indication)
Example #19
0
def _get_X11_window_property(xid, name, req_type):
    try:
        from xpra.gtk_common.error import xsync
        from xpra.x11.bindings.window_bindings import X11WindowBindings, PropertyError #@UnresolvedImport
        window_bindings = X11WindowBindings()
        try:
            with xsync:
                prop = window_bindings.XGetWindowProperty(xid, name, req_type)
            log("_get_X11_window_property(%#x, %s, %s)=%s, len=%s", xid, name, req_type, type(prop), len(prop or []))
            return prop
        except PropertyError as e:
            log("_get_X11_window_property(%#x, %s, %s): %s", xid, name, req_type, e)
    except Exception as e:
        log.warn("failed to get X11 window property %s on window %#x: %s", name, xid, e)
    return None
Example #20
0
 def send_maximized_wm_state(mode):
     from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
     init_gdk_display_source()
     from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
     X11Window = X11WindowBindings()
     root = window.get_window().get_screen().get_root_window()
     root_xid = root.get_xid()
     xwin = window.get_window().get_xid()
     SubstructureNotifyMask = constants["SubstructureNotifyMask"]
     SubstructureRedirectMask = constants["SubstructureRedirectMask"]
     event_mask = SubstructureNotifyMask | SubstructureRedirectMask
     X11Window.sendClientMessage(root_xid, xwin, False, event_mask,
                                 "_NET_WM_STATE", mode,
                                 "_NET_WM_STATE_MAXIMIZED_VERT",
                                 "_NET_WM_STATE_MAXIMIZED_HORZ", 0, 0)
Example #21
0
 def __init__(self, window):
     log("XI2_Window(%s)", window)
     self.XI2 = X11XI2Bindings()
     self.X11Window = X11WindowBindings()
     self.window = window
     self.xid = window.get_window().xid
     self.windows = ()
     window.connect("configure-event", self.configured)
     self.configured()
     #replace event handlers with XI2 version:
     self.do_motion_notify_event = window.do_motion_notify_event
     window.do_motion_notify_event = self.noop
     window.do_button_press_event = self.noop
     window.do_button_release_event = self.noop
     window.do_scroll_event = self.noop
     window.connect("destroy", self.cleanup)
def main():
    x, y = 0, 0
    if len(sys.argv) == 3:
        x, y = int(sys.argv[1]), int(sys.argv[2])
    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.set_size_request(width, height)
    window.connect("delete_event", gtk.mainquit)
    window.realize()
    window.move(x, y)
    from xpra.x11.gtk2.gdk_display_source import display
    assert display
    from xpra.x11.bindings.window_bindings import X11WindowBindings
    hints = {"position": (x, y)}
    X11WindowBindings().setSizeHints(window.get_window().xid, hints)
    window.show_all()
    gtk.main()
Example #23
0
def _get_X11_root_property(name, req_type):
    try:
        from xpra.gtk_common.error import xsync
        from xpra.x11.bindings.window_bindings import X11WindowBindings, PropertyError #@UnresolvedImport
        window_bindings = X11WindowBindings()
        root = window_bindings.getDefaultRootWindow()
        try:
            with xsync:
                prop = window_bindings.XGetWindowProperty(root, name, req_type)
            log("_get_X11_root_property(%s, %s)=%s, len=%s", name, req_type, type(prop), len(prop or []))
            return prop
        except PropertyError as e:
            log("_get_X11_root_property(%s, %s): %s", name, req_type, e)
    except Exception as e:
        log.warn("failed to get X11 root property %s: %s", name, e)
    return None
def main():
    x, y = 0, 0
    if len(sys.argv) == 3:
        x, y = int(sys.argv[1]), int(sys.argv[2])
    window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
    window.set_size_request(width, height)
    window.connect("delete_event", Gtk.main_quit)
    window.realize()
    window.move(x, y)
    from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source
    init_gdk_display_source()
    from xpra.x11.bindings.window_bindings import X11WindowBindings
    hints = {"position": (x, y)}
    X11WindowBindings().setSizeHints(window.get_window().get_xid(), hints)
    window.show_all()
    Gtk.main()
Example #25
0
def _get_xsettings():
    try:
        from xpra.x11.bindings.window_bindings import X11WindowBindings #@UnresolvedImport
        window_bindings = X11WindowBindings()
        selection = "_XSETTINGS_S0"
        owner = window_bindings.XGetSelectionOwner(selection)
        if not owner:
            return None
        XSETTINGS = "_XSETTINGS_SETTINGS"
        data = window_bindings.XGetWindowProperty(owner, XSETTINGS, XSETTINGS)
        if not data:
            return None
        from xpra.x11.xsettings_prop import get_settings
        return get_settings(window_bindings.get_display_name(), data)
    except Exception as e:
        log("_get_xsettings error: %s", e)
    return None
Example #26
0
 def moveresize_X11(*args):
     new_x, new_y, new_width, new_height = get_new_geometry()
     from xpra.x11.gtk_x11 import gdk_display_source
     assert gdk_display_source
     from xpra.gtk_common.gobject_compat import get_xid
     from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
     X11Window = X11WindowBindings()
     root = window.get_window().get_screen().get_root_window()
     root_xid = get_xid(root)
     xwin = get_xid(window.get_window())
     SubstructureNotifyMask = constants["SubstructureNotifyMask"]
     SubstructureRedirectMask = constants["SubstructureRedirectMask"]
     event_mask = SubstructureNotifyMask | SubstructureRedirectMask
     X11Window.sendClientMessage(root_xid, xwin, False, event_mask,
                                 "_NET_MOVERESIZE_WINDOW",
                                 1 + 2**8 + 2**9 + 2**10 + 2**11, new_x,
                                 new_y, new_width, new_height)
Example #27
0
def _send_client_message(window, message_type, *values):
    try:
        from xpra.x11.gtk2 import gdk_display_source
        assert gdk_display_source
        from xpra.x11.bindings.window_bindings import constants, X11WindowBindings  #@UnresolvedImport
        X11Window = X11WindowBindings()
        root_xid = X11Window.getDefaultRootWindow()
        if window:
            xid = get_xid(window)
        else:
            xid = root_xid
        SubstructureNotifyMask = constants["SubstructureNotifyMask"]
        SubstructureRedirectMask = constants["SubstructureRedirectMask"]
        event_mask = SubstructureNotifyMask | SubstructureRedirectMask
        X11Window.sendClientMessage(root_xid, xid, False, event_mask, message_type, *values)
    except Exception as e:
        log.warn("failed to send client message '%s' with values=%s: %s", message_type, values, e)
Example #28
0
def main():
    print("main()")
    import gtk
    import signal
    from xpra.server.socket_util import create_unix_domain_socket
    from xpra.x11.vfb_util import start_Xvfb, check_xvfb_process
    from xpra.scripts.parsing import parse_cmdline
    from xpra.scripts.main import configure_logging
    from xpra.platform.dotxpra import DotXpra
    script_file = sys.argv[0]
    print("main() script_file=%s" % script_file)
    cmdline = sys.argv
    print("main() cmdline=%s" % cmdline)
    parser, opts, args, mode = parse_cmdline(cmdline)
    print("main() parser=%s" % parser)
    print("main() options=%s" % opts)
    print("main() mode=%s" % mode)
    display_name = args.pop(0)
    print("main() display=%s" % display_name)
    assert mode == "start", "only start mode is supported by this test server"
    configure_logging(opts, mode)
    dotxpra = DotXpra(opts.socket_dir)
    sockpath = dotxpra.socket_path(display_name)
    socket, cleanup_socket = create_unix_domain_socket(sockpath)
    sockets = [socket]
    xvfb = start_Xvfb(opts.xvfb, display_name)
    assert check_xvfb_process(xvfb), "xvfb error"

    from xpra.x11.bindings import posix_display_source  #@UnusedImport
    from xpra.x11.bindings.window_bindings import X11WindowBindings  #@UnresolvedImport
    X11Window = X11WindowBindings()
    assert X11Window

    try:
        app = UnrespondingServer()
        app.init(opts)
        app.init_sockets(sockets)
        register_os_signals(app.signal_quit)
        signal.signal(signal.SIGINT, app.signal_quit)
        return app.run()
    finally:
        for display in gtk.gdk.display_manager_get().list_displays():
            display.close()
        xvfb.terminate()
        cleanup_socket()
Example #29
0
def _get_xsettings():
    from xpra.gtk_common.error import xsync
    try:
        X11Window = X11WindowBindings()
        with xsync:
            selection = "_XSETTINGS_S0"
            owner = X11Window.XGetSelectionOwner(selection)
            if not owner:
                return None
            XSETTINGS = "_XSETTINGS_SETTINGS"
            data = X11Window.XGetWindowProperty(owner, XSETTINGS, XSETTINGS)
            if not data:
                return None
            from xpra.x11.xsettings_prop import get_settings
            return get_settings(X11Window.get_display_name(), data)
    except Exception as e:
        log("_get_xsettings()", exc_info=True)
    return None
Example #30
0
def main():
    print("main()")
    import gtk
    import signal
    from xpra.scripts.server import setup_local_socket, start_Xvfb, check_xvfb_process
    from xpra.scripts.main import parse_cmdline, configure_logging
    from xpra.dotxpra import DotXpra
    script_file = sys.argv[0]
    print("main() script_file=%s" % script_file)
    cmdline = sys.argv
    print("main() cmdline=%s" % cmdline)
    parser, opts, args, mode = parse_cmdline(cmdline)
    print("main() parser=%s" % parser)
    print("main() options=%s" % opts)
    print("main() mode=%s" % mode)
    display_name = args.pop(0)
    print("main() display=%s" % display_name)
    assert mode=="start", "only start mode is supported by this test server"
    configure_logging(opts, mode)
    dotxpra = DotXpra(opts.socket_dir)
    socket, cleanup_socket = setup_local_socket(dotxpra, display_name, False, opts.mmap_group)
    sockets = [socket]
    xvfb = start_Xvfb(opts.xvfb, display_name)
    assert check_xvfb_process(xvfb), "xvfb error"

    from xpra.x11.gtk_x11 import gdk_display_source
    assert gdk_display_source

    from xpra.x11.bindings.window_bindings import X11WindowBindings     #@UnresolvedImport
    X11Window = X11WindowBindings()
    assert X11Window

    try:
        app = UnrespondingServer()
        app.init(opts)
        app.init_sockets(sockets)
        signal.signal(signal.SIGTERM, app.signal_quit)
        signal.signal(signal.SIGINT, app.signal_quit)
        return app.run()
    finally:
        for display in gtk.gdk.display_manager_get().list_displays():
            display.close()
        xvfb.terminate()
        cleanup_socket()
Example #31
0
 def send():
     root_window = get_xwindow(root)
     window = get_xwindow(self.gdk_window())
     X11WindowBindings.sendClientMessage(
         root_window, window, False, event_mask, "_NET_WM_DESKTOP", workspace, constants["CurrentTime"], 0, 0, 0
     )