Skip to content

Commit 29b7863

Browse files
JunkuiZhangnotpeter
authored andcommitted
macos: Fix menu bar flickering (#37707)
Closes #37526 Release Notes: - Fixed menu bar flickering when using some IMEs on macOS.
1 parent 66fbfd7 commit 29b7863

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

crates/zed/src/zed.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,15 +1317,31 @@ pub fn handle_keymap_file_changes(
13171317
})
13181318
.detach();
13191319

1320-
let mut current_layout_id = cx.keyboard_layout().id().to_string();
1321-
cx.on_keyboard_layout_change(move |cx| {
1322-
let next_layout_id = cx.keyboard_layout().id();
1323-
if next_layout_id != current_layout_id {
1324-
current_layout_id = next_layout_id.to_string();
1325-
keyboard_layout_tx.unbounded_send(()).ok();
1326-
}
1327-
})
1328-
.detach();
1320+
#[cfg(target_os = "windows")]
1321+
{
1322+
let mut current_layout_id = cx.keyboard_layout().id().to_string();
1323+
cx.on_keyboard_layout_change(move |cx| {
1324+
let next_layout_id = cx.keyboard_layout().id();
1325+
if next_layout_id != current_layout_id {
1326+
current_layout_id = next_layout_id.to_string();
1327+
keyboard_layout_tx.unbounded_send(()).ok();
1328+
}
1329+
})
1330+
.detach();
1331+
}
1332+
1333+
#[cfg(not(target_os = "windows"))]
1334+
{
1335+
let mut current_mapping = cx.keyboard_mapper().get_key_equivalents().cloned();
1336+
cx.on_keyboard_layout_change(move |cx| {
1337+
let next_mapping = cx.keyboard_mapper().get_key_equivalents();
1338+
if current_mapping.as_ref() != next_mapping {
1339+
current_mapping = next_mapping.cloned();
1340+
keyboard_layout_tx.unbounded_send(()).ok();
1341+
}
1342+
})
1343+
.detach();
1344+
}
13291345

13301346
load_default_keymap(cx);
13311347

0 commit comments

Comments
 (0)