diff options
author | emersion <contact@emersion.fr> | 2018-07-22 19:25:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-22 19:25:41 +0100 |
commit | be60e44b7c08b87400fed0b9ea586c449883ba11 (patch) | |
tree | 5005c92ed70e19fcd9a316b9a9fad0d3ba07b6ad /sway/desktop/xdg_shell_v6.c | |
parent | Merge pull request #2320 from RedSoxFan/reset-outputs-on-reload (diff) | |
parent | Set cursor when beginning resize and move operations (diff) | |
download | sway-be60e44b7c08b87400fed0b9ea586c449883ba11.tar.gz sway-be60e44b7c08b87400fed0b9ea586c449883ba11.tar.zst sway-be60e44b7c08b87400fed0b9ea586c449883ba11.zip |
Merge pull request #2296 from RyanDwyer/floating-modifier
Implement floating_modifier and mouse operations for floating views
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 4d76f0a7..201b5b1e 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #define _POSIX_C_SOURCE 199309L | 1 | #define _POSIX_C_SOURCE 199309L |
2 | #include <float.h> | ||
2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
4 | #include <wayland-server.h> | 5 | #include <wayland-server.h> |
@@ -94,6 +95,16 @@ static struct sway_xdg_shell_v6_view *xdg_shell_v6_view_from_view( | |||
94 | return (struct sway_xdg_shell_v6_view *)view; | 95 | return (struct sway_xdg_shell_v6_view *)view; |
95 | } | 96 | } |
96 | 97 | ||
98 | static void get_constraints(struct sway_view *view, double *min_width, | ||
99 | double *max_width, double *min_height, double *max_height) { | ||
100 | struct wlr_xdg_toplevel_v6_state *state = | ||
101 | &view->wlr_xdg_surface_v6->toplevel->current; | ||
102 | *min_width = state->min_width > 0 ? state->min_width : DBL_MIN; | ||
103 | *max_width = state->max_width > 0 ? state->max_width : DBL_MAX; | ||
104 | *min_height = state->min_height > 0 ? state->min_height : DBL_MIN; | ||
105 | *max_height = state->max_height > 0 ? state->max_height : DBL_MAX; | ||
106 | } | ||
107 | |||
97 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { | 108 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { |
98 | if (xdg_shell_v6_view_from_view(view) == NULL) { | 109 | if (xdg_shell_v6_view_from_view(view) == NULL) { |
99 | return NULL; | 110 | return NULL; |
@@ -184,6 +195,7 @@ static void destroy(struct sway_view *view) { | |||
184 | } | 195 | } |
185 | 196 | ||
186 | static const struct sway_view_impl view_impl = { | 197 | static const struct sway_view_impl view_impl = { |
198 | .get_constraints = get_constraints, | ||
187 | .get_string_prop = get_string_prop, | 199 | .get_string_prop = get_string_prop, |
188 | .configure = configure, | 200 | .configure = configure, |
189 | .set_activated = set_activated, | 201 | .set_activated = set_activated, |
@@ -243,6 +255,34 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data) | |||
243 | transaction_commit_dirty(); | 255 | transaction_commit_dirty(); |
244 | } | 256 | } |
245 | 257 | ||
258 | static void handle_request_move(struct wl_listener *listener, void *data) { | ||
259 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
260 | wl_container_of(listener, xdg_shell_v6_view, request_move); | ||
261 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
262 | if (!container_is_floating(view->swayc)) { | ||
263 | return; | ||
264 | } | ||
265 | struct wlr_xdg_toplevel_v6_move_event *e = data; | ||
266 | struct sway_seat *seat = e->seat->seat->data; | ||
267 | if (e->serial == seat->last_button_serial) { | ||
268 | seat_begin_move(seat, view->swayc, seat->last_button); | ||
269 | } | ||
270 | } | ||
271 | |||
272 | static void handle_request_resize(struct wl_listener *listener, void *data) { | ||
273 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | ||
274 | wl_container_of(listener, xdg_shell_v6_view, request_resize); | ||
275 | struct sway_view *view = &xdg_shell_v6_view->view; | ||
276 | if (!container_is_floating(view->swayc)) { | ||
277 | return; | ||
278 | } | ||
279 | struct wlr_xdg_toplevel_v6_resize_event *e = data; | ||
280 | struct sway_seat *seat = e->seat->seat->data; | ||
281 | if (e->serial == seat->last_button_serial) { | ||
282 | seat_begin_resize(seat, view->swayc, seat->last_button, e->edges); | ||
283 | } | ||
284 | } | ||
285 | |||
246 | static void handle_unmap(struct wl_listener *listener, void *data) { | 286 | static void handle_unmap(struct wl_listener *listener, void *data) { |
247 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = | 287 | struct sway_xdg_shell_v6_view *xdg_shell_v6_view = |
248 | wl_container_of(listener, xdg_shell_v6_view, unmap); | 288 | wl_container_of(listener, xdg_shell_v6_view, unmap); |
@@ -257,6 +297,8 @@ static void handle_unmap(struct wl_listener *listener, void *data) { | |||
257 | wl_list_remove(&xdg_shell_v6_view->commit.link); | 297 | wl_list_remove(&xdg_shell_v6_view->commit.link); |
258 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); | 298 | wl_list_remove(&xdg_shell_v6_view->new_popup.link); |
259 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); | 299 | wl_list_remove(&xdg_shell_v6_view->request_fullscreen.link); |
300 | wl_list_remove(&xdg_shell_v6_view->request_move.link); | ||
301 | wl_list_remove(&xdg_shell_v6_view->request_resize.link); | ||
260 | } | 302 | } |
261 | 303 | ||
262 | static void handle_map(struct wl_listener *listener, void *data) { | 304 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -294,6 +336,14 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
294 | xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen; | 336 | xdg_shell_v6_view->request_fullscreen.notify = handle_request_fullscreen; |
295 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, | 337 | wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, |
296 | &xdg_shell_v6_view->request_fullscreen); | 338 | &xdg_shell_v6_view->request_fullscreen); |
339 | |||
340 | xdg_shell_v6_view->request_move.notify = handle_request_move; | ||
341 | wl_signal_add(&xdg_surface->toplevel->events.request_move, | ||
342 | &xdg_shell_v6_view->request_move); | ||
343 | |||
344 | xdg_shell_v6_view->request_resize.notify = handle_request_resize; | ||
345 | wl_signal_add(&xdg_surface->toplevel->events.request_resize, | ||
346 | &xdg_shell_v6_view->request_resize); | ||
297 | } | 347 | } |
298 | 348 | ||
299 | static void handle_destroy(struct wl_listener *listener, void *data) { | 349 | static void handle_destroy(struct wl_listener *listener, void *data) { |