xwayland: Add input handling for override redirect windows

This commit is contained in:
Victoria Brekenfeld 2023-01-23 20:32:37 +01:00
parent 0af8d5eb2d
commit 5dfefedb02
4 changed files with 76 additions and 10 deletions

View file

@ -8,7 +8,7 @@ use crate::{
floating::SeatMoveGrabState,
tiling::{Direction, FocusResult},
},
Workspace,
Ordering, OverrideRedirectWindow, Workspace,
}, // shell::grabs::SeatMoveGrabState
state::Common,
utils::prelude::*,
@ -16,11 +16,14 @@ use crate::{
};
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::InputType;
use smithay::{
backend::input::{
Axis, AxisSource, Device, DeviceCapability, InputBackend, InputEvent, KeyState,
PointerAxisEvent,
backend::{
input::{
Axis, AxisSource, Device, DeviceCapability, InputBackend, InputEvent, KeyState,
PointerAxisEvent,
},
renderer::element::Id,
},
desktop::{layer_map_for_output, WindowSurfaceType},
desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType},
input::{
keyboard::{keysyms, FilterResult, KeysymHandle, XkbConfig},
pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent},
@ -314,12 +317,13 @@ impl State {
let serial = SERIAL_COUNTER.next_serial();
let relative_pos = self.common.shell.map_global_to_space(position, &output);
let workspace = self.common.shell.active_space_mut(&output);
let workspace = self.common.shell.active_space(&output);
let under = State::surface_under(
position,
relative_pos,
&output,
output_geometry,
&self.common.shell.override_redirect_windows,
&workspace,
);
@ -362,13 +366,14 @@ impl State {
geometry.size,
);
let relative_pos = self.common.shell.map_global_to_space(position, &output);
let workspace = self.common.shell.active_space_mut(&output);
let workspace = self.common.shell.active_space(&output);
let serial = SERIAL_COUNTER.next_serial();
let under = State::surface_under(
position,
relative_pos,
&output,
geometry,
&self.common.shell.override_redirect_windows,
&workspace,
);
@ -909,6 +914,7 @@ impl State {
relative_pos: Point<f64, Logical>,
output: &Output,
output_geo: Rectangle<i32, Logical>,
override_redirect_windows: &[OverrideRedirectWindow],
workspace: &Workspace,
) -> Option<(PointerFocusTarget, Point<i32, Logical>)> {
let layers = layer_map_for_output(output);
@ -936,12 +942,54 @@ impl State {
return Some((layer.clone().into(), output_geo.loc + layer_loc));
}
}
if let Some(or) = override_redirect_windows.iter().find(|or| {
or.above == Ordering::Above
&& or
.surface
.is_in_input_region(&(global_pos - or.surface.geometry().loc.to_f64()))
}) {
return Some((or.surface.clone().into(), or.surface.geometry().loc));
}
if let Some((mapped, loc)) = workspace.element_under(relative_pos) {
let filter = workspace
.mapped()
.skip_while(|m| *m != mapped)
.collect::<Vec<_>>();
if let Some(or) = override_redirect_windows
.iter()
.filter(|or| {
if let Ordering::AboveWindow(w) = &or.above {
!filter.iter().any(|f| {
f.wl_surface()
.map(|s| Id::from_wayland_resource(&s))
.as_ref()
== Some(&w)
})
} else {
false
}
})
.find(|or| {
or.surface
.is_in_input_region(&(global_pos - or.surface.geometry().loc.to_f64()))
})
{
return Some((or.surface.clone().into(), or.surface.geometry().loc));
}
return Some((
mapped.clone().into(),
loc + (global_pos - relative_pos).to_i32_round(),
));
}
if let Some(or) = override_redirect_windows.iter().find(|or| {
or.above == Ordering::Below
&& or
.surface
.is_in_input_region(&(global_pos - or.surface.geometry().loc.to_f64()))
}) {
return Some((or.surface.clone().into(), or.surface.geometry().loc));
}
if let Some(layer) = layers
.layer_under(WlrLayer::Bottom, relative_pos)
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos))