Another possible fix to missing windows.

This commit is contained in:
Eratosthenes 2009-11-16 13:04:25 -05:00
parent 4abfc0093f
commit 55f1ebedd9

View File

@ -25,6 +25,7 @@ of Table_Window objects representing the windows found.
# Standard Library modules # Standard Library modules
import re import re
import os
# pyGTK modules # pyGTK modules
import pygtk import pygtk
@ -45,26 +46,43 @@ name_atom = disp.get_atom("WM_NAME", 1)
class Table(Table_Window): class Table(Table_Window):
def find_table_parameters(self, search_string): def find_table_parameters(self, search_string):
self.window = None # self.window = None
# done_looping = False
# for outside in root.query_tree().children:
# for inside in outside.query_tree().children:
# if done_looping: break
# prop = inside.get_property(name_atom, Xlib.Xatom.STRING, 0, 1000)
# print prop
# if prop is None: continue
# if prop.value and re.search(search_string, prop.value):
# if self.check_bad_words(prop.value): continue
## if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()):
## if self.check_bad_words(inside.get_wm_name()):
## print "bad word =", inside.get_wm_name()
## continue
# self.window = inside
# self.parent = outside
# done_looping = True
# break
window_number = None
for listing in os.popen('xwininfo -root -tree').readlines():
if re.search(search_string, listing):
print listing
mo = re.match('\s+([\dxabcdef]+)\s', listing)
window_number = int( mo.group(1), 0)
done_looping = False done_looping = False
for outside in root.query_tree().children: for outside in root.query_tree().children:
for inside in outside.query_tree().children: for inside in outside.query_tree().children:
if done_looping: break if done_looping: break
prop = inside.get_property(name_atom, Xlib.Xatom.STRING, 0, 1000) if inside.id == window_number:
print prop
if prop is None: continue
if prop.value and re.search(search_string, prop.value):
if self.check_bad_words(prop.value): continue
# if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()):
# if self.check_bad_words(inside.get_wm_name()):
# print "bad word =", inside.get_wm_name()
# continue
self.window = inside self.window = inside
self.parent = outside self.parent = outside
done_looping = True done_looping = True
break break
if self.window == None or self.parent == None: if window_number is None:
print "Window %s not found. Skipping." % search_string print "Window %s not found. Skipping." % search_string
return None return None