How to use the xpra.x11.gtk_x11.gdk_bindings.get_xwindow function in xpra

To help you get started, we’ve selected a few xpra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dscho / Xpra / trunk / src / xpra / x11 / gtk_x11 / tray.py View on Github external
self.tray_window = gtk.gdk.Window(root, width=1, height=1,
                                           window_type=gtk.gdk.WINDOW_TOPLEVEL,
                                           event_mask = 0,
                                           wclass=gtk.gdk.INPUT_OUTPUT,
                                           title="Xpra-SystemTray",
                                           visual=visual,
                                           colormap=colormap)
        xtray = get_xwindow(self.tray_window)
        set_tray_visual(self.tray_window, visual)
        set_tray_orientation(self.tray_window, TRAY_ORIENTATION_HORZ)
        debug("setup tray: tray window %s", hex(xtray))
        display.request_selection_notification(SELECTION)
        setsel = X11Window.XSetSelectionOwner(xtray, SELECTION)
        debug("setup tray: set selection owner returned %s", setsel)
        event_mask = constants["StructureNotifyMask"]
        xroot = get_xwindow(root)
        X11Window.sendClientMessage(xroot, xroot, False, event_mask, "MANAGER",
                          constants["CurrentTime"], SELECTION,
                          xtray, 0, 0)
        owner = X11Window.XGetSelectionOwner(SELECTION)
        #FIXME: cleanup if we fail!
        assert owner==xtray, "we failed to get ownership of the tray selection"
        add_event_receiver(self.tray_window, self)
        debug("setup tray: done")
github dscho / Xpra / tags / v0.11.x / src / xpra / x11 / gtk_x11 / window.py View on Github external
if rating < 0:
                winner = None
        else:
            winner = None
        old_owner = self.get_property("owner")
        if old_owner is winner:
            return
        if old_owner is not None:
            self.corral_window.hide()
            self.corral_window.reparent(self.parking_window, 0, 0)
        self._internal_set_property("owner", winner)
        if winner is not None:
            winner.take_window(self, self.corral_window)
            self._update_client_geometry()
            self.corral_window.show_unraised()
        trap.swallow_synced(X11Window.sendConfigureNotify, get_xwindow(self.client_window))
github dscho / Xpra / src / xpra / x11 / gtk_x11 / tray.py View on Github external
if colormap is None or visual is None:
            log.warn("setup tray: using rgb visual fallback")
            colormap, visual = screen.get_rgb_colormap(), screen.get_rgb_visual()
        assert colormap is not None and visual is not None, "failed to obtain visual or colormap"
        owner = X11Window.XGetSelectionOwner(SELECTION)
        debug("setup tray: current selection owner=%s", owner)
        if owner!=constants["XNone"]:
            raise Exception("%s already owned by %s" % (SELECTION, owner))
        self.tray_window = gtk.gdk.Window(root, width=1, height=1,
                                           window_type=gtk.gdk.WINDOW_TOPLEVEL,
                                           event_mask = 0,
                                           wclass=gtk.gdk.INPUT_OUTPUT,
                                           title="Xpra-SystemTray",
                                           visual=visual,
                                           colormap=colormap)
        xtray = get_xwindow(self.tray_window)
        set_tray_visual(self.tray_window, visual)
        set_tray_orientation(self.tray_window, TRAY_ORIENTATION_HORZ)
        debug("setup tray: tray window %s", hex(xtray))
        display.request_selection_notification(SELECTION)
        setsel = X11Window.XSetSelectionOwner(xtray, SELECTION)
        debug("setup tray: set selection owner returned %s", setsel)
        event_mask = constants["StructureNotifyMask"]
        xroot = get_xwindow(root)
        X11Window.sendClientMessage(xroot, xroot, False, event_mask, "MANAGER",
                          constants["CurrentTime"], SELECTION,
                          xtray, 0, 0)
        owner = X11Window.XGetSelectionOwner(SELECTION)
        #FIXME: cleanup if we fail!
        assert owner==xtray, "we failed to get ownership of the tray selection"
        add_event_receiver(self.tray_window, self)
        debug("setup tray: done")
github dscho / Xpra / trunk / src / xpra / x11 / gtk_x11 / wm.py View on Github external
try:
            ewmh_wm = prop_get(root, "_NET_SUPPORTING_WM_CHECK", "window", ignore_errors=True, raise_xerrors=False)
        except:
            #errors here generally indicate that the window is gone
            #which is fine: it means the previous window manager is no longer active
            continue
        log("_NET_SUPPORTING_WM_CHECK for screen %s: %s", i, ewmh_wm)
        if ewmh_wm:
            try:
                name = prop_get(ewmh_wm, "_NET_WM_NAME", "utf8", ignore_errors=False, raise_xerrors=False)
            except:
                name = None
            if upgrading and name and name==WM_WINDOW_NAME:
                log.info("found previous Xpra instance")
            else:
                log.warn("Warning: found an existing window manager on screen %s using window id %s: %s", i, hex(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):
                log.error("it does not own the selection '%s' or '%s' so we cannot take over and make it exit", wm_prop, cwm_prop)
                log.error("please stop %s so you can run xpra on this display", name or "the existing window manager")
                return False
    return True
github dscho / Xpra / trunk / src / xpra / x11 / gtk_x11 / window.py View on Github external
def setup_failed(self, e):
        log("cannot manage %s: %s", hex(get_xwindow(self.client_window)), e)
        self.do_unmanaged(False)
github dscho / Xpra / trunk / src / xpra / x11 / gtk_x11 / window.py View on Github external
def do_unmanaged(self, wm_exiting):
        log("unmanaging window: %s (%s - %s)", self, self.corral_window, self.client_window)
        self._internal_set_property("owner", None)
        if self.corral_window:
            remove_event_receiver(self.corral_window, self)
            for prop in WindowModel.SCRUB_PROPERTIES:
                trap.swallow_synced(X11Window.XDeleteProperty, get_xwindow(self.client_window), prop)
            if self.client_reparented:
                self.client_window.reparent(gtk.gdk.get_default_root_window(), 0, 0)
                self.client_reparented = False
            self.client_window.set_events(self.client_window_saved_events)
            #it is now safe to destroy the corral window:
            self.corral_window.destroy()
            self.corral_window = None
            # It is important to remove from our save set, even after
            # reparenting, because according to the X spec, windows that are
            # in our save set are always Mapped when we exit, *even if those
            # windows are no longer inferior to any of our windows!* (see
            # section 10. Connection Close).  This causes "ghost windows", see
            # bug #27:
            if self.in_save_set:
                trap.swallow_synced(X11Window.XRemoveFromSaveSet, get_xwindow(self.client_window))
                self.in_save_set = False
github dscho / Xpra / tags / v0.10.x / src / xpra / x11 / server.py View on Github external
self._tray = SystemTray()
            except Exception, e:
                log.error("cannot setup tray forwarding: %s", e, exc_info=True)

        ### Create our window managing data structures:
        self._desktop_manager = DesktopManager()
        self._wm.get_property("toplevel").add(self._desktop_manager)
        self._desktop_manager.show_all()

        ### Load in existing windows:
        for window in self._wm.get_property("windows"):
            self._add_new_window(window)

        root = gtk.gdk.get_default_root_window()
        for window in get_children(root):
            if X11Window.is_override_redirect(get_xwindow(window)) and X11Window.is_mapped(get_xwindow(window)):
                self._add_new_or_window(window)
github dscho / Xpra / src / xpra / x11 / gtk_x11 / composite.py View on Github external
# corral window selection masks, and those don't deserve
                        # clobbering.  They are our friends!  X is driving me
                        # slowly mad.
                        X11Window.addXSelectInput(get_xwindow(win), constants["StructureNotifyMask"])
                        add_event_receiver(win, self, max_receivers=-1)
                        listening.append(win)
                        win = get_parent(win)
                    handle = XImage.get_xcomposite_pixmap(get_xwindow(self._window))
                except Exception, e:
                    try:
                        self._cleanup_listening(listening)
                    except:
                        pass
                    raise
                if handle is None:
                    log("failed to name a window pixmap for %s: %s", get_xwindow(self._window), e)
                    self._cleanup_listening(listening)
                else:
                    self._contents_handle = handle
                    # Don't save the listening set until after
                    # NameWindowPixmap has succeeded, to maintain our
                    # invariant:
                    self._listening_to = listening
            trap.swallow_synced(set_pixmap)
github dscho / Xpra / src / xpra / x11 / gtk_x11 / composite.py View on Github external
def do_get_property_shm_handle(self, name):
        if not self._use_shm or not CompositeHelper.XShmEnabled:
            return None
        if self._shm_handle and self._shm_handle.get_size()!=self._window.get_size():
            #size has changed!
            #make sure the current wrapper gets garbage collected:
            self._shm_handle.cleanup()
            self._shm_handle = None
        if self._shm_handle is None:
            #make a new one:
            self._shm_handle = XImage.get_XShmWrapper(get_xwindow(self._window))
            if self._shm_handle is None:
                #failed (may retry)
                return None
            init_ok, retry_window, xshm_failed = self._shm_handle.setup()
            if not init_ok:
                #this handle is not valid, clear it:
                self._shm_handle = None
            if not retry_window:
                #and it looks like it is not worth re-trying this window:
                self._use_shm = False
            if xshm_failed:
                log.warn("disabling XShm support following irrecoverable error")
                CompositeHelper.XShmEnabled = False
        return self._shm_handle
github dscho / Xpra / src / xpra / x11 / gtk_x11 / composite.py View on Github external
def setup(self):
        xwin = get_xwindow(self._window)
        if not self._already_composited:
            X11Window.XCompositeRedirectWindow(xwin)
        _, _, _, _, self._border_width = X11Window.geometry_with_border(xwin)
        self.invalidate_pixmap()
        self._damage_handle = X11Window.XDamageCreate(xwin)
        log("CompositeHelper.setup() damage handle(%s)=%s", hex(xwin), hex(self._damage_handle))
        add_event_receiver(self._window, self)