From 7d4bded3d5b7076ecf2074309bf9d6407160d3c4 Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 9 Dec 2008 01:43:13 -0500 Subject: [PATCH 1/4] make sure we close each handle opened by ProcessOpen in the win32 calls --- pyfpdb/Hud.py | 1 + pyfpdb/Tables.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 80ec9a82..aaa9b42d 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -307,6 +307,7 @@ class Stat_Window: pass if event.button == 1: # left button event + # TODO: make position saving save sizes as well? if event.state & gtk.gdk.SHIFT_MASK: self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time) else: diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 9f5360e2..d2cb2a24 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -248,7 +248,9 @@ def get_nt_exe(hwnd): """Finds the name of the executable that the given window handle belongs to.""" processid = win32process.GetWindowThreadProcessId(hwnd) pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1]) - return win32process.GetModuleFileNameEx(pshandle, 0) + exename = win32process.GetModuleFileNameEx(pshandle, 0) + win32api.CloseHandle(pshandle) + return exename def decode_windows(c, title, hwnd): """Gets window parameters from the window title and handle--Windows.""" From 9dd6f36df635d4d02df5a286644ceddc7c9a8c8c Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 9 Dec 2008 07:51:41 -0500 Subject: [PATCH 2/4] add Hud::update_table_position(), tracks table.x and table.y, repositions all stat_windows within. triggered each update(), and when the Reposition Stats menu option is selected. fix windows code to use same gdkhandle variables as unix code --- pyfpdb/Hud.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index aaa9b42d..03ba1696 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -120,6 +120,19 @@ class Hud: self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) # self.main_window.set_destroy_with_parent(True) + + def update_table_position(self): + (x, y) = self.main_window.parentgdkhandle.get_origin() + if self.table.x != x or self.table.y != y: + self.table.x = x + self.table.y = y + self.main_window.move(x, y) + adj = self.adj_seats(self.hand, self.config) + loc = self.config.get_locations(self.table.site, self.max) + for i in range(1, self.max + 1): + (x, y) = loc[adj[i]] + if self.stat_windows.has_key(i): + self.stat_windows[i].relocate(x, y) def on_button_press(self, widget, event): if event.button == 1: @@ -137,9 +150,7 @@ class Hud: self.deleted = True def reposition_windows(self, *args): - for w in self.stat_windows: - self.stat_windows[w].window.move(self.stat_windows[w].x, - self.stat_windows[w].y) + self.update_table_position() def debug_stat_windows(self, *args): print self.table, "\n", self.main_window.window.get_transient_for() @@ -216,6 +227,7 @@ class Hud: def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later + self.update_table_position() for s in stat_dict.keys(): try: self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] @@ -260,9 +272,9 @@ class Hud: for w in tl_windows: if w[1] == unique_name: #win32gui.ShowWindow(w[0], win32con.SW_HIDE) - window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) + self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) self.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) - self.main_window.gdkhandle.set_transient_for(window.parentgdkhandle) + self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #win32gui.ShowWindow(w[0], win32con.SW_SHOW) style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) From 7516d17a40999fdd0638221f8b9998c3ddc96b4d Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 9 Dec 2008 08:21:50 -0500 Subject: [PATCH 3/4] add 0.5 sec auto-timer to auto-run update_table_position --- pyfpdb/Hud.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 03ba1696..a98c1421 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -224,6 +224,8 @@ class Hud: if not game_params['aux'] == "": aux_params = config.get_aux_parameters(game_params['aux']) self.aux_windows.append(eval("%s.%s(gtk.Window(), config, 'fpdb')" % (aux_params['module'], aux_params['class']))) + + gobject.timeout_add(0.5, update_table_position) def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later From 5e23b55361b855efb50efdd3ce802a5f44d60594 Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 9 Dec 2008 08:35:19 -0500 Subject: [PATCH 4/4] specify right function name to timer, duh --- pyfpdb/Hud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index a98c1421..dcc7298c 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -225,7 +225,7 @@ class Hud: aux_params = config.get_aux_parameters(game_params['aux']) self.aux_windows.append(eval("%s.%s(gtk.Window(), config, 'fpdb')" % (aux_params['module'], aux_params['class']))) - gobject.timeout_add(0.5, update_table_position) + gobject.timeout_add(0.5, self.update_table_position) def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later