xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #726: unmap-windows.patch

File unmap-windows.patch, 5.3 KB (added by Antoine Martin, 6 years ago)

unmaps windows to hide them, and re-maps them when shown again

  • xpra/x11/bindings/window_bindings.pyx

     
    420420        v = XGetAtomName(self.display, atom)
    421421        return v[:]
    422422
     423    def MapWindow(self, Window xwindow):
     424        XMapWindow(self.display, xwindow)
     425
    423426    def MapRaised(self, Window xwindow):
    424427        XMapRaised(self.display, xwindow)
    425428
     
    429432    def Reparent(self, Window xwindow, Window xparent, int x, int y):
    430433        XReparentWindow(self.display, xwindow, xparent, x, y)
    431434
    432     def Iconify(self, Window xwindow, int screen_number):
    433         return XIconifyWindow(self.display, xwindow, screen_number)
     435    def Iconify(self, Window xwindow, int screen_number=0):
     436        serial = NextRequest(self.display)
     437        XIconifyWindow(self.display, xwindow, screen_number)
     438        return serial
    434439
     440    def NextRequest(self):
     441        return NextRequest(self.display)
     442
    435443    ###################################
    436444    # XUnmapWindow
    437445    ###################################
  • xpra/x11/gtk_x11/window.py

     
    653653                log("do_xpra_client_message_event(%s) atom1=%s", event, atom1)
    654654        elif event.message_type=="WM_CHANGE_STATE" and event.data and len(event.data)==5:
    655655            log("WM_CHANGE_STATE: %s", event.data[0])
    656             if event.data[0]==IconicState:
     656            if event.data[0]==IconicState and event.serial>self.last_unmap_serial:
    657657                self._internal_set_property("iconic", True)
    658658        elif event.message_type=="_NET_WM_MOVERESIZE" and event.data and len(event.data)==5:
    659659            log("_NET_WM_MOVERESIZE: %s", event)
     
    877877        self.corral_window = None
    878878        self.in_save_set = False
    879879        self.client_reparented = False
    880         self.startup_unmap_serial = None
     880        self.last_unmap_serial = 0
    881881        self.kill_count = 0
    882882
    883883        self.connect("notify::iconic", self._handle_iconic_update)
     
    909909        # the window, not from the client withdrawing the window.
    910910        if X11Window.is_mapped(self.client_window.xid):
    911911            log("hiding inherited window")
    912             self.startup_unmap_serial = X11Window.Unmap(self.client_window.xid)
     912            self.last_unmap_serial = X11Window.Unmap(self.client_window.xid)
    913913
    914914        # Process properties
    915915        self._read_initial_properties()
     
    10181018        # Also, if we receive a *synthetic* UnmapNotify event, that always
    10191019        # means that the client has withdrawn the window (even if it was not
    10201020        # mapped in the first place) -- ICCCM section 4.1.4.
    1021         log("do_xpra_unmap_event(%s) client window unmapped", event)
    1022         if event.send_event or event.serial != self.startup_unmap_serial:
     1021        log.info("do_xpra_unmap_event(%s) client window unmapped", event)
     1022        if event.send_event or event.serial>self.last_unmap_serial:
    10231023            self.unmanage()
    10241024
    10251025    def do_xpra_destroy_event(self, event):
     
    15491549            return AutoPropGObjectMixin.do_get_property(self, pspec)
    15501550
    15511551
     1552    def hide(self):
     1553        with xsync:
     1554            self.last_unmap_serial = X11Window.Unmap(self.client_window.xid)
     1555            log.info("client window %#x hidden, serial=%s", self.client_window.xid, self.last_unmap_serial)
     1556
     1557    def show(self):
     1558        with xsync:
     1559            if not X11Window.is_mapped(self.client_window.xid):
     1560                X11Window.MapWindow(self.client_window.xid)
     1561
    15521562    def _handle_iconic_update(self, *args):
    15531563        def set_state(state):
    1554             log("_handle_iconic_update: set_state(%s)", state)
     1564            log.info("_handle_iconic_update: set_state(%s)", state)
    15551565            with xswallow:
    15561566                prop_set(self.client_window, "WM_STATE", ["u32"],
    15571567                             [state, XNone])
     
    15591569        if self.get_property("iconic"):
    15601570            set_state(IconicState)
    15611571            self._state_add("_NET_WM_STATE_HIDDEN")
     1572            #import traceback
     1573            #traceback.print_stack()
     1574            #log.info("Iconify!")
     1575            #self.last_unmap_serial = X11Window.Iconify(self.client_window.xid)
    15621576        else:
    15631577            set_state(NormalState)
    15641578            self._state_remove("_NET_WM_STATE_HIDDEN")
  • xpra/x11/server.py

     
    108108                model.geom = new_geom
    109109        if not self.visible(win):
    110110            model.shown = True
     111            win.show()
    111112            #Note: this will fire a metadata change event, which will fire a message to the client(s),
    112113            #which is wasteful when we only have one client and it is the one that configured the window,
    113114            #but when we have multiple clients, this keeps things in sync
     
    121122    def hide_window(self, model):
    122123        if not model.get_property("iconic"):
    123124            model.set_property("iconic", True)
     125            model.hide()
    124126        self._models[model].shown = False
    125127        model.ownership_election()
    126128