Delete xwininfo stuff. Reinstall Xlib stuff.

This commit is contained in:
Eratosthenes 2010-03-02 23:12:55 -05:00
parent 1c276915d8
commit 12c08f6aa5
2 changed files with 34 additions and 72 deletions

View File

@ -3,7 +3,7 @@
Main program module to test/demo the Tables subclasses. Main program module to test/demo the Tables subclasses.
""" """
# Copyright 2008 - 2009, Ray E. Barker # Copyright 2008 - 2010, Ray E. Barker
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -24,10 +24,8 @@ Main program module to test/demo the Tables subclasses.
# Standard Library modules # Standard Library modules
import sys import sys
import os import os
import re
# pyGTK modules # pyGTK modules
import pygtk
import gtk import gtk
import gobject import gobject
@ -103,7 +101,7 @@ if __name__=="__main__":
fake = fake_hud(table) fake = fake_hud(table)
print "fake =", fake print "fake =", fake
# gobject.timeout_add(100, check_on_table, table, fake) gobject.timeout_add(100, check_on_table, table, fake)
print "calling main" print "calling main"
gtk.main() gtk.main()

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
"""Discover_Tables.py """XTables.py
Inspects the currently open windows and finds those of interest to us--that is XWindows specific methods for TableWindows Class.
poker table windows from supported sites. Returns a list
of Table_Window objects representing the windows found.
""" """
# Copyright 2008 - 2009, Ray E. Barker # Copyright 2008 - 2010, Ray E. Barker
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -25,14 +23,11 @@ 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 gtk import gtk
# Other Library modules # Other Library modules
import Xlib
import Xlib.display import Xlib.display
# FreePokerTools modules # FreePokerTools modules
@ -46,72 +41,41 @@ 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 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.get_wm_name() and re.search(search_string, inside.get_wm_name()):
# print prop if self.check_bad_words(inside.get_wm_name()): continue
# if prop is None: continue self.window = inside
# if prop.value and re.search(search_string, prop.value): self.parent = outside
# if self.check_bad_words(prop.value): continue done_looping = True
## if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()): break
## 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 if self.window == None or self.parent == None:
for listing in os.popen('xwininfo -root -tree').readlines(): print "Window %s not found. Skipping." % search_string
if re.search(search_string, listing):
# print listing
mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z.]+)\".+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing)
self.number = int( mo.group(1), 0)
self.width = int( mo.group(4) )
self.height = int( mo.group(5) )
self.x = int( mo.group(6) )
self.y = int( mo.group(7) )
self.title = re.sub('\"', '', mo.group(2))
self.exe = "" # not used?
self.hud = None
# done_looping = False
# for outside in root.query_tree().children:
# for inside in outside.query_tree().children:
# if done_looping: break
# if inside.id == window_number:
# self.window = inside
# self.parent = outside
# done_looping = True
# break
if window_number is None:
return None return None
# my_geo = self.window.get_geometry() my_geo = self.window.get_geometry()
# pa_geo = self.parent.get_geometry() pa_geo = self.parent.get_geometry()
#
# self.x = pa_geo.x + my_geo.x
# self.y = pa_geo.y + my_geo.y
# self.width = my_geo.width
# self.height = my_geo.height
# self.exe = self.window.get_wm_class()[0]
# self.title = self.window.get_wm_name()
# self.site = ""
# self.hud = None
# window_string = str(self.window) self.x = pa_geo.x + my_geo.x
mo = re.match('Xlib\.display\.Window\(([\dxabcdef]+)', window_string) self.y = pa_geo.y + my_geo.y
self.width = my_geo.width
self.height = my_geo.height
self.exe = self.window.get_wm_class()[0]
self.title = self.window.get_wm_name()
self.site = ""
self.hud = None
self.number = self.get_xid()
def get_xid(self):
mo = re.match('Xlib\.display\.Window\(([\dxabcdef]+)', str(self.window))
if not mo: if not mo:
print "Not matched" return None
self.gdk_handle = None
else: else:
self.number = int( mo.group(1), 0) return int( mo.group(1), 0)
print "number =", self.number
# self.gdk_handle = gtk.gdk.window_foreign_new(int(self.number))
def get_geometry(self): def get_geometry(self):
try: try: