Merge tag 'epoch-1.8.0' into local/yoda-main
Epoch 1.8.0 # Conflicts: # Cargo.lock
This commit is contained in:
commit
a69f659983
50 changed files with 3533 additions and 1713 deletions
|
|
@ -12,7 +12,7 @@ use id_tree::NodeId;
|
|||
use smithay::{
|
||||
backend::{
|
||||
drm::DrmNode,
|
||||
input::KeyState,
|
||||
input::{InputTime, KeyState},
|
||||
renderer::{
|
||||
element::{
|
||||
Element, Kind, RenderElement, UnderlyingStorage,
|
||||
|
|
@ -1012,7 +1012,7 @@ impl KeyboardTarget<State> for CosmicMapped {
|
|||
key: KeysymHandle<'_>,
|
||||
state: KeyState,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Stack(s) => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
shell::{
|
||||
element::{CosmicMappedKey, CosmicMappedKeyInner},
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{ReleaseMode, ResizeEdge},
|
||||
grabs::{GrabType, ReleaseMode, ResizeEdge},
|
||||
layout::tiling::NodeDesc,
|
||||
},
|
||||
state::State,
|
||||
|
|
@ -38,7 +38,7 @@ use shortcuts::action::{Direction, FocusDirection};
|
|||
use smithay::{
|
||||
backend::{
|
||||
drm::DrmNode,
|
||||
input::KeyState,
|
||||
input::{InputTime, KeyState, TabletToolDescriptor},
|
||||
renderer::{
|
||||
ImportAll, ImportMem, Renderer,
|
||||
element::{Element, Id as RendererId, Kind, RenderElement, UnderlyingStorage},
|
||||
|
|
@ -52,14 +52,23 @@ use smithay::{
|
|||
Seat,
|
||||
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorImageStatus,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent,
|
||||
PointerTarget, RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
Tablet, TabletSeatTrait,
|
||||
tool::{
|
||||
AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent,
|
||||
DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolTarget,
|
||||
UpEvent as ToolUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent,
|
||||
TouchTarget, UpEvent,
|
||||
DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -112,6 +121,7 @@ pub struct CosmicStackInternal {
|
|||
previous_keyboard: AtomicUsize,
|
||||
pointer_entered: AtomicU8,
|
||||
touch_serial: AtomicU32,
|
||||
tablet_serial: AtomicU32,
|
||||
reenter: AtomicBool,
|
||||
potential_drag: Mutex<Option<usize>>,
|
||||
override_alive: AtomicBool,
|
||||
|
|
@ -171,6 +181,7 @@ impl CosmicStack {
|
|||
previous_keyboard: AtomicUsize::new(0),
|
||||
pointer_entered: AtomicU8::new(0),
|
||||
touch_serial: AtomicU32::new(0),
|
||||
tablet_serial: AtomicU32::new(0),
|
||||
reenter: AtomicBool::new(false),
|
||||
potential_drag: Mutex::new(None),
|
||||
override_alive: AtomicBool::new(true),
|
||||
|
|
@ -831,7 +842,7 @@ impl CosmicStack {
|
|||
)));
|
||||
};
|
||||
|
||||
let radii = radii.map(|[a, _, c, _]| [a, 0, c, 0]);
|
||||
let radii = radii.map(|[_, _, c, d]| [0, 0, c, d]);
|
||||
windows[active].push_render_elements(
|
||||
renderer,
|
||||
window_loc,
|
||||
|
|
@ -909,12 +920,19 @@ impl CosmicStack {
|
|||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
.set_grab(state, grab, serial, focus),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -997,17 +1015,17 @@ impl CosmicStack {
|
|||
.corner_radius(geometry_size)
|
||||
.unwrap_or([default_radius; 4]);
|
||||
|
||||
corners[0] = 0;
|
||||
corners[1] = 0;
|
||||
corners[3] = 0;
|
||||
|
||||
corners
|
||||
} else {
|
||||
let mut corners = active_window.corner_radius(geometry_size).unwrap_or(radii);
|
||||
|
||||
corners[0] = radii[0].max(corners[0]);
|
||||
corners[0] = radii[0];
|
||||
corners[1] = radii[1];
|
||||
corners[2] = radii[2].max(corners[2]);
|
||||
corners[3] = radii[3];
|
||||
corners[3] = radii[3].max(corners[3]);
|
||||
|
||||
corners
|
||||
}
|
||||
|
|
@ -1089,12 +1107,19 @@ impl Program for CosmicStackInternal {
|
|||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
.set_grab(state, grab, serial, focus),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1547,7 +1572,7 @@ impl KeyboardTarget<State> for CosmicStack {
|
|||
key: KeysymHandle<'_>,
|
||||
state: KeyState,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
let active = self.keyboard_leave_if_previous(seat, data, serial);
|
||||
self.0.with_program(|p| {
|
||||
|
|
@ -1587,7 +1612,7 @@ impl KeyboardTarget<State> for CosmicStack {
|
|||
}
|
||||
|
||||
impl PointerTarget<State> for CosmicStack {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let active_window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
|
||||
|
|
@ -1615,7 +1640,7 @@ impl PointerTarget<State> for CosmicStack {
|
|||
PointerTarget::enter(&self.0, seat, data, &event)
|
||||
}
|
||||
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let active = p.active.load(Ordering::SeqCst);
|
||||
|
|
@ -1658,7 +1683,7 @@ 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: &PointerButtonEvent) {
|
||||
match self.0.with_program(|p| p.current_focus()) {
|
||||
Some(Focus::Header) => PointerTarget::button(&self.0, seat, data, event),
|
||||
Some(x) => {
|
||||
|
|
@ -1689,14 +1714,12 @@ impl PointerTarget<State> for CosmicStack {
|
|||
state.common.config.cosmic_conf.edge_snap_threshold,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
if let Some((grab, focus)) = res
|
||||
&& let GrabType::Pointer = grab.grab_type()
|
||||
{
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1704,7 +1727,7 @@ 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: PointerAxisFrame) {
|
||||
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) {
|
||||
PointerTarget::axis(&self.0, seat, data, frame)
|
||||
}
|
||||
|
|
@ -1716,7 +1739,7 @@ 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: InputTime) {
|
||||
self.0.with_program(|p| {
|
||||
let mut cursor_state = seat
|
||||
.user_data()
|
||||
|
|
@ -1752,14 +1775,12 @@ impl PointerTarget<State> for CosmicStack {
|
|||
&state.common.event_loop_handle,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
if let Some((grab, focus)) = res
|
||||
&& let GrabType::Pointer = grab.grab_type()
|
||||
{
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1832,7 +1853,7 @@ impl PointerTarget<State> for CosmicStack {
|
|||
}
|
||||
|
||||
impl TouchTarget<State> for CosmicStack {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &DownEvent) {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &TouchDownEvent) {
|
||||
let mut event = event.clone();
|
||||
let active_window_geo = self.0.with_program(|p| {
|
||||
p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].geometry()
|
||||
|
|
@ -1843,7 +1864,7 @@ impl TouchTarget<State> for CosmicStack {
|
|||
TouchTarget::down(&self.0, seat, data, &event)
|
||||
}
|
||||
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent) {
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &TouchUpEvent) {
|
||||
TouchTarget::up(&self.0, seat, data, event)
|
||||
}
|
||||
|
||||
|
|
@ -1891,6 +1912,185 @@ impl TouchTarget<State> for CosmicStack {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolTarget<State> for CosmicStack {
|
||||
fn proximity_in(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
tablet: &Tablet,
|
||||
serial: Serial,
|
||||
) {
|
||||
TabletToolTarget::proximity_in(&self.0, seat, data, tool_descriptor, tablet, serial)
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
) {
|
||||
self.0.with_program(|p| {
|
||||
let mut cursor_state = seat
|
||||
.user_data()
|
||||
.get::<CursorState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
cursor_state.unset_shape();
|
||||
let _previous = p.swap_focus(None);
|
||||
});
|
||||
TabletToolTarget::proximity_out(&self.0, seat, data, tool_descriptor);
|
||||
}
|
||||
|
||||
fn down(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolDownEvent,
|
||||
) {
|
||||
self.0.with_program(|p| {
|
||||
p.tablet_serial
|
||||
.store(event.serial.into(), Ordering::Release)
|
||||
});
|
||||
match self.0.with_program(|p| p.current_focus()) {
|
||||
Some(Focus::Header) => {
|
||||
TabletToolTarget::down(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
Some(x) => {
|
||||
let serial = self
|
||||
.0
|
||||
.with_program(|p| p.tablet_serial.load(Ordering::Acquire))
|
||||
.into();
|
||||
let seat = seat.clone();
|
||||
let Some(surface) = self.0.with_program(|p| {
|
||||
let window = &p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)];
|
||||
window.wl_surface().map(Cow::into_owned)
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
self.0.loop_handle().insert_idle(move |state| {
|
||||
let res = state.common.shell.write().resize_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
match x {
|
||||
Focus::ResizeTop => ResizeEdge::TOP,
|
||||
Focus::ResizeTopLeft => ResizeEdge::TOP_LEFT,
|
||||
Focus::ResizeTopRight => ResizeEdge::TOP_RIGHT,
|
||||
Focus::ResizeBottom => ResizeEdge::BOTTOM,
|
||||
Focus::ResizeBottomLeft => ResizeEdge::BOTTOM_LEFT,
|
||||
Focus::ResizeBottomRight => ResizeEdge::BOTTOM_RIGHT,
|
||||
Focus::ResizeLeft => ResizeEdge::LEFT,
|
||||
Focus::ResizeRight => ResizeEdge::RIGHT,
|
||||
Focus::Header => unreachable!(),
|
||||
},
|
||||
state.common.config.cosmic_conf.edge_snap_threshold,
|
||||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res
|
||||
&& let GrabType::TabletTool = grab.grab_type()
|
||||
{
|
||||
seat.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolUpEvent,
|
||||
) {
|
||||
TabletToolTarget::up(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolMotionEvent,
|
||||
) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let active = p.active.load(Ordering::SeqCst);
|
||||
let active_window = &p.windows.lock().unwrap()[active];
|
||||
let Some(next) = Focus::under(active_window, TAB_HEIGHT, event.location) else {
|
||||
return;
|
||||
};
|
||||
let _previous = p.swap_focus(Some(next));
|
||||
|
||||
let mut cursor_state = seat
|
||||
.user_data()
|
||||
.get::<CursorState>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
cursor_state.set_shape(next.cursor_shape());
|
||||
seat.set_cursor_image_status(CursorImageStatus::default_named());
|
||||
});
|
||||
|
||||
let active_window_geo = self.0.with_program(|p| {
|
||||
p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)].geometry()
|
||||
});
|
||||
event.location -= active_window_geo.loc.to_f64();
|
||||
|
||||
TabletToolTarget::motion(&self.0, seat, data, tool_descriptor, &event);
|
||||
if event.location.y < 0.0
|
||||
|| event.location.y > TAB_HEIGHT as f64
|
||||
|| event.location.x < 64.0
|
||||
|| event.location.x > (active_window_geo.size.w as f64 - 64.0)
|
||||
{
|
||||
self.start_drag(
|
||||
data,
|
||||
seat,
|
||||
self.0
|
||||
.with_program(|p| p.tablet_serial.load(Ordering::Acquire))
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
frame: ToolAxisFrame,
|
||||
) {
|
||||
TabletToolTarget::axis(&self.0, seat, data, tool_descriptor, frame)
|
||||
}
|
||||
|
||||
fn button(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolButtonEvent,
|
||||
) {
|
||||
TabletToolTarget::button(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
time: InputTime,
|
||||
) {
|
||||
TabletToolTarget::frame(&self.0, seat, data, tool_descriptor, time)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum CosmicStackRenderElement<R: Renderer + ImportAll + ImportMem> {
|
||||
Header(IcedRenderElement<R>),
|
||||
Shadow(PixelShaderElement),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use cosmic::{
|
|||
layout::{Layout, Limits, Node},
|
||||
mouse, overlay, renderer,
|
||||
text::{Ellipsize, EllipsizeHeightLimit, Shaping, Wrapping},
|
||||
touch,
|
||||
widget::{Id, Widget, operation::Operation, tree::Tree},
|
||||
},
|
||||
widget::{self, container::draw_background, rule::FillMode, scrollable::AbsoluteOffset},
|
||||
|
|
@ -370,6 +371,7 @@ where
|
|||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
|
||||
| event::Event::Touch(touch::Event::FingerPressed { .. })
|
||||
) && let Some(message) = self.press_message.clone()
|
||||
{
|
||||
shell.publish(message);
|
||||
|
|
@ -388,6 +390,7 @@ where
|
|||
if matches!(
|
||||
event,
|
||||
event::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
| event::Event::Touch(touch::Event::FingerLifted { .. })
|
||||
) {
|
||||
shell.publish(Message::activate(self.idx));
|
||||
shell.capture_event();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use keyframe::{
|
|||
functions::{EaseInOutCubic, EaseOutCubic},
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
collections::{HashMap, VecDeque},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
|
|
@ -757,12 +757,10 @@ where
|
|||
state.last_state = Some(current_state.clone());
|
||||
}
|
||||
let last_state = state.last_state.as_mut().unwrap();
|
||||
let unknown_keys = current_state
|
||||
.keys()
|
||||
.collect::<HashSet<_>>()
|
||||
.symmetric_difference(&last_state.keys().collect::<HashSet<_>>())
|
||||
.next()
|
||||
.is_some();
|
||||
let unknown_keys = current_state.len() != last_state.len()
|
||||
|| current_state
|
||||
.keys()
|
||||
.any(|key| !last_state.contains_key(key));
|
||||
|
||||
enum Difference {
|
||||
NewOrRemoved,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use std::{
|
|||
use smithay::{
|
||||
backend::{
|
||||
drm::DrmNode,
|
||||
input::InputTime,
|
||||
renderer::{
|
||||
ImportAll, Renderer, buffer_has_alpha,
|
||||
element::{Kind, RenderElementStates, surface::KindEvaluation},
|
||||
|
|
@ -1084,7 +1085,7 @@ impl KeyboardTarget<State> for CosmicSurface {
|
|||
key: KeysymHandle<'_>,
|
||||
state: smithay::backend::input::KeyState,
|
||||
serial: smithay::utils::Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
shell::{
|
||||
element::{CosmicMappedKey, CosmicMappedKeyInner},
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{ReleaseMode, ResizeEdge},
|
||||
grabs::{GrabType, ReleaseMode, ResizeEdge},
|
||||
},
|
||||
state::State,
|
||||
utils::{
|
||||
|
|
@ -21,7 +21,7 @@ use cosmic_comp_config::AppearanceConfig;
|
|||
use smithay::{
|
||||
backend::{
|
||||
drm::DrmNode,
|
||||
input::KeyState,
|
||||
input::{InputTime, KeyState, TabletToolDescriptor},
|
||||
renderer::{
|
||||
ImportAll, ImportMem, Renderer,
|
||||
element::{Element, Id as RendererId, Kind, RenderElement, UnderlyingStorage},
|
||||
|
|
@ -35,14 +35,23 @@ use smithay::{
|
|||
Seat,
|
||||
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, GestureHoldBeginEvent,
|
||||
GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent,
|
||||
GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent,
|
||||
GestureSwipeUpdateEvent, MotionEvent, PointerTarget, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon,
|
||||
CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent,
|
||||
PointerTarget, RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
Tablet, TabletSeatTrait,
|
||||
tool::{
|
||||
AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent,
|
||||
DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolTarget,
|
||||
UpEvent as ToolUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent,
|
||||
TouchTarget, UpEvent,
|
||||
DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -429,12 +438,12 @@ impl CosmicWindow {
|
|||
.map(|x| (x * scale as f32).round() as u8);
|
||||
if has_ssd && !clip {
|
||||
// bottom corners
|
||||
radii[0] = 0;
|
||||
radii[2] = 0;
|
||||
radii[3] = 0;
|
||||
if is_tiled {
|
||||
// top corners
|
||||
radii[0] = 0;
|
||||
radii[1] = 0;
|
||||
radii[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -501,12 +510,12 @@ impl CosmicWindow {
|
|||
&& !is_maximized;
|
||||
if has_ssd && !clip {
|
||||
// bottom corners
|
||||
radii[0] = 0;
|
||||
radii[2] = 0;
|
||||
radii[3] = 0;
|
||||
if is_tiled {
|
||||
// top corners
|
||||
radii[0] = 0;
|
||||
radii[1] = 0;
|
||||
radii[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -551,8 +560,8 @@ impl CosmicWindow {
|
|||
self.0.with_program(|p| {
|
||||
let mut radii = radii;
|
||||
if has_ssd {
|
||||
radii[0] = 0;
|
||||
radii[1] = 0;
|
||||
radii[3] = 0;
|
||||
}
|
||||
let theme = p.theme.lock().unwrap();
|
||||
let frosted = if theme.cosmic().frosted_windows {
|
||||
|
|
@ -576,8 +585,8 @@ impl CosmicWindow {
|
|||
});
|
||||
|
||||
if has_ssd {
|
||||
radii[0] = 0;
|
||||
radii[2] = 0;
|
||||
radii[3] = 0;
|
||||
let ssd_loc = location
|
||||
+ self
|
||||
.0
|
||||
|
|
@ -682,26 +691,26 @@ impl CosmicWindow {
|
|||
(has_ssd, true) => {
|
||||
let mut corners = p.window.corner_radius(geometry_size).unwrap_or(radii);
|
||||
|
||||
corners[0] = radii[0].max(corners[0]);
|
||||
corners[0] = if has_ssd {
|
||||
radii[0]
|
||||
} else {
|
||||
radii[0].max(corners[0])
|
||||
};
|
||||
corners[1] = if has_ssd {
|
||||
radii[1]
|
||||
} else {
|
||||
radii[1].max(corners[1])
|
||||
};
|
||||
corners[2] = radii[2].max(corners[2]);
|
||||
corners[3] = if has_ssd {
|
||||
radii[3]
|
||||
} else {
|
||||
radii[3].max(corners[3])
|
||||
};
|
||||
corners[3] = radii[3].max(corners[3]);
|
||||
|
||||
corners
|
||||
}
|
||||
(true, false) => p
|
||||
.window
|
||||
.corner_radius(geometry_size)
|
||||
.map(|[a, _, c, _]| [a, radii[1], c, radii[3]])
|
||||
.unwrap_or([default_radius, radii[1], default_radius, radii[3]]),
|
||||
.map(|[_, _, c, d]| [radii[0], radii[1], c, d])
|
||||
.unwrap_or([radii[0], radii[1], default_radius, default_radius]),
|
||||
(false, false) => p
|
||||
.window
|
||||
.corner_radius(geometry_size)
|
||||
|
|
@ -746,12 +755,19 @@ impl Program for CosmicWindowInternal {
|
|||
false,
|
||||
);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
.set_grab(state, grab, serial, focus),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -981,7 +997,7 @@ impl KeyboardTarget<State> for CosmicWindow {
|
|||
key: KeysymHandle<'_>,
|
||||
state: KeyState,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
self.0
|
||||
.with_program(|p| KeyboardTarget::key(&p.window, seat, data, key, state, serial, time))
|
||||
|
|
@ -999,7 +1015,7 @@ impl KeyboardTarget<State> for CosmicWindow {
|
|||
}
|
||||
|
||||
impl PointerTarget<State> for CosmicWindow {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||
fn enter(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let has_ssd = p.has_ssd(false);
|
||||
|
|
@ -1012,8 +1028,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
return;
|
||||
};
|
||||
|
||||
let old_focus = p.swap_focus(Some(next));
|
||||
assert_eq!(old_focus, None);
|
||||
let _ = p.swap_focus(Some(next));
|
||||
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().set_shape(next.cursor_shape());
|
||||
|
|
@ -1025,7 +1040,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
PointerTarget::enter(&self.0, seat, data, &event)
|
||||
}
|
||||
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &MotionEvent) {
|
||||
fn motion(&self, seat: &Seat<State>, data: &mut State, event: &PointerMotionEvent) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let has_ssd = p.has_ssd(false);
|
||||
|
|
@ -1057,7 +1072,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
) {
|
||||
}
|
||||
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &PointerButtonEvent) {
|
||||
match self.0.with_program(|p| p.current_focus()) {
|
||||
Some(Focus::Header) => PointerTarget::button(&self.0, seat, data, event),
|
||||
Some(x) => {
|
||||
|
|
@ -1093,14 +1108,12 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
false,
|
||||
);
|
||||
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
if let Some((grab, focus)) = res
|
||||
&& let GrabType::Pointer = grab.grab_type()
|
||||
{
|
||||
seat.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1108,7 +1121,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: PointerAxisFrame) {
|
||||
if let Some(Focus::Header) = self.0.with_program(|p| p.current_focus()) {
|
||||
PointerTarget::axis(&self.0, seat, data, frame)
|
||||
}
|
||||
|
|
@ -1120,7 +1133,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
}
|
||||
}
|
||||
|
||||
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: InputTime) {
|
||||
self.0.with_program(|p| {
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
|
|
@ -1195,7 +1208,7 @@ impl PointerTarget<State> for CosmicWindow {
|
|||
}
|
||||
|
||||
impl TouchTarget<State> for CosmicWindow {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &DownEvent) {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &TouchDownEvent) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
event.location -= p.window.geometry().loc.to_f64();
|
||||
|
|
@ -1203,7 +1216,7 @@ impl TouchTarget<State> for CosmicWindow {
|
|||
TouchTarget::down(&self.0, seat, data, &event)
|
||||
}
|
||||
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent) {
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &TouchUpEvent) {
|
||||
TouchTarget::up(&self.0, seat, data, event)
|
||||
}
|
||||
|
||||
|
|
@ -1234,6 +1247,155 @@ impl TouchTarget<State> for CosmicWindow {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolTarget<State> for CosmicWindow {
|
||||
fn proximity_in(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
tablet: &Tablet,
|
||||
serial: Serial,
|
||||
) {
|
||||
TabletToolTarget::proximity_in(&self.0, seat, data, tool_descriptor, tablet, serial)
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
) {
|
||||
self.0.with_program(|p| {
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
let _previous = p.swap_focus(None);
|
||||
});
|
||||
TabletToolTarget::proximity_out(&self.0, seat, data, tool_descriptor)
|
||||
}
|
||||
|
||||
fn down(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolDownEvent,
|
||||
) {
|
||||
match self.0.with_program(|p| p.current_focus()) {
|
||||
Some(Focus::Header) => {
|
||||
TabletToolTarget::down(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
Some(x) => {
|
||||
let serial = event.serial;
|
||||
let seat = seat.clone();
|
||||
let Some(surface) = self.wl_surface().map(Cow::into_owned) else {
|
||||
return;
|
||||
};
|
||||
|
||||
self.0.loop_handle().insert_idle(move |state| {
|
||||
let res = state.common.shell.write().resize_request(
|
||||
&surface,
|
||||
&seat,
|
||||
serial,
|
||||
match x {
|
||||
Focus::ResizeTop => ResizeEdge::TOP,
|
||||
Focus::ResizeTopLeft => ResizeEdge::TOP_LEFT,
|
||||
Focus::ResizeTopRight => ResizeEdge::TOP_RIGHT,
|
||||
Focus::ResizeBottom => ResizeEdge::BOTTOM,
|
||||
Focus::ResizeBottomLeft => ResizeEdge::BOTTOM_LEFT,
|
||||
Focus::ResizeBottomRight => ResizeEdge::BOTTOM_RIGHT,
|
||||
Focus::ResizeLeft => ResizeEdge::LEFT,
|
||||
Focus::ResizeRight => ResizeEdge::RIGHT,
|
||||
Focus::Header => unreachable!(),
|
||||
},
|
||||
state.common.config.cosmic_conf.edge_snap_threshold,
|
||||
false,
|
||||
);
|
||||
|
||||
if let Some((grab, focus)) = res
|
||||
&& let GrabType::TabletTool = grab.grab_type()
|
||||
{
|
||||
seat.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus)
|
||||
}
|
||||
});
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolUpEvent,
|
||||
) {
|
||||
TabletToolTarget::up(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolMotionEvent,
|
||||
) {
|
||||
let mut event = event.clone();
|
||||
self.0.with_program(|p| {
|
||||
let has_ssd = p.has_ssd(false);
|
||||
if has_ssd || p.has_tiled_state() {
|
||||
let Some(next) = Focus::under(
|
||||
&p.window,
|
||||
if has_ssd { SSD_HEIGHT } else { 0 },
|
||||
event.location,
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let _previous = p.swap_focus(Some(next));
|
||||
|
||||
let cursor_state = seat.user_data().get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().set_shape(next.cursor_shape());
|
||||
seat.set_cursor_image_status(CursorImageStatus::default_named());
|
||||
}
|
||||
});
|
||||
|
||||
event.location -= self.0.with_program(|p| p.window.geometry().loc.to_f64());
|
||||
TabletToolTarget::motion(&self.0, seat, data, tool_descriptor, &event)
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
frame: ToolAxisFrame,
|
||||
) {
|
||||
TabletToolTarget::axis(&self.0, seat, data, tool_descriptor, frame)
|
||||
}
|
||||
|
||||
fn button(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolButtonEvent,
|
||||
) {
|
||||
TabletToolTarget::button(&self.0, seat, data, tool_descriptor, event)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
time: InputTime,
|
||||
) {
|
||||
TabletToolTarget::frame(&self.0, seat, data, tool_descriptor, time)
|
||||
}
|
||||
}
|
||||
|
||||
impl WaylandFocus for CosmicWindow {
|
||||
fn wl_surface(&self) -> Option<Cow<'_, WlSurface>> {
|
||||
self.0.with_program(|p| {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use crate::{
|
|||
};
|
||||
use indexmap::IndexSet;
|
||||
use smithay::{
|
||||
backend::input::InputTime,
|
||||
desktop::{PopupUngrabStrategy, layer_map_for_output},
|
||||
input::{Seat, pointer::MotionEvent},
|
||||
output::Output,
|
||||
|
|
@ -419,7 +420,7 @@ fn update_focus_state(
|
|||
&MotionEvent {
|
||||
location: new_pos.as_logical(),
|
||||
serial: SERIAL_COUNTER.next_serial(),
|
||||
time: 0,
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
@ -768,7 +769,7 @@ fn update_pointer_focus(state: &mut State, seat: &Seat<State>) {
|
|||
&MotionEvent {
|
||||
location: pointer.current_location(),
|
||||
serial: SERIAL_COUNTER.next_serial(),
|
||||
time: state.common.clock.now().as_millis(),
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,30 @@ use crate::{
|
|||
};
|
||||
use id_tree::NodeId;
|
||||
use smithay::{
|
||||
backend::input::KeyState,
|
||||
backend::input::{InputTime, KeyState, TabletToolDescriptor},
|
||||
desktop::{LayerSurface, PopupKind, WindowSurface, WindowSurfaceType, space::SpaceElement},
|
||||
input::{
|
||||
Seat,
|
||||
dnd::{DndFocus, OfferData, Source},
|
||||
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
MotionEvent as PointerMotionEvent, PointerTarget, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent,
|
||||
PointerTarget, RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
Tablet,
|
||||
tool::{
|
||||
AxisFrame as ToolAxisFrame, ButtonEvent as ToolButtonEvent,
|
||||
DownEvent as ToolDownEvent, MotionEvent as ToolMotionEvent, TabletToolHandle,
|
||||
TabletToolTarget, UpEvent as ToolUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent,
|
||||
TouchTarget, UpEvent,
|
||||
DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
reexports::wayland_server::{
|
||||
|
|
@ -164,6 +173,17 @@ impl PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn inner_tablet_tool_target(&self) -> &dyn TabletToolTarget<State> {
|
||||
match self {
|
||||
PointerFocusTarget::WlSurface { surface, .. } => surface,
|
||||
PointerFocusTarget::X11Surface { surface, .. } => surface,
|
||||
PointerFocusTarget::StackUI(u) => u,
|
||||
PointerFocusTarget::WindowUI(u) => u,
|
||||
PointerFocusTarget::ResizeFork(f) => f,
|
||||
PointerFocusTarget::ZoomUI(e) => e,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn under_surface<P: Into<Point<f64, Logical>>>(
|
||||
surface: &CosmicSurface,
|
||||
point: P,
|
||||
|
|
@ -272,9 +292,10 @@ impl PointerFocusTarget {
|
|||
None
|
||||
};
|
||||
|
||||
let cursor_hotspot = if let Some(CursorGeometry { hotspot, .. }) =
|
||||
seat.cursor_geometry((0.0, 0.0), Duration::from_millis(event.time as u64).into())
|
||||
{
|
||||
let cursor_hotspot = if let Some(CursorGeometry { hotspot, .. }) = seat.cursor_geometry(
|
||||
(0.0, 0.0),
|
||||
Duration::from_millis(event.time.millis() as u64).into(),
|
||||
) {
|
||||
hotspot
|
||||
} else {
|
||||
Point::from((0, 0))
|
||||
|
|
@ -285,6 +306,16 @@ impl PointerFocusTarget {
|
|||
session.set_cursor_hotspot(cursor_hotspot);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_tool(&self, tool_handle: &TabletToolHandle<State>) -> bool {
|
||||
match self {
|
||||
Self::WlSurface { surface, .. } if surface.client().is_some() => tool_handle
|
||||
.client_tools(&surface.client().unwrap())
|
||||
.next()
|
||||
.is_some(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl KeyboardFocusTarget {
|
||||
|
|
@ -408,16 +439,16 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
self.inner_pointer_target()
|
||||
.relative_motion(seat, data, event);
|
||||
}
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &PointerButtonEvent) {
|
||||
self.inner_pointer_target().button(seat, data, event);
|
||||
}
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: PointerAxisFrame) {
|
||||
self.inner_pointer_target().axis(seat, data, frame);
|
||||
}
|
||||
fn frame(&self, seat: &Seat<State>, data: &mut State) {
|
||||
self.inner_pointer_target().frame(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: InputTime) {
|
||||
let toplevel = self.toplevel(&data.common.shell.read());
|
||||
if let Some(element) = toplevel {
|
||||
for session in element.cursor_sessions() {
|
||||
|
|
@ -497,12 +528,102 @@ impl PointerTarget<State> for PointerFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolTarget<State> for PointerFocusTarget {
|
||||
fn proximity_in(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
tablet: &Tablet,
|
||||
serial: Serial,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.proximity_in(seat, data, tool_descriptor, tablet, serial);
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.proximity_out(seat, data, tool_descriptor);
|
||||
}
|
||||
|
||||
fn down(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolDownEvent,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.down(seat, data, tool_descriptor, event);
|
||||
}
|
||||
|
||||
fn up(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolUpEvent,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.up(seat, data, tool_descriptor, event);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolMotionEvent,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.motion(seat, data, tool_descriptor, event);
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
frame: ToolAxisFrame,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.axis(seat, data, tool_descriptor, frame);
|
||||
}
|
||||
|
||||
fn button(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &ToolButtonEvent,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.button(seat, data, tool_descriptor, event);
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
time: InputTime,
|
||||
) {
|
||||
self.inner_tablet_tool_target()
|
||||
.frame(seat, data, tool_descriptor, time);
|
||||
}
|
||||
}
|
||||
|
||||
impl TouchTarget<State> for PointerFocusTarget {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &DownEvent) {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &TouchDownEvent) {
|
||||
self.inner_touch_target().down(seat, data, event);
|
||||
}
|
||||
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent) {
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &TouchUpEvent) {
|
||||
self.inner_touch_target().up(seat, data, event);
|
||||
}
|
||||
|
||||
|
|
@ -593,7 +714,7 @@ impl DndFocus<State> for PointerFocusTarget {
|
|||
offer: Option<&mut CosmicOfferData<S>>,
|
||||
seat: &Seat<State>,
|
||||
location: Point<f64, Logical>,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
match self {
|
||||
PointerFocusTarget::WlSurface { surface, .. } => {
|
||||
|
|
@ -695,7 +816,7 @@ impl KeyboardTarget<State> for KeyboardFocusTarget {
|
|||
key: KeysymHandle<'_>,
|
||||
state: KeyState,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
if let Some(inner) = self.inner_keyboard_target() {
|
||||
inner.key(seat, data, key, state, serial, time);
|
||||
|
|
|
|||
|
|
@ -1,22 +1,34 @@
|
|||
use smithay::{
|
||||
backend::input::{InputTime, TabletToolDescriptor},
|
||||
input::{
|
||||
Seat, SeatHandler,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent as PointerMotionEvent, PointerGrab,
|
||||
PointerInnerHandle, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, Focus,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
TabletSeatHandler, TabletSeatTrait,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData,
|
||||
MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent,
|
||||
TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
|
||||
DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab,
|
||||
TouchInnerHandle, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
utils::{Logical, Point, SERIAL_COUNTER, Serial},
|
||||
};
|
||||
|
||||
use crate::state::State;
|
||||
use crate::{shell::grabs::GrabType, state::State};
|
||||
|
||||
use super::GrabStartData;
|
||||
|
||||
|
|
@ -44,10 +56,15 @@ impl<G> DelayGrab<G> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
self.start_data.type_()
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
if let GrabStartData::TabletTool { tool, .. } = &self.start_data {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92,7 +109,7 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
handle.button(data, event);
|
||||
if handle.current_pressed().is_empty() {
|
||||
|
|
@ -104,7 +121,7 @@ impl<G: PointerGrab<State>> PointerGrab<State> for DelayGrab<G> {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
handle.axis(data, details);
|
||||
}
|
||||
|
|
@ -201,12 +218,17 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
focus: Option<(<State as SeatHandler>::TouchFocus, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
handle.down(data, focus, event);
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
handle.up(data, event);
|
||||
|
||||
if event.slot == TouchGrab::start_data(self).slot {
|
||||
|
|
@ -273,3 +295,110 @@ impl<G: TouchGrab<State>> TouchGrab<State> for DelayGrab<G> {
|
|||
|
||||
fn unset(&mut self, _data: &mut State) {}
|
||||
}
|
||||
|
||||
impl<G: TabletToolGrab<State>> TabletToolGrab<State> for DelayGrab<G> {
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match &self.start_data {
|
||||
GrabStartData::TabletTool { data, .. } => data,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
handle.proximity_out(data, event);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
handle.motion(data, focus, event);
|
||||
|
||||
let distance = self.start_data.distance(event.location);
|
||||
if distance >= 1.
|
||||
&& let Some(factory) = self.grab_factory.take()
|
||||
{
|
||||
let seat = self.seat.clone();
|
||||
let serial = self.serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial());
|
||||
let time = InputTime::now();
|
||||
let Some(tool) = self.tool().cloned() else {
|
||||
handle.unset_grab(self, data, serial, time, true);
|
||||
return;
|
||||
};
|
||||
data.common.event_loop_handle.insert_idle(move |data| {
|
||||
if let Some((grab, focus)) = factory(data) {
|
||||
seat.tablet_seat()
|
||||
.get_tool(&tool)
|
||||
.unwrap()
|
||||
.set_grab(data, grab, time, serial, focus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
handle.down(data, event)
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
handle.up(data, event);
|
||||
handle.unset_grab(self, data, event.serial, event.time, false);
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
handle.button(data, event);
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
handle.axis(data, frame)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
time: InputTime,
|
||||
) {
|
||||
handle.frame(data, time)
|
||||
}
|
||||
|
||||
fn unset(&mut self, _data: &mut State) {}
|
||||
|
||||
fn proximity_in(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &ProximityInEvent,
|
||||
) {
|
||||
handle.proximity_in(data, focus, event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
use cosmic_settings_config::shortcuts::Action;
|
||||
use smithay::{
|
||||
input::pointer::MotionEvent, reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
utils::SERIAL_COUNTER, wayland::seat::WaylandFocus,
|
||||
backend::input::InputTime,
|
||||
input::{pointer::MotionEvent, tablet::TabletSeatTrait},
|
||||
reexports::wayland_server::protocol::wl_surface::WlSurface,
|
||||
utils::SERIAL_COUNTER,
|
||||
wayland::seat::WaylandFocus,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -10,7 +13,7 @@ use crate::{
|
|||
shell::{
|
||||
CosmicSurface, PointGlobalExt, Shell,
|
||||
element::{CosmicMapped, CosmicWindow},
|
||||
grabs::ReleaseMode,
|
||||
grabs::{GrabType, ReleaseMode},
|
||||
},
|
||||
state::State,
|
||||
utils::{prelude::SeatExt, screenshot::screenshot_window},
|
||||
|
|
@ -352,19 +355,20 @@ pub fn window_items(
|
|||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
)
|
||||
} else {
|
||||
seat.get_pointer().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
focus,
|
||||
);
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -388,21 +392,29 @@ pub fn window_items(
|
|||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: state.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
GrabType::Pointer => {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -423,21 +435,30 @@ pub fn window_items(
|
|||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: state.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
GrabType::TabletTool => {
|
||||
seat.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -458,21 +479,30 @@ pub fn window_items(
|
|||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: state.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
GrabType::TabletTool => {
|
||||
seat.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -493,21 +523,29 @@ pub fn window_items(
|
|||
std::mem::drop(shell);
|
||||
if let Some(((target, loc), (grab, focus))) = res {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: state.common.clock.now().as_millis(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
pointer.motion(
|
||||
state,
|
||||
target,
|
||||
&MotionEvent {
|
||||
location: loc.as_logical().to_f64(),
|
||||
serial,
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
pointer.frame(state);
|
||||
pointer.set_grab(state, grab, serial, focus);
|
||||
}
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -627,19 +665,20 @@ pub fn fullscreen_items(window: &CosmicSurface, config: &Config) -> impl Iterato
|
|||
|
||||
std::mem::drop(shell);
|
||||
if let Some((grab, focus)) = res {
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
)
|
||||
} else {
|
||||
seat.get_pointer().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
SERIAL_COUNTER.next_serial(),
|
||||
focus,
|
||||
);
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat
|
||||
.get_pointer()
|
||||
.unwrap()
|
||||
.set_grab(state, grab, serial, focus),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(state, grab, InputTime::now(), serial, focus),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,22 +19,33 @@ use cosmic::{
|
|||
};
|
||||
use smithay::{
|
||||
backend::{
|
||||
input::{ButtonState, TouchSlot},
|
||||
input::{ButtonState, InputTime, TabletToolDescriptor, TouchSlot},
|
||||
renderer::ImportMem,
|
||||
},
|
||||
desktop::space::SpaceElement,
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent as PointerMotionEvent, PointerGrab,
|
||||
PointerInnerHandle, PointerTarget, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, PointerTarget,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
TabletSeatHandler,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData,
|
||||
MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent,
|
||||
TabletToolGrab, TabletToolInnerHandle, TabletToolTarget, UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||
TouchGrab, TouchInnerHandle, TouchTarget, UpEvent,
|
||||
DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, TouchGrab, TouchInnerHandle, TouchTarget,
|
||||
UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -43,7 +54,7 @@ use smithay::{
|
|||
|
||||
use crate::{
|
||||
backend::render::element::AsGlowRenderer,
|
||||
shell::{SeatExt, focus::target::PointerFocusTarget},
|
||||
shell::{SeatExt, focus::target::PointerFocusTarget, grabs::GrabType},
|
||||
state::State,
|
||||
utils::{
|
||||
iced::{IcedElement, IcedRenderElement, Program},
|
||||
|
|
@ -350,6 +361,7 @@ impl Program for ContextMenu {
|
|||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
tablet_entered: None,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
@ -509,6 +521,7 @@ pub struct Element {
|
|||
position: Point<i32, Global>,
|
||||
pointer_entered: bool,
|
||||
touch_entered: Option<TouchSlot>,
|
||||
tablet_entered: Option<TabletToolDescriptor>,
|
||||
}
|
||||
|
||||
pub struct MenuGrab {
|
||||
|
|
@ -517,6 +530,7 @@ pub struct MenuGrab {
|
|||
seat: Seat<State>,
|
||||
screen_space_relative: Option<Output>,
|
||||
scale: Arc<Mutex<f64>>,
|
||||
last_tablet_idx: Option<usize>,
|
||||
}
|
||||
|
||||
impl PointerGrab<State> for MenuGrab {
|
||||
|
|
@ -599,7 +613,7 @@ impl PointerGrab<State> for MenuGrab {
|
|||
&mut self,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
let any_entered = self
|
||||
.elements
|
||||
|
|
@ -633,7 +647,7 @@ impl PointerGrab<State> for MenuGrab {
|
|||
&mut self,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
handle.axis(state, details);
|
||||
}
|
||||
|
|
@ -730,7 +744,7 @@ impl TouchGrab<State> for MenuGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
{
|
||||
let mut guard = self.elements.lock().unwrap();
|
||||
|
|
@ -758,7 +772,7 @@ impl TouchGrab<State> for MenuGrab {
|
|||
}) {
|
||||
let element = &mut elements[i];
|
||||
|
||||
let new_event = DownEvent {
|
||||
let new_event = TouchDownEvent {
|
||||
slot: event.slot,
|
||||
location: event_location - element.position.as_logical().to_f64(),
|
||||
serial: event.serial,
|
||||
|
|
@ -773,7 +787,12 @@ impl TouchGrab<State> for MenuGrab {
|
|||
handle.down(data, None, event);
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
{
|
||||
let elements = self.elements.lock().unwrap();
|
||||
for element in elements.iter().filter(|elem| {
|
||||
|
|
@ -849,6 +868,248 @@ impl TouchGrab<State> for MenuGrab {
|
|||
fn unset(&mut self, _data: &mut State) {}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for MenuGrab {
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match &self.start_data {
|
||||
GrabStartData::TabletTool { data, .. } => data,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_in(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &ProximityInEvent,
|
||||
) {
|
||||
{
|
||||
let location = if let Some(output) = self.screen_space_relative.as_ref() {
|
||||
if data.common.shell.read().zoom_state().is_some() {
|
||||
event
|
||||
.location
|
||||
.as_global()
|
||||
.to_zoomed(output)
|
||||
.to_global(output)
|
||||
.as_logical()
|
||||
} else {
|
||||
event.location
|
||||
}
|
||||
} else {
|
||||
event.location
|
||||
};
|
||||
|
||||
let mut elements = self.elements.lock().unwrap();
|
||||
if let Some(i) = elements.iter().position(|elem| {
|
||||
let mut bbox = elem.iced.bbox();
|
||||
bbox.loc = elem.position.as_logical();
|
||||
|
||||
bbox.contains(location.to_i32_floor())
|
||||
}) {
|
||||
let element = &mut elements[i];
|
||||
|
||||
let new_event = TabletMotionEvent {
|
||||
location: location - element.position.as_logical().to_f64(),
|
||||
serial: event.serial,
|
||||
time: event.time,
|
||||
};
|
||||
|
||||
TabletToolTarget::proximity_in(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
&handle.current_tablet(),
|
||||
event.serial,
|
||||
);
|
||||
element.tablet_entered = Some(handle.descriptor().clone());
|
||||
TabletToolTarget::motion(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
&new_event,
|
||||
);
|
||||
self.last_tablet_idx = Some(i);
|
||||
}
|
||||
}
|
||||
handle.proximity_in(data, None, event);
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
{
|
||||
let mut elements = self.elements.lock().unwrap();
|
||||
for element in elements.iter_mut().filter(|elem| {
|
||||
elem.tablet_entered
|
||||
.as_ref()
|
||||
.is_some_and(|tool| tool == handle.descriptor())
|
||||
}) {
|
||||
TabletToolTarget::proximity_out(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
);
|
||||
element.tablet_entered.take();
|
||||
}
|
||||
self.last_tablet_idx.take();
|
||||
}
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
{
|
||||
let location = if let Some(output) = self.screen_space_relative.as_ref() {
|
||||
if data.common.shell.read().zoom_state().is_some() {
|
||||
event
|
||||
.location
|
||||
.as_global()
|
||||
.to_zoomed(output)
|
||||
.to_global(output)
|
||||
.as_logical()
|
||||
} else {
|
||||
event.location
|
||||
}
|
||||
} else {
|
||||
event.location
|
||||
};
|
||||
|
||||
let mut elements = self.elements.lock().unwrap();
|
||||
if let Some(i) = elements.iter().position(|elem| {
|
||||
let mut bbox = elem.iced.bbox();
|
||||
bbox.loc = elem.position.as_logical();
|
||||
|
||||
bbox.contains(location.to_i32_floor())
|
||||
}) {
|
||||
let element = &mut elements[i];
|
||||
|
||||
let new_event = TabletMotionEvent {
|
||||
location: location - element.position.as_logical().to_f64(),
|
||||
serial: event.serial,
|
||||
time: event.time,
|
||||
};
|
||||
|
||||
if element.tablet_entered.is_none() {
|
||||
TabletToolTarget::proximity_in(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
&handle.current_tablet(),
|
||||
event.serial,
|
||||
);
|
||||
element.tablet_entered = Some(handle.descriptor().clone());
|
||||
}
|
||||
TabletToolTarget::motion(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
&new_event,
|
||||
);
|
||||
self.last_tablet_idx = Some(i);
|
||||
} else {
|
||||
elements
|
||||
.iter_mut()
|
||||
.filter(|element| element.tablet_entered.is_some())
|
||||
.skip(1)
|
||||
.for_each(|element| {
|
||||
TabletToolTarget::proximity_out(
|
||||
&element.iced,
|
||||
&self.seat,
|
||||
data,
|
||||
handle.descriptor(),
|
||||
);
|
||||
});
|
||||
self.last_tablet_idx.take();
|
||||
}
|
||||
}
|
||||
handle.motion(data, None, event);
|
||||
}
|
||||
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
let mut guard = self.elements.lock().unwrap();
|
||||
let elements = &mut *guard;
|
||||
|
||||
if let Some(elem) = self.last_tablet_idx.and_then(|i| elements.get_mut(i))
|
||||
&& elem
|
||||
.tablet_entered
|
||||
.as_ref()
|
||||
.is_some_and(|desc| desc == handle.descriptor())
|
||||
{
|
||||
TabletToolTarget::down(&elem.iced, &self.seat, data, handle.descriptor(), event);
|
||||
} else {
|
||||
handle.down(data, event);
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
let mut guard = self.elements.lock().unwrap();
|
||||
let elements = &mut *guard;
|
||||
|
||||
if let Some(elem) = self.last_tablet_idx.and_then(|i| elements.get_mut(i))
|
||||
&& elem
|
||||
.tablet_entered
|
||||
.as_ref()
|
||||
.is_some_and(|desc| desc == handle.descriptor())
|
||||
{
|
||||
TabletToolTarget::up(&elem.iced, &self.seat, data, handle.descriptor(), event);
|
||||
} else {
|
||||
handle.up(data, event);
|
||||
}
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
handle.button(data, event);
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
handle.axis(data, frame);
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
time: InputTime,
|
||||
) {
|
||||
handle.frame(data, time);
|
||||
}
|
||||
|
||||
fn unset(&mut self, _data: &mut State) {}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct MenuAlignment {
|
||||
pub x: AxisAlignment,
|
||||
|
|
@ -1052,6 +1313,7 @@ impl MenuGrab {
|
|||
position,
|
||||
pointer_entered: false,
|
||||
touch_entered: None,
|
||||
tablet_entered: None,
|
||||
}]));
|
||||
|
||||
let scale = Arc::new(Mutex::new(screen_space_relative.unwrap_or(1.)));
|
||||
|
|
@ -1076,6 +1338,7 @@ impl MenuGrab {
|
|||
seat: seat.clone(),
|
||||
screen_space_relative,
|
||||
scale,
|
||||
last_tablet_idx: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1086,10 +1349,15 @@ impl MenuGrab {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
self.start_data.type_()
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
if let GrabStartData::TabletTool { tool, .. } = &self.start_data {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,26 @@
|
|||
use calloop::LoopHandle;
|
||||
use cosmic_settings_config::shortcuts;
|
||||
use smithay::{
|
||||
backend::input::{InputTime, TabletToolDescriptor},
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent, PointerGrab, PointerInnerHandle, RelativeMotionEvent,
|
||||
},
|
||||
tablet::tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData,
|
||||
MotionEvent as TabletMotionEvent, ProximityOutEvent, TabletToolGrab,
|
||||
TabletToolInnerHandle, UpEvent as TabletUpEvent,
|
||||
},
|
||||
touch::{
|
||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
|
||||
DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab,
|
||||
TouchInnerHandle, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -39,6 +47,17 @@ use super::{
|
|||
pub enum GrabStartData {
|
||||
Touch(TouchGrabStartData<State>),
|
||||
Pointer(PointerGrabStartData<State>),
|
||||
TabletTool {
|
||||
tool: TabletToolDescriptor,
|
||||
data: TabletGrabStartData<State>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum GrabType {
|
||||
Touch,
|
||||
Pointer,
|
||||
TabletTool,
|
||||
}
|
||||
|
||||
impl GrabStartData {
|
||||
|
|
@ -46,6 +65,7 @@ impl GrabStartData {
|
|||
match self {
|
||||
Self::Touch(touch) => touch.focus.as_ref(),
|
||||
Self::Pointer(pointer) => pointer.focus.as_ref(),
|
||||
Self::TabletTool { data, .. } => data.focus.as_ref(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +73,7 @@ impl GrabStartData {
|
|||
match self {
|
||||
Self::Touch(touch) => touch.focus = focus,
|
||||
Self::Pointer(pointer) => pointer.focus = focus,
|
||||
Self::TabletTool { data, .. } => data.focus = focus,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +81,7 @@ impl GrabStartData {
|
|||
match self {
|
||||
Self::Touch(touch) => touch.location,
|
||||
Self::Pointer(pointer) => pointer.location,
|
||||
Self::TabletTool { data, .. } => data.location,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +89,7 @@ impl GrabStartData {
|
|||
match self {
|
||||
Self::Touch(touch) => touch.location = location,
|
||||
Self::Pointer(pointer) => pointer.location = location,
|
||||
Self::TabletTool { data, .. } => data.location = location,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,6 +99,14 @@ impl GrabStartData {
|
|||
|
||||
((new.x - old.x).powi(2) + (new.y - old.y).powi(2)).sqrt()
|
||||
}
|
||||
|
||||
pub fn type_(&self) -> GrabType {
|
||||
match self {
|
||||
Self::Pointer(_) => GrabType::Pointer,
|
||||
Self::Touch(_) => GrabType::Touch,
|
||||
Self::TabletTool { .. } => GrabType::TabletTool,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
@ -203,10 +234,17 @@ impl From<ResizeForkGrab> for ResizeGrab {
|
|||
}
|
||||
|
||||
impl ResizeGrab {
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => grab.is_touch_grab(),
|
||||
ResizeGrab::Tiling(grab) => grab.is_touch_grab(),
|
||||
ResizeGrab::Floating(grab) => grab.grab_type(),
|
||||
ResizeGrab::Tiling(grab) => grab.grab_type(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => grab.tool(),
|
||||
ResizeGrab::Tiling(grab) => grab.tool(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -242,11 +280,11 @@ impl PointerGrab<State> for ResizeGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => grab.button(data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => grab.button(data, handle, event),
|
||||
ResizeGrab::Floating(grab) => PointerGrab::button(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => PointerGrab::button(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,11 +292,11 @@ impl PointerGrab<State> for ResizeGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => grab.axis(data, handle, details),
|
||||
ResizeGrab::Tiling(grab) => grab.axis(data, handle, details),
|
||||
ResizeGrab::Floating(grab) => PointerGrab::axis(grab, data, handle, details),
|
||||
ResizeGrab::Tiling(grab) => PointerGrab::axis(grab, data, handle, details),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,7 +424,7 @@ impl TouchGrab<State> for ResizeGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TouchGrab::down(grab, data, handle, focus, event),
|
||||
|
|
@ -394,7 +432,12 @@ impl TouchGrab<State> for ResizeGrab {
|
|||
}
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TouchGrab::up(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => TouchGrab::up(grab, data, handle, event),
|
||||
|
|
@ -467,6 +510,107 @@ impl TouchGrab<State> for ResizeGrab {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for ResizeGrab {
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::down(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::down(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::up(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::up(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::motion(grab, data, handle, focus, event),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::motion(grab, data, handle, focus, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
serial: InputTime,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::frame(grab, data, handle, serial),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::frame(grab, data, handle, serial),
|
||||
}
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::button(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::button(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
details: TabletAxisFrame,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::axis(grab, data, handle, details),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::axis(grab, data, handle, details),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::proximity_out(grab, data, handle, event),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::proximity_out(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::start_data(grab),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::start_data(grab),
|
||||
}
|
||||
}
|
||||
|
||||
fn unset(&mut self, data: &mut State) {
|
||||
match self {
|
||||
ResizeGrab::Floating(grab) => TabletToolGrab::unset(grab, data),
|
||||
ResizeGrab::Tiling(grab) => TabletToolGrab::unset(grab, data),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum MoveGrab {
|
||||
Move(moving::MoveGrab),
|
||||
Delayed(delay::DelayGrab<MoveGrab>),
|
||||
|
|
@ -536,10 +680,17 @@ impl MoveGrab {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
match self {
|
||||
MoveGrab::Move(m) => m.is_touch_grab(),
|
||||
MoveGrab::Delayed(d) => d.is_touch_grab(),
|
||||
MoveGrab::Move(m) => m.grab_type(),
|
||||
MoveGrab::Delayed(d) => d.grab_type(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
match self {
|
||||
MoveGrab::Move(m) => m.tool(),
|
||||
MoveGrab::Delayed(d) => d.tool(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -574,11 +725,11 @@ impl PointerGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => grab.button(data, handle, event),
|
||||
MoveGrab::Delayed(grab) => grab.button(data, handle, event),
|
||||
MoveGrab::Move(grab) => PointerGrab::button(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => PointerGrab::button(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -586,11 +737,11 @@ impl PointerGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => grab.axis(data, handle, details),
|
||||
MoveGrab::Delayed(grab) => grab.axis(data, handle, details),
|
||||
MoveGrab::Move(grab) => PointerGrab::axis(grab, data, handle, details),
|
||||
MoveGrab::Delayed(grab) => PointerGrab::axis(grab, data, handle, details),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -718,7 +869,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TouchGrab::down(grab, data, handle, focus, event),
|
||||
|
|
@ -726,7 +877,12 @@ impl TouchGrab<State> for MoveGrab {
|
|||
}
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TouchGrab::up(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => TouchGrab::up(grab, data, handle, event),
|
||||
|
|
@ -798,3 +954,104 @@ impl TouchGrab<State> for MoveGrab {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for MoveGrab {
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::down(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::down(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::up(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::up(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::motion(grab, data, handle, focus, event),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::motion(grab, data, handle, focus, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
serial: InputTime,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::frame(grab, data, handle, serial),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::frame(grab, data, handle, serial),
|
||||
}
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::button(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::button(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
details: TabletAxisFrame,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::axis(grab, data, handle, details),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::axis(grab, data, handle, details),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::proximity_out(grab, data, handle, event),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::proximity_out(grab, data, handle, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::start_data(grab),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::start_data(grab),
|
||||
}
|
||||
}
|
||||
|
||||
fn unset(&mut self, data: &mut State) {
|
||||
match self {
|
||||
MoveGrab::Move(grab) => TabletToolGrab::unset(grab, data),
|
||||
MoveGrab::Delayed(grab) => TabletToolGrab::unset(grab, data),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::{
|
|||
CosmicMapped, CosmicSurface, Direction, ManagedLayer,
|
||||
element::{CosmicMappedRenderElement, stack_hover::StackHover},
|
||||
focus::target::{KeyboardFocusTarget, PointerFocusTarget},
|
||||
grabs::GrabType,
|
||||
layout::floating::TiledCorners,
|
||||
},
|
||||
utils::prelude::*,
|
||||
|
|
@ -20,7 +21,7 @@ use smallvec::SmallVec;
|
|||
use smithay::{
|
||||
backend::{
|
||||
drm::DrmNode,
|
||||
input::ButtonState,
|
||||
input::{ButtonState, InputTime, TabletToolDescriptor},
|
||||
renderer::{
|
||||
ImportAll, ImportMem,
|
||||
element::{RenderElement, utils::RescaleRenderElement},
|
||||
|
|
@ -30,13 +31,27 @@ use smithay::{
|
|||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
touch::{self, GrabStartData as TouchGrabStartData, TouchGrab, TouchInnerHandle},
|
||||
tablet::{
|
||||
TabletSeatHandler,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData,
|
||||
MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent,
|
||||
TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab,
|
||||
TouchInnerHandle, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
utils::{IsAlive, Logical, Point, Rectangle, SERIAL_COUNTER, Scale},
|
||||
|
|
@ -503,7 +518,7 @@ impl PointerGrab<State> for MoveGrab {
|
|||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
event: &PointerMotionEvent,
|
||||
) {
|
||||
self.update_location(state, event.location);
|
||||
|
||||
|
|
@ -529,7 +544,7 @@ impl PointerGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
handle.button(state, event);
|
||||
match self.release {
|
||||
|
|
@ -550,7 +565,7 @@ impl PointerGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
state: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
handle.axis(state, details);
|
||||
}
|
||||
|
|
@ -647,7 +662,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &touch::DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
handle.down(data, None, event)
|
||||
}
|
||||
|
|
@ -656,7 +671,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &touch::UpEvent,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
||||
handle.unset_grab(self, data);
|
||||
|
|
@ -670,7 +685,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &touch::MotionEvent,
|
||||
event: &TouchMotionEvent,
|
||||
) {
|
||||
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
||||
self.update_location(data, event.location);
|
||||
|
|
@ -691,7 +706,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &touch::ShapeEvent,
|
||||
event: &ShapeEvent,
|
||||
) {
|
||||
handle.shape(data, event)
|
||||
}
|
||||
|
|
@ -700,7 +715,7 @@ impl TouchGrab<State> for MoveGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &touch::OrientationEvent,
|
||||
event: &OrientationEvent,
|
||||
) {
|
||||
handle.orientation(data, event)
|
||||
}
|
||||
|
|
@ -715,6 +730,98 @@ impl TouchGrab<State> for MoveGrab {
|
|||
fn unset(&mut self, _data: &mut State) {}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for MoveGrab {
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match &self.start_data {
|
||||
GrabStartData::TabletTool { data, .. } => data,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
handle.proximity_out(data, event);
|
||||
handle.unset_grab(self, data, event.serial, event.time, false);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
handle.motion(data, None, event);
|
||||
|
||||
self.update_location(data, event.location);
|
||||
if !self.window.alive() {
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
}
|
||||
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
handle.down(data, event)
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
handle.up(data, event);
|
||||
handle.unset_grab(self, data, event.serial, event.time, false);
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
handle.button(data, event)
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
handle.axis(data, frame)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
time: InputTime,
|
||||
) {
|
||||
handle.frame(data, time)
|
||||
}
|
||||
|
||||
fn proximity_in(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &ProximityInEvent,
|
||||
) {
|
||||
handle.proximity_in(data, focus, event);
|
||||
}
|
||||
|
||||
fn unset(&mut self, _data: &mut State) {}
|
||||
}
|
||||
|
||||
impl MoveGrab {
|
||||
pub fn new(
|
||||
start_data: GrabStartData,
|
||||
|
|
@ -778,10 +885,15 @@ impl MoveGrab {
|
|||
self.previous == ManagedLayer::Tiling
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
self.start_data.type_()
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
if let GrabStartData::TabletTool { tool, .. } = &self.start_data {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -793,7 +905,7 @@ impl Drop for MoveGrab {
|
|||
let seat = self.seat.clone();
|
||||
// false-positive: `Output`s hash is based on it's inner ptr
|
||||
#[allow(clippy::mutable_key_type)]
|
||||
let window_outputs = self.window_outputs.drain().collect::<HashSet<_>>();
|
||||
let window_outputs = std::mem::take(&mut self.window_outputs);
|
||||
let previous = self.previous;
|
||||
let window = self.window.clone();
|
||||
let is_touch_grab = matches!(self.start_data, GrabStartData::Touch(_));
|
||||
|
|
@ -953,10 +1065,10 @@ impl Drop for MoveGrab {
|
|||
position.as_logical().to_f64() - window.geometry().loc.to_f64()
|
||||
+ offset,
|
||||
)),
|
||||
&MotionEvent {
|
||||
&PointerMotionEvent {
|
||||
location: pointer.current_location(),
|
||||
serial,
|
||||
time: state.common.clock.now().as_millis(),
|
||||
time: InputTime::now(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,25 +7,36 @@ use crate::{
|
|||
shell::{
|
||||
element::CosmicMapped,
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{GrabStartData, ReleaseMode, ResizeEdge},
|
||||
grabs::{GrabStartData, GrabType, ReleaseMode, ResizeEdge},
|
||||
},
|
||||
utils::prelude::*,
|
||||
};
|
||||
use smithay::{
|
||||
backend::input::ButtonState,
|
||||
backend::input::{ButtonState, InputTime, TabletToolDescriptor},
|
||||
desktop::{WindowSurface, space::SpaceElement},
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, CursorIcon, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
TabletSeatHandler,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletGrabStartData,
|
||||
MotionEvent as TabletMotionEvent, ProximityInEvent, ProximityOutEvent,
|
||||
TabletToolGrab, TabletToolInnerHandle, UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, GrabStartData as TouchGrabStartData, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchGrab, TouchInnerHandle, UpEvent,
|
||||
DownEvent as TouchDownEvent, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab,
|
||||
TouchInnerHandle, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -170,10 +181,19 @@ impl ResizeSurfaceGrab {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
GrabStartData::Pointer(_) => GrabType::Pointer,
|
||||
GrabStartData::Touch(_) => GrabType::Touch,
|
||||
GrabStartData::TabletTool { .. } => GrabType::TabletTool,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
if let GrabStartData::TabletTool { tool, .. } = &self.start_data {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -184,7 +204,7 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
event: &PointerMotionEvent,
|
||||
) {
|
||||
// While the grab is active, no client has pointer focus
|
||||
handle.motion(data, None, event);
|
||||
|
|
@ -209,7 +229,7 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
handle.button(data, event);
|
||||
match self.release {
|
||||
|
|
@ -230,7 +250,7 @@ impl PointerGrab<State> for ResizeSurfaceGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
handle.axis(data, details)
|
||||
}
|
||||
|
|
@ -329,12 +349,17 @@ impl TouchGrab<State> for ResizeSurfaceGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
handle.down(data, None, event)
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
||||
handle.unset_grab(self, data);
|
||||
}
|
||||
|
|
@ -396,6 +421,99 @@ impl TouchGrab<State> for ResizeSurfaceGrab {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for ResizeSurfaceGrab {
|
||||
fn start_data(&self) -> &TabletGrabStartData<State> {
|
||||
match &self.start_data {
|
||||
GrabStartData::TabletTool { data, .. } => data,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
handle.proximity_out(data, event);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
if self.update_location(event.location.as_global()) {
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
|
||||
handle.motion(data, None, event);
|
||||
}
|
||||
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
handle.down(data, event)
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
handle.up(data, event);
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
handle.button(data, event)
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
handle.axis(data, frame)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
time: InputTime,
|
||||
) {
|
||||
handle.frame(data, time)
|
||||
}
|
||||
|
||||
fn unset(&mut self, _data: &mut State) {
|
||||
self.ungrab()
|
||||
}
|
||||
|
||||
fn proximity_in(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &ProximityInEvent,
|
||||
) {
|
||||
handle.proximity_in(data, None, event);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ResizeGrabMarker(AtomicBool);
|
||||
|
||||
impl ResizeGrabMarker {
|
||||
|
|
|
|||
|
|
@ -4,31 +4,42 @@ use crate::{
|
|||
backend::render::cursor::CursorState,
|
||||
shell::{
|
||||
focus::target::PointerFocusTarget,
|
||||
grabs::{GrabStartData, ReleaseMode},
|
||||
grabs::{GrabStartData, GrabType, ReleaseMode},
|
||||
layout::Orientation,
|
||||
},
|
||||
utils::prelude::*,
|
||||
};
|
||||
use id_tree::{NodeId, Tree};
|
||||
use smithay::{
|
||||
backend::input::ButtonState,
|
||||
backend::input::{ButtonState, InputTime, TabletToolDescriptor},
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, CursorIcon, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
GrabStartData as PointerGrabStartData, MotionEvent, PointerGrab, PointerInnerHandle,
|
||||
PointerTarget, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, CursorIcon, Focus,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, GrabStartData as PointerGrabStartData,
|
||||
MotionEvent as PointerMotionEvent, PointerGrab, PointerInnerHandle, PointerTarget,
|
||||
RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
Tablet, TabletSeatHandler, TabletSeatTrait,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, GrabStartData as TabletToolGrabStartData,
|
||||
GrabTrigger as TabletToolGrabTrigger, MotionEvent as TabletMotionEvent,
|
||||
ProximityInEvent, ProximityOutEvent, TabletToolGrab, TabletToolInnerHandle,
|
||||
TabletToolTarget, UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, FrameMarker, GrabStartData as TouchGrabStartData,
|
||||
DownEvent as TouchDownEvent, FrameMarker, GrabStartData as TouchGrabStartData,
|
||||
MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchGrab,
|
||||
TouchInnerHandle, TouchTarget, UpEvent,
|
||||
TouchInnerHandle, TouchTarget, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::WeakOutput,
|
||||
utils::{IsAlive, Logical, Point},
|
||||
utils::{IsAlive, Logical, Point, Serial},
|
||||
};
|
||||
|
||||
use super::super::{Data, TilingLayout};
|
||||
|
|
@ -48,7 +59,7 @@ impl IsAlive for ResizeForkTarget {
|
|||
}
|
||||
|
||||
impl PointerTarget<State> for ResizeForkTarget {
|
||||
fn enter(&self, seat: &Seat<State>, _data: &mut State, _event: &MotionEvent) {
|
||||
fn enter(&self, seat: &Seat<State>, _data: &mut State, _event: &PointerMotionEvent) {
|
||||
let user_data = seat.user_data();
|
||||
let cursor_state = user_data.get::<CursorState>().unwrap();
|
||||
cursor_state
|
||||
|
|
@ -60,19 +71,13 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
});
|
||||
}
|
||||
|
||||
fn leave(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_serial: smithay::utils::Serial,
|
||||
_time: u32,
|
||||
) {
|
||||
fn leave(&self, seat: &Seat<State>, _data: &mut State, _serial: Serial, _time: InputTime) {
|
||||
let user_data = seat.user_data();
|
||||
let cursor_state = user_data.get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
}
|
||||
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &PointerButtonEvent) {
|
||||
if event.button == 0x110 && event.state == ButtonState::Pressed {
|
||||
let seat = seat.clone();
|
||||
let node = self.node.clone();
|
||||
|
|
@ -106,7 +111,7 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn motion(&self, _seat: &Seat<State>, _data: &mut State, _event: &MotionEvent) {}
|
||||
fn motion(&self, _seat: &Seat<State>, _data: &mut State, _event: &PointerMotionEvent) {}
|
||||
fn relative_motion(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
|
|
@ -114,7 +119,7 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
_event: &RelativeMotionEvent,
|
||||
) {
|
||||
}
|
||||
fn axis(&self, _seat: &Seat<State>, _data: &mut State, _frame: AxisFrame) {}
|
||||
fn axis(&self, _seat: &Seat<State>, _data: &mut State, _frame: PointerAxisFrame) {}
|
||||
fn frame(&self, _seat: &Seat<State>, _data: &mut State) {}
|
||||
fn gesture_swipe_begin(&self, _: &Seat<State>, _: &mut State, _: &GestureSwipeBeginEvent) {}
|
||||
fn gesture_swipe_update(&self, _: &Seat<State>, _: &mut State, _: &GestureSwipeUpdateEvent) {}
|
||||
|
|
@ -127,7 +132,7 @@ impl PointerTarget<State> for ResizeForkTarget {
|
|||
}
|
||||
|
||||
impl TouchTarget<State> for ResizeForkTarget {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &DownEvent) {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &TouchDownEvent) {
|
||||
let seat = seat.clone();
|
||||
let node = self.node.clone();
|
||||
let output = self.output.clone();
|
||||
|
|
@ -158,7 +163,7 @@ impl TouchTarget<State> for ResizeForkTarget {
|
|||
});
|
||||
}
|
||||
|
||||
fn up(&self, _seat: &Seat<State>, _data: &mut State, _event: &UpEvent) {}
|
||||
fn up(&self, _seat: &Seat<State>, _data: &mut State, _event: &TouchUpEvent) {}
|
||||
fn motion(&self, _seat: &Seat<State>, _data: &mut State, _event: &TouchMotionEvent) {}
|
||||
fn frame(&self, _seat: &Seat<State>, _data: &mut State, _frame: FrameMarker) {}
|
||||
fn cancel(&self, _seat: &Seat<State>, _data: &mut State, _frame: FrameMarker) {}
|
||||
|
|
@ -169,6 +174,121 @@ impl TouchTarget<State> for ResizeForkTarget {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolTarget<State> for ResizeForkTarget {
|
||||
fn down(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
let seat = seat.clone();
|
||||
let node = self.node.clone();
|
||||
let output = self.output.clone();
|
||||
let left_up_idx = self.left_up_idx;
|
||||
let orientation = self.orientation;
|
||||
let serial = event.serial;
|
||||
let time = event.time;
|
||||
let tool = tool_descriptor.clone();
|
||||
data.common.event_loop_handle.insert_idle(move |state| {
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let location = pointer.current_location();
|
||||
let tablet = seat.tablet_seat().get_tool(&tool).unwrap();
|
||||
tablet.set_grab(
|
||||
state,
|
||||
ResizeForkGrab::new(
|
||||
GrabStartData::TabletTool {
|
||||
tool,
|
||||
data: TabletToolGrabStartData {
|
||||
focus: None,
|
||||
location,
|
||||
trigger: TabletToolGrabTrigger::Tip,
|
||||
},
|
||||
},
|
||||
location.as_global(),
|
||||
node,
|
||||
left_up_idx,
|
||||
orientation,
|
||||
output,
|
||||
ReleaseMode::NoMouseButtons,
|
||||
),
|
||||
time,
|
||||
serial,
|
||||
Focus::Keep,
|
||||
)
|
||||
});
|
||||
}
|
||||
fn motion(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_event: &TabletMotionEvent,
|
||||
) {
|
||||
}
|
||||
fn proximity_out(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
) {
|
||||
let user_data = seat.user_data();
|
||||
let cursor_state = user_data.get::<CursorState>().unwrap();
|
||||
cursor_state.lock().unwrap().unset_shape();
|
||||
}
|
||||
|
||||
fn proximity_in(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_tablet: &Tablet,
|
||||
_serial: Serial,
|
||||
) {
|
||||
let user_data = seat.user_data();
|
||||
let cursor_state = user_data.get::<CursorState>().unwrap();
|
||||
cursor_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.set_shape(match self.orientation {
|
||||
Orientation::Horizontal => CursorIcon::RowResize,
|
||||
Orientation::Vertical => CursorIcon::ColResize,
|
||||
});
|
||||
}
|
||||
fn up(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_event: &TabletUpEvent,
|
||||
) {
|
||||
}
|
||||
fn axis(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_frame: TabletAxisFrame,
|
||||
) {
|
||||
}
|
||||
fn button(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_event: &TabletButtonEvent,
|
||||
) {
|
||||
}
|
||||
fn frame(
|
||||
&self,
|
||||
_seat: &Seat<State>,
|
||||
_data: &mut State,
|
||||
_tool_descriptor: &TabletToolDescriptor,
|
||||
_time: InputTime,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ResizeForkGrab {
|
||||
start_data: GrabStartData,
|
||||
last_loc: Point<f64, Global>,
|
||||
|
|
@ -338,10 +458,19 @@ impl ResizeForkGrab {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn is_touch_grab(&self) -> bool {
|
||||
pub fn grab_type(&self) -> GrabType {
|
||||
match self.start_data {
|
||||
GrabStartData::Touch(_) => true,
|
||||
GrabStartData::Pointer(_) => false,
|
||||
GrabStartData::Pointer(_) => GrabType::Pointer,
|
||||
GrabStartData::Touch(_) => GrabType::Touch,
|
||||
GrabStartData::TabletTool { .. } => GrabType::TabletTool,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tool(&self) -> Option<&TabletToolDescriptor> {
|
||||
if let GrabStartData::TabletTool { tool, .. } = &self.start_data {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -352,7 +481,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &MotionEvent,
|
||||
event: &PointerMotionEvent,
|
||||
) {
|
||||
// While the grab is active, no client has pointer focus
|
||||
handle.motion(data, None, event);
|
||||
|
|
@ -377,7 +506,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
event: &ButtonEvent,
|
||||
event: &PointerButtonEvent,
|
||||
) {
|
||||
handle.button(data, event);
|
||||
match self.release {
|
||||
|
|
@ -398,7 +527,7 @@ impl PointerGrab<State> for ResizeForkGrab {
|
|||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut PointerInnerHandle<'_, State>,
|
||||
details: AxisFrame,
|
||||
details: PointerAxisFrame,
|
||||
) {
|
||||
handle.axis(data, details)
|
||||
}
|
||||
|
|
@ -497,12 +626,17 @@ impl TouchGrab<State> for ResizeForkGrab {
|
|||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
_focus: Option<(PointerFocusTarget, Point<f64, Logical>)>,
|
||||
event: &DownEvent,
|
||||
event: &TouchDownEvent,
|
||||
) {
|
||||
handle.down(data, None, event)
|
||||
}
|
||||
|
||||
fn up(&mut self, data: &mut State, handle: &mut TouchInnerHandle<'_, State>, event: &UpEvent) {
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TouchInnerHandle<'_, State>,
|
||||
event: &TouchUpEvent,
|
||||
) {
|
||||
if event.slot == <Self as TouchGrab<State>>::start_data(self).slot {
|
||||
handle.unset_grab(self, data);
|
||||
}
|
||||
|
|
@ -563,3 +697,96 @@ impl TouchGrab<State> for ResizeForkGrab {
|
|||
self.update_location(data, self.last_loc.as_logical(), true);
|
||||
}
|
||||
}
|
||||
|
||||
impl TabletToolGrab<State> for ResizeForkGrab {
|
||||
fn start_data(&self) -> &TabletToolGrabStartData<State> {
|
||||
match &self.start_data {
|
||||
GrabStartData::TabletTool { data, .. } => data,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &ProximityOutEvent,
|
||||
) {
|
||||
handle.proximity_out(data, event);
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
_focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
handle.motion(data, None, event);
|
||||
|
||||
if self.update_location(data, event.location, false) {
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
}
|
||||
|
||||
fn down(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
handle.down(data, event);
|
||||
}
|
||||
|
||||
fn up(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
handle.up(data, event);
|
||||
handle.unset_grab(self, data, event.serial, event.time, true);
|
||||
}
|
||||
|
||||
fn button(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
handle.button(data, event)
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
handle.axis(data, frame)
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
time: InputTime,
|
||||
) {
|
||||
handle.frame(data, time)
|
||||
}
|
||||
|
||||
fn unset(&mut self, data: &mut State) {
|
||||
self.update_location(data, self.last_loc.as_logical(), true);
|
||||
}
|
||||
|
||||
fn proximity_in(
|
||||
&mut self,
|
||||
data: &mut State,
|
||||
handle: &mut TabletToolInnerHandle<'_, State>,
|
||||
focus: Option<(<State as TabletSeatHandler>::ToolFocus, Point<f64, Logical>)>,
|
||||
event: &ProximityInEvent,
|
||||
) {
|
||||
handle.proximity_in(data, focus, event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use cosmic_settings_config::shortcuts;
|
||||
use smithay::{
|
||||
backend::input::{KeyState, Keycode},
|
||||
backend::input::{InputTime, KeyState, Keycode},
|
||||
input::{
|
||||
Seat, SeatHandler,
|
||||
keyboard::{
|
||||
|
|
@ -38,7 +38,7 @@ impl KeyboardGrab<State> for SwapWindowGrab {
|
|||
state: KeyState,
|
||||
modifiers: Option<ModifiersState>,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
time: InputTime,
|
||||
) {
|
||||
if !matches!(&data.common.shell.read().overview_mode.active_trigger(), Some(Trigger::KeyboardSwap(_, d)) if d == &self.desc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3381,7 +3381,7 @@ impl TilingLayout {
|
|||
let Some(root) = tree.root_node_id() else {
|
||||
if matches!(
|
||||
overview.active_trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_))
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _))
|
||||
) && location_f64.is_some()
|
||||
{
|
||||
let mut tree = tree.copy_clone();
|
||||
|
|
@ -3414,7 +3414,7 @@ impl TilingLayout {
|
|||
|
||||
if matches!(
|
||||
overview.active_trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_))
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _))
|
||||
) {
|
||||
let non_exclusive_zone = layer_map_for_output(&self.output)
|
||||
.non_exclusive_zone()
|
||||
|
|
@ -4062,8 +4062,11 @@ impl TilingLayout {
|
|||
let draw_groups = overview.0.alpha();
|
||||
|
||||
let is_overview = !matches!(overview.0, OverviewMode::None);
|
||||
let is_mouse_tiling = (matches!(overview.0.trigger(), Some(Trigger::Pointer(_))))
|
||||
.then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone));
|
||||
let is_mouse_tiling = (matches!(
|
||||
overview.0.trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Tool(_, _))
|
||||
))
|
||||
.then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone));
|
||||
let swap_desc = if let Some(Trigger::KeyboardSwap(_, desc)) = overview.0.trigger() {
|
||||
Some(desc.clone())
|
||||
} else {
|
||||
|
|
@ -4216,8 +4219,11 @@ impl TilingLayout {
|
|||
};
|
||||
let draw_groups = overview.0.alpha();
|
||||
|
||||
let is_mouse_tiling = (matches!(overview.0.trigger(), Some(Trigger::Pointer(_))))
|
||||
.then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone));
|
||||
let is_mouse_tiling = (matches!(
|
||||
overview.0.trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Tool(_, _))
|
||||
))
|
||||
.then(|| self.last_overview_hover.as_ref().map(|(_, zone)| zone));
|
||||
let swap_desc = if let Some(Trigger::KeyboardSwap(_, desc)) = overview.0.trigger() {
|
||||
Some(desc.clone())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@ use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection, Resiz
|
|||
use cosmic_settings_config::{shortcuts, window_rules::ApplicationException};
|
||||
use keyframe::{ease, functions::EaseInOutCubic};
|
||||
use smithay::{
|
||||
backend::{input::TouchSlot, renderer::element::RenderElementStates},
|
||||
backend::{
|
||||
input::{TabletToolDescriptor, TouchSlot},
|
||||
renderer::element::RenderElementStates,
|
||||
},
|
||||
desktop::{
|
||||
LayerSurface, PopupKind, WindowSurface, WindowSurfaceType, layer_map_for_output,
|
||||
space::SpaceElement,
|
||||
|
|
@ -46,6 +49,7 @@ use smithay::{
|
|||
pointer::{
|
||||
CursorImageStatus, CursorImageSurfaceData, Focus, GrabStartData as PointerGrabStartData,
|
||||
},
|
||||
tablet::{TabletSeatTrait, tool::GrabTrigger as TabletGrabTrigger},
|
||||
},
|
||||
output::{Output, WeakOutput},
|
||||
reexports::{
|
||||
|
|
@ -130,6 +134,7 @@ pub enum Trigger {
|
|||
KeyboardMove(shortcuts::Modifiers),
|
||||
Pointer(u32),
|
||||
Touch(TouchSlot),
|
||||
Tool(TabletToolDescriptor, TabletGrabTrigger),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -254,6 +259,7 @@ pub struct PendingWindow {
|
|||
pub surface: CosmicSurface,
|
||||
pub seat: Seat<State>,
|
||||
pub fullscreen: Option<Output>,
|
||||
pub minimized: bool,
|
||||
pub maximized: bool,
|
||||
pub sticky: bool,
|
||||
}
|
||||
|
|
@ -1754,7 +1760,7 @@ impl Shell {
|
|||
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
||||
if matches!(
|
||||
self.overview_mode.active_trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_))
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _))
|
||||
) {
|
||||
set.workspaces[set.active].tiling_layer.cleanup_drag();
|
||||
}
|
||||
|
|
@ -1805,7 +1811,7 @@ impl Shell {
|
|||
if let Some(set) = self.workspaces.sets.get_mut(output) {
|
||||
if matches!(
|
||||
self.overview_mode.active_trigger(),
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_))
|
||||
Some(Trigger::Pointer(_) | Trigger::Touch(_) | Trigger::Tool(_, _))
|
||||
) {
|
||||
set.workspaces[set.active].tiling_layer.cleanup_drag();
|
||||
}
|
||||
|
|
@ -2856,6 +2862,7 @@ impl Shell {
|
|||
surface: window,
|
||||
seat,
|
||||
fullscreen: output,
|
||||
minimized: should_be_minimized,
|
||||
maximized: should_be_maximized,
|
||||
sticky: mut should_be_sticky,
|
||||
} = self.pending_windows.remove(pos);
|
||||
|
|
@ -2939,6 +2946,7 @@ impl Shell {
|
|||
if let Some(FocusTarget::Window(focused)) = maybe_focused
|
||||
&& let Some(stack) = focused.stack_ref()
|
||||
&& !is_dialog
|
||||
&& !should_be_minimized
|
||||
&& !should_be_maximized
|
||||
&& !(workspace.is_tiled(&focused.active_window()) && floating_exception)
|
||||
{
|
||||
|
|
@ -2988,8 +2996,13 @@ impl Shell {
|
|||
self.maximize_request(&mapped, &seat, false, loop_handle);
|
||||
}
|
||||
|
||||
let new_target = if (workspace_output == seat.active_output()
|
||||
&& active_handle == workspace_handle)
|
||||
if should_be_minimized {
|
||||
self.minimize_request(&window);
|
||||
}
|
||||
|
||||
let new_target = if should_be_minimized {
|
||||
None
|
||||
} else if (workspace_output == seat.active_output() && active_handle == workspace_handle)
|
||||
|| should_be_sticky
|
||||
{
|
||||
// TODO: enforce focus stealing prevention by also checking the same rules as for the else case.
|
||||
|
|
@ -3113,6 +3126,7 @@ impl Shell {
|
|||
surface,
|
||||
seat: seat.clone(),
|
||||
fullscreen: None,
|
||||
minimized: false,
|
||||
maximized: false,
|
||||
sticky: false,
|
||||
});
|
||||
|
|
@ -3831,6 +3845,7 @@ impl Shell {
|
|||
let trigger = match &start_data {
|
||||
GrabStartData::Pointer(start_data) => Trigger::Pointer(start_data.button),
|
||||
GrabStartData::Touch(start_data) => Trigger::Touch(start_data.slot),
|
||||
GrabStartData::TabletTool { tool, data } => Trigger::Tool(tool.clone(), data.trigger),
|
||||
};
|
||||
let active_hint = if config.cosmic_conf.active_hint {
|
||||
self.theme.cosmic().active_hint as u8
|
||||
|
|
@ -5149,10 +5164,19 @@ pub fn check_grab_preconditions(
|
|||
|
||||
let pointer = seat.get_pointer().unwrap();
|
||||
let touch = seat.get_touch().unwrap();
|
||||
let tablet = seat.tablet_seat();
|
||||
let tools = tablet.get_tools();
|
||||
|
||||
let start_data =
|
||||
if serial.is_some_and(|serial| touch.has_grab(serial)) {
|
||||
GrabStartData::Touch(touch.grab_start_data().unwrap())
|
||||
} else if let Some((desc, tool)) =
|
||||
serial.and_then(|serial| tools.iter().find(|(_, tool)| tool.has_grab(serial)))
|
||||
{
|
||||
GrabStartData::TabletTool {
|
||||
tool: desc.clone(),
|
||||
data: tool.grab_start_data().unwrap(),
|
||||
}
|
||||
} else {
|
||||
GrabStartData::Pointer(pointer.grab_start_data().unwrap_or_else(|| {
|
||||
PointerGrabStartData {
|
||||
|
|
@ -5166,8 +5190,16 @@ pub fn check_grab_preconditions(
|
|||
if let Some(surface) = client_initiated {
|
||||
// Check that this surface has a click or touch down grab.
|
||||
if !match serial {
|
||||
Some(serial) => pointer.has_grab(serial) || touch.has_grab(serial),
|
||||
None => pointer.is_grabbed() | touch.is_grabbed(),
|
||||
Some(serial) => {
|
||||
pointer.has_grab(serial)
|
||||
|| touch.has_grab(serial)
|
||||
|| tools.values().any(|tool| tool.has_grab(serial))
|
||||
}
|
||||
None => {
|
||||
pointer.is_grabbed()
|
||||
|| touch.is_grabbed()
|
||||
|| tools.values().any(|tool| tool.is_grabbed())
|
||||
}
|
||||
} {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,19 +11,31 @@ use cosmic_comp_config::{ZoomConfig, ZoomMovement};
|
|||
use cosmic_config::ConfigSet;
|
||||
use keyframe::{ease, functions::Linear};
|
||||
use smithay::{
|
||||
backend::renderer::ImportMem,
|
||||
backend::{
|
||||
input::{InputTime, TabletToolDescriptor},
|
||||
renderer::ImportMem,
|
||||
},
|
||||
desktop::space::SpaceElement,
|
||||
input::{
|
||||
Seat,
|
||||
pointer::{
|
||||
AxisFrame, ButtonEvent, Focus, GestureHoldBeginEvent, GestureHoldEndEvent,
|
||||
GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent,
|
||||
GestureSwipeBeginEvent, GestureSwipeEndEvent, GestureSwipeUpdateEvent,
|
||||
MotionEvent as PointerMotionEvent, PointerTarget, RelativeMotionEvent,
|
||||
AxisFrame as PointerAxisFrame, ButtonEvent as PointerButtonEvent, Focus,
|
||||
GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
|
||||
GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent,
|
||||
GestureSwipeEndEvent, GestureSwipeUpdateEvent, MotionEvent as PointerMotionEvent,
|
||||
PointerTarget, RelativeMotionEvent,
|
||||
},
|
||||
tablet::{
|
||||
Tablet, TabletSeatTrait,
|
||||
tool::{
|
||||
AxisFrame as TabletAxisFrame, ButtonEvent as TabletButtonEvent,
|
||||
DownEvent as TabletDownEvent, MotionEvent as TabletMotionEvent, TabletToolTarget,
|
||||
UpEvent as TabletUpEvent,
|
||||
},
|
||||
},
|
||||
touch::{
|
||||
DownEvent, FrameMarker, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent,
|
||||
TouchTarget, UpEvent,
|
||||
DownEvent as TouchDownEvent, FrameMarker, MotionEvent as TouchMotionEvent,
|
||||
OrientationEvent, ShapeEvent, TouchTarget, UpEvent as TouchUpEvent,
|
||||
},
|
||||
},
|
||||
output::Output,
|
||||
|
|
@ -33,6 +45,7 @@ use tracing::error;
|
|||
|
||||
use crate::{
|
||||
backend::render::element::AsGlowRenderer,
|
||||
shell::grabs::GrabType,
|
||||
state::State,
|
||||
utils::{
|
||||
iced::{IcedElement, IcedRenderElement, Program},
|
||||
|
|
@ -699,15 +712,27 @@ impl Program for ZoomProgram {
|
|||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer().unwrap().set_grab(
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat.get_pointer().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
serial,
|
||||
Focus::Clear,
|
||||
);
|
||||
),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(
|
||||
state,
|
||||
grab,
|
||||
InputTime::now(),
|
||||
serial,
|
||||
Focus::Clear,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -786,15 +811,27 @@ impl Program for ZoomProgram {
|
|||
);
|
||||
|
||||
std::mem::drop(shell);
|
||||
if grab.is_touch_grab() {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial);
|
||||
} else {
|
||||
seat.get_pointer().unwrap().set_grab(
|
||||
match grab.grab_type() {
|
||||
GrabType::Touch => {
|
||||
seat.get_touch().unwrap().set_grab(state, grab, serial)
|
||||
}
|
||||
GrabType::Pointer => seat.get_pointer().unwrap().set_grab(
|
||||
state,
|
||||
grab,
|
||||
serial,
|
||||
Focus::Clear,
|
||||
);
|
||||
),
|
||||
GrabType::TabletTool => seat
|
||||
.tablet_seat()
|
||||
.get_tool(grab.tool().unwrap())
|
||||
.unwrap()
|
||||
.set_grab(
|
||||
state,
|
||||
grab,
|
||||
InputTime::now(),
|
||||
serial,
|
||||
Focus::Clear,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -884,14 +921,14 @@ impl PointerTarget<State> for ZoomFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &ButtonEvent) {
|
||||
fn button(&self, seat: &Seat<State>, data: &mut State, event: &PointerButtonEvent) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => PointerTarget::button(elem, seat, data, event),
|
||||
ZoomFocusTarget::Menu(elem) => PointerTarget::button(elem, seat, data, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: AxisFrame) {
|
||||
fn axis(&self, seat: &Seat<State>, data: &mut State, frame: PointerAxisFrame) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => PointerTarget::axis(elem, seat, data, frame),
|
||||
ZoomFocusTarget::Menu(elem) => PointerTarget::axis(elem, seat, data, frame),
|
||||
|
|
@ -1024,7 +1061,7 @@ impl PointerTarget<State> for ZoomFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
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: InputTime) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => PointerTarget::leave(elem, seat, data, serial, time),
|
||||
ZoomFocusTarget::Menu(elem) => PointerTarget::leave(elem, seat, data, serial, time),
|
||||
|
|
@ -1033,14 +1070,14 @@ impl PointerTarget<State> for ZoomFocusTarget {
|
|||
}
|
||||
|
||||
impl TouchTarget<State> for ZoomFocusTarget {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &DownEvent) {
|
||||
fn down(&self, seat: &Seat<State>, data: &mut State, event: &TouchDownEvent) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => TouchTarget::down(elem, seat, data, event),
|
||||
ZoomFocusTarget::Menu(elem) => TouchTarget::down(elem, seat, data, event),
|
||||
}
|
||||
}
|
||||
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &UpEvent) {
|
||||
fn up(&self, seat: &Seat<State>, data: &mut State, event: &TouchUpEvent) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => TouchTarget::up(elem, seat, data, event),
|
||||
ZoomFocusTarget::Menu(elem) => TouchTarget::up(elem, seat, data, event),
|
||||
|
|
@ -1090,6 +1127,144 @@ impl TouchTarget<State> for ZoomFocusTarget {
|
|||
}
|
||||
}
|
||||
|
||||
impl TabletToolTarget<State> for ZoomFocusTarget {
|
||||
fn proximity_in(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
tablet: &Tablet,
|
||||
serial: Serial,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::proximity_in(elem, seat, data, tool_descriptor, tablet, serial)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::proximity_in(elem, seat, data, tool_descriptor, tablet, serial)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn proximity_out(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::proximity_out(elem, seat, data, tool_descriptor)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::proximity_out(elem, seat, data, tool_descriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn down(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &TabletDownEvent,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::down(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::down(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn up(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &TabletUpEvent,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::up(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::up(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &TabletMotionEvent,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::motion(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::motion(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn axis(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
frame: TabletAxisFrame,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::axis(elem, seat, data, tool_descriptor, frame)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::axis(elem, seat, data, tool_descriptor, frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn button(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
event: &TabletButtonEvent,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::button(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::button(elem, seat, data, tool_descriptor, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn frame(
|
||||
&self,
|
||||
seat: &Seat<State>,
|
||||
data: &mut State,
|
||||
tool_descriptor: &TabletToolDescriptor,
|
||||
time: InputTime,
|
||||
) {
|
||||
match self {
|
||||
ZoomFocusTarget::Main(elem) => {
|
||||
TabletToolTarget::frame(elem, seat, data, tool_descriptor, time)
|
||||
}
|
||||
ZoomFocusTarget::Menu(elem) => {
|
||||
TabletToolTarget::frame(elem, seat, data, tool_descriptor, time)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl IsAlive for ZoomFocusTarget {
|
||||
fn alive(&self) -> bool {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue