focus: Fix screencopy
This commit is contained in:
parent
5459f52d5e
commit
3cff426805
4 changed files with 226 additions and 178 deletions
|
|
@ -732,7 +732,7 @@ impl State {
|
||||||
ptr.frame(self);
|
ptr.frame(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let PointerFocusTarget::WlSurface(surface) = surface {
|
if let PointerFocusTarget::WlSurface { surface, .. } = surface {
|
||||||
if under_from_surface_tree(
|
if under_from_surface_tree(
|
||||||
surface,
|
surface,
|
||||||
position.as_logical() - surface_loc.to_f64(),
|
position.as_logical() - surface_loc.to_f64(),
|
||||||
|
|
@ -2296,7 +2296,10 @@ impl State {
|
||||||
if let Some(session_lock) = session_lock {
|
if let Some(session_lock) = session_lock {
|
||||||
return session_lock.surfaces.get(output).map(|surface| {
|
return session_lock.surfaces.get(output).map(|surface| {
|
||||||
(
|
(
|
||||||
PointerFocusTarget::WlSurface(surface.wl_surface().clone()),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: surface.wl_surface().clone(),
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
output_geo.loc,
|
output_geo.loc,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
@ -2311,7 +2314,10 @@ impl State {
|
||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
) {
|
) {
|
||||||
return Some((
|
return Some((
|
||||||
wl_surface.into(),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: wl_surface,
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -2329,7 +2335,13 @@ impl State {
|
||||||
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return Some((surface.into(), geo));
|
return Some((
|
||||||
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface,
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
|
geo,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
PointerFocusTarget::under_surface(window, relative_pos.as_logical())
|
PointerFocusTarget::under_surface(window, relative_pos.as_logical())
|
||||||
.map(|(target, surface_loc)| (target, output_geo.loc + surface_loc.as_global()))
|
.map(|(target, surface_loc)| (target, output_geo.loc + surface_loc.as_global()))
|
||||||
|
|
@ -2346,7 +2358,10 @@ impl State {
|
||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
) {
|
) {
|
||||||
return Some((
|
return Some((
|
||||||
wl_surface.into(),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: wl_surface,
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
@ -2365,7 +2380,13 @@ impl State {
|
||||||
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
.map(|surface| (surface, X11Surface::geometry(or).loc.as_global()))
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return Some((surface.into(), geo));
|
return Some((
|
||||||
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface,
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
|
geo,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if let Some((target, loc)) = shell.surface_under(global_pos, output) {
|
if let Some((target, loc)) = shell.surface_under(global_pos, output) {
|
||||||
return Some((target, loc));
|
return Some((target, loc));
|
||||||
|
|
@ -2382,7 +2403,10 @@ impl State {
|
||||||
WindowSurfaceType::ALL,
|
WindowSurfaceType::ALL,
|
||||||
) {
|
) {
|
||||||
return Some((
|
return Some((
|
||||||
wl_surface.into(),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: wl_surface,
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
output_geo.loc + layer_loc.as_global() + surface_loc.as_global(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ use crate::{
|
||||||
iced::{IcedElement, Program},
|
iced::{IcedElement, Program},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
},
|
},
|
||||||
wayland::handlers::screencopy::SessionHolder,
|
|
||||||
};
|
};
|
||||||
use calloop::LoopHandle;
|
use calloop::LoopHandle;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
|
@ -47,7 +46,7 @@ use smithay::{
|
||||||
},
|
},
|
||||||
output::Output,
|
output::Output,
|
||||||
render_elements,
|
render_elements,
|
||||||
utils::{Buffer, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size, Transform},
|
utils::{Buffer, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size},
|
||||||
wayland::seat::WaylandFocus,
|
wayland::seat::WaylandFocus,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
|
@ -58,7 +57,6 @@ use std::{
|
||||||
atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering},
|
atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
},
|
},
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod tab;
|
mod tab;
|
||||||
|
|
@ -97,7 +95,6 @@ pub struct CosmicStackInternal {
|
||||||
potential_drag: Arc<Mutex<Option<usize>>>,
|
potential_drag: Arc<Mutex<Option<usize>>>,
|
||||||
override_alive: Arc<AtomicBool>,
|
override_alive: Arc<AtomicBool>,
|
||||||
last_seat: Arc<Mutex<Option<(Seat<State>, Serial)>>>,
|
last_seat: Arc<Mutex<Option<(Seat<State>, Serial)>>>,
|
||||||
last_location: Arc<Mutex<Option<(Point<f64, Logical>, Serial, u32)>>>,
|
|
||||||
geometry: Arc<Mutex<Option<Rectangle<i32, Global>>>>,
|
geometry: Arc<Mutex<Option<Rectangle<i32, Global>>>>,
|
||||||
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
|
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +166,6 @@ impl CosmicStack {
|
||||||
potential_drag: Arc::new(Mutex::new(None)),
|
potential_drag: Arc::new(Mutex::new(None)),
|
||||||
override_alive: Arc::new(AtomicBool::new(true)),
|
override_alive: Arc::new(AtomicBool::new(true)),
|
||||||
last_seat: Arc::new(Mutex::new(None)),
|
last_seat: Arc::new(Mutex::new(None)),
|
||||||
last_location: Arc::new(Mutex::new(None)),
|
|
||||||
geometry: Arc::new(Mutex::new(None)),
|
geometry: Arc::new(Mutex::new(None)),
|
||||||
mask: Arc::new(Mutex::new(None)),
|
mask: Arc::new(Mutex::new(None)),
|
||||||
},
|
},
|
||||||
|
|
@ -458,7 +454,10 @@ impl CosmicStack {
|
||||||
.surface_under(relative_pos, WindowSurfaceType::ALL)
|
.surface_under(relative_pos, WindowSurfaceType::ALL)
|
||||||
.map(|(surface, surface_offset)| {
|
.map(|(surface, surface_offset)| {
|
||||||
(
|
(
|
||||||
PointerFocusTarget::WlSurface(surface),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface,
|
||||||
|
toplevel: Some(active_window.clone().into()),
|
||||||
|
},
|
||||||
surface_offset + Point::from((0, TAB_HEIGHT)),
|
surface_offset + Point::from((0, TAB_HEIGHT)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
@ -524,59 +523,6 @@ impl CosmicStack {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pointer_leave_if_previous(
|
|
||||||
&self,
|
|
||||||
seat: &Seat<State>,
|
|
||||||
data: &mut State,
|
|
||||||
serial: Serial,
|
|
||||||
time: u32,
|
|
||||||
location: Point<f64, Logical>,
|
|
||||||
) -> usize {
|
|
||||||
self.0.with_program(|p| {
|
|
||||||
let active = p.active.load(Ordering::SeqCst);
|
|
||||||
let previous = p.previous_pointer.swap(active, Ordering::SeqCst);
|
|
||||||
if previous != active {
|
|
||||||
let windows = p.windows.lock().unwrap();
|
|
||||||
if let Some(previous) = windows.get(previous) {
|
|
||||||
for session in previous.cursor_sessions() {
|
|
||||||
session.set_cursor_pos(None);
|
|
||||||
}
|
|
||||||
PointerTarget::leave(previous, seat, data, serial, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
for session in windows[active].cursor_sessions() {
|
|
||||||
session.set_cursor_pos(Some(
|
|
||||||
location
|
|
||||||
.to_buffer(
|
|
||||||
1.0,
|
|
||||||
Transform::Normal,
|
|
||||||
&windows[active].geometry().size.to_f64(),
|
|
||||||
)
|
|
||||||
.to_i32_round(),
|
|
||||||
));
|
|
||||||
if let Some((_, hotspot)) =
|
|
||||||
seat.cursor_geometry((0.0, 0.0), Duration::from_millis(time as u64).into())
|
|
||||||
{
|
|
||||||
session.set_cursor_hotspot(hotspot);
|
|
||||||
} else {
|
|
||||||
session.set_cursor_hotspot((0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PointerTarget::enter(
|
|
||||||
&windows[active],
|
|
||||||
seat,
|
|
||||||
data,
|
|
||||||
&MotionEvent {
|
|
||||||
location,
|
|
||||||
serial,
|
|
||||||
time,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
active
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(in super::super) fn focus_stack(&self) {
|
pub(in super::super) fn focus_stack(&self) {
|
||||||
self.0
|
self.0
|
||||||
.with_program(|p| p.group_focused.store(true, Ordering::SeqCst));
|
.with_program(|p| p.group_focused.store(true, Ordering::SeqCst));
|
||||||
|
|
@ -1208,10 +1154,8 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
|
|
||||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||||
let mut event = event.clone();
|
let mut event = event.clone();
|
||||||
let active =
|
|
||||||
self.pointer_leave_if_previous(seat, data, event.serial, event.time, event.location);
|
|
||||||
|
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
|
let active = p.active.load(Ordering::SeqCst);
|
||||||
let active_window = &p.windows.lock().unwrap()[active];
|
let active_window = &p.windows.lock().unwrap()[active];
|
||||||
let geo = active_window.geometry();
|
let geo = active_window.geometry();
|
||||||
let loc = event.location.to_i32_round::<i32>();
|
let loc = event.location.to_i32_round::<i32>();
|
||||||
|
|
@ -1250,9 +1194,9 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
*cursor_status.borrow_mut() = CursorImageStatus::default_named();
|
*cursor_status.borrow_mut() = CursorImageStatus::default_named();
|
||||||
});
|
});
|
||||||
|
|
||||||
let active_window_geo = self
|
let active_window_geo = self.0.with_program(|p| {
|
||||||
.0
|
p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].geometry()
|
||||||
.with_program(|p| p.windows.lock().unwrap()[active].geometry());
|
});
|
||||||
event.location -= active_window_geo.loc.to_f64();
|
event.location -= active_window_geo.loc.to_f64();
|
||||||
|
|
||||||
PointerTarget::motion(&self.0, seat, data, &event);
|
PointerTarget::motion(&self.0, seat, data, &event);
|
||||||
|
|
@ -1298,13 +1242,6 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||||
if let Some((location, _serial, _time)) = self
|
|
||||||
.0
|
|
||||||
.with_program(|p| p.last_location.lock().unwrap().clone())
|
|
||||||
{
|
|
||||||
self.pointer_leave_if_previous(seat, data, event.serial, event.time, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.0.with_program(|p| p.current_focus()) {
|
match self.0.with_program(|p| p.current_focus()) {
|
||||||
Focus::Header => {
|
Focus::Header => {
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
|
|
@ -1346,13 +1283,6 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||||
if let Some((location, serial, time)) = self
|
|
||||||
.0
|
|
||||||
.with_program(|p| p.last_location.lock().unwrap().clone())
|
|
||||||
{
|
|
||||||
self.pointer_leave_if_previous(seat, data, serial, time, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.0.with_program(|p| p.current_focus()) {
|
match self.0.with_program(|p| p.current_focus()) {
|
||||||
Focus::Header => PointerTarget::axis(&self.0, seat, data, frame),
|
Focus::Header => PointerTarget::axis(&self.0, seat, data, frame),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -1360,13 +1290,6 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame(&self, seat: &Seat<State>, data: &mut State) {
|
fn frame(&self, seat: &Seat<State>, data: &mut State) {
|
||||||
if let Some((location, serial, time)) = self
|
|
||||||
.0
|
|
||||||
.with_program(|p| p.last_location.lock().unwrap().clone())
|
|
||||||
{
|
|
||||||
self.pointer_leave_if_previous(seat, data, serial, time, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.0.with_program(|p| p.current_focus()) {
|
match self.0.with_program(|p| p.current_focus()) {
|
||||||
Focus::Header => PointerTarget::frame(&self.0, seat, data),
|
Focus::Header => PointerTarget::frame(&self.0, seat, data),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
@ -1374,13 +1297,6 @@ impl PointerTarget<State> for CosmicStack {
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
if let Some((location, serial, time)) = self
|
|
||||||
.0
|
|
||||||
.with_program(|p| p.last_location.lock().unwrap().clone())
|
|
||||||
{
|
|
||||||
self.pointer_leave_if_previous(seat, data, serial, time, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.0.with_program(|p| {
|
self.0.with_program(|p| {
|
||||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||||
cursor_state.set_shape(CursorShape::Default);
|
cursor_state.set_shape(CursorShape::Default);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use crate::{
|
||||||
iced::{IcedElement, Program},
|
iced::{IcedElement, Program},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
},
|
},
|
||||||
wayland::handlers::screencopy::SessionHolder,
|
|
||||||
};
|
};
|
||||||
use calloop::LoopHandle;
|
use calloop::LoopHandle;
|
||||||
use cosmic::{iced::Command, widget::mouse_area, Apply};
|
use cosmic::{iced::Command, widget::mouse_area, Apply};
|
||||||
|
|
@ -39,7 +38,7 @@ use smithay::{
|
||||||
output::Output,
|
output::Output,
|
||||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||||
render_elements,
|
render_elements,
|
||||||
utils::{Buffer as BufferCoords, IsAlive, Logical, Point, Rectangle, Serial, Size, Transform},
|
utils::{Buffer as BufferCoords, IsAlive, Logical, Point, Rectangle, Serial, Size},
|
||||||
wayland::seat::WaylandFocus,
|
wayland::seat::WaylandFocus,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
|
@ -50,7 +49,6 @@ use std::{
|
||||||
atomic::{AtomicBool, AtomicU8, Ordering},
|
atomic::{AtomicBool, AtomicU8, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
},
|
},
|
||||||
time::Duration,
|
|
||||||
};
|
};
|
||||||
use wayland_backend::server::ObjectId;
|
use wayland_backend::server::ObjectId;
|
||||||
|
|
||||||
|
|
@ -221,7 +219,10 @@ impl CosmicWindow {
|
||||||
.surface_under(relative_pos, WindowSurfaceType::ALL)
|
.surface_under(relative_pos, WindowSurfaceType::ALL)
|
||||||
.map(|(surface, surface_offset)| {
|
.map(|(surface, surface_offset)| {
|
||||||
(
|
(
|
||||||
PointerFocusTarget::WlSurface(surface),
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface,
|
||||||
|
toplevel: Some(p.window.clone().into()),
|
||||||
|
},
|
||||||
offset + surface_offset,
|
offset + surface_offset,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::sync::Weak;
|
use std::{sync::Weak, time::Duration};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{
|
shell::{
|
||||||
|
|
@ -7,12 +7,12 @@ use crate::{
|
||||||
CosmicSurface,
|
CosmicSurface,
|
||||||
},
|
},
|
||||||
utils::prelude::*,
|
utils::prelude::*,
|
||||||
wayland::handlers::xdg_shell::popup::get_popup_toplevel,
|
wayland::handlers::{screencopy::SessionHolder, xdg_shell::popup::get_popup_toplevel},
|
||||||
};
|
};
|
||||||
use id_tree::NodeId;
|
use id_tree::NodeId;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::KeyState,
|
backend::input::KeyState,
|
||||||
desktop::{LayerSurface, PopupKind, WindowSurface, WindowSurfaceType},
|
desktop::{space::SpaceElement, LayerSurface, PopupKind, WindowSurface, WindowSurfaceType},
|
||||||
input::{
|
input::{
|
||||||
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
|
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
|
||||||
pointer::{
|
pointer::{
|
||||||
|
|
@ -24,19 +24,39 @@ use smithay::{
|
||||||
Seat,
|
Seat,
|
||||||
},
|
},
|
||||||
reexports::wayland_server::{backend::ObjectId, protocol::wl_surface::WlSurface, Resource},
|
reexports::wayland_server::{backend::ObjectId, protocol::wl_surface::WlSurface, Resource},
|
||||||
utils::{IsAlive, Logical, Point, Serial},
|
utils::{IsAlive, Logical, Point, Serial, Transform},
|
||||||
wayland::{seat::WaylandFocus, session_lock::LockSurface},
|
wayland::{seat::WaylandFocus, session_lock::LockSurface},
|
||||||
};
|
};
|
||||||
|
|
||||||
// discuss: should contain WlSurface, IcedElement
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum PointerFocusTarget {
|
pub enum PointerFocusTarget {
|
||||||
WlSurface(WlSurface),
|
WlSurface {
|
||||||
|
surface: WlSurface,
|
||||||
|
toplevel: Option<PointerFocusToplevel>,
|
||||||
|
},
|
||||||
StackUI(CosmicStack),
|
StackUI(CosmicStack),
|
||||||
WindowUI(CosmicWindow),
|
WindowUI(CosmicWindow),
|
||||||
ResizeFork(ResizeForkTarget),
|
ResizeFork(ResizeForkTarget),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub enum PointerFocusToplevel {
|
||||||
|
Surface(CosmicSurface),
|
||||||
|
Popup(PopupKind),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CosmicSurface> for PointerFocusToplevel {
|
||||||
|
fn from(value: CosmicSurface) -> Self {
|
||||||
|
PointerFocusToplevel::Surface(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<PopupKind> for PointerFocusToplevel {
|
||||||
|
fn from(value: PopupKind) -> Self {
|
||||||
|
PointerFocusToplevel::Popup(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum KeyboardFocusTarget {
|
pub enum KeyboardFocusTarget {
|
||||||
Element(CosmicMapped),
|
Element(CosmicMapped),
|
||||||
|
|
@ -52,41 +72,34 @@ impl From<KeyboardFocusTarget> for PointerFocusTarget {
|
||||||
fn from(target: KeyboardFocusTarget) -> Self {
|
fn from(target: KeyboardFocusTarget) -> Self {
|
||||||
match target {
|
match target {
|
||||||
KeyboardFocusTarget::Element(elem) => {
|
KeyboardFocusTarget::Element(elem) => {
|
||||||
PointerFocusTarget::WlSurface(elem.active_window().wl_surface().unwrap())
|
let window = elem.active_window();
|
||||||
}
|
let surface = window.wl_surface().unwrap();
|
||||||
KeyboardFocusTarget::Fullscreen(elem) => {
|
PointerFocusTarget::WlSurface {
|
||||||
PointerFocusTarget::WlSurface(elem.wl_surface().unwrap())
|
surface,
|
||||||
}
|
toplevel: Some(window.into()),
|
||||||
KeyboardFocusTarget::LayerSurface(layer) => {
|
}
|
||||||
PointerFocusTarget::WlSurface(layer.wl_surface().clone())
|
|
||||||
}
|
|
||||||
KeyboardFocusTarget::Popup(popup) => {
|
|
||||||
PointerFocusTarget::WlSurface(popup.wl_surface().clone())
|
|
||||||
}
|
|
||||||
KeyboardFocusTarget::LockSurface(lock) => {
|
|
||||||
PointerFocusTarget::WlSurface(lock.wl_surface().clone())
|
|
||||||
}
|
}
|
||||||
|
KeyboardFocusTarget::Fullscreen(elem) => PointerFocusTarget::WlSurface {
|
||||||
|
surface: elem.wl_surface().unwrap(),
|
||||||
|
toplevel: Some(elem.into()),
|
||||||
|
},
|
||||||
|
KeyboardFocusTarget::LayerSurface(layer) => PointerFocusTarget::WlSurface {
|
||||||
|
surface: layer.wl_surface().clone(),
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
|
KeyboardFocusTarget::Popup(popup) => PointerFocusTarget::WlSurface {
|
||||||
|
surface: popup.wl_surface().clone(),
|
||||||
|
toplevel: Some(popup.into()),
|
||||||
|
},
|
||||||
|
KeyboardFocusTarget::LockSurface(lock) => PointerFocusTarget::WlSurface {
|
||||||
|
surface: lock.wl_surface().clone(),
|
||||||
|
toplevel: None,
|
||||||
|
},
|
||||||
_ => unreachable!("A group cannot start a popup grab"),
|
_ => unreachable!("A group cannot start a popup grab"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
impl TryFrom<PointerFocusTarget> for KeyboardFocusTarget {
|
|
||||||
type Error = ();
|
|
||||||
fn try_from(target: PointerFocusTarget) -> Result<Self, Self::Error> {
|
|
||||||
match target {
|
|
||||||
PointerFocusTarget::Element(mapped) => Ok(KeyboardFocusTarget::Element(mapped)),
|
|
||||||
PointerFocusTarget::Fullscreen(surf) => Ok(KeyboardFocusTarget::Fullscreen(surf)),
|
|
||||||
PointerFocusTarget::LayerSurface(layer) => Ok(KeyboardFocusTarget::LayerSurface(layer)),
|
|
||||||
PointerFocusTarget::Popup(popup) => Ok(KeyboardFocusTarget::Popup(popup)),
|
|
||||||
PointerFocusTarget::LockSurface(lock) => Ok(KeyboardFocusTarget::LockSurface(lock)),
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
impl PointerFocusTarget {
|
impl PointerFocusTarget {
|
||||||
pub fn under_surface<P: Into<Point<f64, Logical>>>(
|
pub fn under_surface<P: Into<Point<f64, Logical>>>(
|
||||||
surface: &CosmicSurface,
|
surface: &CosmicSurface,
|
||||||
|
|
@ -96,10 +109,49 @@ impl PointerFocusTarget {
|
||||||
WindowSurface::Wayland(_toplevel) => surface
|
WindowSurface::Wayland(_toplevel) => surface
|
||||||
.0
|
.0
|
||||||
.surface_under(point, WindowSurfaceType::ALL)
|
.surface_under(point, WindowSurfaceType::ALL)
|
||||||
.map(|(wl_surface, point)| (Self::WlSurface(wl_surface), point)),
|
.map(|(wl_surface, point)| {
|
||||||
WindowSurface::X11(surface) => {
|
(
|
||||||
Some((Self::WlSurface(surface.wl_surface()?), Point::default()))
|
Self::WlSurface {
|
||||||
}
|
surface: wl_surface,
|
||||||
|
toplevel: Some(surface.clone().into()),
|
||||||
|
},
|
||||||
|
point,
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
WindowSurface::X11(x11_surface) => Some((
|
||||||
|
Self::WlSurface {
|
||||||
|
surface: x11_surface.wl_surface()?,
|
||||||
|
toplevel: Some(surface.clone().into()),
|
||||||
|
},
|
||||||
|
Point::default(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toplevel(&self, data: &mut State) -> Option<CosmicSurface> {
|
||||||
|
match &self {
|
||||||
|
PointerFocusTarget::WlSurface {
|
||||||
|
toplevel: Some(PointerFocusToplevel::Surface(surface)),
|
||||||
|
..
|
||||||
|
} => Some(surface.clone()),
|
||||||
|
PointerFocusTarget::WlSurface {
|
||||||
|
toplevel: Some(PointerFocusToplevel::Popup(PopupKind::Xdg(popup))),
|
||||||
|
..
|
||||||
|
} => get_popup_toplevel(popup)
|
||||||
|
.and_then(|s| {
|
||||||
|
data.common
|
||||||
|
.shell
|
||||||
|
.element_for_surface(&s)
|
||||||
|
.map(|mapped| (mapped, s))
|
||||||
|
})
|
||||||
|
.and_then(|(m, s)| {
|
||||||
|
m.windows()
|
||||||
|
.find(|(w, _)| w.wl_surface().map(|s2| s == s2).unwrap_or(false))
|
||||||
|
.map(|(s, _)| s)
|
||||||
|
}),
|
||||||
|
PointerFocusTarget::StackUI(stack) => Some(stack.active()),
|
||||||
|
PointerFocusTarget::WindowUI(window) => Some(window.surface()),
|
||||||
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +183,7 @@ impl IsAlive for PointerFocusTarget {
|
||||||
fn alive(&self) -> bool {
|
fn alive(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
// XXX? does this change anything
|
// XXX? does this change anything
|
||||||
PointerFocusTarget::WlSurface(s) => s.alive(),
|
PointerFocusTarget::WlSurface { surface, .. } => surface.alive(),
|
||||||
PointerFocusTarget::StackUI(e) => e.alive(),
|
PointerFocusTarget::StackUI(e) => e.alive(),
|
||||||
PointerFocusTarget::WindowUI(e) => e.alive(),
|
PointerFocusTarget::WindowUI(e) => e.alive(),
|
||||||
PointerFocusTarget::ResizeFork(f) => f.alive(),
|
PointerFocusTarget::ResizeFork(f) => f.alive(),
|
||||||
|
|
@ -154,16 +206,56 @@ impl IsAlive for KeyboardFocusTarget {
|
||||||
|
|
||||||
impl PointerTarget<State> for PointerFocusTarget {
|
impl PointerTarget<State> for PointerFocusTarget {
|
||||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||||
|
if let Some(element) = self.toplevel(data) {
|
||||||
|
for session in element.cursor_sessions() {
|
||||||
|
session.set_cursor_pos(Some(
|
||||||
|
event
|
||||||
|
.location
|
||||||
|
.to_buffer(1.0, Transform::Normal, &element.geometry().size.to_f64())
|
||||||
|
.to_i32_round(),
|
||||||
|
));
|
||||||
|
if let Some((_, hotspot)) = seat
|
||||||
|
.cursor_geometry((0.0, 0.0), Duration::from_millis(event.time as u64).into())
|
||||||
|
{
|
||||||
|
session.set_cursor_hotspot(hotspot);
|
||||||
|
} else {
|
||||||
|
session.set_cursor_hotspot((0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::enter(s, seat, data, event),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::enter(surface, seat, data, event)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::enter(u, seat, data, event),
|
PointerFocusTarget::StackUI(u) => PointerTarget::enter(u, seat, data, event),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::enter(u, seat, data, event),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::enter(u, seat, data, event),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::enter(f, seat, data, event),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::enter(f, 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) {
|
||||||
|
if let Some(element) = self.toplevel(data) {
|
||||||
|
for session in element.cursor_sessions() {
|
||||||
|
session.set_cursor_pos(Some(
|
||||||
|
event
|
||||||
|
.location
|
||||||
|
.to_buffer(1.0, Transform::Normal, &element.geometry().size.to_f64())
|
||||||
|
.to_i32_round(),
|
||||||
|
));
|
||||||
|
if let Some((_, hotspot)) = seat
|
||||||
|
.cursor_geometry((0.0, 0.0), Duration::from_millis(event.time as u64).into())
|
||||||
|
{
|
||||||
|
session.set_cursor_hotspot(hotspot);
|
||||||
|
} else {
|
||||||
|
session.set_cursor_hotspot((0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::motion(s, seat, data, event),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::motion(surface, seat, data, event)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::motion(u, seat, data, event),
|
PointerFocusTarget::StackUI(u) => PointerTarget::motion(u, seat, data, event),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::motion(u, seat, data, event),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::motion(u, seat, data, event),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::motion(f, seat, data, event),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::motion(f, seat, data, event),
|
||||||
|
|
@ -171,8 +263,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn relative_motion(&self, seat: &Seat<State>, data: &mut State, event: &RelativeMotionEvent) {
|
fn relative_motion(&self, seat: &Seat<State>, data: &mut State, event: &RelativeMotionEvent) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::relative_motion(s, seat, data, event)
|
PointerTarget::relative_motion(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::relative_motion(u, seat, data, event),
|
PointerFocusTarget::StackUI(u) => PointerTarget::relative_motion(u, seat, data, event),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::relative_motion(u, seat, data, event),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::relative_motion(u, seat, data, event),
|
||||||
|
|
@ -183,7 +275,9 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::button(s, seat, data, event),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::button(surface, seat, data, event)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::button(u, seat, data, event),
|
PointerFocusTarget::StackUI(u) => PointerTarget::button(u, seat, data, event),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::button(u, seat, data, event),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::button(u, seat, data, event),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::button(f, seat, data, event),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::button(f, seat, data, event),
|
||||||
|
|
@ -191,7 +285,9 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::axis(s, seat, data, frame),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::axis(surface, seat, data, frame)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::axis(u, seat, data, frame),
|
PointerFocusTarget::StackUI(u) => PointerTarget::axis(u, seat, data, frame),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::axis(u, seat, data, frame),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::axis(u, seat, data, frame),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::axis(f, seat, data, frame),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::axis(f, seat, data, frame),
|
||||||
|
|
@ -199,15 +295,26 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn frame(&self, seat: &Seat<State>, data: &mut State) {
|
fn frame(&self, seat: &Seat<State>, data: &mut State) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::frame(s, seat, data),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::frame(surface, seat, data)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::frame(u, seat, data),
|
PointerFocusTarget::StackUI(u) => PointerTarget::frame(u, seat, data),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::frame(u, seat, data),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::frame(u, seat, data),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::frame(f, seat, data),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::frame(f, seat, data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
if let Some(element) = self.toplevel(data) {
|
||||||
|
for session in element.cursor_sessions() {
|
||||||
|
session.set_cursor_pos(None);
|
||||||
|
session.set_cursor_hotspot((0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => PointerTarget::leave(s, seat, data, serial, time),
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
|
PointerTarget::leave(surface, seat, data, serial, time)
|
||||||
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::leave(u, seat, data, serial, time),
|
PointerFocusTarget::StackUI(u) => PointerTarget::leave(u, seat, data, serial, time),
|
||||||
PointerFocusTarget::WindowUI(u) => PointerTarget::leave(u, seat, data, serial, time),
|
PointerFocusTarget::WindowUI(u) => PointerTarget::leave(u, seat, data, serial, time),
|
||||||
PointerFocusTarget::ResizeFork(f) => PointerTarget::leave(f, seat, data, serial, time),
|
PointerFocusTarget::ResizeFork(f) => PointerTarget::leave(f, seat, data, serial, time),
|
||||||
|
|
@ -220,8 +327,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GestureSwipeBeginEvent,
|
event: &GestureSwipeBeginEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_swipe_begin(s, seat, data, event)
|
PointerTarget::gesture_swipe_begin(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_swipe_begin(u, seat, data, event)
|
PointerTarget::gesture_swipe_begin(u, seat, data, event)
|
||||||
|
|
@ -241,8 +348,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GestureSwipeUpdateEvent,
|
event: &GestureSwipeUpdateEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_swipe_update(s, seat, data, event)
|
PointerTarget::gesture_swipe_update(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_swipe_update(u, seat, data, event)
|
PointerTarget::gesture_swipe_update(u, seat, data, event)
|
||||||
|
|
@ -262,8 +369,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GestureSwipeEndEvent,
|
event: &GestureSwipeEndEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_swipe_end(s, seat, data, event)
|
PointerTarget::gesture_swipe_end(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_swipe_end(u, seat, data, event)
|
PointerTarget::gesture_swipe_end(u, seat, data, event)
|
||||||
|
|
@ -283,8 +390,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GesturePinchBeginEvent,
|
event: &GesturePinchBeginEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_pinch_begin(s, seat, data, event)
|
PointerTarget::gesture_pinch_begin(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_pinch_begin(u, seat, data, event)
|
PointerTarget::gesture_pinch_begin(u, seat, data, event)
|
||||||
|
|
@ -304,8 +411,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GesturePinchUpdateEvent,
|
event: &GesturePinchUpdateEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_pinch_update(s, seat, data, event)
|
PointerTarget::gesture_pinch_update(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_pinch_update(u, seat, data, event)
|
PointerTarget::gesture_pinch_update(u, seat, data, event)
|
||||||
|
|
@ -325,8 +432,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GesturePinchEndEvent,
|
event: &GesturePinchEndEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_pinch_end(s, seat, data, event)
|
PointerTarget::gesture_pinch_end(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_pinch_end(u, seat, data, event)
|
PointerTarget::gesture_pinch_end(u, seat, data, event)
|
||||||
|
|
@ -346,8 +453,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
event: &GestureHoldBeginEvent,
|
event: &GestureHoldBeginEvent,
|
||||||
) {
|
) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_hold_begin(s, seat, data, event)
|
PointerTarget::gesture_hold_begin(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => {
|
PointerFocusTarget::StackUI(u) => {
|
||||||
PointerTarget::gesture_hold_begin(u, seat, data, event)
|
PointerTarget::gesture_hold_begin(u, seat, data, event)
|
||||||
|
|
@ -362,8 +469,8 @@ impl PointerTarget<State> for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn gesture_hold_end(&self, seat: &Seat<State>, data: &mut State, event: &GestureHoldEndEvent) {
|
fn gesture_hold_end(&self, seat: &Seat<State>, data: &mut State, event: &GestureHoldEndEvent) {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => {
|
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||||
PointerTarget::gesture_hold_end(s, seat, data, event)
|
PointerTarget::gesture_hold_end(surface, seat, data, event)
|
||||||
}
|
}
|
||||||
PointerFocusTarget::StackUI(u) => PointerTarget::gesture_hold_end(u, seat, data, event),
|
PointerFocusTarget::StackUI(u) => PointerTarget::gesture_hold_end(u, seat, data, event),
|
||||||
PointerFocusTarget::WindowUI(u) => {
|
PointerFocusTarget::WindowUI(u) => {
|
||||||
|
|
@ -497,7 +604,7 @@ impl WaylandFocus for KeyboardFocusTarget {
|
||||||
impl WaylandFocus for PointerFocusTarget {
|
impl WaylandFocus for PointerFocusTarget {
|
||||||
fn wl_surface(&self) -> Option<WlSurface> {
|
fn wl_surface(&self) -> Option<WlSurface> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
PointerFocusTarget::WlSurface(s) => s.clone(),
|
PointerFocusTarget::WlSurface { surface, .. } => surface.clone(),
|
||||||
PointerFocusTarget::ResizeFork(_)
|
PointerFocusTarget::ResizeFork(_)
|
||||||
| PointerFocusTarget::StackUI(_)
|
| PointerFocusTarget::StackUI(_)
|
||||||
| PointerFocusTarget::WindowUI(_) => {
|
| PointerFocusTarget::WindowUI(_) => {
|
||||||
|
|
@ -507,7 +614,7 @@ impl WaylandFocus for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
fn same_client_as(&self, object_id: &ObjectId) -> bool {
|
||||||
match self {
|
match self {
|
||||||
PointerFocusTarget::WlSurface(s) => s.id().same_client_as(object_id),
|
PointerFocusTarget::WlSurface { surface, .. } => surface.id().same_client_as(object_id),
|
||||||
PointerFocusTarget::StackUI(stack) => stack
|
PointerFocusTarget::StackUI(stack) => stack
|
||||||
.active()
|
.active()
|
||||||
.wl_surface()
|
.wl_surface()
|
||||||
|
|
@ -522,15 +629,12 @@ impl WaylandFocus for PointerFocusTarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<WlSurface> for PointerFocusTarget {
|
|
||||||
fn from(s: WlSurface) -> Self {
|
|
||||||
PointerFocusTarget::WlSurface(s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PopupKind> for PointerFocusTarget {
|
impl From<PopupKind> for PointerFocusTarget {
|
||||||
fn from(p: PopupKind) -> Self {
|
fn from(p: PopupKind) -> Self {
|
||||||
PointerFocusTarget::WlSurface(p.wl_surface().clone())
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: p.wl_surface().clone(),
|
||||||
|
toplevel: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,7 +646,10 @@ impl From<ResizeForkTarget> for PointerFocusTarget {
|
||||||
|
|
||||||
impl From<LockSurface> for PointerFocusTarget {
|
impl From<LockSurface> for PointerFocusTarget {
|
||||||
fn from(l: LockSurface) -> Self {
|
fn from(l: LockSurface) -> Self {
|
||||||
PointerFocusTarget::WlSurface(l.wl_surface().clone())
|
PointerFocusTarget::WlSurface {
|
||||||
|
surface: l.wl_surface().clone(),
|
||||||
|
toplevel: None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue