[pygtk] wnck.window.set_geometry() misbehaving
Jason Grant
expires07 at logular.com
Tue Jun 3 12:50:44 WST 2008
I understand this is the pygtk list but am hoping for tips on use of
wnck via python - after looking at the source of gnome-python-desktop,
I'm not sure where else to go for gnome-python discussion.
I'm writing my first python program - my aim is to implement some window
tiling support for gnome.
After calculating window positions, I invoke wnck.window.set_geometry(),
however the windows are not being placed according to the supplied
x,y,width,height - see output & code below.
My calls to set_geometry() are made from a callback that is invoked when
the main loop is idle as shown below. I am hoping that the placement
anomaly is due to my ignorance about manipulating windows within the
main loop - you can see my efforts to invoke main_iteration() and
force_update() below.
Thanks for any ideas about why the windows are not placed as specified.
Jason.
--------------------------------
Code extract
--------------------------------
# register a callback to be invoked when main loop is idle
screen = wnck.screen_get_default()
gobject.idle_add(self.invoke_tile, screen)
gtk.main()
# In the callback set geometry on a window with type "normal"
flags=wnck.WINDOW_CHANGE_X | wnck.WINDOW_CHANGE_Y |
wnck.WINDOW_CHANGE_WIDTH | wnck.WINDOW_CHANGE_HEIGHT
window.set_geometry(wnck.WINDOW_GRAVITY_NORTHWEST, flags, left, top,
width, height)
# Found that rolling the main loop helps
while gtk.events_pending() : gtk.main_iteration()
self.workspace.get_screen().force_update()
# However final location is never as requested
geom = window.get_geometry()
print "Request: " + repr(left) + ", " + repr(top) + ", " + repr(width) +
", " + repr(height)
print "Placed : " + repr(geom[0]) + ", " + repr(geom[1]) + ", " +
repr(geom[2]) + ", " + repr(geom[3])
--------------------------------
Sample output for two windows - see how they are not placed
where requested.
--------------------------------
Request: 10, 35, 615, 725
Placed : 211, 95, 752, 470
Request: 650, 35, 615, 725
Placed : 653, 50, 615, 725
More information about the pygtk
mailing list