Explorar o código

edge-triggered control-center reveal + Escape on press

Milan Jurkulak hai 3 meses
pai
achega
df5694dff5

+ 1 - 0
.claude/scheduled_tasks.lock

@@ -0,0 +1 @@
+{"sessionId":"e9af53df-1f46-4d08-bd20-4b0460385a29","pid":7313,"procStart":"19681","acquiredAt":1783111002739}

+ 8 - 4
shared/src/desktopMain/kotlin/org/mjdev/desktop/state/DesktopState.kt

@@ -51,6 +51,7 @@ class DesktopState(
     // facts about the world
     private var barOverlapped = false
     private var pointerInBarZone = false
+    private var pointerWasInCcHotspot = false
 
     fun register(
         kind: SurfaceKind,
@@ -73,10 +74,13 @@ class DesktopState(
     ) {
         val px = x.toDouble()
         val py = y.toDouble()
-        // control center opens when the pointer reaches its reveal edge (stays open until dismissed)
-        surfaces[SurfaceKind.ControlCenter]?.revealHotspot?.invoke()?.let { hotspot ->
-            if (hotspot.contains(px, py)) controlCenterOpen = true
-        }
+        // control center opens on a fresh ENTER into its reveal edge (edge-triggered). Level-
+        // triggering re-opened it right after a dismiss while the pointer sat in the edge strip;
+        // now the pointer must leave and re-enter to reveal again.
+        val inCcHotspot =
+            surfaces[SurfaceKind.ControlCenter]?.revealHotspot?.invoke()?.contains(px, py) == true
+        if (inCcHotspot && !pointerWasInCcHotspot) controlCenterOpen = true
+        pointerWasInCcHotspot = inCcHotspot
         // the bar's zone = the bar itself plus its bottom reveal strip; only matters when overlapped
         pointerInBarZone =
             surfaces[SurfaceKind.Bar]?.let { bar ->

+ 2 - 1
shared/src/desktopMain/kotlin/org/mjdev/desktop/state/DesktopStateDriver.kt

@@ -30,7 +30,8 @@ fun DesktopStateDriver(desktopState: DesktopState) {
         val clicks = GlobalClickListener { x, y, _ -> desktopState.onClick(x, y) }
         val keys =
             GlobalKeyListener { event ->
-                if (event.id != KeyEvent.KEY_RELEASED) return@GlobalKeyListener
+                // act on press (fires first; dismiss/toggle are idempotent so a duplicate is fine)
+                if (event.id != KeyEvent.KEY_PRESSED) return@GlobalKeyListener
                 when (event.keyCode) {
                     // Escape closes whatever is open (menu or control center); the bar stays if
                     // nothing overlaps it — DesktopPolicy works that out.