Skip to content

Commit

Permalink
#726 unmap windows when they get iconified by the client, and (re)map…
Browse files Browse the repository at this point in the history
… them on configure

git-svn-id: https://xpra.org/svn/Xpra/trunk@8319 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 28, 2014
1 parent 7f947bd commit 2fe9a68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/xpra/x11/bindings/window_bindings.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ cdef class X11WindowBindings(X11CoreBindings):
v = XGetAtomName(self.display, atom)
return v[:]

def MapWindow(self, Window xwindow):
XMapWindow(self.display, xwindow)

def MapRaised(self, Window xwindow):
XMapRaised(self.display, xwindow)

Expand All @@ -429,7 +432,7 @@ cdef class X11WindowBindings(X11CoreBindings):
def Reparent(self, Window xwindow, Window xparent, int x, int y):
XReparentWindow(self.display, xwindow, xparent, x, y)

def Iconify(self, Window xwindow, int screen_number):
def Iconify(self, Window xwindow, int screen_number=0):
return XIconifyWindow(self.display, xwindow, screen_number)

###################################
Expand Down
21 changes: 17 additions & 4 deletions src/xpra/x11/gtk_x11/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def do_xpra_client_message_event(self, event):
log("do_xpra_client_message_event(%s) atom1=%s", event, atom1)
elif event.message_type=="WM_CHANGE_STATE" and event.data and len(event.data)==5:
log("WM_CHANGE_STATE: %s", event.data[0])
if event.data[0]==IconicState:
if event.data[0]==IconicState and event.serial>self.last_unmap_serial:
self._internal_set_property("iconic", True)
elif event.message_type=="_NET_WM_MOVERESIZE" and event.data and len(event.data)==5:
log("_NET_WM_MOVERESIZE: %s", event)
Expand Down Expand Up @@ -877,7 +877,7 @@ def __init__(self, parking_window, client_window):
self.corral_window = None
self.in_save_set = False
self.client_reparented = False
self.startup_unmap_serial = None
self.last_unmap_serial = 0
self.kill_count = 0

self.connect("notify::iconic", self._handle_iconic_update)
Expand Down Expand Up @@ -909,7 +909,7 @@ def setup(self):
# the window, not from the client withdrawing the window.
if X11Window.is_mapped(self.client_window.xid):
log("hiding inherited window")
self.startup_unmap_serial = X11Window.Unmap(self.client_window.xid)
self.last_unmap_serial = X11Window.Unmap(self.client_window.xid)

# Process properties
self._read_initial_properties()
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def do_xpra_unmap_event(self, event):
# means that the client has withdrawn the window (even if it was not
# mapped in the first place) -- ICCCM section 4.1.4.
log("do_xpra_unmap_event(%s) client window unmapped", event)
if event.send_event or event.serial != self.startup_unmap_serial:
if event.send_event or event.serial>self.last_unmap_serial:
self.unmanage()

def do_xpra_destroy_event(self, event):
Expand Down Expand Up @@ -1549,6 +1549,19 @@ def do_get_property(self, pspec):
return AutoPropGObjectMixin.do_get_property(self, pspec)


def unmap(self):
with xsync:
if X11Window.is_mapped(self.client_window.xid):
self.last_unmap_serial = X11Window.Unmap(self.client_window.xid)
log("client window %#x unmapped, serial=%s", self.client_window.xid, self.last_unmap_serial)

def map(self):
with xsync:
if not X11Window.is_mapped(self.client_window.xid):
X11Window.MapWindow(self.client_window.xid)
log("client window %#x mapped", self.client_window.xid)


def _handle_iconic_update(self, *args):
def set_state(state):
log("_handle_iconic_update: set_state(%s)", state)
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def configure_window(self, win, x, y, w, h, resize_counter=0):
model.geom = new_geom
if not self.visible(win):
model.shown = True
win.map()
#Note: this will fire a metadata change event, which will fire a message to the client(s),
#which is wasteful when we only have one client and it is the one that configured the window,
#but when we have multiple clients, this keeps things in sync
Expand All @@ -120,6 +121,7 @@ def configure_window(self, win, x, y, w, h, resize_counter=0):

def hide_window(self, model):
if not model.get_property("iconic"):
model.unmap()
model.set_property("iconic", True)
self._models[model].shown = False
model.ownership_election()
Expand Down

0 comments on commit 2fe9a68

Please sign in to comment.