Skip to content

Commit d9f87f3

Browse files
jamesarichclaude
andcommitted
fix(desktop): exclude AltGr from Ctrl shortcuts, import KeyEvent
Windows reports AltGr as Ctrl+Alt, so typing AltGr characters (e.g. @ on German layouts = AltGr+Q) would have fired shortcuts — including quit. Require Alt up on the Ctrl path. Also import KeyEvent instead of repeating the FQN (no clash exists in this file). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4af8637 commit d9f87f3

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • desktopApp/src/main/kotlin/org/meshtastic/desktop

desktopApp/src/main/kotlin/org/meshtastic/desktop/Main.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ import androidx.compose.runtime.snapshotFlow
3030
import androidx.compose.ui.Alignment
3131
import androidx.compose.ui.graphics.painter.Painter
3232
import androidx.compose.ui.input.key.Key
33+
import androidx.compose.ui.input.key.KeyEvent
3334
import androidx.compose.ui.input.key.KeyEventType
35+
import androidx.compose.ui.input.key.isAltPressed
3436
import androidx.compose.ui.input.key.isCtrlPressed
3537
import androidx.compose.ui.input.key.isMetaPressed
3638
import androidx.compose.ui.input.key.key
@@ -360,13 +362,17 @@ private fun CoilImageLoaderSetup() {
360362

361363
private val isMacOS = DesktopOS.current() == DesktopOS.MacOS
362364

363-
/** Platform-conventional shortcut modifier: Cmd on macOS, Ctrl on Windows/Linux. */
364-
private val androidx.compose.ui.input.key.KeyEvent.isShortcutModifierPressed: Boolean
365-
get() = if (isMacOS) isMetaPressed else isCtrlPressed
365+
/**
366+
* Platform-conventional shortcut modifier: Cmd on macOS, Ctrl on Windows/Linux. Alt must be up on the Ctrl path because
367+
* Windows reports AltGr as Ctrl+Alt — otherwise typing AltGr characters (e.g. @ on German layouts, which is AltGr+Q)
368+
* would trigger shortcuts like quit.
369+
*/
370+
private val KeyEvent.isShortcutModifierPressed: Boolean
371+
get() = if (isMacOS) isMetaPressed else isCtrlPressed && !isAltPressed
366372

367373
/** Handles Cmd/Ctrl-key shortcuts. Returns `true` if the event was consumed. */
368374
private fun handleKeyboardShortcut(
369-
event: androidx.compose.ui.input.key.KeyEvent,
375+
event: KeyEvent,
370376
multiBackstack: MultiBackstack,
371377
exitApplication: () -> Unit,
372378
): Boolean {

0 commit comments

Comments
 (0)