aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-18 17:45:26 -0500
committerLibravatar Luminarys <kizunanohikari@gmail.com>2015-08-18 18:03:23 -0500
commit3e950c2b1c77fd3bd6a029eea6d50fbbe124b581 (patch)
tree735860cdfd433d0aab0b7b3a926114b90ced021f
parentDocument new commands in sway(5) (diff)
downloadsway-3e950c2b1c77fd3bd6a029eea6d50fbbe124b581.tar.gz
sway-3e950c2b1c77fd3bd6a029eea6d50fbbe124b581.tar.zst
sway-3e950c2b1c77fd3bd6a029eea6d50fbbe124b581.zip
Basic fixes to floating movement
-rw-r--r--sway/handlers.c24
1 files 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
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++]) {
@@ -348,7 +349,6 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
348 349
349 view->x += dx; 350 view->x += dx;
350 view->y += dy; 351 view->y += dy;
351 changed_floating = true;
352 break; 352 break;
353 } 353 }
354 } 354 }
@@ -366,25 +366,30 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
366 int midway_x = view->x + view->width/2; 366 int midway_x = view->x + view->width/2;
367 int midway_y = view->y + view->height/2; 367 int midway_y = view->y + view->height/2;
368 368
369
369 if (dx < 0) { 370 if (dx < 0) {
370 changed_floating = true; 371 changed_floating = true;
371 if (mouse_origin.x > midway_x) { 372 if (mouse_origin.x > midway_x) {
372 sway_log(L_INFO, "Downsizing view to the left"); 373 sway_log(L_INFO, "Downsizing view to the left");
373 view->width += dx; 374 view->width += dx;
375 edge = WLC_RESIZE_EDGE_RIGHT;
374 } else { 376 } else {
375 sway_log(L_INFO, "Upsizing view to the left"); 377 sway_log(L_INFO, "Upsizing view to the left");
376 view->x += dx; 378 view->x += dx;
377 view->width -= dx; 379 view->width -= dx;
380 edge = WLC_RESIZE_EDGE_LEFT;
378 } 381 }
379 } else if (dx > 0){ 382 } else if (dx > 0){
380 changed_floating = true; 383 changed_floating = true;
381 if (mouse_origin.x > midway_x) { 384 if (mouse_origin.x > midway_x) {
382 sway_log(L_INFO, "Upsizing to the right"); 385 sway_log(L_INFO, "Upsizing to the right");
383 view->width += dx; 386 view->width += dx;
387 edge = WLC_RESIZE_EDGE_RIGHT;
384 } else { 388 } else {
385 sway_log(L_INFO, "Downsizing to the right"); 389 sway_log(L_INFO, "Downsizing to the right");
386 view->x += dx; 390 view->x += dx;
387 view->width -= dx; 391 view->width -= dx;
392 edge = WLC_RESIZE_EDGE_LEFT;
388 } 393 }
389 } 394 }
390 395
@@ -393,20 +398,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
393 if (mouse_origin.y > midway_y) { 398 if (mouse_origin.y > midway_y) {
394 sway_log(L_INFO, "Downsizing view to the top"); 399 sway_log(L_INFO, "Downsizing view to the top");
395 view->height += dy; 400 view->height += dy;
401 edge += WLC_RESIZE_EDGE_BOTTOM;
396 } else { 402 } else {
397 sway_log(L_INFO, "Upsizing the view to the top"); 403 sway_log(L_INFO, "Upsizing the view to the top");
398 view->y += dy; 404 view->y += dy;
399 view->height -= dy; 405 view->height -= dy;
406 edge += WLC_RESIZE_EDGE_TOP;
400 } 407 }
401 } else if (dy > 0) { 408 } else if (dy > 0) {
402 changed_floating = true; 409 changed_floating = true;
403 if (mouse_origin.y > midway_y) { 410 if (mouse_origin.y > midway_y) {
404 sway_log(L_INFO, "Upsizing to the bottom"); 411 sway_log(L_INFO, "Upsizing to the bottom");
405 view->height += dy; 412 view->height += dy;
413 edge += WLC_RESIZE_EDGE_BOTTOM;
406 } else { 414 } else {
415 edge = WLC_RESIZE_EDGE_BOTTOM;
407 sway_log(L_INFO, "Downsizing to the bottom"); 416 sway_log(L_INFO, "Downsizing to the bottom");
408 view->y += dy; 417 view->y += dy;
409 view->height -= dy; 418 view->height -= dy;
419 edge += WLC_RESIZE_EDGE_TOP;
410 } 420 }
411 } 421 }
412 break; 422 break;
@@ -424,7 +434,17 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
424 prev_handle = handle; 434 prev_handle = handle;
425 prev_pos = mouse_origin; 435 prev_pos = mouse_origin;
426 if (changed_floating) { 436 if (changed_floating) {
427 arrange_windows(view, -1, -1); 437 struct wlc_geometry geometry = {
438 .origin = {
439 .x = view->x,
440 .y = view->y
441 },
442 .size = {
443 .w = view->width,
444 .h = view->height
445 }
446 };
447 wlc_view_set_geometry(view->handle, edge, &geometry);
428 return true; 448 return true;
429 } 449 }
430 return false; 450 return false;