From d592e85375a020e73fe259cb518324a402aa3568 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Mon, 16 Nov 2009 11:20:44 -0500 Subject: [PATCH 1/3] Possible fix of not finding windows in X. --- pyfpdb/XTables.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index fd1ce9c1..cbfa8875 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -40,6 +40,7 @@ from TableWindow import Table_Window # We might as well do this once and make them globals disp = Xlib.display.Display() root = disp.screen().root +name_atom = disp.get_atom("WM_NAME", 1) class Table(Table_Window): @@ -49,8 +50,14 @@ class Table(Table_Window): for outside in root.query_tree().children: for inside in outside.query_tree().children: if done_looping: break - if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()): - if self.check_bad_words(inside.get_wm_name()): continue + prop = inside.get_property(name_atom, Xlib.Xatom.STRING, 0, 1000) + 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 From 4abfc0093fb326adf769f0b27f13fff309a3f3c6 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Mon, 16 Nov 2009 11:48:31 -0500 Subject: [PATCH 2/3] test print --- pyfpdb/XTables.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index cbfa8875..590bd743 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -51,6 +51,7 @@ class Table(Table_Window): 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 From 55f1ebedd934e389974d844cc84cbb2c0778a487 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Mon, 16 Nov 2009 13:04:25 -0500 Subject: [PATCH 3/3] Another possible fix to missing windows. --- pyfpdb/XTables.py | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 590bd743..c19db5d9 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -25,6 +25,7 @@ of Table_Window objects representing the windows found. # Standard Library modules import re +import os # pyGTK modules import pygtk @@ -45,26 +46,43 @@ name_atom = disp.get_atom("WM_NAME", 1) class Table(Table_Window): 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 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 + if inside.id == window_number: self.window = inside self.parent = outside done_looping = True break - if self.window == None or self.parent == None: + if window_number is None: print "Window %s not found. Skipping." % search_string return None