diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index 321bc32dd3..ce162ef8dd 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -538,6 +538,11 @@ impl Window { pub fn focus_window(&self) { x11_or_wayland!(match self; Window(w) => w.focus_window()) } + + pub fn activate(&self, token: ActivationToken) { + x11_or_wayland!(match self; Window(w) => w.activate(token)) + } + pub fn request_user_attention(&self, request_type: Option) { x11_or_wayland!(match self; Window(w) => w.request_user_attention(request_type)) } diff --git a/src/platform_impl/linux/wayland/window/mod.rs b/src/platform_impl/linux/wayland/window/mod.rs index 8127595ae1..578a2c3b90 100644 --- a/src/platform_impl/linux/wayland/window/mod.rs +++ b/src/platform_impl/linux/wayland/window/mod.rs @@ -23,8 +23,8 @@ use crate::platform_impl::{ PlatformSpecificWindowBuilderAttributes as PlatformAttributes, }; use crate::window::{ - CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, UserAttentionType, - WindowAttributes, WindowButtons, WindowLevel, + ActivationToken, CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, + UserAttentionType, WindowAttributes, WindowButtons, WindowLevel, }; use super::event_loop::sink::EventSink; @@ -634,6 +634,12 @@ impl Window { #[inline] pub fn focus_window(&self) {} + pub fn activate(&self, token: ActivationToken) { + if let Some(xdg_activation) = &self.xdg_activation { + xdg_activation.activate(token._token, self.surface()); + } + } + #[inline] pub fn surface(&self) -> &WlSurface { self.window.wl_surface() diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 9197b4f00f..d785041dc0 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -33,8 +33,8 @@ use crate::{ PlatformSpecificWindowBuilderAttributes, VideoMode as PlatformVideoMode, }, window::{ - CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, UserAttentionType, - WindowAttributes, WindowButtons, WindowLevel, + ActivationToken, CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, + UserAttentionType, WindowAttributes, WindowButtons, WindowLevel, }, }; @@ -1820,6 +1820,12 @@ impl UnownedWindow { } } + pub fn activate(&self, token: ActivationToken) { + let _ = self + .xconn + .remove_activation_token(self.xwindow, &token._token); + } + #[inline] pub fn request_user_attention(&self, request_type: Option) { let mut wm_hints = diff --git a/src/window.rs b/src/window.rs index 333051eacd..2f331fd248 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1254,6 +1254,10 @@ impl Window { self.window.maybe_queue_on_main(|w| w.focus_window()) } + pub fn activate(&self, token: ActivationToken) { + self.window.maybe_queue_on_main(|w| w.activate(token)) + } + /// Gets whether the window has keyboard focus. /// /// This queries the same state information as [`WindowEvent::Focused`].