From 61499d1f2532818dd03dac06c1cd5f61bd35af0a Mon Sep 17 00:00:00 2001 From: Carl Kaufman <38502076+CJKaufman@users.noreply.github.com> Date: Thu, 19 Nov 2026 21:43:46 +0200 Subject: [PATCH] perf(shell): reduce per-frame surface overhead and add top bar hover toggle --- docs/BRIDGE.md | 2 +- docs/bridge-schema.json | 3 ++ .../Bridge/QtShellBridge.Actions.Settings.cs | 3 ++ src/backend/Bridge/QtShellBridge.State.cs | 1 + src/backend/Core/Preferences.cs | 1 + src/frontend/bridge_pointer.py | 3 +- src/frontend/bridge_theme.py | 12 ++++- src/frontend/i18n/en.json | 4 +- src/frontend/i18n/es.json | 4 +- src/frontend/i18n/fr.json | 4 +- src/frontend/native_glass.py | 8 ++-- src/frontend/qml/settings/PageDocks.qml | 16 +++++++ src/frontend/qml/settings/SettingsIndex.qml | 8 ++++ src/frontend/surface_geometry.py | 45 ++++++++++++++++--- tests/Winlestia.Tests/BridgeHandlerTests.cs | 1 + 15 files changed, 100 insertions(+), 15 deletions(-) diff --git a/docs/BRIDGE.md b/docs/BRIDGE.md index 6597ee2..759fac5 100644 --- a/docs/BRIDGE.md +++ b/docs/BRIDGE.md @@ -164,7 +164,7 @@ Cas spéciaux traités avant le `switch` : `dictation` (renvoie `{"dictation": { ### Clés de `preference` -`args.key` choisit la préférence ; `enabled` (booléen) ou `value` (nombre / chaîne) porte la valeur. Clés : `accentBorders`, `activeBorderOnly`, `autoTile`, `autostart`, `bookmarksRailVisible`, `clipboardHistory`, `clipboardImages`, `clipboardLimit`, `customGlassOpacity`, `desktopIndicator`, `desktopLogo`, `dictationEnabled`, `dictationKey`, `dockDrawerOpen`, `dockVisible`, `dockWidth`, `explorerTheme`, `filesDefaultHandler`, `filesPreload`, `frameThickness`, `glassOpacity`, `iconSize`, `lyrics`, `motion`, `osd`, `peripheralBattery`, `pill`, `quietFullscreen`, `reducedEffects`, `replaceTaskbar`, `screenFrame`, `socialBackground`, `socialRailVisible`, `taskbar`, `tileExclusionRemove`, `topActivationMargin`. Le détail des champs par clé est dans le schéma (`preferenceKeys`). +`args.key` choisit la préférence ; `enabled` (booléen) ou `value` (nombre / chaîne) porte la valeur. Clés : `accentBorders`, `activeBorderOnly`, `autoTile`, `autostart`, `bookmarksRailVisible`, `clipboardHistory`, `clipboardImages`, `clipboardLimit`, `customGlassOpacity`, `desktopIndicator`, `desktopLogo`, `dictationEnabled`, `dictationKey`, `dockDrawerOpen`, `dockVisible`, `dockWidth`, `explorerTheme`, `filesDefaultHandler`, `filesPreload`, `frameThickness`, `glassOpacity`, `iconSize`, `lyrics`, `motion`, `osd`, `peripheralBattery`, `pill`, `quietFullscreen`, `reducedEffects`, `replaceTaskbar`, `screenFrame`, `socialBackground`, `socialRailVisible`, `taskbar`, `tileExclusionRemove`, `topActivationMargin`, `topHoverEnabled`. Le détail des champs par clé est dans le schéma (`preferenceKeys`). ## Réponse générale (serveur -> client) diff --git a/docs/bridge-schema.json b/docs/bridge-schema.json index eceef47..f99b25e 100644 --- a/docs/bridge-schema.json +++ b/docs/bridge-schema.json @@ -980,6 +980,9 @@ }, "topActivationMargin": { "value": "number" + }, + "topHoverEnabled": { + "enabled": "boolean" } }, "replyKeys": { diff --git a/src/backend/Bridge/QtShellBridge.Actions.Settings.cs b/src/backend/Bridge/QtShellBridge.Actions.Settings.cs index fefc81e..171523b 100644 --- a/src/backend/Bridge/QtShellBridge.Actions.Settings.cs +++ b/src/backend/Bridge/QtShellBridge.Actions.Settings.cs @@ -262,6 +262,9 @@ async Task OnPreference(BridgeCall c) case "socialRailVisible": Store.State.SocialRailVisible = Flag(c.Args, "enabled"); break; + case "topHoverEnabled": + Store.State.TopHoverEnabled = Flag(c.Args, "enabled"); + break; case "clipboardImages": Store.State.ClipboardImages = Flag(c.Args, "enabled"); owner.ApplyClipboardSettings(); diff --git a/src/backend/Bridge/QtShellBridge.State.cs b/src/backend/Bridge/QtShellBridge.State.cs index eada2af..89eec59 100644 --- a/src/backend/Bridge/QtShellBridge.State.cs +++ b/src/backend/Bridge/QtShellBridge.State.cs @@ -105,6 +105,7 @@ object State() replaceTaskbar = Store.State.ReplaceTaskbar, bookmarksRailVisible = Store.State.BookmarksRailVisible, socialRailVisible = Store.State.SocialRailVisible, + topHoverEnabled = Store.State.TopHoverEnabled, clipboardImages = Store.State.ClipboardImages, clipboardLimit = Store.State.ClipboardLimit, shortcuts = owner.Shortcuts.List(), diff --git a/src/backend/Core/Preferences.cs b/src/backend/Core/Preferences.cs index a03f42a..8150b2b 100644 --- a/src/backend/Core/Preferences.cs +++ b/src/backend/Core/Preferences.cs @@ -72,6 +72,7 @@ public int SettingsSchema public bool DockVisible { get; set; } = true; public bool BookmarksRailVisible { get; set; } = true; public bool SocialRailVisible { get; set; } = true; + public bool TopHoverEnabled { get; set; } = true; // Win+Alt+S : ouvre la page de réglages public ShortcutPreferences SettingsShortcut { get; set; } = new() { Modifiers = 9, Key = 0x53 }; // Écran de verrouillage : jamais de mot de passe en clair, seulement sel + empreinte PBKDF2 (voir LockSecret). diff --git a/src/frontend/bridge_pointer.py b/src/frontend/bridge_pointer.py index 2d563a0..c1953b2 100644 --- a/src/frontend/bridge_pointer.py +++ b/src/frontend/bridge_pointer.py @@ -238,7 +238,8 @@ def _poll_pointer(self): self.pill_was_over = over_pill top_inside = self.top.isVisible() and (panel_rect.adjusted(-12, -2, 12, 16).contains(point) or over_pill) top_edge = ( - geometry.top() + bool(self._state.get("settings", {}).get("topHoverEnabled", True)) + and geometry.top() <= point.y() <= geometry.top() + int(self._state.get("settings", {}).get("topActivationMargin", 2)) and abs(point.x() - geometry.center().x()) < 460 diff --git a/src/frontend/bridge_theme.py b/src/frontend/bridge_theme.py index e8885a7..81c229a 100644 --- a/src/frontend/bridge_theme.py +++ b/src/frontend/bridge_theme.py @@ -98,7 +98,17 @@ def theme_pending_expire(self): @Slot(str, int, result='QVariantMap') def surfaceForScreen(self, name, revision): - return self.surface_scene.data.get(name, {}) if self.surface_scene else {} + if not self.surface_scene: + return {} + entry = self.surface_scene.data.get(name) + if not entry: + return {} + if 'path' not in entry and name in self.surface_scene.paths: + from surface_geometry import svg_path + + outline = svg_path(self.surface_scene.paths[name]) + return {**entry, 'path': outline, 'outline': outline} + return entry def sync_explorer_theme(self): if not self.settings.get('explorerTheme', False) and not self.settings.get('accentBorders', True): diff --git a/src/frontend/i18n/en.json b/src/frontend/i18n/en.json index 456bf19..6c3b3ca 100644 --- a/src/frontend/i18n/en.json +++ b/src/frontend/i18n/en.json @@ -1152,5 +1152,7 @@ "Paramètres Wi-Fi": "Wi-Fi settings", "Entrée audio": "Audio input", "Dictée": "Dictation", - "Fonds d’écran": "Wallpapers" + "Fonds d’écran": "Wallpapers", + "Barre supérieure (bord haut)": "Top bar (top edge)", + "Se déploie quand la souris touche le haut de l’écran": "Expands when the pointer touches the top edge of the screen" } diff --git a/src/frontend/i18n/es.json b/src/frontend/i18n/es.json index 496770b..5c3ac9a 100644 --- a/src/frontend/i18n/es.json +++ b/src/frontend/i18n/es.json @@ -1152,5 +1152,7 @@ "Paramètres Wi-Fi": "Ajustes de Wi-Fi", "Entrée audio": "Entrada de audio", "Dictée": "Dictado", - "Fonds d’écran": "Fondos de pantalla" + "Fonds d’écran": "Fondos de pantalla", + "Barre supérieure (bord haut)": "Barra superior (borde superior)", + "Se déploie quand la souris touche le haut de l’écran": "Se despliega cuando el puntero toca el borde superior de la pantalla" } diff --git a/src/frontend/i18n/fr.json b/src/frontend/i18n/fr.json index 626f89d..9d98053 100644 --- a/src/frontend/i18n/fr.json +++ b/src/frontend/i18n/fr.json @@ -1152,5 +1152,7 @@ "Paramètres Wi-Fi": "Paramètres Wi-Fi", "Entrée audio": "Entrée audio", "Dictée": "Dictée", - "Fonds d’écran": "Fonds d’écran" + "Fonds d’écran": "Fonds d’écran", + "Barre supérieure (bord haut)": "Barre supérieure (bord haut)", + "Se déploie quand la souris touche le haut de l’écran": "Se déploie quand la souris touche le haut de l’écran" } diff --git a/src/frontend/native_glass.py b/src/frontend/native_glass.py index e66546b..5520cb9 100644 --- a/src/frontend/native_glass.py +++ b/src/frontend/native_glass.py @@ -100,7 +100,7 @@ def __init__(self, bridge, library=None): bridge.surfaceChanged.connect(self.request_sync) self.timer = QTimer(self) self.timer.setInterval(250) - self.timer.timeout.connect(self.sync) + self.timer.timeout.connect(lambda: self.sync(from_timer=True)) self.timer.start() self.request_sync() @@ -109,7 +109,7 @@ def request_sync(self, *args): self.queued = True QTimer.singleShot(0, self.sync) - def sync(self): + def sync(self, from_timer=False): self.queued = False if self.stopped: return @@ -226,7 +226,9 @@ def sync(self): busy = bool(visible) # Pendant une animation (la géométrie change à chaque image) l'ordre Z ne change pas : la passe n'a lieu qu'à # l'apparition d'une fenêtre, puis à la première synchronisation sans mouvement (fin d'animation, tick de 250 ms). - if topmost_due(self.topmost_handles, handles, moved): + if (handles != self.topmost_handles or from_timer) if not self.windows else topmost_due( + self.topmost_handles, handles, moved + ): self.raise_content(handles) self.topmost_handles = handles for window in locking: diff --git a/src/frontend/qml/settings/PageDocks.qml b/src/frontend/qml/settings/PageDocks.qml index bcfb215..e1f35de 100644 --- a/src/frontend/qml/settings/PageDocks.qml +++ b/src/frontend/qml/settings/PageDocks.qml @@ -94,6 +94,22 @@ ColumnLayout { }) } } + + SettingsRow { + rowId: "topHover" + target: topHover + + SettingsSwitch { + id: topHover + + objectName: "topHoverToggle" + value: Bridge.settings.topHoverEnabled ?? true + onToggled: Bridge.action("preference", { + key: "topHoverEnabled", + enabled: checked + }) + } + } } SettingsSection { diff --git a/src/frontend/qml/settings/SettingsIndex.qml b/src/frontend/qml/settings/SettingsIndex.qml index 6aa7002..8daf65a 100644 --- a/src/frontend/qml/settings/SettingsIndex.qml +++ b/src/frontend/qml/settings/SettingsIndex.qml @@ -246,6 +246,14 @@ QtObject { desc: qsTr("Se déploie quand la souris touche le bord droit de l’écran"), kw: "reseaux sociaux messagerie social rail droite" }, + { + id: "topHover", + page: 2, + section: qsTr("Visibilité"), + label: qsTr("Barre supérieure (bord haut)"), + desc: qsTr("Se déploie quand la souris touche le haut de l’écran"), + kw: "barre superieure top bar dashboard hover survol haut" + }, { id: "replaceTaskbar", page: 2, diff --git a/src/frontend/surface_geometry.py b/src/frontend/surface_geometry.py index c5a4ef2..2fe64cd 100644 --- a/src/frontend/surface_geometry.py +++ b/src/frontend/surface_geometry.py @@ -2,6 +2,7 @@ from PySide6.QtCore import QObject, QTimer, QRectF, Qt from PySide6.QtGui import QPainterPath, QTransform, QRegion from functools import lru_cache +import time from PySide6.QtWidgets import QApplication @@ -158,6 +159,12 @@ def __init__(self, bridge): self.revision = 0 self.stopped = False self.input_masks = {} + self._top_mask_at = 0.0 + self._top_mask_pending = None + self._top_mask_timer = QTimer(self) + self._top_mask_timer.setSingleShot(True) + self._top_mask_timer.setInterval(100) + self._top_mask_timer.timeout.connect(self._apply_top_mask_pending) self.pill_watched = None bridge.changed.connect(self.request) bridge.geometryChanged.connect(self.request) @@ -320,8 +327,8 @@ def pill_view(window): int(window.winId()), None ) # dock masqué : on oublie son masque, il est réappliqué à la prochaine apparition if window and spec: - offset = spec[1] - window.y() if is_dock else 0 - mask_key = (window.width(), window.height(), round(spec[2]), round(spec[3]), spec[4], round(offset)) + offset = 0 + mask_key = (window.width(), window.height(), round(spec[2]), round(spec[3]), spec[4]) handle = int(window.winId()) if self.input_masks.get(handle) != mask_key: path = ( @@ -329,7 +336,19 @@ def pill_view(window): .translate((window.width() - spec[2]) / 2, offset) .map(builder(spec[2], spec[3], spec[4])) ) - window.setMask(QRegion(path.toFillPolygon().toPolygon(), Qt.WindingFill)) + region = QRegion(path.toFillPolygon().toPolygon(), Qt.WindingFill) + if is_dock: + window.setMask(region) + else: + now = time.monotonic() + if handle not in self.input_masks or now - self._top_mask_at >= 0.10: + window.setMask(region) + self._top_mask_at = now + self._top_mask_pending = None + self._top_mask_timer.stop() + else: + self._top_mask_pending = (window, region) + self._top_mask_timer.start() self.input_masks[handle] = mask_key displays = [ (s.name(), s.geometry().x(), s.geometry().y(), s.geometry().width(), s.geometry().height()) @@ -352,6 +371,13 @@ def pill_view(window): if signature == self.signature: return self.signature = signature + if not (bridge.glassEnabled and not bridge.reducedEffects): + if self.paths or self.data: + self.paths = {} + self.data = {} + self.revision += 1 + bridge.surfaceChanged.emit() + return paths = {} data = {} for name, x, y, w, h in displays: @@ -380,11 +406,8 @@ def local(spec): ) # Le rendu de courbes de Qt exige une silhouette normalisée pour les contours qui se chevauchent. simple = path.simplified() - outline = svg_path(simple) paths[name] = simple data[name] = { - 'path': outline, - 'outline': outline, 'visible': not path.isEmpty(), 'components': (thickness, local(top), local(dock), local(rail), local(left), local(dictation), local(pill)), } @@ -393,6 +416,16 @@ def local(spec): self.revision += 1 bridge.surfaceChanged.emit() + def _apply_top_mask_pending(self): + pending = self._top_mask_pending + self._top_mask_pending = None + if pending and not self.stopped: + window, region = pending + window.setMask(region) + self._top_mask_at = time.monotonic() + def stop(self): self.stopped = True self.timer.stop() + self._top_mask_timer.stop() + self._top_mask_pending = None diff --git a/tests/Winlestia.Tests/BridgeHandlerTests.cs b/tests/Winlestia.Tests/BridgeHandlerTests.cs index 66c3049..c06ebb9 100644 --- a/tests/Winlestia.Tests/BridgeHandlerTests.cs +++ b/tests/Winlestia.Tests/BridgeHandlerTests.cs @@ -291,6 +291,7 @@ public void CaptureShortcutModeFollowsTheFlag() => With(r => [InlineData("dockDrawerOpen", nameof(Preferences.DockDrawerOpen))] [InlineData("bookmarksRailVisible", nameof(Preferences.BookmarksRailVisible))] [InlineData("socialRailVisible", nameof(Preferences.SocialRailVisible))] + [InlineData("topHoverEnabled", nameof(Preferences.TopHoverEnabled))] [InlineData("clipboardImages", nameof(Preferences.ClipboardImages))] [InlineData("clipboardHistory", nameof(Preferences.ClipboardHistory))] [InlineData("socialBackground", nameof(Preferences.SocialBackground))]