Skip to content

Commit 9795322

Browse files
committed
Revert "feat(windows): implement keyboard shortcut hints via tab-separated text"
This reverts commit ae85961.
1 parent ae85961 commit 9795322

2 files changed

Lines changed: 78 additions & 104 deletions

File tree

src/jvmMain/kotlin/com/kdroid/composetray/menu/api/KeyShortcut.kt

Lines changed: 74 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ package com.kdroid.composetray.menu.api
77
* On macOS, the shortcut renders as native key equivalent glyphs (e.g. ⌘S, ⇧⌘N).
88
* On Linux, the shortcut is serialized as a DBusMenu `shortcut` property
99
* and rendered by the desktop environment's indicator renderer (KDE, GNOME, etc.).
10-
* On Windows, the shortcut renders as right-aligned accelerator text (e.g. Ctrl+S, Ctrl+Shift+N)
11-
* using the native Win32 tab-separated text convention.
10+
* On Windows, this is currently a no-op.
1211
*
1312
* Example:
1413
* ```
@@ -45,110 +44,94 @@ data class KeyShortcut(
4544
* Returns the DBusMenu key name for Linux shortcut hints.
4645
*/
4746
internal fun toLinuxKey(): String = key.linuxKeyName
48-
49-
/**
50-
* Returns the Windows accelerator display text (e.g. "Ctrl+S", "Ctrl+Shift+N").
51-
* Used with the Win32 tab-separated text convention for menu items.
52-
*/
53-
internal fun toWindowsAcceleratorText(): String {
54-
val parts = mutableListOf<String>()
55-
if (ctrl) parts.add("Ctrl")
56-
if (meta) parts.add("Win")
57-
if (alt) parts.add("Alt")
58-
if (shift) parts.add("Shift")
59-
parts.add(key.windowsDisplayName)
60-
return parts.joinToString("+")
61-
}
6247
}
6348

6449
/**
6550
* Keyboard keys that can be used in [KeyShortcut].
6651
*
6752
* @property macKeyEquivalent The string value passed to NSMenuItem.setKeyEquivalent on macOS.
6853
* @property linuxKeyName The DBusMenu key name string for Linux (follows XKB naming).
69-
* @property windowsDisplayName The display name shown in Win32 menu accelerator text.
7054
*/
7155
enum class Key(
7256
internal val macKeyEquivalent: String,
7357
internal val linuxKeyName: String,
74-
internal val windowsDisplayName: String,
7558
) {
76-
A("a", "a", "A"),
77-
B("b", "b", "B"),
78-
C("c", "c", "C"),
79-
D("d", "d", "D"),
80-
E("e", "e", "E"),
81-
F("f", "f", "F"),
82-
G("g", "g", "G"),
83-
H("h", "h", "H"),
84-
I("i", "i", "I"),
85-
J("j", "j", "J"),
86-
K("k", "k", "K"),
87-
L("l", "l", "L"),
88-
M("m", "m", "M"),
89-
N("n", "n", "N"),
90-
O("o", "o", "O"),
91-
P("p", "p", "P"),
92-
Q("q", "q", "Q"),
93-
R("r", "r", "R"),
94-
S("s", "s", "S"),
95-
T("t", "t", "T"),
96-
U("u", "u", "U"),
97-
V("v", "v", "V"),
98-
W("w", "w", "W"),
99-
X("x", "x", "X"),
100-
Y("y", "y", "Y"),
101-
Z("z", "z", "Z"),
59+
A("a", "a"),
60+
B("b", "b"),
61+
C("c", "c"),
62+
D("d", "d"),
63+
E("e", "e"),
64+
F("f", "f"),
65+
G("g", "g"),
66+
H("h", "h"),
67+
I("i", "i"),
68+
J("j", "j"),
69+
K("k", "k"),
70+
L("l", "l"),
71+
M("m", "m"),
72+
N("n", "n"),
73+
O("o", "o"),
74+
P("p", "p"),
75+
Q("q", "q"),
76+
R("r", "r"),
77+
S("s", "s"),
78+
T("t", "t"),
79+
U("u", "u"),
80+
V("v", "v"),
81+
W("w", "w"),
82+
X("x", "x"),
83+
Y("y", "y"),
84+
Z("z", "z"),
10285

103-
Num0("0", "0", "0"),
104-
Num1("1", "1", "1"),
105-
Num2("2", "2", "2"),
106-
Num3("3", "3", "3"),
107-
Num4("4", "4", "4"),
108-
Num5("5", "5", "5"),
109-
Num6("6", "6", "6"),
110-
Num7("7", "7", "7"),
111-
Num8("8", "8", "8"),
112-
Num9("9", "9", "9"),
86+
Num0("0", "0"),
87+
Num1("1", "1"),
88+
Num2("2", "2"),
89+
Num3("3", "3"),
90+
Num4("4", "4"),
91+
Num5("5", "5"),
92+
Num6("6", "6"),
93+
Num7("7", "7"),
94+
Num8("8", "8"),
95+
Num9("9", "9"),
11396

11497
// Function keys (AppKit private-use Unicode)
115-
F1("\uF704", "F1", "F1"),
116-
F2("\uF705", "F2", "F2"),
117-
F3("\uF706", "F3", "F3"),
118-
F4("\uF707", "F4", "F4"),
119-
F5("\uF708", "F5", "F5"),
120-
F6("\uF709", "F6", "F6"),
121-
F7("\uF70A", "F7", "F7"),
122-
F8("\uF70B", "F8", "F8"),
123-
F9("\uF70C", "F9", "F9"),
124-
F10("\uF70D", "F10", "F10"),
125-
F11("\uF70E", "F11", "F11"),
126-
F12("\uF70F", "F12", "F12"),
98+
F1("\uF704", "F1"),
99+
F2("\uF705", "F2"),
100+
F3("\uF706", "F3"),
101+
F4("\uF707", "F4"),
102+
F5("\uF708", "F5"),
103+
F6("\uF709", "F6"),
104+
F7("\uF70A", "F7"),
105+
F8("\uF70B", "F8"),
106+
F9("\uF70C", "F9"),
107+
F10("\uF70D", "F10"),
108+
F11("\uF70E", "F11"),
109+
F12("\uF70F", "F12"),
127110

128111
// Special keys
129-
Return("\r", "Return", "Enter"),
130-
Tab("\t", "Tab", "Tab"),
131-
Space(" ", "space", "Space"),
132-
Escape("\u001B", "Escape", "Esc"),
133-
Delete("\u007F", "BackSpace", "Backspace"),
134-
ForwardDelete("\uF728", "Delete", "Del"),
135-
UpArrow("\uF700", "Up", "Up"),
136-
DownArrow("\uF701", "Down", "Down"),
137-
LeftArrow("\uF702", "Left", "Left"),
138-
RightArrow("\uF703", "Right", "Right"),
139-
Home("\uF729", "Home", "Home"),
140-
End("\uF72B", "End", "End"),
141-
PageUp("\uF72C", "Page_Up", "PgUp"),
142-
PageDown("\uF72D", "Page_Down", "PgDn"),
143-
Minus("-", "minus", "-"),
144-
Equal("=", "equal", "="),
145-
LeftBracket("[", "bracketleft", "["),
146-
RightBracket("]", "bracketright", "]"),
147-
Backslash("\\", "backslash", "\\"),
148-
Semicolon(";", "semicolon", ";"),
149-
Quote("'", "apostrophe", "'"),
150-
Comma(",", "comma", ","),
151-
Period(".", "period", "."),
152-
Slash("/", "slash", "/"),
153-
Backquote("`", "grave", "`"),
112+
Return("\r", "Return"),
113+
Tab("\t", "Tab"),
114+
Space(" ", "space"),
115+
Escape("\u001B", "Escape"),
116+
Delete("\u007F", "BackSpace"),
117+
ForwardDelete("\uF728", "Delete"),
118+
UpArrow("\uF700", "Up"),
119+
DownArrow("\uF701", "Down"),
120+
LeftArrow("\uF702", "Left"),
121+
RightArrow("\uF703", "Right"),
122+
Home("\uF729", "Home"),
123+
End("\uF72B", "End"),
124+
PageUp("\uF72C", "Page_Up"),
125+
PageDown("\uF72D", "Page_Down"),
126+
Minus("-", "minus"),
127+
Equal("=", "equal"),
128+
LeftBracket("[", "bracketleft"),
129+
RightBracket("]", "bracketright"),
130+
Backslash("\\", "backslash"),
131+
Semicolon(";", "semicolon"),
132+
Quote("'", "apostrophe"),
133+
Comma(",", "comma"),
134+
Period(".", "period"),
135+
Slash("/", "slash"),
136+
Backquote("`", "grave"),
154137
}

src/jvmMain/kotlin/com/kdroid/composetray/menu/impl/WindowsTrayMenuBuilderImpl.kt

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal class WindowsTrayMenuBuilderImpl(
3939
lock.withLock {
4040
val menuItem =
4141
WindowsTrayManager.MenuItem(
42-
text = label.withShortcut(shortcut),
42+
text = label,
4343
iconPath = null,
4444
isEnabled = isEnabled,
4545
onClick = onClick,
@@ -62,7 +62,7 @@ internal class WindowsTrayMenuBuilderImpl(
6262

6363
val menuItem =
6464
WindowsTrayManager.MenuItem(
65-
text = label.withShortcut(shortcut),
65+
text = label,
6666
iconPath = iconPath,
6767
isEnabled = isEnabled,
6868
onClick = onClick,
@@ -148,7 +148,7 @@ internal class WindowsTrayMenuBuilderImpl(
148148
lock.withLock {
149149
val menuItem =
150150
WindowsTrayManager.MenuItem(
151-
text = label.withShortcut(shortcut),
151+
text = label,
152152
iconPath = null,
153153
isEnabled = isEnabled,
154154
isCheckable = true,
@@ -177,7 +177,7 @@ internal class WindowsTrayMenuBuilderImpl(
177177

178178
val menuItem =
179179
WindowsTrayManager.MenuItem(
180-
text = label.withShortcut(shortcut),
180+
text = label,
181181
iconPath = iconPath,
182182
isEnabled = isEnabled,
183183
isCheckable = true,
@@ -393,13 +393,4 @@ internal class WindowsTrayMenuBuilderImpl(
393393
}
394394

395395
fun build(): List<WindowsTrayManager.MenuItem> = lock.withLock { menuItems.toList() }
396-
397-
companion object {
398-
/**
399-
* Appends Win32 tab-separated accelerator text to a menu label.
400-
* Windows natively right-aligns everything after `\t` in menu item strings.
401-
*/
402-
private fun String.withShortcut(shortcut: KeyShortcut?): String =
403-
if (shortcut != null) "$this\t${shortcut.toWindowsAcceleratorText()}" else this
404-
}
405396
}

0 commit comments

Comments
 (0)