From 55de5ed66282f5d2b89607937e2bd1480d1607f8 Mon Sep 17 00:00:00 2001 From: DETROYAT Alexis <alexis.detroyat@inria.fr> Date: Tue, 20 Jun 2023 16:42:56 +0200 Subject: [PATCH] Fixed a regex issue that prevented the vim code window to snap accordingly to the agdbentures window + a window scaling issue --- lib/code_window.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/code_window.py b/lib/code_window.py index bdcae674..4eab9ef0 100644 --- a/lib/code_window.py +++ b/lib/code_window.py @@ -54,7 +54,7 @@ class NoServerWindow(GenServerWindow): self._window_title = "NoServerWindow" -pos_re = re.compile(r'Position: (\d+),(\d+) ') +pos_re = re.compile(r'Position: (-?\d+),(-?\d+)') geom_re = re.compile(r'Geometry: (\d+)x(\d+)') wid_re = re.compile(r'WID: (\d+)\n') dimen_re = re.compile(r'dimensions: +(\d+)x(\d+) pixels') @@ -99,7 +99,7 @@ class ServerWindow(GenServerWindow): map(int, m[-1]) ) - # print ("SCREEN DIMENSIONS", self._screen_width, self._screen_height, self._screen_offset_x) + log.debug(f"SCREEN DIMENSIONS : {self._screen_width, self._screen_height, self._screen_offset_x}") self.xdotool = shutil.which("xdotool") if not self.xdotool: @@ -169,24 +169,29 @@ class ServerWindow(GenServerWindow): winid = self._window_id x = run([self.xdotool, "getwindowgeometry", winid], capture_output=True) + log.debug(f"Window geometry : {x}") m = pos_re.search(x.stdout.decode()) + log.debug(f"Position regex search result : {m}") if not m: log.error( f"xdotool cannot find position for {winid} window! (output was {x.stdout.decode()})" ) return 0, 0, 0, 0 - return + + log.debug(f"Slicing : {m.groups()}") xpos, ypos = list(map(int, m.groups())) log.debug(f"Position found for {winid} window: {xpos, ypos}") m = geom_re.search(x.stdout.decode()) + log.debug(f"Geometry regex search result : {m}") if not m: log.error( f"xdotool cannot find geometry for {winid} window! (output was {x.stdout.decode()})" ) return 0, 0, 0, 0 return + log.debug(f"Slicing : {m.groups()}") width, height = list(map(int, m.groups())) - log.debug(f"Geometry found for {winid} window: {width, height}") + log.debug(f"Geometry found for {winid} window: {width}x{height}") return xpos, ypos, width, height @@ -198,12 +203,14 @@ class ServerWindow(GenServerWindow): self.get_agdb_window_id() # ax, ay, awidth, aheight = self.get_window_geometry(self._agdbwindow_id) - + log.debug("SCANNING FOR AGDBENTURES WINDOW DATA") ax, ay = self.agdb_window.get_location() + log.debug(f"Position found for {self._agdbwindow_id} window : {ax, ay}") awidth = self.agdb_window.width aheight = self.agdb_window.height - # print ("LOCATION: ", x, y, ax, ay) + log.debug(f"Geometry found for {self._agdbwindow_id} window : {awidth}x{aheight}") + log.debug("SCANNING FOR VIM CODE WINDOW DATA") cx, cy, cwidth, cheight = self.get_window_geometry() # snap code window on the left side of agdbentures window @@ -213,11 +220,7 @@ class ServerWindow(GenServerWindow): # new_cwidth = 400 new_cwidth = cwidth # we do not resize, but this might change in the future - self.resize_window( - new_cwidth, aheight - ) # resize to same height as arcade window - - border_x = 3 + border_x = 5 new_ypos = 0 + 20 if ( @@ -237,14 +240,19 @@ class ServerWindow(GenServerWindow): new_ypos, winid=self._agdbwindow_id, ) - # print("MOVING VIM TO", (new_xpos, new_ypos)) - # print("MOVING AGDB TO", (new_xpos - cst.Win.INIT_W, new_ypos)) + elif GenServerWindow.window_alignment == 'left': new_xpos = self._screen_offset_x + border_x ## moving code window to the left edge of the screen, and agdb window on the left of it self.move_window(new_xpos, new_ypos, winid=self._agdbwindow_id) self.move_window(new_xpos + cst.Win.INIT_W + border_x, new_ypos) + # we do not resize, but this might change in the future + self.resize_window( + new_cwidth, aheight + ) # resize to same height as arcade window + log.debug(f"Resized {self._window_id} window : from {cwidth}x{cheight} to {new_cwidth}x{aheight}") + # self.move_window(ax - new_cwidth//2, new_ypos) # self.move_window(ax + new_cwidth//2, new_ypos, winid=self._agdbwindow_id) -- GitLab