[pygtk] wnck.window.is_visible_on_workspace(ws) not working under compiz

2009-08-24 Thread Jason Grant
Hello,

Hopefully it is OK to post queries here relating to use of wnck via
python.  I'm not sure where else to go...

I've written a little python program to tile windows under gnome.  It
worked nicely until I started using compiz.  Under compiz, all windows
report that they are on 'Workspace 1', and so
is_visible_on_workspace(ws) reports that all windows are visible on the
current workspace, even though they are spread across different
workspaces as depicted in the gnome panel's workspace switcher.

It looks to me as though the concept of workspaces no longer holds under
compiz?  i.e. they are all called Workspace 1 and are number 0
according to wnck?

I've included a sample program at [1] below with output at [2].  My
versions are shown at [3].

Thanks for any tips,

Jason.

--
[1] Sample program
--

#!/usr/bin/env python

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

class TestClass:

def printWindows(self, screen):

  # Print windows on the current workspace
  ws = screen.get_active_workspace()
  windows = screen.get_windows()
  for w in windows:
type=w.get_window_type()
if w.is_visible_on_workspace(ws) and type == wnck.WINDOW_NORMAL:
  print Window:  + repr(w.get_name()) +   +
repr(w.get_workspace().get_name())

  # Our work is done - quit the main loop
  gtk.main_quit()

def main(self):
  # register a callback to be invoked when main loop is idle
  screen = wnck.screen_get_default()
  gobject.idle_add(self.printWindows, screen)
  gtk.main()

# This is the entry point if we are invoked on the command-line
if __name__ == __main__:
  testClass = TestClass()
  testClass.main()


--
[2] Program output
--
[...@talby temp]$ ./windows.py 
Window: 'Inbox (2 unread, 44 total) - Evolution' 0
Window: 'screen' 0
Window: 'windows.py (~/temp) - GVIM' 0
Window: 'j...@powell:~' 0
Window: 'wnck.window.is_visible_on_workspace(ws) not working under
compiz' 0
Window: 'WnckWorkspace - Mozilla Firefox 3.5 Beta 4' 0


--
[3] Versions (under fedora 11)
--

[...@talby temp]$ uname -a
Linux talby 2.6.29.4-167.fc11.i686.PAE #1 SMP Wed May 27 17:28:22 EDT
2009 i686 i686 i386 GNU/Linux

[r...@talby ~]# rpm -qa | egrep 'wnck|gtk' | sort
authconfig-gtk-5.4.10-1.fc11.i586
GConf2-gtk-2.26.2-1.fc11.i586
gnome-python2-gtkhtml2-2.25.3-6.fc11.i586
gnome-python2-libwnck-2.26.0-3.fc11.i586
gtk2-2.16.2-1.fc11.i586
gtk2-devel-2.16.2-1.fc11.i586
gtk2-engines-2.18.1-1.fc11.i586
gtk-doc-1.11-4.fc11.noarch
gtkglext-libs-1.2.0-9.fc11.i586
gtkhtml2-2.11.1-5.fc11.i586
gtkhtml3-3.26.1.1-1.fc11.i586
gtkmm24-2.16.0-1.fc11.i586
gtk-nodoka-engine-0.7.2-4.fc11.i586
gtk-sharp2-2.12.7-4.fc11.i586
gtksourceview2-2.6.1-1.fc11.i586
gtkspell-2.0.15-1.fc11.i586
ibus-gtk-1.1.0.20090423-1.fc11.i586
libcanberra-gtk2-0.12-1.fc11.i586
libwnck-2.26.1-1.fc11.i586
PackageKit-gtk-module-0.4.8-2.fc11.i586
pygtk2-2.14.1-1.fc11.i586
pygtk2-libglade-2.14.1-1.fc11.i586
pygtkglext-1.1.0-6.fc11.i586
pygtksourceview-2.4.0-3.fc11.i586
python-slip-gtk-0.1.15-3.fc11.noarch
usermode-gtk-1.100-2.i586
webkitgtk-1.1.4-1.fc11.i586
xdg-user-dirs-gtk-0.8-3.fc11.i586

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] How to get window decoration sizes?

2008-11-14 Thread Jason Grant
Hi,

There has been a bug for some time relating to wnck set_geometry() not
placing windows as specified.  (See my post in June
wnck.window.set_geometry() misbehaving and gnome bug 518606).

Alas, this bug still remains, and so as a work-around, I need to
determine the width/height of the decorations surrounding a window.  I
am new to python and GTK, and it is not clear to me how to make a query
for these sizes.

I'm including my code below that illustrates how the new geometry
differs from the requested geometry.

Thanks for any tips,

Jason.

==

The following little program prints:

Requested: 1, 50, 550, 250
New  : 4, 71, 548, 246

==

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

class WindowPlacer:

def report(self, screen):
  # Compare new geometry with requested geometry
  window=screen.get_active_window()
  geom = window.get_geometry()
  print New :  + repr(geom[0]) + ,  + repr(geom[1]) + ,  + 
repr(geom[2]) + ,  + repr(geom[3])

  # Quit the main loop
  gtk.main_quit()

def place(self, screen):
  window=screen.get_active_window()

  # Indicate that we want to change all geometry params
  flags=wnck.WINDOW_CHANGE_X  | wnck.WINDOW_CHANGE_Y | 
wnck.WINDOW_CHANGE_WIDTH | wnck.WINDOW_CHANGE_HEIGHT

  # Set the geometry, flush pending events, and force an update
  left=1
  top=50
  width=550
  height=250
  window.set_geometry(wnck.WINDOW_GRAVITY_NORTHWEST, flags, left, top, 
width, height)
  print Requested:  + repr(left) + ,  + repr(top) + ,  + repr(width) 
+ ,  + repr(height)

  # Quit the main loop
  gtk.main_quit()

def main(self):
  # register a callback to be invoked when main loop is idle
  screen=wnck.screen_get_default()
  gobject.idle_add(self.place, screen)
  gtk.main()
  screen.force_update()
  # while gtk.events_pending() : gtk.main_iteration()
  gobject.idle_add(self.report, screen)
  gtk.main()

# This is the entry point if we are invoked on the command-line
if __name__ == __main__:
  windowPlacer = WindowPlacer()
  windowPlacer.main()

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] wnck.window.set_geometry() misbehaving

2008-06-09 Thread Jason Grant
It turns out that set_geometry() does not place windows as specified
because it does not take window decorations, etc., into account:

http://bugzilla.gnome.org/show_bug.cgi?id=518606

A fix has been coded - I am awaiting release of same before going back
to my window tiling app.

J.

On Sun, 2008-06-08 at 00:56 +0200, Gian Mario Tagliaretti wrote:
 On Tue, Jun 3, 2008 at 6:50 AM, Jason Grant [EMAIL PROTECTED] wrote:
 
 Hi Jason,
 
  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 think this is the best place too.
 
  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.
 
 I think a minimal example that shows the problem will be a great help
 in trying to help you :)
 Anyway the bindings for this function are not being manually wrapped,
 so it's really weird.
 
 cheers

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/