diff options
Diffstat (limited to 'include/rootston')
-rw-r--r-- | include/rootston/cursor.h | 41 | ||||
-rw-r--r-- | include/rootston/desktop.h | 8 | ||||
-rw-r--r-- | include/rootston/input.h | 2 | ||||
-rw-r--r-- | include/rootston/output.h | 4 | ||||
-rw-r--r-- | include/rootston/seat.h | 12 | ||||
-rw-r--r-- | include/rootston/text_input.h | 63 |
6 files changed, 117 insertions, 13 deletions
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index 2c687a39..b5bb682f 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -1,6 +1,7 @@ #ifndef ROOTSTON_CURSOR_H #define ROOTSTON_CURSOR_H +#include <wlr/types/wlr_pointer_constraints_v1.h> #include "rootston/seat.h" enum roots_cursor_mode { @@ -14,6 +15,9 @@ struct roots_cursor { struct roots_seat *seat; struct wlr_cursor *cursor; + struct wlr_pointer_constraint_v1 *active_constraint; + pixman_region32_t confine; // invalid if active_constraint == NULL + const char *default_xcursor; enum roots_cursor_mode mode; @@ -28,6 +32,7 @@ struct roots_cursor { uint32_t resize_edges; struct roots_seat_view *pointer_view; + struct wlr_surface *wlr_surface; struct wl_listener motion; struct wl_listener motion_absolute; @@ -44,6 +49,10 @@ struct roots_cursor { struct wl_listener tool_button; struct wl_listener request_set_cursor; + + struct wl_listener focus_change; + + struct wl_listener constraint_commit; }; struct roots_cursor *roots_cursor_create(struct roots_seat *seat); @@ -51,36 +60,46 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat); void roots_cursor_destroy(struct roots_cursor *cursor); void roots_cursor_handle_motion(struct roots_cursor *cursor, - struct wlr_event_pointer_motion *event); + struct wlr_event_pointer_motion *event); void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, - struct wlr_event_pointer_motion_absolute *event); + struct wlr_event_pointer_motion_absolute *event); void roots_cursor_handle_button(struct roots_cursor *cursor, - struct wlr_event_pointer_button *event); + struct wlr_event_pointer_button *event); void roots_cursor_handle_axis(struct roots_cursor *cursor, - struct wlr_event_pointer_axis *event); + struct wlr_event_pointer_axis *event); void roots_cursor_handle_touch_down(struct roots_cursor *cursor, - struct wlr_event_touch_down *event); + struct wlr_event_touch_down *event); void roots_cursor_handle_touch_up(struct roots_cursor *cursor, - struct wlr_event_touch_up *event); + struct wlr_event_touch_up *event); void roots_cursor_handle_touch_motion(struct roots_cursor *cursor, - struct wlr_event_touch_motion *event); + struct wlr_event_touch_motion *event); void roots_cursor_handle_tool_axis(struct roots_cursor *cursor, - struct wlr_event_tablet_tool_axis *event); + struct wlr_event_tablet_tool_axis *event); void roots_cursor_handle_tool_tip(struct roots_cursor *cursor, - struct wlr_event_tablet_tool_tip *event); + struct wlr_event_tablet_tool_tip *event); void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor, - struct wlr_seat_pointer_request_set_cursor_event *event); + struct wlr_seat_pointer_request_set_cursor_event *event); + +void roots_cursor_handle_focus_change(struct roots_cursor *cursor, + struct wlr_seat_pointer_focus_change_event *event); + +void roots_cursor_handle_constraint_commit(struct roots_cursor *cursor); void roots_cursor_update_position(struct roots_cursor *cursor, - uint32_t time); + uint32_t time); + +void roots_cursor_update_focus(struct roots_cursor *cursor); + +void roots_cursor_constrain(struct roots_cursor *cursor, + struct wlr_pointer_constraint_v1 *constraint, double sx, double sy); #endif diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 89d8af4a..345c9c09 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -9,13 +9,16 @@ #include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_input_inhibitor.h> +#include <wlr/types/wlr_input_method_v2.h> #include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_list.h> #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output.h> +#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_screencopy_v1.h> #include <wlr/types/wlr_screenshooter.h> +#include <wlr/types/wlr_text_input_v3.h> #include <wlr/types/wlr_virtual_keyboard_v1.h> #include <wlr/types/wlr_wl_shell.h> #include <wlr/types/wlr_xcursor_manager.h> @@ -53,9 +56,13 @@ struct roots_desktop { struct wlr_idle_inhibit_manager_v1 *idle_inhibit; struct wlr_input_inhibit_manager *input_inhibit; struct wlr_layer_shell_v1 *layer_shell; + struct wlr_input_method_manager_v2 *input_method; + struct wlr_text_input_manager_v3 *text_input; struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_screencopy_manager_v1 *screencopy; struct wlr_tablet_manager_v2 *tablet_v2; + struct wlr_pointer_constraints_v1 *pointer_constraints; + struct wlr_presentation *presentation; struct wl_listener new_output; struct wl_listener layout_change; @@ -67,6 +74,7 @@ struct roots_desktop { struct wl_listener input_inhibit_activate; struct wl_listener input_inhibit_deactivate; struct wl_listener virtual_keyboard_new; + struct wl_listener pointer_constraint; #ifdef WLR_HAS_XWAYLAND struct wlr_xwayland *xwayland; diff --git a/include/rootston/input.h b/include/rootston/input.h index 2cdb13e6..31810b4d 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -16,7 +16,7 @@ struct roots_input { struct wl_listener new_input; - struct wl_list seats; + struct wl_list seats; // roots_seat::link }; struct roots_input *input_create(struct roots_server *server, diff --git a/include/rootston/output.h b/include/rootston/output.h index f78ee81d..3f07ab6f 100644 --- a/include/rootston/output.h +++ b/include/rootston/output.h @@ -24,10 +24,14 @@ struct roots_output { struct wl_listener destroy; struct wl_listener mode; struct wl_listener transform; + struct wl_listener present; struct wl_listener damage_frame; struct wl_listener damage_destroy; }; +void rotate_child_position(double *sx, double *sy, double sw, double sh, + double pw, double ph, float rotation); + void handle_new_output(struct wl_listener *listener, void *data); struct roots_view; diff --git a/include/rootston/seat.h b/include/rootston/seat.h index c5e584b6..0187c6cc 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -5,12 +5,13 @@ #include "rootston/input.h" #include "rootston/keyboard.h" #include "rootston/layers.h" +#include "rootston/text_input.h" struct roots_seat { struct roots_input *input; struct wlr_seat *seat; struct roots_cursor *cursor; - struct wl_list link; + struct wl_list link; // roots_input::seats // coordinates of the first touch point if it exists int32_t touch_id; @@ -19,6 +20,8 @@ struct roots_seat { // If the focused layer is set, views cannot receive keyboard focus struct wlr_layer_surface_v1 *focused_layer; + struct roots_input_method_relay im_relay; + // If non-null, only this client can receive input events struct wl_client *exclusive_client; @@ -114,6 +117,7 @@ struct roots_tablet_tool { struct wlr_tablet_v2_tablet_tool *tablet_v2_tool; struct roots_seat *seat; + double tilt_x, tilt_y; struct wl_listener set_cursor; struct wl_listener tool_destroy; @@ -122,6 +126,12 @@ struct roots_tablet_tool { struct wl_listener tablet_destroy; }; +struct roots_pointer_constraint { + struct wlr_pointer_constraint_v1 *constraint; + + struct wl_listener destroy; +}; + struct roots_seat *roots_seat_create(struct roots_input *input, char *name); void roots_seat_destroy(struct roots_seat *seat); diff --git a/include/rootston/text_input.h b/include/rootston/text_input.h new file mode 100644 index 00000000..82e45e3e --- /dev/null +++ b/include/rootston/text_input.h @@ -0,0 +1,63 @@ +#ifndef ROOTSTON_TEXT_INPUT_H +#define ROOTSTON_TEXT_INPUT_H + +#include <wlr/types/wlr_text_input_v3.h> +#include <wlr/types/wlr_input_method_v2.h> +#include <wlr/types/wlr_surface.h> +#include "rootston/seat.h" + +/** + * The relay structure manages the relationship between text-input and + * input_method interfaces on a given seat. Multiple text-input interfaces may + * be bound to a relay, but at most one will be focused (reveiving events) at + * a time. At most one input-method interface may be bound to the seat. The + * relay manages life cycle of both sides. When both sides are present and + * focused, the relay passes messages between them. + * + * Text input focus is a subset of keyboard focus - if the text-input is + * in the focused state, wl_keyboard sent an enter as well. However, having + * wl_keyboard focused doesn't mean that text-input will be focused. + */ +struct roots_input_method_relay { + struct roots_seat *seat; + + struct wl_list text_inputs; // roots_text_input::link + struct wlr_input_method_v2 *input_method; // doesn't have to be present + + struct wl_listener text_input_new; + struct wl_listener text_input_enable; + struct wl_listener text_input_commit; + struct wl_listener text_input_disable; + struct wl_listener text_input_destroy; + + struct wl_listener input_method_new; + struct wl_listener input_method_commit; + struct wl_listener input_method_destroy; +}; + +struct roots_text_input { + struct roots_input_method_relay *relay; + + struct wlr_text_input_v3 *input; + // The surface getting seat's focus. Stored for when text-input cannot + // be sent an enter event immediately after getting focus, e.g. when + // there's no input method available. Cleared once text-input is entered. + struct wlr_surface *pending_focused_surface; + + struct wl_list link; + + struct wl_listener pending_focused_surface_destroy; +}; + +void roots_input_method_relay_init(struct roots_seat *seat, + struct roots_input_method_relay *relay); + +// Updates currently focused surface. Surface must belong to the same seat. +void roots_input_method_relay_set_focus(struct roots_input_method_relay *relay, + struct wlr_surface *surface); + +struct roots_text_input *roots_text_input_create( + struct roots_input_method_relay *relay, + struct wlr_text_input_v3 *text_input); + +#endif |