diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-01-13 20:38:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-13 20:38:34 -0500 |
commit | 23ab56bbf746e7aa4a940caa343d447a969fa37e (patch) | |
tree | 087201fd4d39c3a551c925c4f5479311e10e6623 /include | |
parent | Merge pull request #3388 from RedSoxFan/reset-inputs-on-reload (diff) | |
parent | Refactor seat operations to use an interface (diff) | |
download | sway-23ab56bbf746e7aa4a940caa343d447a969fa37e.tar.gz sway-23ab56bbf746e7aa4a940caa343d447a969fa37e.tar.zst sway-23ab56bbf746e7aa4a940caa343d447a969fa37e.zip |
Merge pull request #3402 from RyanDwyer/refactor-seatops
Refactor seat operations to use an interface
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/input/cursor.h | 6 | ||||
-rw-r--r-- | include/sway/input/seat.h | 83 | ||||
-rw-r--r-- | include/sway/output.h | 8 | ||||
-rw-r--r-- | include/sway/tree/container.h | 2 |
4 files changed, 67 insertions, 32 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 4636bf6b..9f699dcd 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -50,6 +50,12 @@ struct sway_cursor { | |||
50 | size_t pressed_button_count; | 50 | size_t pressed_button_count; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | struct sway_node; | ||
54 | |||
55 | struct sway_node *node_at_coords( | ||
56 | struct sway_seat *seat, double lx, double ly, | ||
57 | struct wlr_surface **surface, double *sx, double *sy); | ||
58 | |||
53 | void sway_cursor_destroy(struct sway_cursor *cursor); | 59 | void sway_cursor_destroy(struct sway_cursor *cursor); |
54 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | 60 | struct sway_cursor *sway_cursor_create(struct sway_seat *seat); |
55 | 61 | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index c10b48b1..d2f14895 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -6,6 +6,17 @@ | |||
6 | #include <wlr/util/edges.h> | 6 | #include <wlr/util/edges.h> |
7 | #include "sway/input/input-manager.h" | 7 | #include "sway/input/input-manager.h" |
8 | 8 | ||
9 | struct sway_seat; | ||
10 | |||
11 | struct sway_seatop_impl { | ||
12 | void (*motion)(struct sway_seat *seat, uint32_t time_msec); | ||
13 | void (*finish)(struct sway_seat *seat); | ||
14 | void (*abort)(struct sway_seat *seat); | ||
15 | void (*unref)(struct sway_seat *seat, struct sway_container *con); | ||
16 | void (*render)(struct sway_seat *seat, struct sway_output *output, | ||
17 | pixman_region32_t *damage); | ||
18 | }; | ||
19 | |||
9 | struct sway_seat_device { | 20 | struct sway_seat_device { |
10 | struct sway_seat *sway_seat; | 21 | struct sway_seat *sway_seat; |
11 | struct sway_input_device *input_device; | 22 | struct sway_input_device *input_device; |
@@ -35,16 +46,6 @@ struct sway_drag_icon { | |||
35 | struct wl_listener destroy; | 46 | struct wl_listener destroy; |
36 | }; | 47 | }; |
37 | 48 | ||
38 | enum sway_seat_operation { | ||
39 | OP_NONE, | ||
40 | OP_DOWN, | ||
41 | OP_MOVE_FLOATING, | ||
42 | OP_MOVE_TILING_THRESHOLD, | ||
43 | OP_MOVE_TILING, | ||
44 | OP_RESIZE_FLOATING, | ||
45 | OP_RESIZE_TILING, | ||
46 | }; | ||
47 | |||
48 | struct sway_seat { | 49 | struct sway_seat { |
49 | struct wlr_seat *wlr_seat; | 50 | struct wlr_seat *wlr_seat; |
50 | struct sway_cursor *cursor; | 51 | struct sway_cursor *cursor; |
@@ -64,19 +65,10 @@ struct sway_seat { | |||
64 | int32_t touch_id; | 65 | int32_t touch_id; |
65 | double touch_x, touch_y; | 66 | double touch_x, touch_y; |
66 | 67 | ||
67 | // Operations (drag and resize) | 68 | // Seat operations (drag and resize) |
68 | enum sway_seat_operation operation; | 69 | const struct sway_seatop_impl *seatop_impl; |
69 | struct sway_container *op_container; | 70 | void *seatop_data; |
70 | struct sway_node *op_target_node; // target for tiling move | 71 | uint32_t seatop_button; |
71 | enum wlr_edges op_target_edge; | ||
72 | struct wlr_box op_drop_box; | ||
73 | enum wlr_edges op_resize_edge; | ||
74 | uint32_t op_button; | ||
75 | bool op_resize_preserve_ratio; | ||
76 | double op_ref_lx, op_ref_ly; // cursor's x/y at start of op | ||
77 | double op_ref_width, op_ref_height; // container's size at start of op | ||
78 | double op_ref_con_lx, op_ref_con_ly; // container's x/y at start of op | ||
79 | bool op_moved; // if the mouse moved during a down op | ||
80 | 72 | ||
81 | uint32_t last_button; | 73 | uint32_t last_button; |
82 | uint32_t last_button_serial; | 74 | uint32_t last_button_serial; |
@@ -184,32 +176,59 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | |||
184 | 176 | ||
185 | void drag_icon_update_position(struct sway_drag_icon *icon); | 177 | void drag_icon_update_position(struct sway_drag_icon *icon); |
186 | 178 | ||
187 | void seat_begin_down(struct sway_seat *seat, struct sway_container *con, | 179 | void seatop_begin_down(struct sway_seat *seat, |
188 | uint32_t button, double sx, double sy); | 180 | struct sway_container *con, uint32_t button, int sx, int sy); |
189 | 181 | ||
190 | void seat_begin_move_floating(struct sway_seat *seat, | 182 | void seatop_begin_move_floating(struct sway_seat *seat, |
191 | struct sway_container *con, uint32_t button); | 183 | struct sway_container *con, uint32_t button); |
192 | 184 | ||
193 | void seat_begin_move_tiling_threshold(struct sway_seat *seat, | 185 | void seatop_begin_move_tiling_threshold(struct sway_seat *seat, |
194 | struct sway_container *con, uint32_t button); | 186 | struct sway_container *con, uint32_t button); |
195 | 187 | ||
196 | void seat_begin_move_tiling(struct sway_seat *seat, | 188 | void seatop_begin_move_tiling(struct sway_seat *seat, |
197 | struct sway_container *con, uint32_t button); | 189 | struct sway_container *con, uint32_t button); |
198 | 190 | ||
199 | void seat_begin_resize_floating(struct sway_seat *seat, | 191 | void seatop_begin_resize_floating(struct sway_seat *seat, |
200 | struct sway_container *con, uint32_t button, enum wlr_edges edge); | 192 | struct sway_container *con, uint32_t button, enum wlr_edges edge); |
201 | 193 | ||
202 | void seat_begin_resize_tiling(struct sway_seat *seat, | 194 | void seatop_begin_resize_tiling(struct sway_seat *seat, |
203 | struct sway_container *con, uint32_t button, enum wlr_edges edge); | 195 | struct sway_container *con, uint32_t button, enum wlr_edges edge); |
204 | 196 | ||
205 | struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, | 197 | struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, |
206 | struct sway_workspace *workspace); | 198 | struct sway_workspace *workspace); |
207 | 199 | ||
208 | void seat_end_mouse_operation(struct sway_seat *seat); | ||
209 | |||
210 | void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, | 200 | void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, |
211 | uint32_t button, enum wlr_button_state state); | 201 | uint32_t button, enum wlr_button_state state); |
212 | 202 | ||
213 | void seat_consider_warp_to_focus(struct sway_seat *seat); | 203 | void seat_consider_warp_to_focus(struct sway_seat *seat); |
214 | 204 | ||
205 | bool seat_doing_seatop(struct sway_seat *seat); | ||
206 | |||
207 | void seatop_motion(struct sway_seat *seat, uint32_t time_msec); | ||
208 | |||
209 | /** | ||
210 | * End a seatop and apply the affects. | ||
211 | */ | ||
212 | void seatop_finish(struct sway_seat *seat); | ||
213 | |||
214 | /** | ||
215 | * End a seatop without applying the affects. | ||
216 | */ | ||
217 | void seatop_abort(struct sway_seat *seat); | ||
218 | |||
219 | /** | ||
220 | * Instructs the seatop implementation to drop any references to the given | ||
221 | * container (eg. because the container is destroying). | ||
222 | * The seatop may choose to abort itself in response to this. | ||
223 | */ | ||
224 | void seatop_unref(struct sway_seat *seat, struct sway_container *con); | ||
225 | |||
226 | /** | ||
227 | * Instructs a seatop to render anything that it needs to render | ||
228 | * (eg. dropzone for move-tiling) | ||
229 | */ | ||
230 | void seatop_render(struct sway_seat *seat, struct sway_output *output, | ||
231 | pixman_region32_t *damage); | ||
232 | |||
233 | |||
215 | #endif | 234 | #endif |
diff --git a/include/sway/output.h b/include/sway/output.h index f7c5ceba..bdf9614d 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -146,4 +146,12 @@ enum sway_container_layout output_get_default_layout( | |||
146 | 146 | ||
147 | void output_add_listeners(struct sway_output *output); | 147 | void output_add_listeners(struct sway_output *output); |
148 | 148 | ||
149 | void render_rect(struct wlr_output *wlr_output, | ||
150 | pixman_region32_t *output_damage, const struct wlr_box *_box, | ||
151 | float color[static 4]); | ||
152 | |||
153 | void premultiply_alpha(float color[4], float opacity); | ||
154 | |||
155 | void scale_box(struct wlr_box *box, float scale); | ||
156 | |||
149 | #endif | 157 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 1d0a0ad1..9a432cb2 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -333,4 +333,6 @@ void container_add_mark(struct sway_container *container, char *mark); | |||
333 | 333 | ||
334 | void container_update_marks_textures(struct sway_container *container); | 334 | void container_update_marks_textures(struct sway_container *container); |
335 | 335 | ||
336 | void container_raise_floating(struct sway_container *con); | ||
337 | |||
336 | #endif | 338 | #endif |