fix get_geometry to use the correct parameters to IsWindow and GetWindowRect (too much error trapping will create pitfalls), use main_window.window instead of window_foreign_new() to get gdkhandle for gtkwindow, remove process enumeration in topify() for windows

This commit is contained in:
eblade 2009-06-10 13:47:07 -04:00
parent 6e63e2a5e9
commit eb37de3594

View File

@ -79,12 +79,11 @@ class Table(Table_Window):
self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window)) self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window))
def get_geometry(self): def get_geometry(self):
if not win32gui.IsWindow(self.number): # window closed
if not win32gui.IsWindow(self.window): # window closed
return None return None
try: try:
(x, y, width, height) = win32gui.GetWindowRect(hwnd) (x, y, width, height) = win32gui.GetWindowRect(self.number)
width = width - x width = width - x
height = height - y height = height - y
return {'x' : int(x) + b_width, return {'x' : int(x) + b_width,
@ -121,20 +120,21 @@ class Table(Table_Window):
def topify(self, hud): def topify(self, hud):
"""Set the specified gtk window to stayontop in MS Windows.""" """Set the specified gtk window to stayontop in MS Windows."""
def windowEnumerationHandler(hwnd, resultList): # def windowEnumerationHandler(hwnd, resultList):
'''Callback for win32gui.EnumWindows() to generate list of window handles.''' # '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
resultList.append((hwnd, win32gui.GetWindowText(hwnd))) # resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
#
unique_name = 'unique name for finding this window' # unique_name = 'unique name for finding this window'
real_name = hud.main_window.get_title() # real_name = hud.main_window.get_title()
hud.main_window.set_title(unique_name) # hud.main_window.set_title(unique_name)
tl_windows = [] # tl_windows = []
win32gui.EnumWindows(windowEnumerationHandler, tl_windows) # win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
#
for w in tl_windows: # for w in tl_windows:
if w[1] == unique_name: # if w[1] == unique_name:
# hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) # hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
# hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) hud.main_window.gdkhandle = hud.main_window.window
hud.main_window.gdkhandle.set_transient_for(self.gdkhandle)
rect = self.gdkhandle.get_frame_extents() rect = self.gdkhandle.get_frame_extents()
(innerx, innery) = self.gdkhandle.get_origin() (innerx, innery) = self.gdkhandle.get_origin()
b_width = rect.x - innerx b_width = rect.x - innerx
@ -143,9 +143,9 @@ class Table(Table_Window):
# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE) # style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE)
# style |= win32con.WS_CLIPCHILDREN # style |= win32con.WS_CLIPCHILDREN
# win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style) # win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style)
break # break
hud.main_window.set_title(real_name) # hud.main_window.set_title(real_name)
def win_enum_handler(hwnd, titles): def win_enum_handler(hwnd, titles):
titles[hwnd] = win32gui.GetWindowText(hwnd) titles[hwnd] = win32gui.GetWindowText(hwnd)