From daa10ca870f442a92dcd03b6bb2a6308f0590b01 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 8 Aug 2025 17:50:01 +0545 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(switcher):=20adapt=20window=20?= =?UTF-8?q?preview=20size=20to=20screen=20dimensions=20and=20reduce=20butt?= =?UTF-8?q?on=20border=20radius?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/switcher.py | 21 +++++++++++++++++---- styles/switcher.css | 3 +-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/switcher.py b/modules/switcher.py index 6c3f876..723fdb1 100644 --- a/modules/switcher.py +++ b/modules/switcher.py @@ -10,6 +10,7 @@ from fabric.widgets.eventbox import EventBox from fabric.widgets.image import Image from fabric.widgets.label import Label from utils.icon_resolver import IconResolver +from utils.occlusion import get_screen_dimensions from widgets.wayland import WaylandWindow as Window gi.require_version("Glace", "0.1") @@ -38,7 +39,14 @@ class ApplicationSwitcher(Window): # Initialize Glace manager for window previews self._manager = Glace.Manager() - self.preview_size = [150, 100] # Preview size for each window in switcher + + # Calculate preview size based on screen ratio + # Formula: screen_ratio = a:b, width = x, height = (x*b)/a + screen_width, screen_height = get_screen_dimensions() + preview_width = 150 # Base width + preview_height = int((preview_width * screen_height) / screen_width) + self.preview_size = [preview_width, preview_height] + self.glace_clients = {} # Map window addresses to Glace clients self.window_previews = {} # Map window addresses to preview images @@ -113,8 +121,12 @@ class ApplicationSwitcher(Window): client_app_id = client.get_app_id() client_title = client.get_title() - if (client_app_id and client_app_id.lower() == window_class and - client_title and client_title == window_title): + if ( + client_app_id + and client_app_id.lower() == window_class + and client_title + and client_title == window_title + ): return client except Exception: continue @@ -141,12 +153,13 @@ class ApplicationSwitcher(Window): preview_image = Image() if glace_client: + def capture_callback(pbuf, _): try: scaled_pixbuf = pbuf.scale_simple( self.preview_size[0], self.preview_size[1], - 2 # GdkPixbuf.InterpType.BILINEAR + 2, # GdkPixbuf.InterpType.BILINEAR ) preview_image.set_from_pixbuf(scaled_pixbuf) except Exception as e: diff --git a/styles/switcher.css b/styles/switcher.css index a1e1bf5..5302281 100644 --- a/styles/switcher.css +++ b/styles/switcher.css @@ -11,12 +11,11 @@ #switcher-button { padding: 4px; min-width: 100px; - border-radius: 16px; } #window-button { background-color: var(--surface); - border-radius: 16px; + border-radius: 4px; } #switcher-button:hover {