From 5dbdd36a72c2960d639af22dff796c50e9e26ed5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 18 Jan 2023 23:25:19 -0700 Subject: [PATCH] macos: implement window:focus() refs: https://github.com/wez/wezterm/issues/2973 --- docs/config/lua/window/focus.md | 2 +- window/src/os/macos/window.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/config/lua/window/focus.md b/docs/config/lua/window/focus.md index 98a394c91..73e1b2f65 100644 --- a/docs/config/lua/window/focus.md +++ b/docs/config/lua/window/focus.md @@ -6,7 +6,7 @@ Attempts to focus and activate the window. |OS |Supported?| |---------------|------------------------| -|macOS |Not yet implemented | +|macOS |Yes | |Windows |Yes | |X11 |Yes | |Wayland |Wayland does not allow this action| diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index a7e008e40..3b7e95219 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -994,7 +994,11 @@ impl WindowInner { } } - fn focus(&mut self) {} + fn focus(&mut self) { + unsafe{ + self.window.makeKeyAndOrderFront_(nil); + } + } fn hide(&mut self) { unsafe {