backend: add ButtonState
This commit is contained in:
parent
e22e6680b6
commit
0e1be7544f
17 changed files with 75 additions and 66 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::{InputDeviceId, KeyState, ScrollAxis},
|
||||
backend::{ButtonState, InputDeviceId, KeyState, ScrollAxis},
|
||||
client::Client,
|
||||
fixed::Fixed,
|
||||
ifs::wl_seat::{
|
||||
|
|
@ -79,7 +79,7 @@ impl JaySeatEvents {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn send_button(&self, seat: SeatId, time_usec: u64, button: u32, state: KeyState) {
|
||||
pub fn send_button(&self, seat: SeatId, time_usec: u64, button: u32, state: ButtonState) {
|
||||
self.client.event(Button {
|
||||
self_id: self.id,
|
||||
seat: seat.raw(),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub mod zwp_virtual_keyboard_v1;
|
|||
use {
|
||||
crate::{
|
||||
async_engine::SpawnedFuture,
|
||||
backend::{KeyState, Leds},
|
||||
backend::{ButtonState, Leds},
|
||||
client::{Client, ClientError, ClientId},
|
||||
cursor_user::{CursorUser, CursorUserGroup, CursorUserOwner},
|
||||
ei::ei_ifs::ei_seat::EiSeat,
|
||||
|
|
@ -1387,10 +1387,10 @@ impl WlSeatGlobal {
|
|||
node: Rc<dyn Node>,
|
||||
time_usec: u64,
|
||||
button: u32,
|
||||
state: KeyState,
|
||||
state: ButtonState,
|
||||
serial: u64,
|
||||
) {
|
||||
if self.tray_popups.is_not_empty() && state == KeyState::Pressed {
|
||||
if self.tray_popups.is_not_empty() && state == ButtonState::Pressed {
|
||||
let id = node.node_tray_item();
|
||||
self.tray_popups.lock().retain(|&(tray_item_id, _), item| {
|
||||
let retain = Some(tray_item_id) == id;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::{
|
||||
AXIS_120, AxisSource, ConnectorId, InputDeviceId, InputEvent, KeyState, ScrollAxis,
|
||||
AXIS_120, AxisSource, ButtonState, ConnectorId, InputDeviceId, InputEvent, KeyState,
|
||||
ScrollAxis,
|
||||
},
|
||||
client::ClientId,
|
||||
config::InvokedShortcut,
|
||||
|
|
@ -672,7 +673,7 @@ impl WlSeatGlobal {
|
|||
self.motion_event_abs(time_usec, x, y, false);
|
||||
}
|
||||
|
||||
pub fn button_event(self: &Rc<Self>, time_usec: u64, button: u32, state: KeyState) {
|
||||
pub fn button_event(self: &Rc<Self>, time_usec: u64, button: u32, state: ButtonState) {
|
||||
self.for_each_ei_seat(|ei_seat| {
|
||||
ei_seat.handle_button(time_usec, button, state);
|
||||
});
|
||||
|
|
@ -1314,12 +1315,12 @@ impl WlSeatGlobal {
|
|||
surface: &Rc<WlSurface>,
|
||||
time_usec: u64,
|
||||
button: u32,
|
||||
state: KeyState,
|
||||
state: ButtonState,
|
||||
serial: u64,
|
||||
) {
|
||||
let (state, pressed) = match state {
|
||||
KeyState::Released => (wl_pointer::RELEASED, false),
|
||||
KeyState::Pressed => {
|
||||
ButtonState::Released => (wl_pointer::RELEASED, false),
|
||||
ButtonState::Pressed => {
|
||||
surface.client.focus_stealing_serial.set(Some(serial));
|
||||
(wl_pointer::PRESSED, true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::{AXIS_120, AxisSource, KeyState, ScrollAxis},
|
||||
backend::{AXIS_120, AxisSource, ButtonState, ScrollAxis},
|
||||
cursor::KnownCursor,
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
|
|
@ -57,7 +57,7 @@ impl Default for PointerOwnerHolder {
|
|||
}
|
||||
|
||||
impl PointerOwnerHolder {
|
||||
pub fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: KeyState) {
|
||||
pub fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: ButtonState) {
|
||||
self.owner.get().button(seat, time_usec, button, state)
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ impl PointerOwnerHolder {
|
|||
}
|
||||
|
||||
trait PointerOwner {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: KeyState);
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: ButtonState);
|
||||
fn axis_node(&self, seat: &Rc<WlSeatGlobal>) -> Option<Rc<dyn Node>> {
|
||||
let _ = seat;
|
||||
None
|
||||
|
|
@ -318,8 +318,8 @@ struct SelectWorkspaceUsecase<S: ?Sized> {
|
|||
struct WindowManagementUsecase;
|
||||
|
||||
impl<T: SimplePointerOwnerUsecase> PointerOwner for SimplePointerOwner<T> {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: KeyState) {
|
||||
if state != KeyState::Pressed {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: ButtonState) {
|
||||
if state != ButtonState::Pressed {
|
||||
return;
|
||||
}
|
||||
let pn = match seat.pointer_node() {
|
||||
|
|
@ -436,9 +436,9 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimplePointerOwner<T> {
|
|||
}
|
||||
|
||||
impl<T: SimplePointerOwnerUsecase> PointerOwner for SimpleGrabPointerOwner<T> {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: KeyState) {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, button: u32, state: ButtonState) {
|
||||
match state {
|
||||
KeyState::Released => {
|
||||
ButtonState::Released => {
|
||||
if self.buttons.remove(&button).is_none() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -449,7 +449,7 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimpleGrabPointerOwner<T> {
|
|||
seat.tree_changed.trigger();
|
||||
}
|
||||
}
|
||||
KeyState::Pressed => {
|
||||
ButtonState::Pressed => {
|
||||
if self.buttons.insert(button, ()).is_some() {
|
||||
return;
|
||||
}
|
||||
|
|
@ -493,7 +493,7 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimpleGrabPointerOwner<T> {
|
|||
self.node.clone(),
|
||||
time_usec,
|
||||
button,
|
||||
KeyState::Released,
|
||||
ButtonState::Released,
|
||||
serial,
|
||||
);
|
||||
}
|
||||
|
|
@ -511,8 +511,8 @@ impl<T: SimplePointerOwnerUsecase> PointerOwner for SimpleGrabPointerOwner<T> {
|
|||
}
|
||||
|
||||
impl PointerOwner for DndPointerOwner {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: KeyState) {
|
||||
if button != self.button || state != KeyState::Released {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: ButtonState) {
|
||||
if button != self.button || state != ButtonState::Released {
|
||||
return;
|
||||
}
|
||||
let target = self.target.get();
|
||||
|
|
@ -1068,8 +1068,8 @@ impl<T> PointerOwner for ToplevelGrabPointerOwner<T>
|
|||
where
|
||||
T: WindowManagementGrabUsecase,
|
||||
{
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: KeyState) {
|
||||
if button != T::BUTTON || state != KeyState::Released {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: ButtonState) {
|
||||
if button != T::BUTTON || state != ButtonState::Released {
|
||||
return;
|
||||
}
|
||||
self.tl.node_seat_state().remove_pointer_grab(seat);
|
||||
|
|
@ -1238,12 +1238,12 @@ impl<T> PointerOwner for UiDragPointerOwner<T>
|
|||
where
|
||||
T: UiDragUsecase,
|
||||
{
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: KeyState) {
|
||||
fn button(&self, seat: &Rc<WlSeatGlobal>, _time_usec: u64, button: u32, state: ButtonState) {
|
||||
if button == BTN_RIGHT {
|
||||
self.do_revert_to_default(seat, false);
|
||||
return;
|
||||
}
|
||||
if button != BTN_LEFT || state != KeyState::Released {
|
||||
if button != BTN_LEFT || state != ButtonState::Released {
|
||||
return;
|
||||
}
|
||||
self.apply_changes(seat);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub mod zwp_input_popup_surface_v2;
|
|||
|
||||
use {
|
||||
crate::{
|
||||
backend::KeyState,
|
||||
backend::{ButtonState, KeyState},
|
||||
client::{Client, ClientError},
|
||||
cmm::cmm_description::ColorDescription,
|
||||
cursor_user::{CursorUser, CursorUserId},
|
||||
|
|
@ -1907,7 +1907,7 @@ impl Node for WlSurface {
|
|||
seat: &Rc<WlSeatGlobal>,
|
||||
time_usec: u64,
|
||||
button: u32,
|
||||
state: KeyState,
|
||||
state: ButtonState,
|
||||
serial: u64,
|
||||
) {
|
||||
seat.button_surface(&self, time_usec, button, state, serial);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue