Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC for xdg activation v1 #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserAttentionType>) {
x11_or_wayland!(match self; Window(w) => w.request_user_attention(request_type))
}
Expand Down
10 changes: 8 additions & 2 deletions src/platform_impl/linux/wayland/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions src/platform_impl/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};

Expand Down Expand Up @@ -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<UserAttentionType>) {
let mut wm_hints =
Expand Down
4 changes: 4 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
Loading