From 7bbb102e2d49e90f70fa8a954febb091a4d8bb81 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 10:45:40 -0700 Subject: [PATCH 1/2] reset floating view on floating_mod repress --- sway/handlers.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sway/handlers.c b/sway/handlers.c index 71691d7db..46d1fff55 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -91,6 +91,31 @@ swayc_t *container_under_pointer(void) { return lookup; } +static struct wlc_geometry saved_floating; + +static void start_floating(swayc_t *view) { + if (view->is_floating) { + saved_floating.origin.x = view->x; + saved_floating.origin.y = view->y; + saved_floating.size.w = view->width; + saved_floating.size.h = view->height; + } +} + +static void reset_floating(swayc_t *view) { + if (view->is_floating) { + view->x = saved_floating.origin.x; + view->y = saved_floating.origin.y; + view->width = saved_floating.size.w; + view->height = saved_floating.size.h; + arrange_windows(view->parent, -1, -1); + } + dragging = resizing = false; + lock_left = lock_right = lock_top = lock_bottom = false; +} + +/* Handles */ + static bool handle_output_created(wlc_handle output) { swayc_t *op = new_output(output); @@ -291,6 +316,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier } bool cmd_success = false; + if ((modifiers->mods & config->floating_mod) && (dragging||resizing)) { + reset_floating(get_focused_view(&root_container)); + } + struct sway_mode *mode = config->current_mode; // Lowercase if necessary sym = tolower(sym); @@ -500,6 +529,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w lock_top = !lock_bottom; lock_right = origin->x < midway_x; lock_left = !lock_right; + start_floating(pointer); } //Dont want pointer sent to window while dragging or resizing return (dragging || resizing); From e53a95c60d281ab751e05f4af43eb117ab0880be Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 11:15:13 -0700 Subject: [PATCH 2/2] style --- sway/handlers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 46d1fff55..f7d5386a5 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -258,7 +258,7 @@ static void handle_view_focus(wlc_handle view, bool focus) { static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", - geometry->origin.x, geometry->origin.y, geometry->size.w,geometry->size.h); + geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h); // If the view is floating, then apply the geometry. // Otherwise save the desired width/height for the view. // This will not do anything for the time being as WLC improperly sends geometry requests @@ -279,12 +279,12 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) { swayc_t *c = NULL; - switch(state) { + switch (state) { case WLC_BIT_FULLSCREEN: // i3 just lets it become fullscreen wlc_view_set_state(view, state, toggle); c = get_swayc_for_handle(view, &root_container); - sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle); + sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d", view, c->name, toggle); if (c) { arrange_windows(c->parent, -1, -1); // Set it as focused window for that workspace if its going fullscreen @@ -316,7 +316,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier } bool cmd_success = false; - if ((modifiers->mods & config->floating_mod) && (dragging||resizing)) { + if ((modifiers->mods & config->floating_mod) && (dragging || resizing)) { reset_floating(get_focused_view(&root_container)); }