xwayland: Add input handling for override redirect windows
This commit is contained in:
parent
0af8d5eb2d
commit
5dfefedb02
4 changed files with 76 additions and 10 deletions
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
floating::SeatMoveGrabState,
|
floating::SeatMoveGrabState,
|
||||||
tiling::{Direction, FocusResult},
|
tiling::{Direction, FocusResult},
|
||||||
},
|
},
|
||||||
Workspace,
|
Ordering, OverrideRedirectWindow, Workspace,
|
||||||
}, // shell::grabs::SeatMoveGrabState
|
}, // shell::grabs::SeatMoveGrabState
|
||||||
state::Common,
|
state::Common,
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
|
|
@ -16,11 +16,14 @@ use crate::{
|
||||||
};
|
};
|
||||||
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::InputType;
|
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::InputType;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::{
|
backend::{
|
||||||
Axis, AxisSource, Device, DeviceCapability, InputBackend, InputEvent, KeyState,
|
input::{
|
||||||
PointerAxisEvent,
|
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::{
|
input::{
|
||||||
keyboard::{keysyms, FilterResult, KeysymHandle, XkbConfig},
|
keyboard::{keysyms, FilterResult, KeysymHandle, XkbConfig},
|
||||||
pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent},
|
pointer::{AxisFrame, ButtonEvent, CursorImageStatus, MotionEvent},
|
||||||
|
|
@ -314,12 +317,13 @@ impl State {
|
||||||
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let relative_pos = self.common.shell.map_global_to_space(position, &output);
|
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(
|
let under = State::surface_under(
|
||||||
position,
|
position,
|
||||||
relative_pos,
|
relative_pos,
|
||||||
&output,
|
&output,
|
||||||
output_geometry,
|
output_geometry,
|
||||||
|
&self.common.shell.override_redirect_windows,
|
||||||
&workspace,
|
&workspace,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -362,13 +366,14 @@ impl State {
|
||||||
geometry.size,
|
geometry.size,
|
||||||
);
|
);
|
||||||
let relative_pos = self.common.shell.map_global_to_space(position, &output);
|
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 serial = SERIAL_COUNTER.next_serial();
|
||||||
let under = State::surface_under(
|
let under = State::surface_under(
|
||||||
position,
|
position,
|
||||||
relative_pos,
|
relative_pos,
|
||||||
&output,
|
&output,
|
||||||
geometry,
|
geometry,
|
||||||
|
&self.common.shell.override_redirect_windows,
|
||||||
&workspace,
|
&workspace,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -909,6 +914,7 @@ impl State {
|
||||||
relative_pos: Point<f64, Logical>,
|
relative_pos: Point<f64, Logical>,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
output_geo: Rectangle<i32, Logical>,
|
output_geo: Rectangle<i32, Logical>,
|
||||||
|
override_redirect_windows: &[OverrideRedirectWindow],
|
||||||
workspace: &Workspace,
|
workspace: &Workspace,
|
||||||
) -> Option<(PointerFocusTarget, Point<i32, Logical>)> {
|
) -> Option<(PointerFocusTarget, Point<i32, Logical>)> {
|
||||||
let layers = layer_map_for_output(output);
|
let layers = layer_map_for_output(output);
|
||||||
|
|
@ -936,12 +942,54 @@ impl State {
|
||||||
return Some((layer.clone().into(), output_geo.loc + layer_loc));
|
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) {
|
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((
|
return Some((
|
||||||
mapped.clone().into(),
|
mapped.clone().into(),
|
||||||
loc + (global_pos - relative_pos).to_i32_round(),
|
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
|
if let Some(layer) = layers
|
||||||
.layer_under(WlrLayer::Bottom, relative_pos)
|
.layer_under(WlrLayer::Bottom, relative_pos)
|
||||||
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos))
|
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos))
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,6 @@ impl SpaceElement for CosmicWindow {
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let mut bbox = SpaceElement::bbox(&p.window);
|
let mut bbox = SpaceElement::bbox(&p.window);
|
||||||
if p.has_ssd() {
|
if p.has_ssd() {
|
||||||
bbox.loc.y -= SSD_HEIGHT;
|
|
||||||
bbox.size.h += SSD_HEIGHT;
|
bbox.size.h += SSD_HEIGHT;
|
||||||
}
|
}
|
||||||
bbox
|
bbox
|
||||||
|
|
@ -310,7 +309,6 @@ impl SpaceElement for CosmicWindow {
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let mut geo = SpaceElement::geometry(&p.window);
|
let mut geo = SpaceElement::geometry(&p.window);
|
||||||
if p.has_ssd() {
|
if p.has_ssd() {
|
||||||
geo.loc.y -= SSD_HEIGHT;
|
|
||||||
geo.size.h += SSD_HEIGHT;
|
geo.size.h += SSD_HEIGHT;
|
||||||
}
|
}
|
||||||
geo
|
geo
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use smithay::{
|
||||||
reexports::wayland_server::{backend::ObjectId, protocol::wl_surface::WlSurface, Resource},
|
reexports::wayland_server::{backend::ObjectId, protocol::wl_surface::WlSurface, Resource},
|
||||||
utils::{IsAlive, Serial},
|
utils::{IsAlive, Serial},
|
||||||
wayland::seat::WaylandFocus,
|
wayland::seat::WaylandFocus,
|
||||||
|
xwayland::X11Surface,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
@ -25,6 +26,7 @@ pub enum PointerFocusTarget {
|
||||||
Fullscreen(CosmicSurface),
|
Fullscreen(CosmicSurface),
|
||||||
LayerSurface(LayerSurface),
|
LayerSurface(LayerSurface),
|
||||||
Popup(PopupKind),
|
Popup(PopupKind),
|
||||||
|
OverrideRedirect(X11Surface),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
@ -70,6 +72,7 @@ impl IsAlive for PointerFocusTarget {
|
||||||
PointerFocusTarget::Fullscreen(f) => f.alive(),
|
PointerFocusTarget::Fullscreen(f) => f.alive(),
|
||||||
PointerFocusTarget::LayerSurface(l) => l.alive(),
|
PointerFocusTarget::LayerSurface(l) => l.alive(),
|
||||||
PointerFocusTarget::Popup(p) => p.alive(),
|
PointerFocusTarget::Popup(p) => p.alive(),
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => s.alive(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,6 +96,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
PointerFocusTarget::Fullscreen(w) => PointerTarget::enter(w, seat, data, event),
|
PointerFocusTarget::Fullscreen(w) => PointerTarget::enter(w, seat, data, event),
|
||||||
PointerFocusTarget::LayerSurface(l) => PointerTarget::enter(l, seat, data, event),
|
PointerFocusTarget::LayerSurface(l) => PointerTarget::enter(l, seat, data, event),
|
||||||
PointerFocusTarget::Popup(p) => PointerTarget::enter(p.wl_surface(), seat, data, event),
|
PointerFocusTarget::Popup(p) => PointerTarget::enter(p.wl_surface(), seat, data, event),
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => PointerTarget::enter(s, seat, data, event),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||||
|
|
@ -103,6 +107,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
PointerFocusTarget::Popup(p) => {
|
PointerFocusTarget::Popup(p) => {
|
||||||
PointerTarget::motion(p.wl_surface(), seat, data, event)
|
PointerTarget::motion(p.wl_surface(), seat, data, event)
|
||||||
}
|
}
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => PointerTarget::enter(s, seat, data, event),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||||
|
|
@ -113,6 +118,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
PointerFocusTarget::Popup(p) => {
|
PointerFocusTarget::Popup(p) => {
|
||||||
PointerTarget::button(p.wl_surface(), seat, data, event)
|
PointerTarget::button(p.wl_surface(), seat, data, event)
|
||||||
}
|
}
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => PointerTarget::button(s, seat, data, event),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||||
|
|
@ -121,6 +127,7 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
PointerFocusTarget::Fullscreen(w) => PointerTarget::axis(w, seat, data, frame),
|
PointerFocusTarget::Fullscreen(w) => PointerTarget::axis(w, seat, data, frame),
|
||||||
PointerFocusTarget::LayerSurface(l) => PointerTarget::axis(l, seat, data, frame),
|
PointerFocusTarget::LayerSurface(l) => PointerTarget::axis(l, seat, data, frame),
|
||||||
PointerFocusTarget::Popup(p) => PointerTarget::axis(p.wl_surface(), seat, data, frame),
|
PointerFocusTarget::Popup(p) => PointerTarget::axis(p.wl_surface(), seat, data, frame),
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => PointerTarget::axis(s, seat, data, frame),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
|
fn leave(&self, seat: &Seat<State>, data: &mut State, serial: Serial, time: u32) {
|
||||||
|
|
@ -133,6 +140,9 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
PointerFocusTarget::Popup(p) => {
|
PointerFocusTarget::Popup(p) => {
|
||||||
PointerTarget::leave(p.wl_surface(), seat, data, serial, time)
|
PointerTarget::leave(p.wl_surface(), seat, data, serial, time)
|
||||||
}
|
}
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => {
|
||||||
|
PointerTarget::leave(s, seat, data, serial, time)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -248,6 +258,9 @@ impl WaylandFocus for PointerFocusTarget {
|
||||||
PointerFocusTarget::Fullscreen(w) => WaylandFocus::wl_surface(w)?,
|
PointerFocusTarget::Fullscreen(w) => WaylandFocus::wl_surface(w)?,
|
||||||
PointerFocusTarget::LayerSurface(l) => l.wl_surface().clone(),
|
PointerFocusTarget::LayerSurface(l) => l.wl_surface().clone(),
|
||||||
PointerFocusTarget::Popup(p) => p.wl_surface().clone(),
|
PointerFocusTarget::Popup(p) => p.wl_surface().clone(),
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => {
|
||||||
|
return s.wl_surface();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
||||||
|
|
@ -256,6 +269,7 @@ impl WaylandFocus for PointerFocusTarget {
|
||||||
PointerFocusTarget::Fullscreen(w) => WaylandFocus::same_client_as(w, object_id),
|
PointerFocusTarget::Fullscreen(w) => WaylandFocus::same_client_as(w, object_id),
|
||||||
PointerFocusTarget::LayerSurface(l) => l.wl_surface().id().same_client_as(object_id),
|
PointerFocusTarget::LayerSurface(l) => l.wl_surface().id().same_client_as(object_id),
|
||||||
PointerFocusTarget::Popup(p) => p.wl_surface().id().same_client_as(object_id),
|
PointerFocusTarget::Popup(p) => p.wl_surface().id().same_client_as(object_id),
|
||||||
|
PointerFocusTarget::OverrideRedirect(s) => WaylandFocus::same_client_as(s, object_id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -284,6 +298,12 @@ impl From<PopupKind> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<X11Surface> for PointerFocusTarget {
|
||||||
|
fn from(s: X11Surface) -> Self {
|
||||||
|
PointerFocusTarget::OverrideRedirect(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<CosmicMapped> for KeyboardFocusTarget {
|
impl From<CosmicMapped> for KeyboardFocusTarget {
|
||||||
fn from(w: CosmicMapped) -> Self {
|
fn from(w: CosmicMapped) -> Self {
|
||||||
KeyboardFocusTarget::Element(w)
|
KeyboardFocusTarget::Element(w)
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ impl FloatingLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mapped(&self) -> impl Iterator<Item = &CosmicMapped> {
|
pub fn mapped(&self) -> impl Iterator<Item = &CosmicMapped> {
|
||||||
self.space.elements()
|
self.space.elements().rev()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn windows(&self) -> impl Iterator<Item = CosmicSurface> + '_ {
|
pub fn windows(&self) -> impl Iterator<Item = CosmicSurface> + '_ {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue