From 3e950c2b1c77fd3bd6a029eea6d50fbbe124b581 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 17:45:26 -0500 Subject: Basic fixes to floating movement --- sway/handlers.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 9b96a5cf..d0915fe5 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -337,6 +337,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct } // Do checks to determine if proper keys are being held swayc_t *view = active_workspace->focused; + uint32_t edge = 0; if (m1_held && view) { if (view->is_floating) { while (keys_pressed[i++]) { @@ -348,7 +349,6 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct view->x += dx; view->y += dy; - changed_floating = true; break; } } @@ -366,25 +366,30 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct int midway_x = view->x + view->width/2; int midway_y = view->y + view->height/2; + if (dx < 0) { changed_floating = true; if (mouse_origin.x > midway_x) { sway_log(L_INFO, "Downsizing view to the left"); view->width += dx; + edge = WLC_RESIZE_EDGE_RIGHT; } else { sway_log(L_INFO, "Upsizing view to the left"); view->x += dx; view->width -= dx; + edge = WLC_RESIZE_EDGE_LEFT; } } else if (dx > 0){ changed_floating = true; if (mouse_origin.x > midway_x) { sway_log(L_INFO, "Upsizing to the right"); view->width += dx; + edge = WLC_RESIZE_EDGE_RIGHT; } else { sway_log(L_INFO, "Downsizing to the right"); view->x += dx; view->width -= dx; + edge = WLC_RESIZE_EDGE_LEFT; } } @@ -393,20 +398,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct if (mouse_origin.y > midway_y) { sway_log(L_INFO, "Downsizing view to the top"); view->height += dy; + edge += WLC_RESIZE_EDGE_BOTTOM; } else { sway_log(L_INFO, "Upsizing the view to the top"); view->y += dy; view->height -= dy; + edge += WLC_RESIZE_EDGE_TOP; } } else if (dy > 0) { changed_floating = true; if (mouse_origin.y > midway_y) { sway_log(L_INFO, "Upsizing to the bottom"); view->height += dy; + edge += WLC_RESIZE_EDGE_BOTTOM; } else { + edge = WLC_RESIZE_EDGE_BOTTOM; sway_log(L_INFO, "Downsizing to the bottom"); view->y += dy; view->height -= dy; + edge += WLC_RESIZE_EDGE_TOP; } } break; @@ -424,7 +434,17 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct prev_handle = handle; prev_pos = mouse_origin; if (changed_floating) { - arrange_windows(view, -1, -1); + struct wlc_geometry geometry = { + .origin = { + .x = view->x, + .y = view->y + }, + .size = { + .w = view->width, + .h = view->height + } + }; + wlc_view_set_geometry(view->handle, edge, &geometry); return true; } return false; -- cgit v1.2.3-54-g00ecf From 7137be9a3fac4780c356d3f7a5d33c4235314a57 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 18:03:11 -0500 Subject: Fixes to make floating windows work better --- sway/handlers.c | 3 +-- sway/layout.c | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index d0915fe5..99d57529 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -345,10 +345,10 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct int dx = mouse_origin.x - prev_pos.x; int dy = mouse_origin.y - prev_pos.y; sway_log(L_DEBUG, "Moving from px: %d to cx: %d and from py: %d to cy: %d", prev_pos.x, mouse_origin.x, prev_pos.y, mouse_origin.y); - sway_log(L_DEBUG, "Moving: dx: %d, dy: %d", dx, dy); view->x += dx; view->y += dy; + changed_floating = true; break; } } @@ -360,7 +360,6 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct int dx = mouse_origin.x - prev_pos.x; int dy = mouse_origin.y - prev_pos.y; sway_log(L_DEBUG, "Moving from px: %d to cx: %d and from py: %d to cy: %d", prev_pos.x, mouse_origin.x, prev_pos.y, mouse_origin.y); - sway_log(L_INFO, "Moving: dx: %d, dy: %d", dx, dy); // Move and resize the view based on the dx/dy and mouse position int midway_x = view->x + view->width/2; diff --git a/sway/layout.c b/sway/layout.c index 7cb9186a..2f8027a8 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -237,8 +237,6 @@ void arrange_windows(swayc_t *container, int width, int height) { wlc_view_bring_to_front(view->handle); } else { wlc_view_set_geometry(view->handle, 0, &geometry); - view->width = width; - view->height = height; // Bring the views to the front in order of the list, the list // will be kept up to date so that more recently focused views // have higher indexes -- cgit v1.2.3-54-g00ecf From ab43927a470f46271ae98faa4e1cfe3a936c6c9d Mon Sep 17 00:00:00 2001 From: Luminarys Date: Tue, 18 Aug 2015 18:04:46 -0500 Subject: Minor fixes that might be helpful later --- sway/handlers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 99d57529..c20f3ca0 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -371,24 +371,24 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct if (mouse_origin.x > midway_x) { sway_log(L_INFO, "Downsizing view to the left"); view->width += dx; - edge = WLC_RESIZE_EDGE_RIGHT; + edge += WLC_RESIZE_EDGE_RIGHT; } else { sway_log(L_INFO, "Upsizing view to the left"); view->x += dx; view->width -= dx; - edge = WLC_RESIZE_EDGE_LEFT; + edge += WLC_RESIZE_EDGE_LEFT; } } else if (dx > 0){ changed_floating = true; if (mouse_origin.x > midway_x) { sway_log(L_INFO, "Upsizing to the right"); view->width += dx; - edge = WLC_RESIZE_EDGE_RIGHT; + edge += WLC_RESIZE_EDGE_RIGHT; } else { sway_log(L_INFO, "Downsizing to the right"); view->x += dx; view->width -= dx; - edge = WLC_RESIZE_EDGE_LEFT; + edge += WLC_RESIZE_EDGE_LEFT; } } -- cgit v1.2.3-54-g00ecf