Skip to content

Commit

Permalink
#537 fix maximize / unmaximize:
Browse files Browse the repository at this point in the history
* fix faulty test: "unmaximize" callback was calling "maximize()"
* more compact layout for test
* remove "_last_wm_state_serial" nonsense
* correct handling for ADD / REMOVE / TOGGLE modes

git-svn-id: https://xpra.org/svn/Xpra/trunk@8294 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 26, 2014
1 parent 76af3fd commit 7dfa6da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/tests/xpra/test_apps/test_window_maximize.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@

def main():
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_size_request(600, 200)
window.set_size_request(200, 300)
window.connect("delete_event", gtk.mainquit)
vbox = gtk.VBox(False, 0)
hbox = gtk.HBox(False, 0)
vbox.pack_start(hbox, expand=False, fill=False, padding=10)

maximize_btn = gtk.Button("maximize me")
def maximize(*args):
window.maximize()
maximize_btn.connect('clicked', maximize)
hbox.pack_start(maximize_btn, expand=False, fill=False, padding=10)
vbox.pack_start(maximize_btn, expand=False, fill=False, padding=10)

unmaximize_btn = gtk.Button("unmaximize me")
def unmaximize(*args):
window.unmaximize()
maximize_btn.connect('clicked', unmaximize)
hbox.pack_start(unmaximize_btn, expand=False, fill=False, padding=10)
unmaximize_btn.connect('clicked', unmaximize)
vbox.pack_start(unmaximize_btn, expand=False, fill=False, padding=10)

fullscreen_btn = gtk.Button("fullscreen me")
def fullscreen(*args):
window.fullscreen()
fullscreen_btn.connect('clicked', fullscreen)
hbox.pack_start(fullscreen_btn, expand=False, fill=False, padding=10)
vbox.pack_start(fullscreen_btn, expand=False, fill=False, padding=10)

unfullscreen_btn = gtk.Button("unfullscreen me")
def unfullscreen(*args):
window.unfullscreen()
unfullscreen_btn.connect('clicked', unfullscreen)
hbox.pack_start(unfullscreen_btn, expand=False, fill=False, padding=10)
vbox.pack_start(unfullscreen_btn, expand=False, fill=False, padding=10)

def window_state(widget, event):
STATES = {
Expand Down
18 changes: 11 additions & 7 deletions src/xpra/x11/gtk_x11/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ def __init__(self, client_window):
self._input_field = True # The WM_HINTS input field
self._geometry = None
self._damage_forward_handle = None
self._last_wm_state_serial = 0
self._internal_set_property("client-window", client_window)
use_xshm = USE_XSHM and (not self.is_OR() and not self.is_tray())
self._composite = CompositeHelper(self.client_window, False, use_xshm)
Expand Down Expand Up @@ -635,12 +634,18 @@ def do_xpra_client_message_event(self, event):
atom2 = get_pyatom(event.window, event.data[2])
log("%s: atom2=%s", atom1, atom2)
if atom2 in ("_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_HORZ"):
if self._last_wm_state_serial == event.serial:
#already seen!
if event.data[0]==_NET_WM_STATE_ADD:
maximized = True
elif event.data[0]==_NET_WM_STATE_REMOVE:
maximized = False
elif event.data[0]==_NET_WM_STATE_TOGGLE:
maximized = not self.get_property("maximized")
else:
log.warn("invalid mode for _NET_WM_STATE: %s", event.data[0])
return
maximized = event.data[0]==_NET_WM_STATE_ADD
log("do_xpra_client_message_event(%s) window maximized=%s", event, maximized)
self.set_property("maximized", maximized)
log("do_xpra_client_message_event(%s) window maximized=%s (current state=%s)", event, maximized, self.get_property("maximized"))
if maximized!=self.get_property("maximized"):
self.set_property("maximized", maximized)
elif atom1 in ("_NET_WM_STATE_ABOVE", "_NET_WM_STATE_BELOW"):
#TODO: keep track of this preference and pass it to the client
pass
Expand All @@ -661,7 +666,6 @@ def do_xpra_client_message_event(self, event):
self.emit("raised", event)
else:
log("do_xpra_client_message_event(%s)", event)
self._last_wm_state_serial = event.serial

def set_active(self):
prop_set(self.client_window.get_screen().get_root_window(), "_NET_ACTIVE_WINDOW", "u32", self.client_window.xid)
Expand Down

0 comments on commit 7dfa6da

Please sign in to comment.