Update wlr_seat and friends to new compositor

This commit is contained in:
Scott Anderson 2019-05-16 19:00:53 +12:00
parent 8630988eae
commit 841031031e
12 changed files with 159 additions and 142 deletions

View file

@ -12,6 +12,8 @@
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
struct wlr_surface_2;
extern const struct wlr_pointer_grab_interface extern const struct wlr_pointer_grab_interface
wlr_data_device_pointer_drag_interface; wlr_data_device_pointer_drag_interface;
@ -93,7 +95,7 @@ struct wlr_drag;
struct wlr_drag_icon { struct wlr_drag_icon {
struct wlr_drag *drag; struct wlr_drag *drag;
struct wlr_surface *surface; struct wlr_surface_2 *surface;
bool mapped; bool mapped;
struct { struct {
@ -102,6 +104,7 @@ struct wlr_drag_icon {
struct wl_signal destroy; struct wl_signal destroy;
} events; } events;
struct wl_listener surface_commit;
struct wl_listener surface_destroy; struct wl_listener surface_destroy;
void *data; void *data;
@ -124,7 +127,7 @@ struct wlr_drag {
struct wlr_seat_client *focus_client; struct wlr_seat_client *focus_client;
struct wlr_drag_icon *icon; // can be NULL struct wlr_drag_icon *icon; // can be NULL
struct wlr_surface *focus; // can be NULL struct wlr_surface_2 *focus; // can be NULL
struct wlr_data_source *source; // can be NULL struct wlr_data_source *source; // can be NULL
bool started, dropped, cancelling; bool started, dropped, cancelling;
@ -187,13 +190,13 @@ void wlr_seat_set_selection(struct wlr_seat *seat,
* `wlr_seat_request_start_drag`. * `wlr_seat_request_start_drag`.
*/ */
struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client, struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client,
struct wlr_data_source *source, struct wlr_surface *icon_surface); struct wlr_data_source *source, struct wlr_surface_2 *icon_surface);
/** /**
* Requests a drag to be started on the seat. * Requests a drag to be started on the seat.
*/ */
void wlr_seat_request_start_drag(struct wlr_seat *seat, struct wlr_drag *drag, void wlr_seat_request_start_drag(struct wlr_seat *seat, struct wlr_drag *drag,
struct wlr_surface *origin, uint32_t serial); struct wlr_surface_2 *origin, uint32_t serial);
/** /**
* Starts a drag on the seat. This starts an implicit keyboard grab, but doesn't * Starts a drag on the seat. This starts an implicit keyboard grab, but doesn't

View file

@ -13,7 +13,8 @@
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_surface.h>
struct wlr_surface_2;
/** /**
* Contains state for a single client's bound wl_seat resource and can be used * Contains state for a single client's bound wl_seat resource and can be used
@ -39,10 +40,10 @@ struct wlr_seat_client {
struct wlr_touch_point { struct wlr_touch_point {
int32_t touch_id; int32_t touch_id;
struct wlr_surface *surface; struct wlr_surface_2 *surface;
struct wlr_seat_client *client; struct wlr_seat_client *client;
struct wlr_surface *focus_surface; struct wlr_surface_2 *focus_surface;
struct wlr_seat_client *focus_client; struct wlr_seat_client *focus_client;
double sx, sy; double sx, sy;
@ -60,7 +61,7 @@ struct wlr_seat_pointer_grab;
struct wlr_pointer_grab_interface { struct wlr_pointer_grab_interface {
void (*enter)(struct wlr_seat_pointer_grab *grab, void (*enter)(struct wlr_seat_pointer_grab *grab,
struct wlr_surface *surface, double sx, double sy); struct wlr_surface_2 *surface, double sx, double sy);
void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, void (*motion)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
double sx, double sy); double sx, double sy);
uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec, uint32_t (*button)(struct wlr_seat_pointer_grab *grab, uint32_t time_msec,
@ -76,7 +77,7 @@ struct wlr_seat_keyboard_grab;
struct wlr_keyboard_grab_interface { struct wlr_keyboard_grab_interface {
void (*enter)(struct wlr_seat_keyboard_grab *grab, void (*enter)(struct wlr_seat_keyboard_grab *grab,
struct wlr_surface *surface, uint32_t keycodes[], struct wlr_surface_2 *surface, uint32_t keycodes[],
size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers); size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers);
void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time_msec, void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time_msec,
uint32_t key, uint32_t state); uint32_t key, uint32_t state);
@ -134,7 +135,7 @@ struct wlr_seat_pointer_grab {
struct wlr_seat_pointer_state { struct wlr_seat_pointer_state {
struct wlr_seat *seat; struct wlr_seat *seat;
struct wlr_seat_client *focused_client; struct wlr_seat_client *focused_client;
struct wlr_surface *focused_surface; struct wlr_surface_2 *focused_surface;
double sx, sy; double sx, sy;
struct wlr_seat_pointer_grab *grab; struct wlr_seat_pointer_grab *grab;
@ -158,7 +159,7 @@ struct wlr_seat_keyboard_state {
struct wlr_keyboard *keyboard; struct wlr_keyboard *keyboard;
struct wlr_seat_client *focused_client; struct wlr_seat_client *focused_client;
struct wlr_surface *focused_surface; struct wlr_surface_2 *focused_surface;
struct wl_listener keyboard_destroy; struct wl_listener keyboard_destroy;
struct wl_listener keyboard_keymap; struct wl_listener keyboard_keymap;
@ -250,7 +251,7 @@ struct wlr_seat {
struct wlr_seat_pointer_request_set_cursor_event { struct wlr_seat_pointer_request_set_cursor_event {
struct wlr_seat_client *seat_client; struct wlr_seat_client *seat_client;
struct wlr_surface *surface; struct wlr_surface_2 *surface;
uint32_t serial; uint32_t serial;
int32_t hotspot_x, hotspot_y; int32_t hotspot_x, hotspot_y;
}; };
@ -267,19 +268,19 @@ struct wlr_seat_request_set_primary_selection_event {
struct wlr_seat_request_start_drag_event { struct wlr_seat_request_start_drag_event {
struct wlr_drag *drag; struct wlr_drag *drag;
struct wlr_surface *origin; struct wlr_surface_2 *origin;
uint32_t serial; uint32_t serial;
}; };
struct wlr_seat_pointer_focus_change_event { struct wlr_seat_pointer_focus_change_event {
struct wlr_seat *seat; struct wlr_seat *seat;
struct wlr_surface *old_surface, *new_surface; struct wlr_surface_2 *old_surface, *new_surface;
double sx, sy; double sx, sy;
}; };
struct wlr_seat_keyboard_focus_change_event { struct wlr_seat_keyboard_focus_change_event {
struct wlr_seat *seat; struct wlr_seat *seat;
struct wlr_surface *old_surface, *new_surface; struct wlr_surface_2 *old_surface, *new_surface;
}; };
/** /**
@ -312,7 +313,7 @@ void wlr_seat_set_name(struct wlr_seat *wlr_seat, const char *name);
* Whether or not the surface has pointer focus * Whether or not the surface has pointer focus
*/ */
bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat, bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
/** /**
* Send a pointer enter event to the given surface and consider it to be the * Send a pointer enter event to the given surface and consider it to be the
@ -322,7 +323,7 @@ bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
* focus to respect pointer grabs. * focus to respect pointer grabs.
*/ */
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy); struct wlr_surface_2 *surface, double sx, double sy);
/** /**
* Clear the focused surface for the pointer and leave all entered surfaces. * Clear the focused surface for the pointer and leave all entered surfaces.
@ -382,7 +383,7 @@ void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat);
* where the enter occurred. * where the enter occurred.
*/ */
void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat, void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy); struct wlr_surface_2 *surface, double sx, double sy);
/** /**
* Notify the seat of motion over the given surface. Pass surface-local * Notify the seat of motion over the given surface. Pass surface-local
@ -474,7 +475,7 @@ void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
* keyboard. * keyboard.
*/ */
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers); struct wlr_keyboard_modifiers *modifiers);
/** /**
@ -485,7 +486,7 @@ void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
* keyboard grabs. * keyboard grabs.
*/ */
void wlr_seat_keyboard_enter(struct wlr_seat *seat, void wlr_seat_keyboard_enter(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers); struct wlr_keyboard_modifiers *modifiers);
/** /**
@ -523,7 +524,7 @@ struct wlr_touch_point *wlr_seat_touch_get_point(struct wlr_seat *seat,
* the touch device. * the touch device.
*/ */
uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time_msec, struct wlr_surface_2 *surface, uint32_t time_msec,
int32_t touch_id, double sx, double sy); int32_t touch_id, double sx, double sy);
/** /**
@ -548,7 +549,7 @@ void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time_msec,
* `wlr_seat_touch_point_clear_focus()`. * `wlr_seat_touch_point_clear_focus()`.
*/ */
void wlr_seat_touch_point_focus(struct wlr_seat *seat, void wlr_seat_touch_point_focus(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time_msec, struct wlr_surface_2 *surface, uint32_t time_msec,
int32_t touch_id, double sx, double sy); int32_t touch_id, double sx, double sy);
/** /**
@ -566,7 +567,7 @@ void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time_msec,
* `wlr_seat_touch_notify_down()` to respect any grabs of the touch device. * `wlr_seat_touch_notify_down()` to respect any grabs of the touch device.
*/ */
uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time_msec, struct wlr_surface_2 *surface, uint32_t time_msec,
int32_t touch_id, double sx, double sy); int32_t touch_id, double sx, double sy);
/** /**
@ -607,7 +608,7 @@ bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial);
* Check whether this serial is valid to start a pointer grab action. * Check whether this serial is valid to start a pointer grab action.
*/ */
bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat, bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial); struct wlr_surface_2 *origin, uint32_t serial);
/** /**
* Check whether this serial is valid to start a touch grab action. If it's the * Check whether this serial is valid to start a touch grab action. If it's the
@ -615,7 +616,7 @@ bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat,
* the serial. * the serial.
*/ */
bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat, bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial, struct wlr_surface_2 *origin, uint32_t serial,
struct wlr_touch_point **point_ptr); struct wlr_touch_point **point_ptr);
/** /**

View file

@ -19,6 +19,7 @@
#define WLR_TABLET_V2_TOOL_BUTTONS_CAP 16 #define WLR_TABLET_V2_TOOL_BUTTONS_CAP 16
struct wlr_tablet_pad_v2_grab_interface; struct wlr_tablet_pad_v2_grab_interface;
struct wlr_surface_2;
struct wlr_tablet_pad_v2_grab { struct wlr_tablet_pad_v2_grab {
const struct wlr_tablet_pad_v2_grab_interface *interface; const struct wlr_tablet_pad_v2_grab_interface *interface;
@ -71,7 +72,7 @@ struct wlr_tablet_v2_tablet_tool {
struct wl_listener tool_destroy; struct wl_listener tool_destroy;
struct wlr_tablet_tool_client_v2 *current_client; struct wlr_tablet_tool_client_v2 *current_client;
struct wlr_surface *focused_surface; struct wlr_surface_2 *focused_surface;
struct wl_listener surface_destroy; struct wl_listener surface_destroy;
struct wlr_tablet_tool_v2_grab *grab; struct wlr_tablet_tool_v2_grab *grab;
@ -112,7 +113,7 @@ struct wlr_tablet_v2_tablet_pad {
}; };
struct wlr_tablet_v2_event_cursor { struct wlr_tablet_v2_event_cursor {
struct wlr_surface *surface; struct wlr_surface_2 *surface;
uint32_t serial; uint32_t serial;
int32_t hotspot_x; int32_t hotspot_x;
int32_t hotspot_y; int32_t hotspot_y;
@ -146,7 +147,7 @@ void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);
void wlr_send_tablet_v2_tablet_tool_proximity_in( void wlr_send_tablet_v2_tablet_tool_proximity_in(
struct wlr_tablet_v2_tablet_tool *tool, struct wlr_tablet_v2_tablet_tool *tool,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void wlr_send_tablet_v2_tablet_tool_down(struct wlr_tablet_v2_tablet_tool *tool); void wlr_send_tablet_v2_tablet_tool_down(struct wlr_tablet_v2_tablet_tool *tool);
void wlr_send_tablet_v2_tablet_tool_up(struct wlr_tablet_v2_tablet_tool *tool); void wlr_send_tablet_v2_tablet_tool_up(struct wlr_tablet_v2_tablet_tool *tool);
@ -184,7 +185,7 @@ void wlr_send_tablet_v2_tablet_tool_button(
void wlr_tablet_v2_tablet_tool_notify_proximity_in( void wlr_tablet_v2_tablet_tool_notify_proximity_in(
struct wlr_tablet_v2_tablet_tool *tool, struct wlr_tablet_v2_tablet_tool *tool,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void wlr_tablet_v2_tablet_tool_notify_down(struct wlr_tablet_v2_tablet_tool *tool); void wlr_tablet_v2_tablet_tool_notify_down(struct wlr_tablet_v2_tablet_tool *tool);
void wlr_tablet_v2_tablet_tool_notify_up(struct wlr_tablet_v2_tablet_tool *tool); void wlr_tablet_v2_tablet_tool_notify_up(struct wlr_tablet_v2_tablet_tool *tool);
@ -222,7 +223,7 @@ struct wlr_tablet_tool_v2_grab_interface {
void (*proximity_in)( void (*proximity_in)(
struct wlr_tablet_tool_v2_grab *grab, struct wlr_tablet_tool_v2_grab *grab,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void (*down)(struct wlr_tablet_tool_v2_grab *grab); void (*down)(struct wlr_tablet_tool_v2_grab *grab);
void (*up)(struct wlr_tablet_tool_v2_grab *grab); void (*up)(struct wlr_tablet_tool_v2_grab *grab);
@ -258,7 +259,7 @@ void wlr_tablet_tool_v2_start_implicit_grab(struct wlr_tablet_v2_tablet_tool *to
uint32_t wlr_send_tablet_v2_tablet_pad_enter( uint32_t wlr_send_tablet_v2_tablet_pad_enter(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void wlr_send_tablet_v2_tablet_pad_button( void wlr_send_tablet_v2_tablet_pad_button(
struct wlr_tablet_v2_tablet_pad *pad, size_t button, struct wlr_tablet_v2_tablet_pad *pad, size_t button,
@ -270,7 +271,7 @@ void wlr_send_tablet_v2_tablet_pad_ring(struct wlr_tablet_v2_tablet_pad *pad,
uint32_t ring, double position, bool finger, uint32_t time); uint32_t ring, double position, bool finger, uint32_t time);
uint32_t wlr_send_tablet_v2_tablet_pad_leave(struct wlr_tablet_v2_tablet_pad *pad, uint32_t wlr_send_tablet_v2_tablet_pad_leave(struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
uint32_t wlr_send_tablet_v2_tablet_pad_mode(struct wlr_tablet_v2_tablet_pad *pad, uint32_t wlr_send_tablet_v2_tablet_pad_mode(struct wlr_tablet_v2_tablet_pad *pad,
size_t group, uint32_t mode, uint32_t time); size_t group, uint32_t mode, uint32_t time);
@ -279,7 +280,7 @@ uint32_t wlr_send_tablet_v2_tablet_pad_mode(struct wlr_tablet_v2_tablet_pad *pad
uint32_t wlr_tablet_v2_tablet_pad_notify_enter( uint32_t wlr_tablet_v2_tablet_pad_notify_enter(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void wlr_tablet_v2_tablet_pad_notify_button( void wlr_tablet_v2_tablet_pad_notify_button(
struct wlr_tablet_v2_tablet_pad *pad, size_t button, struct wlr_tablet_v2_tablet_pad *pad, size_t button,
@ -293,7 +294,7 @@ void wlr_tablet_v2_tablet_pad_notify_ring(
uint32_t ring, double position, bool finger, uint32_t time); uint32_t ring, double position, bool finger, uint32_t time);
uint32_t wlr_tablet_v2_tablet_pad_notify_leave( uint32_t wlr_tablet_v2_tablet_pad_notify_leave(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_surface *surface); struct wlr_tablet_v2_tablet_pad *pad, struct wlr_surface_2 *surface);
uint32_t wlr_tablet_v2_tablet_pad_notify_mode( uint32_t wlr_tablet_v2_tablet_pad_notify_mode(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_v2_tablet_pad *pad,
@ -303,7 +304,7 @@ struct wlr_tablet_pad_v2_grab_interface {
uint32_t (*enter)( uint32_t (*enter)(
struct wlr_tablet_pad_v2_grab *grab, struct wlr_tablet_pad_v2_grab *grab,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
void (*button)(struct wlr_tablet_pad_v2_grab *grab,size_t button, void (*button)(struct wlr_tablet_pad_v2_grab *grab,size_t button,
uint32_t time, enum zwp_tablet_pad_v2_button_state state); uint32_t time, enum zwp_tablet_pad_v2_button_state state);
@ -314,7 +315,7 @@ struct wlr_tablet_pad_v2_grab_interface {
uint32_t ring, double position, bool finger, uint32_t time); uint32_t ring, double position, bool finger, uint32_t time);
uint32_t (*leave)(struct wlr_tablet_pad_v2_grab *grab, uint32_t (*leave)(struct wlr_tablet_pad_v2_grab *grab,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
uint32_t (*mode)(struct wlr_tablet_pad_v2_grab *grab, uint32_t (*mode)(struct wlr_tablet_pad_v2_grab *grab,
size_t group, uint32_t mode, uint32_t time); size_t group, uint32_t mode, uint32_t time);
@ -326,5 +327,5 @@ void wlr_tablet_v2_end_grab(struct wlr_tablet_v2_tablet_pad *pad);
void wlr_tablet_v2_start_grab(struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_pad_v2_grab *grab); void wlr_tablet_v2_start_grab(struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_pad_v2_grab *grab);
bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet, bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface); struct wlr_surface_2 *surface);
#endif /* WLR_TYPES_WLR_TABLET_V2_H */ #endif /* WLR_TYPES_WLR_TABLET_V2_H */

View file

@ -6,6 +6,7 @@
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_data_device.h" #include "types/wlr_data_device.h"
#include "util/signal.h" #include "util/signal.h"
@ -55,18 +56,19 @@ static void data_device_start_drag(struct wl_client *client,
return; return;
} }
struct wlr_surface *origin = wlr_surface_from_resource(origin_resource); struct wlr_surface_2 *origin = wlr_surface_from_resource_2(origin_resource);
struct wlr_client_data_source *source = NULL; struct wlr_client_data_source *source = NULL;
if (source_resource != NULL) { if (source_resource != NULL) {
source = client_data_source_from_resource(source_resource); source = client_data_source_from_resource(source_resource);
} }
struct wlr_surface *icon = NULL; struct wlr_surface_2 *icon = NULL;
if (icon_resource) { if (icon_resource) {
icon = wlr_surface_from_resource(icon_resource); icon = wlr_surface_from_resource_2(icon_resource);
if (!wlr_surface_set_role(icon, &drag_icon_surface_role, NULL, if (!wlr_surface_set_role_2(icon, "wl_data_device")) {
icon_resource, WL_DATA_DEVICE_ERROR_ROLE)) { wl_resource_post_error(icon_resource, WL_DATA_DEVICE_ERROR_ROLE,
"surface already has role");
return; return;
} }
} }

View file

@ -5,6 +5,7 @@
#include <unistd.h> #include <unistd.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_data_device.h" #include "types/wlr_data_device.h"
@ -20,7 +21,7 @@ static void drag_handle_seat_client_destroy(struct wl_listener *listener,
} }
static void drag_set_focus(struct wlr_drag *drag, static void drag_set_focus(struct wlr_drag *drag,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
if (drag->focus == surface) { if (drag->focus == surface) {
return; return;
} }
@ -154,7 +155,7 @@ static void drag_destroy(struct wlr_drag *drag) {
} }
static void drag_handle_pointer_enter(struct wlr_seat_pointer_grab *grab, static void drag_handle_pointer_enter(struct wlr_seat_pointer_grab *grab,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
struct wlr_drag *drag = grab->data; struct wlr_drag *drag = grab->data;
drag_set_focus(drag, surface, sx, sy); drag_set_focus(drag, surface, sx, sy);
} }
@ -298,7 +299,7 @@ static const struct wlr_touch_grab_interface
}; };
static void drag_handle_keyboard_enter(struct wlr_seat_keyboard_grab *grab, static void drag_handle_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers) { struct wlr_keyboard_modifiers *modifiers) {
// nothing has keyboard focus during drags // nothing has keyboard focus during drags
} }
@ -347,10 +348,25 @@ static void drag_icon_destroy(struct wlr_drag_icon *icon) {
drag_icon_set_mapped(icon, false); drag_icon_set_mapped(icon, false);
wlr_signal_emit_safe(&icon->events.destroy, icon); wlr_signal_emit_safe(&icon->events.destroy, icon);
icon->surface->role_data = NULL; icon->surface->role_data = NULL;
wl_list_remove(&icon->surface_commit.link);
wl_list_remove(&icon->surface_destroy.link); wl_list_remove(&icon->surface_destroy.link);
free(icon); free(icon);
} }
static void drag_icon_handle_surface_commit(struct wl_listener *listener,
void *data) {
struct wlr_drag_icon *icon =
wl_container_of(listener, icon, surface_commit);
struct wlr_commit *commit = wlr_surface_get_commit(icon->surface);
bool has_buffer = commit->buffer;
wlr_commit_unref(commit);
if (has_buffer) {
drag_icon_set_mapped(icon, true);
}
}
static void drag_icon_handle_surface_destroy(struct wl_listener *listener, static void drag_icon_handle_surface_destroy(struct wl_listener *listener,
void *data) { void *data) {
struct wlr_drag_icon *icon = struct wlr_drag_icon *icon =
@ -358,23 +374,8 @@ static void drag_icon_handle_surface_destroy(struct wl_listener *listener,
drag_icon_destroy(icon); drag_icon_destroy(icon);
} }
static void drag_icon_surface_role_commit(struct wlr_surface *surface) {
assert(surface->role == &drag_icon_surface_role);
struct wlr_drag_icon *icon = surface->role_data;
if (icon == NULL) {
return;
}
drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
}
const struct wlr_surface_role drag_icon_surface_role = {
.name = "wl_data_device-icon",
.commit = drag_icon_surface_role_commit,
};
static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag, static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
struct wlr_drag_icon *icon = calloc(1, sizeof(struct wlr_drag_icon)); struct wlr_drag_icon *icon = calloc(1, sizeof(struct wlr_drag_icon));
if (!icon) { if (!icon) {
return NULL; return NULL;
@ -387,13 +388,21 @@ static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
wl_signal_init(&icon->events.unmap); wl_signal_init(&icon->events.unmap);
wl_signal_init(&icon->events.destroy); wl_signal_init(&icon->events.destroy);
wl_signal_add(&icon->surface->events.commit, &icon->surface_commit);
icon->surface_commit.notify = drag_icon_handle_surface_commit;
wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy); wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
icon->surface_destroy.notify = drag_icon_handle_surface_destroy; icon->surface_destroy.notify = drag_icon_handle_surface_destroy;
icon->surface->role_data = icon; icon->surface->role_data = icon;
if (wlr_surface_has_buffer(surface)) { struct wlr_commit *commit = wlr_surface_get_commit(icon->surface);
drag_icon_set_mapped(icon, true); if (commit) {
bool has_buffer = commit->buffer;
wlr_commit_unref(commit);
if (has_buffer) {
drag_icon_set_mapped(icon, true);
}
} }
return icon; return icon;
@ -401,7 +410,7 @@ static struct wlr_drag_icon *drag_icon_create(struct wlr_drag *drag,
struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client, struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client,
struct wlr_data_source *source, struct wlr_surface *icon_surface) { struct wlr_data_source *source, struct wlr_surface_2 *icon_surface) {
struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag)); struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag));
if (drag == NULL) { if (drag == NULL) {
return NULL; return NULL;
@ -447,7 +456,7 @@ struct wlr_drag *wlr_drag_create(struct wlr_seat_client *seat_client,
} }
void wlr_seat_request_start_drag(struct wlr_seat *seat, struct wlr_drag *drag, void wlr_seat_request_start_drag(struct wlr_seat *seat, struct wlr_drag *drag,
struct wlr_surface *origin, uint32_t serial) { struct wlr_surface_2 *origin, uint32_t serial) {
assert(drag->seat == seat); assert(drag->seat == seat);
if (seat->drag != NULL) { if (seat->drag != NULL) {

View file

@ -1,18 +1,18 @@
lib_wlr_types = static_library( lib_wlr_types = static_library(
'wlr_types', 'wlr_types',
files( files(
#'data_device/wlr_data_device.c', 'data_device/wlr_data_device.c',
#'data_device/wlr_data_offer.c', 'data_device/wlr_data_offer.c',
#'data_device/wlr_data_source.c', 'data_device/wlr_data_source.c',
#'data_device/wlr_drag.c', 'data_device/wlr_drag.c',
#'seat/wlr_seat_keyboard.c', 'seat/wlr_seat_keyboard.c',
#'seat/wlr_seat_pointer.c', 'seat/wlr_seat_pointer.c',
#'seat/wlr_seat_touch.c', 'seat/wlr_seat_touch.c',
#'seat/wlr_seat.c', 'seat/wlr_seat.c',
#'tablet_v2/wlr_tablet_v2_pad.c', 'tablet_v2/wlr_tablet_v2_pad.c',
#'tablet_v2/wlr_tablet_v2_tablet.c', 'tablet_v2/wlr_tablet_v2_tablet.c',
#'tablet_v2/wlr_tablet_v2_tool.c', 'tablet_v2/wlr_tablet_v2_tool.c',
#'tablet_v2/wlr_tablet_v2.c', 'tablet_v2/wlr_tablet_v2.c',
#'xdg_shell_v6/wlr_xdg_popup_v6.c', #'xdg_shell_v6/wlr_xdg_popup_v6.c',
#'xdg_shell_v6/wlr_xdg_positioner_v6.c', #'xdg_shell_v6/wlr_xdg_positioner_v6.c',
#'xdg_shell_v6/wlr_xdg_shell_v6.c', #'xdg_shell_v6/wlr_xdg_shell_v6.c',
@ -27,18 +27,18 @@ lib_wlr_types = static_library(
'wlr_compositor.c', 'wlr_compositor.c',
'wlr_subcompositor.c', 'wlr_subcompositor.c',
#'wlr_cursor.c', #'wlr_cursor.c',
#'wlr_data_control_v1.c', 'wlr_data_control_v1.c',
#'wlr_export_dmabuf_v1.c', #'wlr_export_dmabuf_v1.c',
#'wlr_foreign_toplevel_management_v1.c', #'wlr_foreign_toplevel_management_v1.c',
#'wlr_fullscreen_shell_v1.c', #'wlr_fullscreen_shell_v1.c',
#'wlr_gamma_control_v1.c', #'wlr_gamma_control_v1.c',
#'wlr_gamma_control.c', #'wlr_gamma_control.c',
#'wlr_gtk_primary_selection.c', 'wlr_gtk_primary_selection.c',
#'wlr_idle_inhibit_v1.c', #'wlr_idle_inhibit_v1.c',
#'wlr_idle.c', 'wlr_idle.c',
#'wlr_input_device.c', 'wlr_input_device.c',
#'wlr_input_inhibitor.c', 'wlr_input_inhibitor.c',
#'wlr_input_method_v2.c', 'wlr_input_method_v2.c',
'wlr_keyboard.c', 'wlr_keyboard.c',
#'wlr_layer_shell_v1.c', #'wlr_layer_shell_v1.c',
'wlr_linux_dmabuf_v1.c', 'wlr_linux_dmabuf_v1.c',
@ -49,22 +49,22 @@ lib_wlr_types = static_library(
'wlr_output_management_v1.c', 'wlr_output_management_v1.c',
#'wlr_output.c', #'wlr_output.c',
#'wlr_pointer_constraints_v1.c', #'wlr_pointer_constraints_v1.c',
#'wlr_pointer_gestures_v1.c', 'wlr_pointer_gestures_v1.c',
'wlr_pointer.c', 'wlr_pointer.c',
#'wlr_presentation_time.c', #'wlr_presentation_time.c',
#'wlr_primary_selection_v1.c', 'wlr_primary_selection_v1.c',
#'wlr_primary_selection.c', 'wlr_primary_selection.c',
#'wlr_relative_pointer_v1.c', 'wlr_relative_pointer_v1.c',
#'wlr_screencopy_v1.c', #'wlr_screencopy_v1.c',
#'wlr_screenshooter.c', #'wlr_screenshooter.c',
#'wlr_server_decoration.c', #'wlr_server_decoration.c',
#'wlr_surface.c', #'wlr_surface.c',
'wlr_switch.c', 'wlr_switch.c',
'wlr_tablet_pad.c', 'wlr_tablet_pad.c',
#'wlr_tablet_tool.c', 'wlr_tablet_tool.c',
#'wlr_text_input_v3.c', 'wlr_text_input_v3.c',
'wlr_touch.c', 'wlr_touch.c',
#'wlr_virtual_keyboard_v1.c', 'wlr_virtual_keyboard_v1.c',
#'wlr_xcursor_manager.c', #'wlr_xcursor_manager.c',
#'wlr_xdg_decoration_v1.c', #'wlr_xdg_decoration_v1.c',
#'wlr_xdg_output_v1.c', #'wlr_xdg_output_v1.c',

View file

@ -9,6 +9,7 @@
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_gtk_primary_selection.h> #include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_data_device.h" #include "types/wlr_data_device.h"
#include "types/wlr_seat.h" #include "types/wlr_seat.h"
@ -16,7 +17,7 @@
#include "util/signal.h" #include "util/signal.h"
static void default_keyboard_enter(struct wlr_seat_keyboard_grab *grab, static void default_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers) { struct wlr_keyboard_modifiers *modifiers) {
wlr_seat_keyboard_enter(grab->seat, surface, keycodes, num_keycodes, modifiers); wlr_seat_keyboard_enter(grab->seat, surface, keycodes, num_keycodes, modifiers);
} }
@ -219,7 +220,7 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
} }
void wlr_seat_keyboard_enter(struct wlr_seat *seat, void wlr_seat_keyboard_enter(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers) { struct wlr_keyboard_modifiers *modifiers) {
if (seat->keyboard_state.focused_surface == surface) { if (seat->keyboard_state.focused_surface == surface) {
// this surface already got an enter notify // this surface already got an enter notify
@ -235,7 +236,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
struct wlr_seat_client *focused_client = struct wlr_seat_client *focused_client =
seat->keyboard_state.focused_client; seat->keyboard_state.focused_client;
struct wlr_surface *focused_surface = struct wlr_surface_2 *focused_surface =
seat->keyboard_state.focused_surface; seat->keyboard_state.focused_surface;
// leave the previously entered surface // leave the previously entered surface
@ -304,7 +305,7 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
} }
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes, struct wlr_surface_2 *surface, uint32_t keycodes[], size_t num_keycodes,
struct wlr_keyboard_modifiers *modifiers) { struct wlr_keyboard_modifiers *modifiers) {
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab; struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
grab->interface->enter(grab, surface, keycodes, num_keycodes, modifiers); grab->interface->enter(grab, surface, keycodes, num_keycodes, modifiers);

View file

@ -5,12 +5,13 @@
#include <time.h> #include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_seat.h" #include "types/wlr_seat.h"
#include "util/signal.h" #include "util/signal.h"
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab, static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
wlr_seat_pointer_enter(grab->seat, surface, sx, sy); wlr_seat_pointer_enter(grab->seat, surface, sx, sy);
} }
@ -65,10 +66,6 @@ struct wlr_seat_client *wlr_seat_client_from_pointer_resource(
return wl_resource_get_user_data(resource); return wl_resource_get_user_data(resource);
} }
static const struct wlr_surface_role pointer_cursor_surface_role = {
.name = "wl_pointer-cursor",
};
static void pointer_set_cursor(struct wl_client *client, static void pointer_set_cursor(struct wl_client *client,
struct wl_resource *pointer_resource, uint32_t serial, struct wl_resource *pointer_resource, uint32_t serial,
struct wl_resource *surface_resource, struct wl_resource *surface_resource,
@ -79,11 +76,12 @@ static void pointer_set_cursor(struct wl_client *client,
return; return;
} }
struct wlr_surface *surface = NULL; struct wlr_surface_2 *surface = NULL;
if (surface_resource != NULL) { if (surface_resource != NULL) {
surface = wlr_surface_from_resource(surface_resource); surface = wlr_surface_from_resource_2(surface_resource);
if (!wlr_surface_set_role(surface, &pointer_cursor_surface_role, NULL, if (!wlr_surface_set_role_2(surface, "wl_pointer")) {
surface_resource, WL_POINTER_ERROR_ROLE)) { wl_resource_post_error(surface_resource, WL_POINTER_ERROR_ROLE,
"surface already has role");
return; return;
} }
} }
@ -115,7 +113,7 @@ static void pointer_handle_resource_destroy(struct wl_resource *resource) {
bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat, bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
return surface == wlr_seat->pointer_state.focused_surface; return surface == wlr_seat->pointer_state.focused_surface;
} }
@ -129,7 +127,7 @@ static void seat_pointer_handle_surface_destroy(struct wl_listener *listener,
} }
void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
if (wlr_seat->pointer_state.focused_surface == surface) { if (wlr_seat->pointer_state.focused_surface == surface) {
// this surface already got an enter notify // this surface already got an enter notify
return; return;
@ -143,7 +141,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat,
struct wlr_seat_client *focused_client = struct wlr_seat_client *focused_client =
wlr_seat->pointer_state.focused_client; wlr_seat->pointer_state.focused_client;
struct wlr_surface *focused_surface = struct wlr_surface_2 *focused_surface =
wlr_seat->pointer_state.focused_surface; wlr_seat->pointer_state.focused_surface;
// leave the previously entered surface // leave the previously entered surface
@ -324,7 +322,7 @@ void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat) {
} }
void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat, void wlr_seat_pointer_notify_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab; struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab;
grab->interface->enter(grab, surface, sx, sy); grab->interface->enter(grab, surface, sx, sy);
} }
@ -409,7 +407,7 @@ void seat_client_destroy_pointer(struct wl_resource *resource) {
} }
bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat, bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial) { struct wlr_surface_2 *origin, uint32_t serial) {
if (seat->pointer_state.button_count != 1 || if (seat->pointer_state.button_count != 1 ||
seat->pointer_state.grab_serial != serial) { seat->pointer_state.grab_serial != serial) {
wlr_log(WLR_DEBUG, "Pointer grab serial validation failed: " wlr_log(WLR_DEBUG, "Pointer grab serial validation failed: "

View file

@ -5,6 +5,7 @@
#include <time.h> #include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "types/wlr_seat.h" #include "types/wlr_seat.h"
#include "util/signal.h" #include "util/signal.h"
@ -114,7 +115,7 @@ static void touch_point_handle_surface_destroy(struct wl_listener *listener,
static struct wlr_touch_point *touch_point_create( static struct wlr_touch_point *touch_point_create(
struct wlr_seat *seat, int32_t touch_id, struct wlr_seat *seat, int32_t touch_id,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
struct wl_client *wl_client = wl_resource_get_client(surface->resource); struct wl_client *wl_client = wl_resource_get_client(surface->resource);
struct wlr_seat_client *client = struct wlr_seat_client *client =
wlr_seat_client_for_wl_client(seat, wl_client); wlr_seat_client_for_wl_client(seat, wl_client);
@ -159,7 +160,7 @@ struct wlr_touch_point *wlr_seat_touch_get_point(
} }
uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, struct wlr_surface_2 *surface, uint32_t time, int32_t touch_id, double sx,
double sy) { double sy) {
clock_gettime(CLOCK_MONOTONIC, &seat->last_event); clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
struct wlr_seat_touch_grab *grab = seat->touch_state.grab; struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
@ -217,7 +218,7 @@ static void handle_point_focus_destroy(struct wl_listener *listener,
} }
static void touch_point_set_focus(struct wlr_touch_point *point, static void touch_point_set_focus(struct wlr_touch_point *point,
struct wlr_surface *surface, double sx, double sy) { struct wlr_surface_2 *surface, double sx, double sy) {
if (point->focus_surface == surface) { if (point->focus_surface == surface) {
return; return;
} }
@ -241,7 +242,7 @@ static void touch_point_set_focus(struct wlr_touch_point *point,
} }
void wlr_seat_touch_point_focus(struct wlr_seat *seat, void wlr_seat_touch_point_focus(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, struct wlr_surface_2 *surface, uint32_t time, int32_t touch_id, double sx,
double sy) { double sy) {
assert(surface); assert(surface);
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id); struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
@ -249,7 +250,7 @@ void wlr_seat_touch_point_focus(struct wlr_seat *seat,
wlr_log(WLR_ERROR, "got touch point focus for unknown touch point"); wlr_log(WLR_ERROR, "got touch point focus for unknown touch point");
return; return;
} }
struct wlr_surface *focus = point->focus_surface; struct wlr_surface_2 *focus = point->focus_surface;
touch_point_set_focus(point, surface, sx, sy); touch_point_set_focus(point, surface, sx, sy);
if (focus != point->focus_surface) { if (focus != point->focus_surface) {
@ -270,7 +271,7 @@ void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time,
} }
uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat,
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, struct wlr_surface_2 *surface, uint32_t time, int32_t touch_id, double sx,
double sy) { double sy) {
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id); struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
if (!point) { if (!point) {
@ -361,7 +362,7 @@ void seat_client_destroy_touch(struct wl_resource *resource) {
} }
bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat, bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial, struct wlr_surface_2 *origin, uint32_t serial,
struct wlr_touch_point **point_ptr) { struct wlr_touch_point **point_ptr) {
if (wlr_seat_touch_num_points(seat) != 1 || if (wlr_seat_touch_num_points(seat) != 1 ||
seat->touch_state.grab_serial != serial) { seat->touch_state.grab_serial != serial) {

View file

@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <types/wlr_tablet_v2.h> #include <types/wlr_tablet_v2.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
@ -413,7 +414,7 @@ struct wlr_tablet_pad_client_v2 *tablet_pad_client_from_resource(struct wl_resou
uint32_t wlr_send_tablet_v2_tablet_pad_enter( uint32_t wlr_send_tablet_v2_tablet_pad_enter(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
struct wl_client *client = wl_resource_get_client(surface->resource); struct wl_client *client = wl_resource_get_client(surface->resource);
struct wlr_tablet_client_v2 *tablet_tmp; struct wlr_tablet_client_v2 *tablet_tmp;
@ -520,7 +521,7 @@ void wlr_send_tablet_v2_tablet_pad_ring(struct wlr_tablet_v2_tablet_pad *pad,
} }
uint32_t wlr_send_tablet_v2_tablet_pad_leave(struct wlr_tablet_v2_tablet_pad *pad, uint32_t wlr_send_tablet_v2_tablet_pad_leave(struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
struct wl_client *client = wl_resource_get_client(surface->resource); struct wl_client *client = wl_resource_get_client(surface->resource);
if (!pad->current_client || client != pad->current_client->client) { if (!pad->current_client || client != pad->current_client->client) {
return 0; return 0;
@ -555,7 +556,7 @@ uint32_t wlr_send_tablet_v2_tablet_pad_mode(struct wlr_tablet_v2_tablet_pad *pad
} }
bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet, bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
struct wl_client *client = wl_resource_get_client(surface->resource); struct wl_client *client = wl_resource_get_client(surface->resource);
if (tablet->current_client && if (tablet->current_client &&
@ -577,7 +578,7 @@ bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet,
uint32_t wlr_tablet_v2_tablet_pad_notify_enter( uint32_t wlr_tablet_v2_tablet_pad_notify_enter(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
if (pad->grab && pad->grab->interface->enter) { if (pad->grab && pad->grab->interface->enter) {
return pad->grab->interface->enter(pad->grab, tablet, surface); return pad->grab->interface->enter(pad->grab, tablet, surface);
} }
@ -610,7 +611,7 @@ void wlr_tablet_v2_tablet_pad_notify_ring(
} }
uint32_t wlr_tablet_v2_tablet_pad_notify_leave( uint32_t wlr_tablet_v2_tablet_pad_notify_leave(
struct wlr_tablet_v2_tablet_pad *pad, struct wlr_surface *surface) { struct wlr_tablet_v2_tablet_pad *pad, struct wlr_surface_2 *surface) {
if (pad->grab && pad->grab->interface->leave) { if (pad->grab && pad->grab->interface->leave) {
return pad->grab->interface->leave(pad->grab, surface); return pad->grab->interface->leave(pad->grab, surface);
} }
@ -653,7 +654,7 @@ void wlr_tablet_v2_end_grab(struct wlr_tablet_v2_tablet_pad *pad) {
static uint32_t default_pad_enter( static uint32_t default_pad_enter(
struct wlr_tablet_pad_v2_grab *grab, struct wlr_tablet_pad_v2_grab *grab,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
return wlr_send_tablet_v2_tablet_pad_enter(grab->pad, tablet, surface); return wlr_send_tablet_v2_tablet_pad_enter(grab->pad, tablet, surface);
} }
@ -673,7 +674,7 @@ static void default_pad_ring(struct wlr_tablet_pad_v2_grab *grab,
} }
static uint32_t default_pad_leave(struct wlr_tablet_pad_v2_grab *grab, static uint32_t default_pad_leave(struct wlr_tablet_pad_v2_grab *grab,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
return wlr_send_tablet_v2_tablet_pad_leave(grab->pad, surface); return wlr_send_tablet_v2_tablet_pad_leave(grab->pad, surface);
} }

View file

@ -8,16 +8,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <types/wlr_tablet_v2.h> #include <types/wlr_tablet_v2.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
static const struct wlr_tablet_tool_v2_grab_interface default_tool_grab_interface; static const struct wlr_tablet_tool_v2_grab_interface default_tool_grab_interface;
static const struct wlr_surface_role tablet_tool_cursor_surface_role = {
.name = "wp_tablet_tool-cursor",
};
static void handle_tablet_tool_v2_set_cursor(struct wl_client *client, static void handle_tablet_tool_v2_set_cursor(struct wl_client *client,
struct wl_resource *resource, uint32_t serial, struct wl_resource *resource, uint32_t serial,
struct wl_resource *surface_resource, struct wl_resource *surface_resource,
@ -27,11 +24,13 @@ static void handle_tablet_tool_v2_set_cursor(struct wl_client *client,
return; return;
} }
struct wlr_surface *surface = NULL; struct wlr_surface_2 *surface = NULL;
if (surface_resource != NULL) { if (surface_resource != NULL) {
surface = wlr_surface_from_resource(surface_resource); surface = wlr_surface_from_resource_2(surface_resource);
if (!wlr_surface_set_role(surface, &tablet_tool_cursor_surface_role, NULL, if (!wlr_surface_set_role_2(surface, "wp_tablet_tool")) {
surface_resource, ZWP_TABLET_TOOL_V2_ERROR_ROLE)) { wl_resource_post_error(surface_resource,
ZWP_TABLET_TOOL_V2_ERROR_ROLE,
"surface already has role");
return; return;
} }
} }
@ -307,7 +306,7 @@ static void queue_tool_frame(struct wlr_tablet_tool_client_v2 *tool) {
void wlr_send_tablet_v2_tablet_tool_proximity_in( void wlr_send_tablet_v2_tablet_tool_proximity_in(
struct wlr_tablet_v2_tablet_tool *tool, struct wlr_tablet_v2_tablet_tool *tool,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
struct wl_client *client = wl_resource_get_client(surface->resource); struct wl_client *client = wl_resource_get_client(surface->resource);
if (tool->focused_surface == surface) { if (tool->focused_surface == surface) {
@ -525,7 +524,7 @@ void wlr_send_tablet_v2_tablet_tool_up(struct wlr_tablet_v2_tablet_tool *tool) {
void wlr_tablet_v2_tablet_tool_notify_proximity_in( void wlr_tablet_v2_tablet_tool_notify_proximity_in(
struct wlr_tablet_v2_tablet_tool *tool, struct wlr_tablet_v2_tablet_tool *tool,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
if (tool->grab->interface->proximity_in) { if (tool->grab->interface->proximity_in) {
tool->grab->interface->proximity_in(tool->grab, tablet, surface); tool->grab->interface->proximity_in(tool->grab, tablet, surface);
} }
@ -623,7 +622,7 @@ void wlr_tablet_tool_v2_end_grab(struct wlr_tablet_v2_tablet_tool *tool) {
static void default_tool_proximity_in( static void default_tool_proximity_in(
struct wlr_tablet_tool_v2_grab *grab, struct wlr_tablet_tool_v2_grab *grab,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
wlr_send_tablet_v2_tablet_tool_proximity_in(grab->tool, tablet, surface); wlr_send_tablet_v2_tablet_tool_proximity_in(grab->tool, tablet, surface);
} }
@ -701,10 +700,10 @@ static const struct wlr_tablet_tool_v2_grab_interface
}; };
struct implicit_grab_state { struct implicit_grab_state {
struct wlr_surface *original; struct wlr_surface_2 *original;
bool released; bool released;
struct wlr_surface *focused; struct wlr_surface_2 *focused;
struct wlr_tablet_v2_tablet *tablet; struct wlr_tablet_v2_tablet *tablet;
}; };
@ -735,7 +734,7 @@ static void check_and_release_implicit_grab(struct wlr_tablet_tool_v2_grab *grab
static void implicit_tool_proximity_in( static void implicit_tool_proximity_in(
struct wlr_tablet_tool_v2_grab *grab, struct wlr_tablet_tool_v2_grab *grab,
struct wlr_tablet_v2_tablet *tablet, struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface) { struct wlr_surface_2 *surface) {
/* As long as we got an implicit grab, proximity won't change /* As long as we got an implicit grab, proximity won't change
* But should track the currently focused surface to change to it when * But should track the currently focused surface to change to it when

View file

@ -5,6 +5,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_pointer.h> #include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_pointer_gestures_v1.h> #include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
@ -47,7 +48,7 @@ void wlr_pointer_gestures_v1_send_swipe_begin(
struct wlr_seat *seat, struct wlr_seat *seat,
uint32_t time_msec, uint32_t time_msec,
uint32_t fingers) { uint32_t fingers) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }
@ -74,7 +75,7 @@ void wlr_pointer_gestures_v1_send_swipe_update(
uint32_t time_msec, uint32_t time_msec,
double dx, double dx,
double dy) { double dy) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }
@ -98,7 +99,7 @@ void wlr_pointer_gestures_v1_send_swipe_end(
struct wlr_seat *seat, struct wlr_seat *seat,
uint32_t time_msec, uint32_t time_msec,
bool cancelled) { bool cancelled) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }
@ -159,7 +160,7 @@ void wlr_pointer_gestures_v1_send_pinch_begin(
struct wlr_seat *seat, struct wlr_seat *seat,
uint32_t time_msec, uint32_t time_msec,
uint32_t fingers) { uint32_t fingers) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }
@ -188,7 +189,7 @@ void wlr_pointer_gestures_v1_send_pinch_update(
double dy, double dy,
double scale, double scale,
double rotation) { double rotation) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }
@ -214,7 +215,7 @@ void wlr_pointer_gestures_v1_send_pinch_end(
struct wlr_seat *seat, struct wlr_seat *seat,
uint32_t time_msec, uint32_t time_msec,
bool cancelled) { bool cancelled) {
struct wlr_surface *focus = seat->pointer_state.focused_surface; struct wlr_surface_2 *focus = seat->pointer_state.focused_surface;
if (focus == NULL) { if (focus == NULL) {
return; return;
} }