wayland: implement tablet-v2
This commit is contained in:
parent
86e283d255
commit
7ed499eabd
62 changed files with 5174 additions and 318 deletions
|
|
@ -11,8 +11,10 @@ use {
|
|||
wl_buffer::WlBufferStorage,
|
||||
wl_output::WlOutputGlobal,
|
||||
wl_seat::{
|
||||
collect_kb_foci2, wl_pointer::PendingScroll, NodeSeatState, SeatId, WlSeatGlobal,
|
||||
BTN_LEFT,
|
||||
collect_kb_foci2,
|
||||
tablet::{TabletTool, TabletToolChanges, TabletToolId},
|
||||
wl_pointer::PendingScroll,
|
||||
NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT,
|
||||
},
|
||||
wl_surface::{
|
||||
ext_session_lock_surface_v1::ExtSessionLockSurfaceV1,
|
||||
|
|
@ -63,7 +65,7 @@ pub struct OutputNode {
|
|||
pub is_dummy: bool,
|
||||
pub status: CloneCell<Rc<String>>,
|
||||
pub scroll: Scroller,
|
||||
pub pointer_positions: CopyHashMap<SeatId, (i32, i32)>,
|
||||
pub pointer_positions: CopyHashMap<PointerType, (i32, i32)>,
|
||||
pub lock_surface: CloneCell<Option<Rc<ExtSessionLockSurfaceV1>>>,
|
||||
pub hardware_cursor: CloneCell<Option<Rc<dyn HardwareCursor>>>,
|
||||
pub hardware_cursor_needs_render: Cell<bool>,
|
||||
|
|
@ -72,6 +74,12 @@ pub struct OutputNode {
|
|||
pub screencopies: CopyHashMap<(ClientId, ZwlrScreencopyFrameV1Id), Rc<ZwlrScreencopyFrameV1>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub enum PointerType {
|
||||
Seat(SeatId),
|
||||
TabletTool(TabletToolId),
|
||||
}
|
||||
|
||||
pub async fn output_render_data(state: Rc<State>) {
|
||||
loop {
|
||||
let container = state.pending_output_render_data.pop().await;
|
||||
|
|
@ -593,8 +601,9 @@ impl OutputNode {
|
|||
self.schedule_update_render_data();
|
||||
}
|
||||
|
||||
fn pointer_move(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>, x: i32, y: i32) {
|
||||
self.pointer_positions.set(seat.id(), (x, y));
|
||||
fn pointer_move(self: &Rc<Self>, id: PointerType, x: Fixed, y: Fixed) {
|
||||
self.pointer_positions
|
||||
.set(id, (x.round_down(), y.round_down()));
|
||||
}
|
||||
|
||||
pub fn has_fullscreen(&self) -> bool {
|
||||
|
|
@ -641,6 +650,29 @@ impl OutputNode {
|
|||
set_layer_visible!(self.layers[2], visible);
|
||||
set_layer_visible!(self.layers[3], visible);
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, id: PointerType) {
|
||||
let (x, y) = match self.pointer_positions.get(&id) {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if y >= self.state.theme.sizes.title_height.get() {
|
||||
return;
|
||||
}
|
||||
let ws = 'ws: {
|
||||
let rd = self.render_data.borrow_mut();
|
||||
for title in &rd.titles {
|
||||
if x >= title.x1 && x < title.x2 {
|
||||
break 'ws title.ws.clone();
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
self.show_workspace(&ws);
|
||||
ws.flush_jay_workspaces();
|
||||
self.schedule_update_render_data();
|
||||
self.state.tree_changed();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OutputTitle {
|
||||
|
|
@ -844,26 +876,7 @@ impl Node for OutputNode {
|
|||
if state != KeyState::Pressed || button != BTN_LEFT {
|
||||
return;
|
||||
}
|
||||
let (x, y) = match self.pointer_positions.get(&seat.id()) {
|
||||
Some(p) => p,
|
||||
_ => return,
|
||||
};
|
||||
if y >= self.state.theme.sizes.title_height.get() {
|
||||
return;
|
||||
}
|
||||
let ws = 'ws: {
|
||||
let rd = self.render_data.borrow_mut();
|
||||
for title in &rd.titles {
|
||||
if x >= title.x1 && x < title.x2 {
|
||||
break 'ws title.ws.clone();
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
self.show_workspace(&ws);
|
||||
ws.flush_jay_workspaces();
|
||||
self.schedule_update_render_data();
|
||||
self.state.tree_changed();
|
||||
self.button(PointerType::Seat(seat.id()));
|
||||
}
|
||||
|
||||
fn node_on_axis_event(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, event: &PendingScroll) {
|
||||
|
|
@ -905,7 +918,7 @@ impl Node for OutputNode {
|
|||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
self.pointer_move(PointerType::Seat(seat.id()), x, y);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
|
|
@ -914,7 +927,40 @@ impl Node for OutputNode {
|
|||
}
|
||||
|
||||
fn node_on_pointer_motion(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, x: Fixed, y: Fixed) {
|
||||
self.pointer_move(seat, x.round_down(), y.round_down());
|
||||
self.pointer_move(PointerType::Seat(seat.id()), x, y);
|
||||
}
|
||||
|
||||
fn node_on_tablet_tool_leave(&self, tool: &Rc<TabletTool>, _time_usec: u64) {
|
||||
self.pointer_positions
|
||||
.remove(&PointerType::TabletTool(tool.id));
|
||||
}
|
||||
|
||||
fn node_on_tablet_tool_enter(
|
||||
self: Rc<Self>,
|
||||
tool: &Rc<TabletTool>,
|
||||
_time_usec: u64,
|
||||
x: Fixed,
|
||||
y: Fixed,
|
||||
) {
|
||||
tool.cursor().set_known(KnownCursor::Default);
|
||||
self.pointer_move(PointerType::TabletTool(tool.id), x, y);
|
||||
}
|
||||
|
||||
fn node_on_tablet_tool_apply_changes(
|
||||
self: Rc<Self>,
|
||||
tool: &Rc<TabletTool>,
|
||||
_time_usec: u64,
|
||||
changes: Option<&TabletToolChanges>,
|
||||
x: Fixed,
|
||||
y: Fixed,
|
||||
) {
|
||||
let id = PointerType::TabletTool(tool.id);
|
||||
self.pointer_move(id, x, y);
|
||||
if let Some(changes) = changes {
|
||||
if changes.down == Some(true) {
|
||||
self.button(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue