input: Rework PointerFocus to operate directly on WlSurface
This commit is contained in:
parent
4579cca6fa
commit
5459f52d5e
12 changed files with 619 additions and 1107 deletions
128
src/input/mod.rs
128
src/input/mod.rs
|
|
@ -5,7 +5,10 @@ use crate::{
|
|||
config::{xkb_config_to_wl, Action, Config, KeyModifiers, KeyPattern},
|
||||
input::gestures::{GestureState, SwipeAction},
|
||||
shell::{
|
||||
focus::{target::PointerFocusTarget, FocusDirection},
|
||||
focus::{
|
||||
target::{KeyboardFocusTarget, PointerFocusTarget},
|
||||
FocusDirection,
|
||||
},
|
||||
grabs::{ResizeEdge, SeatMenuGrabState, SeatMoveGrabState},
|
||||
layout::{
|
||||
floating::ResizeGrabMarker,
|
||||
|
|
@ -32,7 +35,10 @@ use smithay::{
|
|||
TabletToolEvent, TabletToolProximityEvent, TabletToolTipEvent, TabletToolTipState,
|
||||
TouchEvent,
|
||||
},
|
||||
desktop::{layer_map_for_output, space::SpaceElement, WindowSurfaceType},
|
||||
desktop::{
|
||||
layer_map_for_output, space::SpaceElement, utils::under_from_surface_tree,
|
||||
WindowSurfaceType,
|
||||
},
|
||||
input::{
|
||||
keyboard::{FilterResult, KeysymHandle, LedState, XkbConfig},
|
||||
pointer::{
|
||||
|
|
@ -726,11 +732,15 @@ impl State {
|
|||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
if let PointerFocusTarget::Element(element) = surface {
|
||||
//if !element.is_in_input_region(&(position.to_i32_round() - *surface_loc).to_f64()) {
|
||||
if !element.is_in_input_region(
|
||||
&(position.as_logical() - surface_loc.to_f64()),
|
||||
) {
|
||||
if let PointerFocusTarget::WlSurface(surface) = surface {
|
||||
if under_from_surface_tree(
|
||||
surface,
|
||||
position.as_logical() - surface_loc.to_f64(),
|
||||
(0, 0),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
ptr.frame(self);
|
||||
return;
|
||||
}
|
||||
|
|
@ -907,7 +917,7 @@ impl State {
|
|||
|
||||
let pos = seat.get_pointer().unwrap().current_location().as_global();
|
||||
let relative_pos = pos.to_local(&output);
|
||||
let mut under = None;
|
||||
let mut under: Option<KeyboardFocusTarget> = None;
|
||||
|
||||
if let Some(session_lock) = self.common.shell.session_lock.as_ref() {
|
||||
under = session_lock
|
||||
|
|
@ -968,7 +978,7 @@ impl State {
|
|||
if !done {
|
||||
// Don't check override redirect windows, because we don't set keyboard focus to them explicitly.
|
||||
// These cases are handled by the XwaylandKeyboardGrab.
|
||||
if let Some((target, _)) =
|
||||
if let Some(target) =
|
||||
self.common.shell.element_under(pos, &output)
|
||||
{
|
||||
under = Some(target);
|
||||
|
|
@ -1003,12 +1013,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
}
|
||||
Common::set_focus(
|
||||
self,
|
||||
under.and_then(|target| target.try_into().ok()).as_ref(),
|
||||
&seat,
|
||||
Some(serial),
|
||||
);
|
||||
Common::set_focus(self, under.as_ref(), &seat, Some(serial));
|
||||
}
|
||||
} else {
|
||||
if let OverviewMode::Started(Trigger::Pointer(action_button), _) =
|
||||
|
|
@ -2291,7 +2296,7 @@ impl State {
|
|||
if let Some(session_lock) = session_lock {
|
||||
return session_lock.surfaces.get(output).map(|surface| {
|
||||
(
|
||||
PointerFocusTarget::LockSurface(surface.clone()),
|
||||
PointerFocusTarget::WlSurface(surface.wl_surface().clone()),
|
||||
output_geo.loc,
|
||||
)
|
||||
});
|
||||
|
|
@ -2301,24 +2306,33 @@ impl State {
|
|||
let layers = layer_map_for_output(output);
|
||||
if let Some(layer) = layers.layer_under(WlrLayer::Overlay, relative_pos.as_logical()) {
|
||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||
if layer
|
||||
.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
return Some((layer.clone().into(), output_geo.loc + layer_loc.as_global()));
|
||||
if let Some((wl_surface, surface_loc)) = layer.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
) {
|
||||
return Some((
|
||||
wl_surface.into(),
|
||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Some(or) = shell.override_redirect_windows.iter().find(|or| {
|
||||
or.is_in_input_region(
|
||||
&(global_pos.as_logical() - X11Surface::geometry(*or).loc.to_f64()),
|
||||
)
|
||||
}) {
|
||||
return Some((or.clone().into(), X11Surface::geometry(or).loc.as_global()));
|
||||
if let Some((surface, geo)) = shell
|
||||
.override_redirect_windows
|
||||
.iter()
|
||||
.find(|or| {
|
||||
or.is_in_input_region(
|
||||
&(global_pos.as_logical() - X11Surface::geometry(*or).loc.to_f64()),
|
||||
)
|
||||
})
|
||||
.and_then(|or| {
|
||||
or.wl_surface()
|
||||
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
||||
})
|
||||
{
|
||||
return Some((surface.into(), geo));
|
||||
}
|
||||
Some((window.clone().into(), output_geo.loc))
|
||||
PointerFocusTarget::under_surface(window, relative_pos.as_logical())
|
||||
.map(|(target, surface_loc)| (target, output_geo.loc + surface_loc.as_global()))
|
||||
} else {
|
||||
{
|
||||
let layers = layer_map_for_output(output);
|
||||
|
|
@ -2327,28 +2341,33 @@ impl State {
|
|||
.or_else(|| layers.layer_under(WlrLayer::Top, relative_pos.as_logical()))
|
||||
{
|
||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||
if layer
|
||||
.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
if let Some((wl_surface, surface_loc)) = layer.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
) {
|
||||
return Some((
|
||||
layer.clone().into(),
|
||||
output_geo.loc + layer_loc.as_global(),
|
||||
wl_surface.into(),
|
||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(or) = shell.override_redirect_windows.iter().find(|or| {
|
||||
or.is_in_input_region(
|
||||
&(global_pos.as_logical() - X11Surface::geometry(*or).loc.to_f64()),
|
||||
)
|
||||
}) {
|
||||
return Some((or.clone().into(), X11Surface::geometry(or).loc.as_global()));
|
||||
if let Some((surface, geo)) = shell
|
||||
.override_redirect_windows
|
||||
.iter()
|
||||
.find(|or| {
|
||||
or.is_in_input_region(
|
||||
&(global_pos.as_logical() - X11Surface::geometry(*or).loc.to_f64()),
|
||||
)
|
||||
})
|
||||
.and_then(|or| {
|
||||
or.wl_surface()
|
||||
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
||||
})
|
||||
{
|
||||
return Some((surface.into(), geo));
|
||||
}
|
||||
if let Some((target, loc)) = shell.element_under(global_pos, output) {
|
||||
if let Some((target, loc)) = shell.surface_under(global_pos, output) {
|
||||
return Some((target, loc));
|
||||
}
|
||||
{
|
||||
|
|
@ -2358,16 +2377,13 @@ impl State {
|
|||
.or_else(|| layers.layer_under(WlrLayer::Background, relative_pos.as_logical()))
|
||||
{
|
||||
let layer_loc = layers.layer_geometry(layer).unwrap().loc;
|
||||
if layer
|
||||
.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
if let Some((wl_surface, surface_loc)) = layer.surface_under(
|
||||
relative_pos.as_logical() - layer_loc.to_f64(),
|
||||
WindowSurfaceType::ALL,
|
||||
) {
|
||||
return Some((
|
||||
layer.clone().into(),
|
||||
output_geo.loc + layer_loc.as_global(),
|
||||
wl_surface.into(),
|
||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue