summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-18 19:25:16 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-18 19:25:16 -0400
commitab5805ca6eacb77494b09b1b20d278141dfa7093 (patch)
tree251a7291b6daf626a34288042dc0a69659cce36e
parentDocument new commands in sway(5) (diff)
parentMinor fixes that might be helpful later (diff)
downloadsway-ab5805ca6eacb77494b09b1b20d278141dfa7093.tar.gz
sway-ab5805ca6eacb77494b09b1b20d278141dfa7093.tar.zst
sway-ab5805ca6eacb77494b09b1b20d278141dfa7093.zip
Merge pull request #74 from Luminarys/master
Added in proper floating window resizing
-rw-r--r--sway/handlers.c25
-rw-r--r--sway/layout.c2
2 files changed, 22 insertions, 5 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 9b96a5cf..c20f3ca0 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
337 } 337 }
338 // Do checks to determine if proper keys are being held 338 // Do checks to determine if proper keys are being held
339 swayc_t *view = active_workspace->focused; 339 swayc_t *view = active_workspace->focused;
340 uint32_t edge = 0;
340 if (m1_held && view) { 341 if (m1_held && view) {
341 if (view->is_floating) { 342 if (view->is_floating) {
342 while (keys_pressed[i++]) { 343 while (keys_pressed[i++]) {
@@ -344,7 +345,6 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
344 int dx = mouse_origin.x - prev_pos.x; 345 int dx = mouse_origin.x - prev_pos.x;
345 int dy = mouse_origin.y - prev_pos.y; 346 int dy = mouse_origin.y - prev_pos.y;
346 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); 347 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);
347 sway_log(L_DEBUG, "Moving: dx: %d, dy: %d", dx, dy);
348 348
349 view->x += dx; 349 view->x += dx;
350 view->y += dy; 350 view->y += dy;
@@ -360,31 +360,35 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
360 int dx = mouse_origin.x - prev_pos.x; 360 int dx = mouse_origin.x - prev_pos.x;
361 int dy = mouse_origin.y - prev_pos.y; 361 int dy = mouse_origin.y - prev_pos.y;
362 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); 362 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);
363 sway_log(L_INFO, "Moving: dx: %d, dy: %d", dx, dy);
364 363
365 // Move and resize the view based on the dx/dy and mouse position 364 // Move and resize the view based on the dx/dy and mouse position
366 int midway_x = view->x + view->width/2; 365 int midway_x = view->x + view->width/2;
367 int midway_y = view->y + view->height/2; 366 int midway_y = view->y + view->height/2;
368 367
368
369 if (dx < 0) { 369 if (dx < 0) {
370 changed_floating = true; 370 changed_floating = true;
371 if (mouse_origin.x > midway_x) { 371 if (mouse_origin.x > midway_x) {
372 sway_log(L_INFO, "Downsizing view to the left"); 372 sway_log(L_INFO, "Downsizing view to the left");
373 view->width += dx; 373 view->width += dx;
374 edge += WLC_RESIZE_EDGE_RIGHT;
374 } else { 375 } else {
375 sway_log(L_INFO, "Upsizing view to the left"); 376 sway_log(L_INFO, "Upsizing view to the left");
376 view->x += dx; 377 view->x += dx;
377 view->width -= dx; 378 view->width -= dx;
379 edge += WLC_RESIZE_EDGE_LEFT;
378 } 380 }
379 } else if (dx > 0){ 381 } else if (dx > 0){
380 changed_floating = true; 382 changed_floating = true;
381 if (mouse_origin.x > midway_x) { 383 if (mouse_origin.x > midway_x) {
382 sway_log(L_INFO, "Upsizing to the right"); 384 sway_log(L_INFO, "Upsizing to the right");
383 view->width += dx; 385 view->width += dx;
386 edge += WLC_RESIZE_EDGE_RIGHT;
384 } else { 387 } else {
385 sway_log(L_INFO, "Downsizing to the right"); 388 sway_log(L_INFO, "Downsizing to the right");
386 view->x += dx; 389 view->x += dx;
387 view->width -= dx; 390 view->width -= dx;
391 edge += WLC_RESIZE_EDGE_LEFT;
388 } 392 }
389 } 393 }
390 394
@@ -393,20 +397,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
393 if (mouse_origin.y > midway_y) { 397 if (mouse_origin.y > midway_y) {
394 sway_log(L_INFO, "Downsizing view to the top"); 398 sway_log(L_INFO, "Downsizing view to the top");
395 view->height += dy; 399 view->height += dy;
400 edge += WLC_RESIZE_EDGE_BOTTOM;
396 } else { 401 } else {
397 sway_log(L_INFO, "Upsizing the view to the top"); 402 sway_log(L_INFO, "Upsizing the view to the top");
398 view->y += dy; 403 view->y += dy;
399 view->height -= dy; 404 view->height -= dy;
405 edge += WLC_RESIZE_EDGE_TOP;
400 } 406 }
401 } else if (dy > 0) { 407 } else if (dy > 0) {
402 changed_floating = true; 408 changed_floating = true;
403 if (mouse_origin.y > midway_y) { 409 if (mouse_origin.y > midway_y) {
404 sway_log(L_INFO, "Upsizing to the bottom"); 410 sway_log(L_INFO, "Upsizing to the bottom");
405 view->height += dy; 411 view->height += dy;
412 edge += WLC_RESIZE_EDGE_BOTTOM;
406 } else { 413 } else {
414 edge = WLC_RESIZE_EDGE_BOTTOM;
407 sway_log(L_INFO, "Downsizing to the bottom"); 415 sway_log(L_INFO, "Downsizing to the bottom");
408 view->y += dy; 416 view->y += dy;
409 view->height -= dy; 417 view->height -= dy;
418 edge += WLC_RESIZE_EDGE_TOP;
410 } 419 }
411 } 420 }
412 break; 421 break;
@@ -424,7 +433,17 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
424 prev_handle = handle; 433 prev_handle = handle;
425 prev_pos = mouse_origin; 434 prev_pos = mouse_origin;
426 if (changed_floating) { 435 if (changed_floating) {
427 arrange_windows(view, -1, -1); 436 struct wlc_geometry geometry = {
437 .origin = {
438 .x = view->x,
439 .y = view->y
440 },
441 .size = {
442 .w = view->width,
443 .h = view->height
444 }
445 };
446 wlc_view_set_geometry(view->handle, edge, &geometry);
428 return true; 447 return true;
429 } 448 }
430 return false; 449 return false;
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) {
237 wlc_view_bring_to_front(view->handle); 237 wlc_view_bring_to_front(view->handle);
238 } else { 238 } else {
239 wlc_view_set_geometry(view->handle, 0, &geometry); 239 wlc_view_set_geometry(view->handle, 0, &geometry);
240 view->width = width;
241 view->height = height;
242 // Bring the views to the front in order of the list, the list 240 // Bring the views to the front in order of the list, the list
243 // will be kept up to date so that more recently focused views 241 // will be kept up to date so that more recently focused views
244 // have higher indexes 242 // have higher indexes