mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Move pointer_grab_start_data into grab
This commit is contained in:
parent
ea913e898c
commit
5c88ceac83
5 changed files with 41 additions and 43 deletions
39
src/grab.rs
39
src/grab.rs
|
@ -2,3 +2,42 @@
|
|||
|
||||
pub mod move_grab;
|
||||
pub mod resize_grab;
|
||||
|
||||
use smithay::{
|
||||
input::{
|
||||
pointer::{GrabStartData, PointerHandle},
|
||||
SeatHandler,
|
||||
},
|
||||
reexports::wayland_server::{protocol::wl_surface::WlSurface, Resource},
|
||||
utils::Serial,
|
||||
wayland::seat::WaylandFocus,
|
||||
};
|
||||
|
||||
use crate::focus::FocusTarget;
|
||||
|
||||
/// Returns the [GrabStartData] from a pointer grab, if any.
|
||||
pub fn pointer_grab_start_data<S>(
|
||||
pointer: &PointerHandle<S>,
|
||||
surface: &WlSurface,
|
||||
serial: Serial,
|
||||
) -> Option<GrabStartData<S>>
|
||||
where
|
||||
S: SeatHandler<PointerFocus = FocusTarget> + 'static,
|
||||
{
|
||||
tracing::debug!("start of pointer_grab_start_data");
|
||||
if !pointer.has_grab(serial) {
|
||||
tracing::debug!("pointer doesn't have grab");
|
||||
return None;
|
||||
}
|
||||
|
||||
let start_data = pointer.grab_start_data()?;
|
||||
|
||||
let (focus_surface, _point) = start_data.focus.as_ref()?;
|
||||
|
||||
if !focus_surface.same_client_as(&surface.id()) {
|
||||
tracing::debug!("surface isn't the same");
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(start_data)
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ pub fn move_request_client(
|
|||
button_used: u32,
|
||||
) {
|
||||
let pointer = seat.get_pointer().expect("seat had no pointer");
|
||||
if let Some(start_data) = crate::pointer::pointer_grab_start_data(&pointer, surface, serial) {
|
||||
if let Some(start_data) = crate::grab::pointer_grab_start_data(&pointer, surface, serial) {
|
||||
let Some(window) = state.window_for_surface(surface) else {
|
||||
tracing::error!("Surface had no window, cancelling move request");
|
||||
return;
|
||||
|
|
|
@ -431,7 +431,7 @@ pub fn resize_request_client(
|
|||
) {
|
||||
let pointer = seat.get_pointer().expect("seat had no pointer");
|
||||
|
||||
if let Some(start_data) = crate::pointer::pointer_grab_start_data(&pointer, surface, serial) {
|
||||
if let Some(start_data) = crate::grab::pointer_grab_start_data(&pointer, surface, serial) {
|
||||
let Some(window) = state.window_for_surface(surface) else {
|
||||
tracing::error!("Surface had no window, cancelling resize request");
|
||||
return;
|
||||
|
|
|
@ -25,7 +25,6 @@ mod handlers;
|
|||
mod input;
|
||||
mod layout;
|
||||
mod output;
|
||||
mod pointer;
|
||||
mod render;
|
||||
mod state;
|
||||
mod tag;
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use smithay::{
|
||||
input::{
|
||||
pointer::{GrabStartData, PointerHandle},
|
||||
SeatHandler,
|
||||
},
|
||||
reexports::wayland_server::{protocol::wl_surface::WlSurface, Resource},
|
||||
utils::Serial,
|
||||
wayland::seat::WaylandFocus,
|
||||
};
|
||||
|
||||
use crate::focus::FocusTarget;
|
||||
|
||||
/// Returns the [GrabStartData] from a pointer grab, if any.
|
||||
pub fn pointer_grab_start_data<S>(
|
||||
pointer: &PointerHandle<S>,
|
||||
surface: &WlSurface,
|
||||
serial: Serial,
|
||||
) -> Option<GrabStartData<S>>
|
||||
where
|
||||
S: SeatHandler<PointerFocus = FocusTarget> + 'static,
|
||||
{
|
||||
tracing::debug!("start of pointer_grab_start_data");
|
||||
if !pointer.has_grab(serial) {
|
||||
tracing::debug!("pointer doesn't have grab");
|
||||
return None;
|
||||
}
|
||||
|
||||
let start_data = pointer.grab_start_data()?;
|
||||
|
||||
let (focus_surface, _point) = start_data.focus.as_ref()?;
|
||||
|
||||
if !focus_surface.same_client_as(&surface.id()) {
|
||||
tracing::debug!("surface isn't the same");
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(start_data)
|
||||
}
|
Loading…
Reference in a new issue