mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	input: add tablet tool setup
This commit is contained in:
		
							parent
							
								
									9c219564be
								
							
						
					
					
						commit
						abfa100b38
					
				
					 5 changed files with 76 additions and 0 deletions
				
			
		
							
								
								
									
										22
									
								
								include/input/tablet-tool.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								include/input/tablet-tool.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					/* SPDX-License-Identifier: GPL-2.0-only */
 | 
				
			||||||
 | 
					#ifndef LABWC_TABLET_TOOL_H
 | 
				
			||||||
 | 
					#define LABWC_TABLET_TOOL_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <wayland-server-core.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_tablet_v2.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct seat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct drawing_tablet_tool {
 | 
				
			||||||
 | 
						struct seat *seat;
 | 
				
			||||||
 | 
						struct wlr_tablet_v2_tablet_tool *tool_v2;
 | 
				
			||||||
 | 
						struct {
 | 
				
			||||||
 | 
							struct wl_listener set_cursor;
 | 
				
			||||||
 | 
							struct wl_listener destroy;
 | 
				
			||||||
 | 
						} handlers;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void tablet_tool_init(struct seat *seat,
 | 
				
			||||||
 | 
						struct wlr_tablet_tool *wlr_tablet_tool);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif /* LABWC_TABLET_TOOL_H */
 | 
				
			||||||
| 
						 | 
					@ -3,14 +3,17 @@
 | 
				
			||||||
#define LABWC_TABLET_H
 | 
					#define LABWC_TABLET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <wayland-server-core.h>
 | 
					#include <wayland-server-core.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_tablet_v2.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct seat;
 | 
					struct seat;
 | 
				
			||||||
struct wlr_device;
 | 
					struct wlr_device;
 | 
				
			||||||
struct wlr_input_device;
 | 
					struct wlr_input_device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct drawing_tablet {
 | 
					struct drawing_tablet {
 | 
				
			||||||
 | 
						struct wlr_input_device *wlr_input_device;
 | 
				
			||||||
	struct seat *seat;
 | 
						struct seat *seat;
 | 
				
			||||||
	struct wlr_tablet *tablet;
 | 
						struct wlr_tablet *tablet;
 | 
				
			||||||
 | 
						struct wlr_tablet_v2_tablet *tablet_v2;
 | 
				
			||||||
	double x, y;
 | 
						double x, y;
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		struct wl_listener proximity;
 | 
							struct wl_listener proximity;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@ labwc_sources += files(
 | 
				
			||||||
  'cursor.c',
 | 
					  'cursor.c',
 | 
				
			||||||
  'tablet.c',
 | 
					  'tablet.c',
 | 
				
			||||||
  'tablet-pad.c',
 | 
					  'tablet-pad.c',
 | 
				
			||||||
 | 
					  'tablet-tool.c',
 | 
				
			||||||
  'gestures.c',
 | 
					  'gestures.c',
 | 
				
			||||||
  'input.c',
 | 
					  'input.c',
 | 
				
			||||||
  'keyboard.c',
 | 
					  'keyboard.c',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										44
									
								
								src/input/tablet-tool.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/input/tablet-tool.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,44 @@
 | 
				
			||||||
 | 
					// SPDX-License-Identifier: GPL-2.0-only
 | 
				
			||||||
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_tablet_pad.h>
 | 
				
			||||||
 | 
					#include <wlr/types/wlr_tablet_tool.h>
 | 
				
			||||||
 | 
					#include <wlr/util/log.h>
 | 
				
			||||||
 | 
					#include "common/macros.h"
 | 
				
			||||||
 | 
					#include "common/mem.h"
 | 
				
			||||||
 | 
					#include "config/rcxml.h"
 | 
				
			||||||
 | 
					#include "input/cursor.h"
 | 
				
			||||||
 | 
					#include "input/tablet-tool.h"
 | 
				
			||||||
 | 
					#include "labwc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct drawing_tablet_tool *tool =
 | 
				
			||||||
 | 
							wl_container_of(listener, tool, handlers.destroy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wl_list_remove(&tool->handlers.set_cursor.link);
 | 
				
			||||||
 | 
						wl_list_remove(&tool->handlers.destroy.link);
 | 
				
			||||||
 | 
						free(tool);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					tablet_tool_init(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(wlr_tablet_tool, &tool->handlers, destroy);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
#include "config/rcxml.h"
 | 
					#include "config/rcxml.h"
 | 
				
			||||||
#include "input/cursor.h"
 | 
					#include "input/cursor.h"
 | 
				
			||||||
#include "input/tablet.h"
 | 
					#include "input/tablet.h"
 | 
				
			||||||
 | 
					#include "labwc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
tool_supports_absolute_motion(struct wlr_tablet_tool *tool)
 | 
					tool_supports_absolute_motion(struct wlr_tablet_tool *tool)
 | 
				
			||||||
| 
						 | 
					@ -168,8 +169,13 @@ tablet_init(struct seat *seat, struct wlr_input_device *wlr_device)
 | 
				
			||||||
	wlr_log(WLR_DEBUG, "setting up tablet");
 | 
						wlr_log(WLR_DEBUG, "setting up tablet");
 | 
				
			||||||
	struct drawing_tablet *tablet = znew(*tablet);
 | 
						struct drawing_tablet *tablet = znew(*tablet);
 | 
				
			||||||
	tablet->seat = seat;
 | 
						tablet->seat = seat;
 | 
				
			||||||
 | 
						tablet->wlr_input_device = wlr_device;
 | 
				
			||||||
	tablet->tablet = wlr_tablet_from_input_device(wlr_device);
 | 
						tablet->tablet = wlr_tablet_from_input_device(wlr_device);
 | 
				
			||||||
	tablet->tablet->data = tablet;
 | 
						tablet->tablet->data = tablet;
 | 
				
			||||||
 | 
						if (seat->server->tablet_manager) {
 | 
				
			||||||
 | 
							tablet->tablet_v2 = wlr_tablet_create(
 | 
				
			||||||
 | 
								seat->server->tablet_manager, seat->seat, wlr_device);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	tablet->x = 0.0;
 | 
						tablet->x = 0.0;
 | 
				
			||||||
	tablet->y = 0.0;
 | 
						tablet->y = 0.0;
 | 
				
			||||||
	wlr_log(WLR_INFO, "tablet dimensions: %.2fmm x %.2fmm",
 | 
						wlr_log(WLR_INFO, "tablet dimensions: %.2fmm x %.2fmm",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue