Allow crash-free dragging, etc on X.

This commit is contained in:
Eratosthenes 2011-02-08 18:32:25 -05:00
parent b4ef4bdecb
commit ce7f514f08

View File

@ -88,23 +88,51 @@ class Table(Table_Window):
if w.id == id: if w.id == id:
return (w, top_level) return (w, top_level)
#def get_geometry(self):
#try:
#my_geo = self.window.get_geometry()
#if self.parent is None:
#return {'x' : my_geo.x,
#'y' : my_geo.y,
#'width' : my_geo.width,
#'height' : my_geo.height
#}
#else:
#pa_geo = self.parent.get_geometry()
#return {'x' : my_geo.x + pa_geo.x,
#'y' : my_geo.y + pa_geo.y,
#'width' : my_geo.width,
#'height' : my_geo.height
#}
#except:
#return None
def get_geometry(self): def get_geometry(self):
geo_re = '''
Absolute\supper-left\sX: \s+ (?P<X>\d+) # x
.+
Absolute\supper-left\sY: \s+ (?P<Y>\d+) # y
.+
Width: \s+ (?P<W>\d+) # width
.+
Height: \s+ (?P<H>\d+) # height
'''
des_re = 'No such window with id'
listing = os.popen("xwininfo -id %d -stats" % (self.number)).read()
mo = re.search(des_re, listing)
if mo is not None:
return None # table has been destroyed
mo = re.search(geo_re, listing, re.VERBOSE|re.DOTALL)
try: try:
my_geo = self.window.get_geometry() return {'x' : int(mo.groupdict()['X']),
if self.parent is None: 'y' : int(mo.groupdict()['Y']),
return {'x' : my_geo.x, 'width' : int(mo.groupdict()['W']),
'y' : my_geo.y, 'height' : int(mo.groupdict()['H'])
'width' : my_geo.width, }
'height' : my_geo.height except AttributeError:
}
else:
pa_geo = self.parent.get_geometry()
return {'x' : my_geo.x + pa_geo.x,
'y' : my_geo.y + pa_geo.y,
'width' : my_geo.width,
'height' : my_geo.height
}
except:
return None return None
def get_window_title(self): def get_window_title(self):