summaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-07-22 19:25:41 +0100
committerLibravatar GitHub <noreply@github.com>2018-07-22 19:25:41 +0100
commitbe60e44b7c08b87400fed0b9ea586c449883ba11 (patch)
tree5005c92ed70e19fcd9a316b9a9fad0d3ba07b6ad /sway/desktop/xdg_shell.c
parentMerge pull request #2320 from RedSoxFan/reset-outputs-on-reload (diff)
parentSet cursor when beginning resize and move operations (diff)
downloadsway-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.c')
-rw-r--r--sway/desktop/xdg_shell.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 98c16faf..706b35c3 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.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>
@@ -95,6 +96,16 @@ static struct sway_xdg_shell_view *xdg_shell_view_from_view(
95 return (struct sway_xdg_shell_view *)view; 96 return (struct sway_xdg_shell_view *)view;
96} 97}
97 98
99static void get_constraints(struct sway_view *view, double *min_width,
100 double *max_width, double *min_height, double *max_height) {
101 struct wlr_xdg_toplevel_state *state =
102 &view->wlr_xdg_surface->toplevel->current;
103 *min_width = state->min_width > 0 ? state->min_width : DBL_MIN;
104 *max_width = state->max_width > 0 ? state->max_width : DBL_MAX;
105 *min_height = state->min_height > 0 ? state->min_height : DBL_MIN;
106 *max_height = state->max_height > 0 ? state->max_height : DBL_MAX;
107}
108
98static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { 109static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) {
99 if (xdg_shell_view_from_view(view) == NULL) { 110 if (xdg_shell_view_from_view(view) == NULL) {
100 return NULL; 111 return NULL;
@@ -188,6 +199,7 @@ static void destroy(struct sway_view *view) {
188} 199}
189 200
190static const struct sway_view_impl view_impl = { 201static const struct sway_view_impl view_impl = {
202 .get_constraints = get_constraints,
191 .get_string_prop = get_string_prop, 203 .get_string_prop = get_string_prop,
192 .configure = configure, 204 .configure = configure,
193 .set_activated = set_activated, 205 .set_activated = set_activated,
@@ -248,6 +260,34 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
248 transaction_commit_dirty(); 260 transaction_commit_dirty();
249} 261}
250 262
263static void handle_request_move(struct wl_listener *listener, void *data) {
264 struct sway_xdg_shell_view *xdg_shell_view =
265 wl_container_of(listener, xdg_shell_view, request_move);
266 struct sway_view *view = &xdg_shell_view->view;
267 if (!container_is_floating(view->swayc)) {
268 return;
269 }
270 struct wlr_xdg_toplevel_move_event *e = data;
271 struct sway_seat *seat = e->seat->seat->data;
272 if (e->serial == seat->last_button_serial) {
273 seat_begin_move(seat, view->swayc, seat->last_button);
274 }
275}
276
277static void handle_request_resize(struct wl_listener *listener, void *data) {
278 struct sway_xdg_shell_view *xdg_shell_view =
279 wl_container_of(listener, xdg_shell_view, request_resize);
280 struct sway_view *view = &xdg_shell_view->view;
281 if (!container_is_floating(view->swayc)) {
282 return;
283 }
284 struct wlr_xdg_toplevel_resize_event *e = data;
285 struct sway_seat *seat = e->seat->seat->data;
286 if (e->serial == seat->last_button_serial) {
287 seat_begin_resize(seat, view->swayc, seat->last_button, e->edges);
288 }
289}
290
251static void handle_unmap(struct wl_listener *listener, void *data) { 291static void handle_unmap(struct wl_listener *listener, void *data) {
252 struct sway_xdg_shell_view *xdg_shell_view = 292 struct sway_xdg_shell_view *xdg_shell_view =
253 wl_container_of(listener, xdg_shell_view, unmap); 293 wl_container_of(listener, xdg_shell_view, unmap);
@@ -262,6 +302,8 @@ static void handle_unmap(struct wl_listener *listener, void *data) {
262 wl_list_remove(&xdg_shell_view->commit.link); 302 wl_list_remove(&xdg_shell_view->commit.link);
263 wl_list_remove(&xdg_shell_view->new_popup.link); 303 wl_list_remove(&xdg_shell_view->new_popup.link);
264 wl_list_remove(&xdg_shell_view->request_fullscreen.link); 304 wl_list_remove(&xdg_shell_view->request_fullscreen.link);
305 wl_list_remove(&xdg_shell_view->request_move.link);
306 wl_list_remove(&xdg_shell_view->request_resize.link);
265} 307}
266 308
267static void handle_map(struct wl_listener *listener, void *data) { 309static void handle_map(struct wl_listener *listener, void *data) {
@@ -299,6 +341,14 @@ static void handle_map(struct wl_listener *listener, void *data) {
299 xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; 341 xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen;
300 wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, 342 wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen,
301 &xdg_shell_view->request_fullscreen); 343 &xdg_shell_view->request_fullscreen);
344
345 xdg_shell_view->request_move.notify = handle_request_move;
346 wl_signal_add(&xdg_surface->toplevel->events.request_move,
347 &xdg_shell_view->request_move);
348
349 xdg_shell_view->request_resize.notify = handle_request_resize;
350 wl_signal_add(&xdg_surface->toplevel->events.request_resize,
351 &xdg_shell_view->request_resize);
302} 352}
303 353
304static void handle_destroy(struct wl_listener *listener, void *data) { 354static void handle_destroy(struct wl_listener *listener, void *data) {