Question

I have a Linux-only wxPython application with a wxFrame that acts as a menu/toolbar, it can open up new windows that are independent of the toolbar itself.
Since the user can move any of these windows to any virtual workspace, I'm looking for a way to move the toolbar to the current workspace whenever the user activates a window.
I tried using Raise(), but in this way the toolbar receives the focus too and I don't want that. Please note that I can't make the toolbar sticky, since I don't want it on every workspace.

Thanks!

(wxPython 2.8.9.1, Ubuntu 9.04)

Follow-up:

I checked the source code of xfwm4 to see how it does its "Move window to workspace N".. It uses the _NET_WM_DESKTOP hint, so I'm trying to do it using Python.. Here's my code right now:

import gtk

def move_to_workspace(frame, ws):
    gdkwin = gtk.gdk.window_lookup(frame.GetHandle())
    win = gdkwin.get_user_data()
    while not isinstance(win, gtk.Window): # Find parent Window object
        win = win.get_parent()
    win.window.property_change(gtk.gdk.atom_intern("_NET_WM_DESKTOP"),
                                                        gtk.gdk.atom_intern("CARDINAL"), 32,
                                                        gtk.gdk.PROP_MODE_REPLACE,
                                                        [ws])

It looks like the code is somewhat successful, since xprop detects the change:

(before execution)
$ xprop | grep WM_DESKTOP
_NET_WM_DESKTOP(CARDINAL) = 0

(after)
$xprop | grep WM_DESKTOP
_NET_WM_DESKTOP(CARDINAL) = 1

but the problem is that the window doesn't move to the desired workspace :/

Should I use python-xlib instead of pygtk? If that's the case, how can I get from a wxFrame (or gtk.Window, or XID) the corresponding Xlib.Window?

Follow-up 2:

The same happens using xprop..

$ xprop -id <id> -f _NET_WM_DESKTOP 32c -set _NET_WM_DESKTOP 1

It detects the changed _NET_WM_DESKTOP, but the window stays there :/ However, I noticed the following:

  • an iconified version of the window appears on the intended workspace
  • if I iconify the window on the "source" workspace, it disappears

So, maybe I should send some kind of "refresh" message to the window manager too..?

Was it helpful?

Solution

It's kinda old, but still... You gotta call flush method of display.Display instance after setting window properties and sending events.

OTHER TIPS

In the end I decided to just use wmctrl.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top