On Ubuntu Linux / Gnome, I'm trying to use the python wnck binding to get a list of all open windows.
My code is as follows:
from pprint import pprint
import wnck
screen = wnck.screen_get_default()
pprint(screen.get_windows())
import pdb ; pdb.set_trace()
pprint(screen.get_windows())
The output is as follows:
** (windowlist.py:4501): WARNING **: Trying to register gtype 'WnckWindowState' as enum when in fact it is of type 'GFlags'
** (windowlist.py:4501): WARNING **: Trying to register gtype 'WnckWindowActions' as enum when in fact it is of type 'GFlags'
** (windowlist.py:4501): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as enum when in fact it is of type 'GFlags'
[]
> /home/rory/personal/diriu/windowlist.py(12)<module>()
-> pprint(screen.get_windows())
(Pdb) c
[<wnck.Window object at 0xb61db0cc (WnckWindow at 0x992c000)>,
<wnck.Window object at 0xb61db0f4 (WnckWindow at 0x992c0a8)>,
<wnck.Window object at 0xb61db11c (WnckWindow at 0x992c150)>,
<wnck.Window object at 0xb61db144 (WnckWindow at 0x992c1f8)>,
<wnck.Window object at 0xb61db16c (WnckWindow at 0x992c2a0)>,
<wnck.Window object at 0xb61db194 (WnckWindow at 0x992c348)>,
<wnck.Window object at 0xb61db1bc (WnckWindow at 0x992c3f0)>,
<wnck.Window object at 0xb61db1e4 (WnckWindow at 0x992c498)>,
<wnck.Window object at 0xb61db20c (WnckWindow at 0x992c540)>,
<wnck.Window object at 0xb61db234 (WnckWindow at 0x992c5e8)>,
<wnck.Window object at 0xb61db25c (WnckWindow at 0x992c690)>,
<wnck.Window object at 0xb61db284 (WnckWindow at 0x992c738)>]
The first call get_windows()returns []an empty list. The second call get_windows()returns a list of open windows. In pdbI just click cto continue and do nothing (in pdb).
If I comment pdb, both get_windows()will call return []. If I repeat the call get_windows()many times before pdb, there is nothing. If I repeat the call get_windows()many times after pdb, I constantly get a complete list.
Why does this call only work after empty pdb? How to make it work without pdb?