Skip to content

Commit

Permalink
#705: more wm-name fixes:
Browse files Browse the repository at this point in the history
* add a config file option
* set the wm-name on the root window too, since some tools don't honour the spec and look it up there instead of on the _NET_SUPPORTING_WM_CHECK window

git-svn-id: https://xpra.org/svn/Xpra/trunk@8329 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 30, 2014
1 parent 5fff8ae commit 89dd7b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/etc/xpra/xpra.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ exit-with-children = no
#start-new-commands = yes
start-new-commands = no

# Set the _NET_WM_NAME,
# used by some application that make too many assumptions (ie: Java)
# To workaround JDK6 window positioning issues, use:
#wm-name = Sawfish
wm-name = Xpra

# Video encoders loaded by the server
# (all of them unless specified)
# examples:
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def debug(*args):
pass

DEFAULT_XPRA_CONF_FILENAME = os.environ.get("XPRA_CONF_FILENAME", 'xpra.conf')
DEFAULT_NET_WM_NAME = os.environ.get("XPRA_NET_WM_NAME", "Xpra")


ENCRYPTION_CIPHERS = []
Expand Down Expand Up @@ -244,6 +245,7 @@ def read_xpra_defaults():
"title" : str,
"username" : str,
"auth" : str,
"wm-name" : str,
"remote-xpra" : str,
"session-name" : str,
"dock-icon" : str,
Expand Down Expand Up @@ -341,6 +343,7 @@ def get_defaults():
"title" : "@title@ on @client-machine@",
"username" : username,
"auth" : "",
"wm-name" : DEFAULT_NET_WM_NAME,
"remote-xpra" : "~/.xpra/run-xpra",
"session-name" : "",
"dock-icon" : "",
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def run_server(error_cb, opts, mode, xpra_file, extra_args):

#check for an existing window manager:
from xpra.x11.gtk_x11.wm import wm_check
if not wm_check(display, upgrading):
if not wm_check(display, opts.wm_name, upgrading):
return 1
try:
# This import is delayed because the module depends on gtk:
Expand Down
14 changes: 7 additions & 7 deletions src/xpra/x11/gtk_x11/wm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
NotifyPointerRoot = constants["NotifyPointerRoot"]
NotifyDetailNone = constants["NotifyDetailNone"]

XPRA_NET_WM_NAME = os.environ.get("XPRA_NET_WM_NAME", "Xpra")
XPRA_FORCE_REPLACE_WM = os.environ.get("XPRA_FORCE_REPLACE_WM", "0")=="1"


def wm_check(display, upgrading=False):
def wm_check(display, wm_name, upgrading=False):
#there should only be one screen... but let's check all of them
for i in range(display.get_n_screens()):
screen = display.get_screen(i)
Expand Down Expand Up @@ -64,7 +63,7 @@ def xid(w):
name = prop_get(ewmh_wm, "_NET_WM_NAME", "utf8", ignore_errors=False, raise_xerrors=False)
except:
name = None
if upgrading and name and name==XPRA_NET_WM_NAME:
if upgrading and name and name==wm_name:
log.info("found previous Xpra instance")
else:
log.warn("Warning: found an existing window manager on screen %s using window %#x: %s", i, ewmh_wm.xid, name or "unknown")
Expand Down Expand Up @@ -200,13 +199,14 @@ class Wm(gobject.GObject):
"xpra-xkb-event": one_arg_signal,
}

def __init__(self, replace_other_wm, display=None):
def __init__(self, replace_other_wm, wm_name, display=None):
gobject.GObject.__init__(self)

if display is None:
display = gtk.gdk.display_manager_get().get_default_display()
self._display = display
self._root = self._display.get_default_screen().get_root_window()
self._wm_name = wm_name
self._ewmh_window = None

self._windows = {}
Expand Down Expand Up @@ -437,11 +437,11 @@ def _setup_ewmh_window(self):
window_type=gtk.gdk.WINDOW_TOPLEVEL,
event_mask=0, # event mask
wclass=gtk.gdk.INPUT_ONLY,
title=XPRA_NET_WM_NAME)
title=self._wm_name)
prop_set(self._ewmh_window, "_NET_SUPPORTING_WM_CHECK",
"window", self._ewmh_window)
self.root_set("_NET_SUPPORTING_WM_CHECK",
"window", self._ewmh_window)
self.root_set("_NET_SUPPORTING_WM_CHECK", "window", self._ewmh_window)
self.root_set("_NET_WM_NAME", "utf8", self._wm_name.decode("utf8"))

def get_net_wm_name(self):
try:
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def __init__(self, clobber):
X11ServerBase.__init__(self, clobber)

def init(self, opts):
X11ServerBase.init(self, opts)
self.xsettings_enabled = opts.xsettings
self.wm_name = opts.wm_name
X11ServerBase.init(self, opts)

def x11_init(self):
X11ServerBase.x11_init(self)
Expand All @@ -208,7 +209,7 @@ def x11_init(self):
add_event_receiver(root, self)

### Create the WM object
self._wm = Wm(self.clobber)
self._wm = Wm(self.clobber, self.wm_name)
self._wm.connect("new-window", self._new_window_signaled)
self._wm.connect("bell", self._bell_signaled)
self._wm.connect("quit", lambda _: self.quit(True))
Expand Down

0 comments on commit 89dd7b3

Please sign in to comment.