mirror of
https://github.com/labwc/labwc.git
synced 2026-02-05 04:06:33 -05:00
input: move tablet tool functions into tablet.c
Just a big move and a rename of the tablet tool destroy handler.
This commit is contained in:
parent
b3c1ef41c3
commit
6f6fcbc2e1
6 changed files with 101 additions and 126 deletions
|
|
@ -13,12 +13,84 @@
|
|||
#include "config/mousebind.h"
|
||||
#include "input/cursor.h"
|
||||
#include "input/tablet.h"
|
||||
#include "input/tablet-tool.h"
|
||||
#include "input/tablet-pad.h"
|
||||
#include "labwc.h"
|
||||
#include "idle.h"
|
||||
#include "action.h"
|
||||
|
||||
bool
|
||||
tablet_tool_has_focused_surface(struct seat *seat)
|
||||
{
|
||||
struct drawing_tablet_tool *tool;
|
||||
wl_list_for_each(tool, &seat->tablet_tools, link) {
|
||||
if (tool->tool_v2->focused_surface) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_set_cursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct drawing_tablet_tool *tool =
|
||||
wl_container_of(listener, tool, handlers.set_cursor);
|
||||
struct wlr_tablet_v2_event_cursor *ev = data;
|
||||
|
||||
struct seat *seat = tool->seat;
|
||||
struct wlr_seat_client *focused_client =
|
||||
seat->seat->pointer_state.focused_client;
|
||||
|
||||
if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->seat_client != focused_client) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_cursor_set_surface(seat->cursor, ev->surface,
|
||||
ev->hotspot_x, ev->hotspot_y);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_tablet_tool_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct drawing_tablet_tool *tool =
|
||||
wl_container_of(listener, tool, handlers.destroy);
|
||||
|
||||
wl_list_remove(&tool->link);
|
||||
wl_list_remove(&tool->handlers.set_cursor.link);
|
||||
wl_list_remove(&tool->handlers.destroy.link);
|
||||
free(tool);
|
||||
}
|
||||
|
||||
void
|
||||
tablet_tool_create(struct seat *seat,
|
||||
struct wlr_tablet_tool *wlr_tablet_tool)
|
||||
{
|
||||
wlr_log(WLR_DEBUG, "setting up tablet tool");
|
||||
struct drawing_tablet_tool *tool = znew(*tool);
|
||||
tool->seat = seat;
|
||||
tool->tool_v2 =
|
||||
wlr_tablet_tool_create(seat->server->tablet_manager,
|
||||
seat->seat, wlr_tablet_tool);
|
||||
wlr_tablet_tool->data = tool;
|
||||
wlr_log(WLR_INFO, "tablet tool capabilities:%s%s%s%s%s%s",
|
||||
wlr_tablet_tool->tilt ? " tilt" : "",
|
||||
wlr_tablet_tool->pressure ? " pressure" : "",
|
||||
wlr_tablet_tool->distance ? " distance" : "",
|
||||
wlr_tablet_tool->rotation ? " rotation" : "",
|
||||
wlr_tablet_tool->slider ? " slider" : "",
|
||||
wlr_tablet_tool->wheel ? " wheel" : "");
|
||||
CONNECT_SIGNAL(tool->tool_v2, &tool->handlers, set_cursor);
|
||||
wl_signal_add(&wlr_tablet_tool->events.destroy, &tool->handlers.destroy);
|
||||
tool->handlers.destroy.notify = handle_tablet_tool_destroy;
|
||||
|
||||
wl_list_insert(&seat->tablet_tools, &tool->link);
|
||||
}
|
||||
|
||||
static enum motion
|
||||
tool_motion_mode(enum motion motion, struct wlr_tablet_tool *tool)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue