Skip to content

Commit

Permalink
#537: add a new "window state" attribute sent back by the client so w…
Browse files Browse the repository at this point in the history
…e can tell the server when we have maximized a window, so the server-side state matches and maximize/unmaximize work as expected, both when used programmatically (from the application on the server) and when triggered using the window manager controls

git-svn-id: https://xpra.org/svn/Xpra/trunk@8295 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 26, 2014
1 parent 7dfa6da commit 81e6a0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
19 changes: 14 additions & 5 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class GTKKeyEvent(AdHocStruct):
class GTKClientWindowBase(ClientWindowBase, gtk.Window):

def init_window(self, metadata):
self._window_state = {}
self._iconified = False
self._resize_counter = 0
self._window_workspace = self._client_properties.get("workspace", -1)
Expand Down Expand Up @@ -195,8 +196,12 @@ def window_state_updated(self, widget, event):
self._fullscreen = bool(event.new_window_state & self.WINDOW_STATE_FULLSCREEN)
maximized = bool(event.new_window_state & self.WINDOW_STATE_MAXIMIZED)
iconified = bool(event.new_window_state & self.WINDOW_STATE_ICONIFIED)
self._client_properties["maximized"] = maximized
log("%s.window_state_updated(%s, %s) new_window_state=%s, fullscreen=%s, maximized=%s, iconified=%s", self, widget, repr(event), event.new_window_state, self._fullscreen, maximized, iconified)
if event.changed_mask & self.WINDOW_STATE_MAXIMIZED:
#this may get sent now as part of map_event code below (and it is irrelevant for the unmap case),
#or when we get the configure event - which should come straight after
#if we're changing the maximized state
self._window_state["maximized"] = maximized
log("%s.window_state_updated(%s, %s) changed_mask=%s, new_window_state=%s, fullscreen=%s, maximized=%s, iconified=%s", self, widget, repr(event), event.changed_mask, event.new_window_state, self._fullscreen, maximized, iconified)
if iconified!=self._iconified:
#handle iconification as map events:
assert not self._override_redirect
Expand Down Expand Up @@ -412,8 +417,10 @@ def do_map_event(self, event):

def process_map_event(self):
x, y, w, h = self.get_window_geometry()
state = self._window_state
props = self._client_properties
self._client_properties = {}
self._window_state = {}
if not self._been_mapped:
#this is the first time around, so set the workspace:
workspace = self.set_workspace()
Expand All @@ -427,8 +434,8 @@ def process_map_event(self):
workspacelog("map event: been_mapped=%s, changed workspace from %s to %s", self._been_mapped, self._window_workspace, workspace)
self._window_workspace = workspace
props["workspace"] = workspace
log("map-window for wid=%s with client props=%s", self._id, props)
self.send("map-window", self._id, x, y, w, h, props)
log("map-window for wid=%s with client props=%s, state=%s", self._id, props, state)
self.send("map-window", self._id, x, y, w, h, props, state)
self._pos = (x, y)
self._size = (w, h)
self.idle_add(self._focus_change, "initial")
Expand All @@ -447,8 +454,10 @@ def process_configure_event(self):
ox, oy = self._pos
dx, dy = x-ox, y-oy
self._pos = (x, y)
state = self._window_state
props = self._client_properties
self._client_properties = {}
self._window_state = {}
if self._been_mapped:
#if the window has been mapped already, the workspace should be set:
props["screen"] = self.get_screen().get_number()
Expand All @@ -457,7 +466,7 @@ def process_configure_event(self):
workspacelog("configure event: changed workspace from %s to %s", self._window_workspace, workspace)
self._window_workspace = workspace
props["workspace"] = workspace
packet = ["configure-window", self._id, x, y, w, h, props]
packet = ["configure-window", self._id, x, y, w, h, props, state]
if self._resize_counter>0:
packet.append(self._resize_counter)
self.send(*packet)
Expand Down
18 changes: 12 additions & 6 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,12 @@ def _raised_window(self, window, event):
for ss in self._server_sources.values():
ss.raise_window(wid, window)


def _set_window_state(self, proto, wid, window, new_window_state):
#only used for setting maximized state:
if "maximized" in new_window_state:
window.set_property("maximized", bool(new_window_state.get("maximized", False)))

def _process_map_window(self, proto, packet):
wid, x, y, width, height = packet[1:6]
window = self._id_to_window.get(wid)
Expand All @@ -677,6 +683,8 @@ def _process_map_window(self, proto, packet):
return
assert not window.is_OR()
windowlog("client mapped window %s - %s, at: %s", wid, window, (x, y, width, height))
if len(packet)>=8:
self._set_window_state(proto, wid, window, packet[7])
self._desktop_manager.configure_window(window, x, y, width, height)
self._desktop_manager.show_window(window)
if len(packet)>=7:
Expand All @@ -698,10 +706,6 @@ def _process_unmap_window(self, proto, packet):

def _process_configure_window(self, proto, packet):
wid, x, y, w, h = packet[1:6]
if len(packet)>=7:
client_properties = packet[6]
else:
client_properties = {}
resize_counter = 0
if len(packet)>=8:
resize_counter = packet[7]
Expand All @@ -717,11 +721,13 @@ def _process_configure_window(self, proto, packet):
else:
assert not window.is_OR()
self.last_client_configure_event = time.time()
if len(packet)>=8:
self._set_window_state(proto, wid, window, packet[7])
owx, owy, oww, owh = self._desktop_manager.window_geometry(window)
windowlog("_process_configure_window(%s) old window geometry: %s", packet[1:], (owx, owy, oww, owh))
self._desktop_manager.configure_window(window, x, y, w, h, resize_counter)
if client_properties:
self._set_client_properties(proto, wid, window, client_properties)
if len(packet)>=7:
self._set_client_properties(proto, wid, window, packet[6])
if window.is_tray() or (self._desktop_manager.visible(window) and (oww!=w or owh!=h)):
self._damage(window, 0, 0, w, h)

Expand Down

0 comments on commit 81e6a0b

Please sign in to comment.