diff options
author | emersion <contact@emersion.fr> | 2017-11-19 22:28:51 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-11-19 22:28:51 +0100 |
commit | 7904b625f0c6a8cef684d60ba136de1ba48e848e (patch) | |
tree | 3d7001509a6229e1b17a0f4c26960e720857c8a9 /include | |
parent | 7375931686e6a58c08a7727ce2f5d88e0be9adfa (diff) | |
parent | fae8d6289a470b8abcf36a5f4b0030ef504caf0b (diff) |
Merge branch 'master' into laggy-move-resize
Diffstat (limited to 'include')
-rw-r--r-- | include/rootston/config.h | 28 | ||||
-rw-r--r-- | include/rootston/cursor.h | 10 | ||||
-rw-r--r-- | include/rootston/desktop.h | 1 | ||||
-rw-r--r-- | include/rootston/seat.h | 24 | ||||
-rw-r--r-- | include/wlr/types/wlr_cursor.h | 7 | ||||
-rw-r--r-- | include/wlr/types/wlr_data_device.h | 36 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 180 | ||||
-rw-r--r-- | include/wlr/types/wlr_touch.h | 8 |
8 files changed, 246 insertions, 48 deletions
diff --git a/include/rootston/config.h b/include/rootston/config.h index 71ee61c7..de20fb8e 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -3,6 +3,8 @@ #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_input_device.h> +#define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0" + struct roots_output_config { char *name; enum wl_output_transform transform; @@ -17,9 +19,9 @@ struct roots_output_config { struct roots_device_config { char *name; + char *seat; char *mapped_output; struct wlr_box *mapped_box; - char *seat; struct wl_list link; }; @@ -33,6 +35,7 @@ struct roots_binding_config { struct roots_keyboard_config { char *name; + char *seat; uint32_t meta_key; char *rules; char *model; @@ -42,18 +45,22 @@ struct roots_keyboard_config { struct wl_list link; }; +struct roots_cursor_config { + char *seat; + char *mapped_output; + struct wlr_box *mapped_box; + char *theme; + struct wl_list link; +}; + struct roots_config { bool xwayland; - struct { - char *mapped_output; - struct wlr_box *mapped_box; - } cursor; - struct wl_list outputs; struct wl_list devices; struct wl_list bindings; struct wl_list keyboards; + struct wl_list cursors; char *config_path; char *startup_cmd; }; @@ -89,6 +96,13 @@ struct roots_device_config *roots_config_get_device(struct roots_config *config, * returns NULL. A NULL device returns the default config for keyboards. */ struct roots_keyboard_config *roots_config_get_keyboard( - struct roots_config *config, struct wlr_input_device *device); + struct roots_config *config, struct wlr_input_device *device); + +/** + * Get configuration for the cursor. If the cursor is not configured, returns + * NULL. A NULL seat_name returns the default config for cursors. + */ +struct roots_cursor_config *roots_config_get_cursor(struct roots_config *config, + const char *seat_name); #endif diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index f49b6439..e2a371bf 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -39,7 +39,6 @@ struct roots_cursor { uint32_t resize_edges; // Ring buffer of input events that could trigger move/resize/rotate int input_events_idx; - struct wl_list touch_points; struct roots_input_event input_events[16]; struct wl_listener motion; @@ -54,9 +53,6 @@ struct roots_cursor { struct wl_listener tool_axis; struct wl_listener tool_tip; - struct wl_listener pointer_grab_begin; - struct wl_listener pointer_grab_end; - struct wl_listener request_set_cursor; }; @@ -94,10 +90,4 @@ void roots_cursor_handle_tool_tip(struct roots_cursor *cursor, void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor, struct wlr_seat_pointer_request_set_cursor_event *event); -void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor, - struct wlr_seat_pointer_grab *grab); - -void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor, - struct wlr_seat_pointer_grab *grab); - #endif diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index b809db43..10e5bbc6 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -50,6 +50,7 @@ struct roots_desktop { #ifdef HAS_XWAYLAND struct wlr_xwayland *xwayland; struct wl_listener xwayland_surface; + struct wl_listener xwayland_ready; #endif }; diff --git a/include/rootston/seat.h b/include/rootston/seat.h index bef515a4..dad8bbc4 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -4,24 +4,15 @@ #include "rootston/input.h" #include "rootston/keyboard.h" -struct roots_drag_icon { - struct wlr_surface *surface; - struct wl_list link; // roots_seat::drag_icons - bool mapped; - - int32_t sx; - int32_t sy; - - struct wl_listener surface_destroy; - struct wl_listener surface_commit; -}; - struct roots_seat { struct roots_input *input; struct wlr_seat *seat; struct roots_cursor *cursor; struct wl_list link; - struct wl_list drag_icons; + + // coordinates of the first touch point if it exists + int32_t touch_id; + double touch_x, touch_y; struct roots_view *focus; @@ -43,13 +34,6 @@ struct roots_touch { struct wl_list link; }; -struct roots_touch_point { - struct roots_touch *device; - int32_t slot; - double x, y; - struct wl_list link; -}; - struct roots_tablet_tool { struct roots_seat *seat; struct wlr_input_device *device; diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 0db32eb2..c73a4c8d 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -126,4 +126,11 @@ void wlr_cursor_map_to_region(struct wlr_cursor *cur, struct wlr_box *box); void wlr_cursor_map_input_to_region(struct wlr_cursor *cur, struct wlr_input_device *dev, struct wlr_box *box); +/** + * Convert absolute coordinates to layout coordinates for the device. + */ +bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur, + struct wlr_input_device *device, double x_mm, double y_mm, + double width_mm, double height_mm, double *lx, double *ly); + #endif diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h index f45c15a2..12b25e45 100644 --- a/include/wlr/types/wlr_data_device.h +++ b/include/wlr/types/wlr_data_device.h @@ -10,6 +10,9 @@ wlr_pointer_grab_interface wlr_data_device_pointer_drag_interface; extern const struct wlr_keyboard_grab_interface wlr_data_device_keyboard_drag_interface; +extern const struct +wlr_touch_grab_interface wlr_data_device_touch_drag_interface; + struct wlr_data_device_manager { struct wl_global *global; }; @@ -50,22 +53,49 @@ struct wlr_data_source { } events; }; +struct wlr_drag_icon { + struct wlr_surface *surface; + struct wlr_seat_client *client; + struct wl_list link; // wlr_seat::drag_icons + bool mapped; + + bool is_pointer; + int32_t touch_id; + + int32_t sx; + int32_t sy; + + struct { + struct wl_signal destroy; + } events; + + struct wl_listener surface_destroy; + struct wl_listener surface_commit; + struct wl_listener seat_client_destroy; +}; + struct wlr_drag { struct wlr_seat_pointer_grab pointer_grab; struct wlr_seat_keyboard_grab keyboard_grab; + struct wlr_seat_touch_grab touch_grab; + struct wlr_seat *seat; struct wlr_seat_client *seat_client; struct wlr_seat_client *focus_client; - struct wlr_surface *icon; + bool is_pointer_grab; + + struct wlr_drag_icon *icon; struct wlr_surface *focus; struct wlr_data_source *source; bool cancelling; + int32_t grab_touch_id; - struct wl_listener icon_destroy; + struct wl_listener point_destroy; struct wl_listener source_destroy; - struct wl_listener seat_client_unbound; + struct wl_listener seat_client_destroy; + struct wl_listener icon_destroy; }; /** diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index a5f00402..6d59315b 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -21,6 +21,30 @@ struct wlr_seat_client { struct wl_resource *touch; struct wl_resource *data_device; + struct { + struct wl_signal destroy; + } events; + + struct wl_list link; +}; + +struct wlr_touch_point { + int32_t touch_id; + struct wlr_surface *surface; + struct wlr_seat_client *client; + + struct wlr_surface *focus_surface; + struct wlr_seat_client *focus_client; + double sx, sy; + + struct wl_listener surface_destroy; + struct wl_listener focus_surface_destroy; + struct wl_listener resource_destroy; + + struct { + struct wl_signal destroy; + } events; + struct wl_list link; }; @@ -49,6 +73,32 @@ struct wlr_keyboard_grab_interface { void (*cancel)(struct wlr_seat_keyboard_grab *grab); }; +struct wlr_seat_touch_grab; + +struct wlr_touch_grab_interface { + uint32_t (*down)(struct wlr_seat_touch_grab *grab, uint32_t time, + struct wlr_touch_point *point); + void (*up)(struct wlr_seat_touch_grab *grab, uint32_t time, + struct wlr_touch_point *point); + void (*motion)(struct wlr_seat_touch_grab *grab, uint32_t time, + struct wlr_touch_point *point); + void (*enter)(struct wlr_seat_touch_grab *grab, uint32_t time, + struct wlr_touch_point *point); + // XXX this will conflict with the actual touch cancel which is different so + // we need to rename this + void (*cancel)(struct wlr_seat_touch_grab *grab); +}; + +/** + * Passed to `wlr_seat_touch_start_grab()` to start a grab of the touch device. + * The grabber is responsible for handling touch events for the seat. + */ +struct wlr_seat_touch_grab { + const struct wlr_touch_grab_interface *interface; + struct wlr_seat *seat; + void *data; +}; + /** * Passed to `wlr_seat_keyboard_start_grab()` to start a grab of the keyboard. * The grabber is responsible for handling keyboard events for the seat. @@ -86,6 +136,7 @@ struct wlr_seat_pointer_state { struct wl_listener resource_destroy; }; +// TODO: May be useful to be able to simulate keyboard input events struct wlr_seat_keyboard_state { struct wlr_seat *seat; struct wlr_keyboard *keyboard; @@ -103,10 +154,23 @@ struct wlr_seat_keyboard_state { struct wlr_seat_keyboard_grab *default_grab; }; +struct wlr_seat_touch_state { + struct wlr_seat *seat; + struct wl_list touch_points; // wlr_touch_point::link + + uint32_t grab_serial; + uint32_t grab_id; + + struct wlr_seat_touch_grab *grab; + struct wlr_seat_touch_grab *default_grab; +}; + struct wlr_seat { struct wl_global *wl_global; struct wl_display *display; struct wl_list clients; + struct wl_list drag_icons; // wlr_drag_icon::link + char *name; uint32_t capabilities; struct timespec last_event; @@ -117,19 +181,20 @@ struct wlr_seat { struct wlr_seat_pointer_state pointer_state; struct wlr_seat_keyboard_state keyboard_state; + struct wlr_seat_touch_state touch_state; struct wl_listener selection_data_source_destroy; struct { - struct wl_signal client_bound; - struct wl_signal client_unbound; - struct wl_signal pointer_grab_begin; struct wl_signal pointer_grab_end; struct wl_signal keyboard_grab_begin; struct wl_signal keyboard_grab_end; + struct wl_signal touch_grab_begin; + struct wl_signal touch_grab_end; + struct wl_signal request_set_cursor; struct wl_signal selection; @@ -260,6 +325,11 @@ void wlr_seat_pointer_notify_axis(struct wlr_seat *wlr_seat, uint32_t time, enum wlr_axis_orientation orientation, double value); /** + * Whether or not the pointer has a grab other than the default grab. + */ +bool wlr_seat_pointer_has_grab(struct wlr_seat *seat); + +/** * Set this keyboard as the active keyboard for the seat. */ void wlr_seat_set_keyboard(struct wlr_seat *seat, struct wlr_input_device *dev); @@ -326,6 +396,108 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, */ void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat); -// TODO: May be useful to be able to simulate keyboard input events +/** + * Whether or not the keyboard has a grab other than the default grab + */ +bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat); + +/** + * Start a grab of the touch device of this seat. The grabber is responsible for + * handling all touch events until the grab ends. + */ +void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat, + struct wlr_seat_touch_grab *grab); + +/** + * End the grab of the touch device of this seat. This reverts the grab back to + * the default grab for the touch device. + */ +void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat); + +/** + * Get the active touch point with the given `touch_id`. If the touch point does + * not exist or is no longer active, returns NULL. + */ +struct wlr_touch_point *wlr_seat_touch_get_point(struct wlr_seat *seat, + int32_t touch_id); + +/** + * Notify the seat of a touch down on the given surface. Defers to any grab of + * the touch device. + */ +uint32_t wlr_seat_touch_notify_down(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, + double sy); + +/** + * Notify the seat that the touch point given by `touch_id` is up. Defers to any + * grab of the touch device. + */ +void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time, + int32_t touch_id); + +/** + * Notify the seat that the touch point given by `touch_id` has moved. Defers to + * any grab of the touch device. The seat should be notified of touch motion + * even if the surface is not the owner of the touch point for processing by + * grabs. + */ +void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time, + int32_t touch_id, double sx, double sy); + +/** + * Notify the seat that the touch point given by `touch_id` has entered a new + * surface. The surface is required. To clear focus, use + * `wlr_seat_touch_point_clear_focus()`. + */ +void wlr_seat_touch_point_focus(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, + double sy); + +/** + * Clear the focused surface for the touch point given by `touch_id`. + */ +void wlr_seat_touch_point_clear_focus(struct wlr_seat *seat, uint32_t time, + int32_t touch_id); + +/** + * Send a touch down event to the client of the given surface. All future touch + * events for this point will go to this surface. If the touch down is valid, + * this will add a new touch point with the given `touch_id`. The touch down may + * not be valid if the surface seat client does not accept touch input. + * Coordinates are surface-local. Compositors should use + * `wlr_seat_touch_notify_down()` to respect any grabs of the touch device. + */ +uint32_t wlr_seat_touch_send_down(struct wlr_seat *seat, + struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx, + double sy); + +/** + * Send a touch up event for the touch point given by the `touch_id`. The event + * will go to the client for the surface given in the cooresponding touch down + * event. This will remove the touch point. Compositors should use + * `wlr_seat_touch_notify_up()` to respect any grabs of the touch device. + */ +void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, + int32_t touch_id); + +/** + * Send a touch motion event for the touch point given by the `touch_id`. The + * event will go to the client for the surface given in the corresponding touch + * down event. Compositors should use `wlr_seat_touch_notify_motion()` to + * respect any grabs of the touch device. + */ +void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, + int32_t touch_id, double sx, double sy); + +/** + * How many touch points are currently down for the seat. + */ +int wlr_seat_touch_num_points(struct wlr_seat *seat); + +/** + * Whether or not the seat has a touch grab other than the default grab. + */ +bool wlr_seat_touch_has_grab(struct wlr_seat *seat); #endif diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index 072e25fd..2925fd01 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -22,7 +22,7 @@ struct wlr_touch { struct wlr_event_touch_down { struct wlr_input_device *device; uint32_t time_msec; - int32_t slot; + int32_t touch_id; double x_mm, y_mm; double width_mm, height_mm; }; @@ -30,13 +30,13 @@ struct wlr_event_touch_down { struct wlr_event_touch_up { struct wlr_input_device *device; uint32_t time_msec; - int32_t slot; + int32_t touch_id; }; struct wlr_event_touch_motion { struct wlr_input_device *device; uint32_t time_msec; - int32_t slot; + int32_t touch_id; double x_mm, y_mm; double width_mm, height_mm; }; @@ -44,7 +44,7 @@ struct wlr_event_touch_motion { struct wlr_event_touch_cancel { struct wlr_input_device *device; uint32_t time_msec; - int32_t slot; + int32_t touch_id; }; #endif |