Skip to content

Commit

Permalink
#794: allow the WM_COMMAND to be updated, moves the code to a set_com…
Browse files Browse the repository at this point in the history
…mand method which is cleaner, includes test app

git-svn-id: https://xpra.org/svn/Xpra/trunk@9963 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 17, 2015
1 parent 5ccebb3 commit 8c547e1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
28 changes: 28 additions & 0 deletions src/tests/xpra/test_apps/test_command_change.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

import gobject
import pygtk
pygtk.require('2.0')
import gtk

from xpra.x11.gtk2 import gdk_display_source
assert gdk_display_source
from xpra.x11.gtk_x11.prop import prop_set
from xpra.gtk_common.error import xsync

def main():
win = gtk.Window()
win.set_size_request(400, 100)
win.set_title("WM_COMMAND test")
win.show()
def change_wmcommand():
with xsync:
prop_set(win.get_window(), "WM_COMMAND", "latin1", u"HELLO WORLD")
print("WM_COMMAND changed!")
gobject.timeout_add(1000, change_wmcommand)
gtk.main()
return 0


if __name__ == '__main__':
main()
6 changes: 6 additions & 0 deletions src/xpra/client/client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ def metadata_replace(match):
if b"shape" in metadata:
self.set_shape(metadata.dictget("shape"))

if b"command" in metadata:
self.set_command(metadata.strget("command"))


def set_command(self, command):
pass

def set_class_instance(self, wmclass_name, wmclass_class):
pass
Expand Down
22 changes: 13 additions & 9 deletions src/xpra/client/gtk_base/gtk_client_window_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def after_window_state_updated(self):
pass


def set_command(self, command):
metalog("set_command(%s) (type=%s)", command, type(command))
if type(command)!=unicode:
v = bytestostr(command)
try:
v = v.decode("utf8")
except:
pass
prop_set(self.get_window(), "WM_COMMAND", "latin1", v)

def set_class_instance(self, wmclass_name, wmclass_class):
if not self.is_realized():
#Warning: window managers may ignore the icons we try to set
Expand Down Expand Up @@ -476,15 +486,9 @@ def realize(self):
if HAS_X11_BINDINGS:
#now it is realized, we can set WM_COMMAND (for X11 clients only)
command = self._metadata.strget("command")
v = command
if type(command)!=unicode:
v = bytestostr(command)
try:
v = v.decode("utf8")
except:
pass
log("realize() command=%s (%s)", v, type(v))
prop_set(self.get_window(), "WM_COMMAND", "latin1", v)
if command:
self.set_command(command)
#and request frame extents if the window manager supports it
self._client.request_frame_extents(self)


Expand Down

0 comments on commit 8c547e1

Please sign in to comment.