aboutsummaryrefslogtreecommitdiff
path: root/include/sway/input
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/input')
-rw-r--r--include/sway/input/cursor.h37
-rw-r--r--include/sway/input/input-manager.h10
-rw-r--r--include/sway/input/seat.h88
3 files changed, 105 insertions, 30 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 50ac453b..77aa0ea1 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -1,10 +1,17 @@
#ifndef _SWAY_INPUT_CURSOR_H
#define _SWAY_INPUT_CURSOR_H
+#include <stdbool.h>
#include <stdint.h>
+#include <wlr/types/wlr_surface.h>
#include "sway/input/seat.h"
#define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32
+#define SWAY_SCROLL_UP KEY_MAX + 1
+#define SWAY_SCROLL_DOWN KEY_MAX + 2
+#define SWAY_SCROLL_LEFT KEY_MAX + 3
+#define SWAY_SCROLL_RIGHT KEY_MAX + 4
+
struct sway_cursor {
struct sway_seat *seat;
struct wlr_cursor *cursor;
@@ -16,6 +23,8 @@ struct sway_cursor {
const char *image;
struct wl_client *image_client;
+ struct wlr_surface *image_surface;
+ int hotspot_x, hotspot_y;
struct wl_listener motion;
struct wl_listener motion_absolute;
@@ -33,11 +42,20 @@ struct sway_cursor {
struct wl_listener request_set_cursor;
+ struct wl_event_source *hide_source;
+ bool hidden;
+
// Mouse binding state
uint32_t pressed_buttons[SWAY_CURSOR_PRESSED_BUTTONS_CAP];
size_t pressed_button_count;
};
+struct sway_node;
+
+struct sway_node *node_at_coords(
+ struct sway_seat *seat, double lx, double ly,
+ struct wlr_surface **surface, double *sx, double *sy);
+
void sway_cursor_destroy(struct sway_cursor *cursor);
struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
@@ -48,6 +66,10 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat);
*/
void cursor_rebase(struct sway_cursor *cursor);
+void cursor_handle_activity(struct sway_cursor *cursor);
+void cursor_unhide(struct sway_cursor *cursor);
+int cursor_get_timeout(struct sway_cursor *cursor);
+
/**
* Like cursor_rebase, but also allows focus to change when the cursor enters a
* new container.
@@ -58,12 +80,27 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
struct wlr_input_device *device, uint32_t time_msec, uint32_t button,
enum wlr_button_state state);
+void dispatch_cursor_axis(struct sway_cursor *cursor,
+ struct wlr_event_pointer_axis *event);
+
void cursor_set_image(struct sway_cursor *cursor, const char *image,
struct wl_client *client);
+void cursor_set_image_surface(struct sway_cursor *cursor,
+ struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y,
+ struct wl_client *client);
+
void cursor_warp_to_container(struct sway_cursor *cursor,
struct sway_container *container);
void cursor_warp_to_workspace(struct sway_cursor *cursor,
struct sway_workspace *workspace);
+
+uint32_t get_mouse_bindsym(const char *name, char **error);
+
+uint32_t get_mouse_bindcode(const char *name, char **error);
+
+// Considers both bindsym and bindcode
+uint32_t get_mouse_button(const char *name, char **error);
+
#endif
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h
index 219aa9ba..8e8bf1f2 100644
--- a/include/sway/input/input-manager.h
+++ b/include/sway/input/input-manager.h
@@ -37,6 +37,10 @@ void input_manager_configure_xcursor(void);
void input_manager_apply_input_config(struct input_config *input_config);
+void input_manager_reset_input(struct sway_input_device *input_device);
+
+void input_manager_reset_all_inputs();
+
void input_manager_apply_seat_config(struct seat_config *seat_config);
struct sway_seat *input_manager_get_default_seat(void);
@@ -44,6 +48,12 @@ struct sway_seat *input_manager_get_default_seat(void);
struct sway_seat *input_manager_get_seat(const char *seat_name);
/**
+ * If none of the seat configs have a fallback setting (either true or false),
+ * create the default seat (if needed) and set it as the fallback
+ */
+void input_manager_verify_fallback_seat(void);
+
+/**
* Gets the last seat the user interacted with
*/
struct sway_seat *input_manager_current_seat(void);
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index bef2af77..d2f14895 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -6,6 +6,17 @@
#include <wlr/util/edges.h>
#include "sway/input/input-manager.h"
+struct sway_seat;
+
+struct sway_seatop_impl {
+ void (*motion)(struct sway_seat *seat, uint32_t time_msec);
+ void (*finish)(struct sway_seat *seat);
+ void (*abort)(struct sway_seat *seat);
+ void (*unref)(struct sway_seat *seat, struct sway_container *con);
+ void (*render)(struct sway_seat *seat, struct sway_output *output,
+ pixman_region32_t *damage);
+};
+
struct sway_seat_device {
struct sway_seat *sway_seat;
struct sway_input_device *input_device;
@@ -35,15 +46,6 @@ struct sway_drag_icon {
struct wl_listener destroy;
};
-enum sway_seat_operation {
- OP_NONE,
- OP_DOWN,
- OP_MOVE_FLOATING,
- OP_MOVE_TILING,
- OP_RESIZE_FLOATING,
- OP_RESIZE_TILING,
-};
-
struct sway_seat {
struct wlr_seat *wlr_seat;
struct sway_cursor *cursor;
@@ -63,19 +65,10 @@ struct sway_seat {
int32_t touch_id;
double touch_x, touch_y;
- // Operations (drag and resize)
- enum sway_seat_operation operation;
- struct sway_container *op_container;
- struct sway_node *op_target_node; // target for tiling move
- enum wlr_edges op_target_edge;
- struct wlr_box op_drop_box;
- enum wlr_edges op_resize_edge;
- uint32_t op_button;
- bool op_resize_preserve_ratio;
- double op_ref_lx, op_ref_ly; // cursor's x/y at start of op
- double op_ref_width, op_ref_height; // container's size at start of op
- double op_ref_con_lx, op_ref_con_ly; // container's x/y at start of op
- bool op_moved; // if the mouse moved during a down op
+ // Seat operations (drag and resize)
+ const struct sway_seatop_impl *seatop_impl;
+ void *seatop_data;
+ uint32_t seatop_button;
uint32_t last_button;
uint32_t last_button_serial;
@@ -99,6 +92,9 @@ void seat_add_device(struct sway_seat *seat,
void seat_configure_device(struct sway_seat *seat,
struct sway_input_device *device);
+void seat_reset_device(struct sway_seat *seat,
+ struct sway_input_device *input_device);
+
void seat_remove_device(struct sway_seat *seat,
struct sway_input_device *device);
@@ -174,33 +170,65 @@ void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config);
struct seat_config *seat_get_config(struct sway_seat *seat);
+struct seat_config *seat_get_config_by_name(const char *name);
+
bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface);
void drag_icon_update_position(struct sway_drag_icon *icon);
-void seat_begin_down(struct sway_seat *seat, struct sway_container *con,
- uint32_t button, double sx, double sy);
+void seatop_begin_down(struct sway_seat *seat,
+ struct sway_container *con, uint32_t button, int sx, int sy);
-void seat_begin_move_floating(struct sway_seat *seat,
+void seatop_begin_move_floating(struct sway_seat *seat,
struct sway_container *con, uint32_t button);
-void seat_begin_move_tiling(struct sway_seat *seat,
+void seatop_begin_move_tiling_threshold(struct sway_seat *seat,
struct sway_container *con, uint32_t button);
-void seat_begin_resize_floating(struct sway_seat *seat,
+void seatop_begin_move_tiling(struct sway_seat *seat,
+ struct sway_container *con, uint32_t button);
+
+void seatop_begin_resize_floating(struct sway_seat *seat,
struct sway_container *con, uint32_t button, enum wlr_edges edge);
-void seat_begin_resize_tiling(struct sway_seat *seat,
+void seatop_begin_resize_tiling(struct sway_seat *seat,
struct sway_container *con, uint32_t button, enum wlr_edges edge);
struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat,
struct sway_workspace *workspace);
-void seat_end_mouse_operation(struct sway_seat *seat);
-
void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec,
uint32_t button, enum wlr_button_state state);
void seat_consider_warp_to_focus(struct sway_seat *seat);
+bool seat_doing_seatop(struct sway_seat *seat);
+
+void seatop_motion(struct sway_seat *seat, uint32_t time_msec);
+
+/**
+ * End a seatop and apply the affects.
+ */
+void seatop_finish(struct sway_seat *seat);
+
+/**
+ * End a seatop without applying the affects.
+ */
+void seatop_abort(struct sway_seat *seat);
+
+/**
+ * Instructs the seatop implementation to drop any references to the given
+ * container (eg. because the container is destroying).
+ * The seatop may choose to abort itself in response to this.
+ */
+void seatop_unref(struct sway_seat *seat, struct sway_container *con);
+
+/**
+ * Instructs a seatop to render anything that it needs to render
+ * (eg. dropzone for move-tiling)
+ */
+void seatop_render(struct sway_seat *seat, struct sway_output *output,
+ pixman_region32_t *damage);
+
+
#endif