mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-18 22:26:12 +01:00
Send pointer events to layer surfaces
This commit is contained in:
parent
f0c77c9e88
commit
7f3ff7ae02
1 changed files with 39 additions and 52 deletions
41
src/input.rs
41
src/input.rs
|
@ -15,7 +15,7 @@ use smithay::{
|
||||||
desktop::{layer_map_for_output, space::SpaceElement},
|
desktop::{layer_map_for_output, space::SpaceElement},
|
||||||
input::{
|
input::{
|
||||||
keyboard::{keysyms, FilterResult},
|
keyboard::{keysyms, FilterResult},
|
||||||
pointer::{AxisFrame, ButtonEvent, MotionEvent, PointerTarget},
|
pointer::{AxisFrame, ButtonEvent, MotionEvent},
|
||||||
},
|
},
|
||||||
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge,
|
reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::ResizeEdge,
|
||||||
utils::{Logical, Point, SERIAL_COUNTER},
|
utils::{Logical, Point, SERIAL_COUNTER},
|
||||||
|
@ -108,13 +108,13 @@ impl<B: Backend> State<B> {
|
||||||
// If the button was clicked, focus on the window below if exists, else
|
// If the button was clicked, focus on the window below if exists, else
|
||||||
// unfocus on windows.
|
// unfocus on windows.
|
||||||
if ButtonState::Pressed == button_state {
|
if ButtonState::Pressed == button_state {
|
||||||
if let Some((window, window_loc)) = self.surface_under(pointer_loc) {
|
if let Some((focus, window_loc)) = self.surface_under(pointer_loc) {
|
||||||
// tracing::debug!("button click on {window:?}");
|
// tracing::debug!("button click on {window:?}");
|
||||||
const BUTTON_LEFT: u32 = 0x110;
|
const BUTTON_LEFT: u32 = 0x110;
|
||||||
const BUTTON_RIGHT: u32 = 0x111;
|
const BUTTON_RIGHT: u32 = 0x111;
|
||||||
if self.move_mode {
|
if self.move_mode {
|
||||||
if event.button_code() == BUTTON_LEFT {
|
if event.button_code() == BUTTON_LEFT {
|
||||||
if let Some(wl_surf) = window.wl_surface() {
|
if let Some(wl_surf) = focus.wl_surface() {
|
||||||
crate::grab::move_grab::move_request_server(
|
crate::grab::move_grab::move_request_server(
|
||||||
self,
|
self,
|
||||||
&wl_surf,
|
&wl_surf,
|
||||||
|
@ -125,7 +125,7 @@ impl<B: Backend> State<B> {
|
||||||
}
|
}
|
||||||
return; // TODO: kinda ugly return here
|
return; // TODO: kinda ugly return here
|
||||||
} else if event.button_code() == BUTTON_RIGHT {
|
} else if event.button_code() == BUTTON_RIGHT {
|
||||||
let FocusTarget::Window(window) = window else { return };
|
let FocusTarget::Window(window) = focus else { return };
|
||||||
let window_geometry = window.geometry();
|
let window_geometry = window.geometry();
|
||||||
let window_x = window_loc.x as f64;
|
let window_x = window_loc.x as f64;
|
||||||
let window_y = window_loc.y as f64;
|
let window_y = window_loc.y as f64;
|
||||||
|
@ -177,8 +177,8 @@ impl<B: Backend> State<B> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Move window to top of stack.
|
// Move window to top of stack.
|
||||||
let FocusTarget::Window(window) = window else { return };
|
if let FocusTarget::Window(window) = &focus {
|
||||||
self.space.raise_element(&window, true);
|
self.space.raise_element(window, true);
|
||||||
if let WindowElement::X11(surface) = &window {
|
if let WindowElement::X11(surface) = &window {
|
||||||
if !surface.is_override_redirect() {
|
if !surface.is_override_redirect() {
|
||||||
self.xwm
|
self.xwm
|
||||||
|
@ -191,11 +191,9 @@ impl<B: Backend> State<B> {
|
||||||
.expect("failed to set x11 win to activated");
|
.expect("failed to set x11 win to activated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tracing::debug!(
|
tracing::debug!("wl_surface focus is some? {}", focus.wl_surface().is_some());
|
||||||
"wl_surface focus is some? {}",
|
|
||||||
window.wl_surface().is_some()
|
|
||||||
);
|
|
||||||
|
|
||||||
// NOTE: *Do not* set keyboard focus to an override redirect window. This leads
|
// NOTE: *Do not* set keyboard focus to an override redirect window. This leads
|
||||||
// | to wonky things like right-click menus not correctly getting pointer
|
// | to wonky things like right-click menus not correctly getting pointer
|
||||||
|
@ -203,8 +201,9 @@ impl<B: Backend> State<B> {
|
||||||
|
|
||||||
// TODO: use update_keyboard_focus from anvil
|
// TODO: use update_keyboard_focus from anvil
|
||||||
|
|
||||||
if !matches!(&window, WindowElement::X11(surf) if surf.is_override_redirect()) {
|
if !matches!(&focus, FocusTarget::Window(WindowElement::X11(surf)) if surf.is_override_redirect())
|
||||||
keyboard.set_focus(self, Some(FocusTarget::Window(window.clone())), serial);
|
{
|
||||||
|
keyboard.set_focus(self, Some(focus.clone()), serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.space.elements().for_each(|window| {
|
self.space.elements().for_each(|window| {
|
||||||
|
@ -213,6 +212,7 @@ impl<B: Backend> State<B> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let FocusTarget::Window(window) = &focus {
|
||||||
let focused_name = match &window {
|
let focused_name = match &window {
|
||||||
WindowElement::Wayland(win) => {
|
WindowElement::Wayland(win) => {
|
||||||
compositor::with_states(win.toplevel().wl_surface(), |states| {
|
compositor::with_states(win.toplevel().wl_surface(), |states| {
|
||||||
|
@ -229,6 +229,7 @@ impl<B: Backend> State<B> {
|
||||||
};
|
};
|
||||||
tracing::debug!("setting keyboard focus to {focused_name}");
|
tracing::debug!("setting keyboard focus to {focused_name}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.space.elements().for_each(|window| match window {
|
self.space.elements().for_each(|window| match window {
|
||||||
WindowElement::Wayland(window) => {
|
WindowElement::Wayland(window) => {
|
||||||
|
@ -435,24 +436,10 @@ impl State<WinitData> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let surface_under_pointer = self
|
let surface_under_pointer = self.surface_under(pointer_loc);
|
||||||
.space
|
|
||||||
.element_under(pointer_loc)
|
|
||||||
.map(|(window, loc)| (FocusTarget::Window(window.clone()), loc));
|
|
||||||
|
|
||||||
// tracing::debug!("surface_under_pointer: {surface_under_pointer:?}");
|
// tracing::debug!("surface_under_pointer: {surface_under_pointer:?}");
|
||||||
// tracing::debug!("pointer focus: {:?}", pointer.current_focus());
|
// tracing::debug!("pointer focus: {:?}", pointer.current_focus());
|
||||||
if let Some((focus, _point)) = &surface_under_pointer {
|
|
||||||
focus.motion(
|
|
||||||
&self.seat.clone(),
|
|
||||||
self,
|
|
||||||
&MotionEvent {
|
|
||||||
location: pointer_loc,
|
|
||||||
serial,
|
|
||||||
time: event.time_msec(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
pointer.motion(
|
pointer.motion(
|
||||||
self,
|
self,
|
||||||
surface_under_pointer,
|
surface_under_pointer,
|
||||||
|
|
Loading…
Reference in a new issue