mirror of
https://github.com/NickHu/sway
synced 2024-12-29 22:23:46 +01:00
Basic fixes to floating movement
This commit is contained in:
parent
e6d83206bd
commit
3e950c2b1c
1 changed files with 22 additions and 2 deletions
|
@ -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
|
// Do checks to determine if proper keys are being held
|
||||||
swayc_t *view = active_workspace->focused;
|
swayc_t *view = active_workspace->focused;
|
||||||
|
uint32_t edge = 0;
|
||||||
if (m1_held && view) {
|
if (m1_held && view) {
|
||||||
if (view->is_floating) {
|
if (view->is_floating) {
|
||||||
while (keys_pressed[i++]) {
|
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->x += dx;
|
||||||
view->y += dy;
|
view->y += dy;
|
||||||
changed_floating = true;
|
|
||||||
break;
|
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_x = view->x + view->width/2;
|
||||||
int midway_y = view->y + view->height/2;
|
int midway_y = view->y + view->height/2;
|
||||||
|
|
||||||
|
|
||||||
if (dx < 0) {
|
if (dx < 0) {
|
||||||
changed_floating = true;
|
changed_floating = true;
|
||||||
if (mouse_origin.x > midway_x) {
|
if (mouse_origin.x > midway_x) {
|
||||||
sway_log(L_INFO, "Downsizing view to the left");
|
sway_log(L_INFO, "Downsizing view to the left");
|
||||||
view->width += dx;
|
view->width += dx;
|
||||||
|
edge = WLC_RESIZE_EDGE_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
sway_log(L_INFO, "Upsizing view to the left");
|
sway_log(L_INFO, "Upsizing view to the left");
|
||||||
view->x += dx;
|
view->x += dx;
|
||||||
view->width -= dx;
|
view->width -= dx;
|
||||||
|
edge = WLC_RESIZE_EDGE_LEFT;
|
||||||
}
|
}
|
||||||
} else if (dx > 0){
|
} else if (dx > 0){
|
||||||
changed_floating = true;
|
changed_floating = true;
|
||||||
if (mouse_origin.x > midway_x) {
|
if (mouse_origin.x > midway_x) {
|
||||||
sway_log(L_INFO, "Upsizing to the right");
|
sway_log(L_INFO, "Upsizing to the right");
|
||||||
view->width += dx;
|
view->width += dx;
|
||||||
|
edge = WLC_RESIZE_EDGE_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
sway_log(L_INFO, "Downsizing to the right");
|
sway_log(L_INFO, "Downsizing to the right");
|
||||||
view->x += dx;
|
view->x += dx;
|
||||||
view->width -= 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) {
|
if (mouse_origin.y > midway_y) {
|
||||||
sway_log(L_INFO, "Downsizing view to the top");
|
sway_log(L_INFO, "Downsizing view to the top");
|
||||||
view->height += dy;
|
view->height += dy;
|
||||||
|
edge += WLC_RESIZE_EDGE_BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
sway_log(L_INFO, "Upsizing the view to the top");
|
sway_log(L_INFO, "Upsizing the view to the top");
|
||||||
view->y += dy;
|
view->y += dy;
|
||||||
view->height -= dy;
|
view->height -= dy;
|
||||||
|
edge += WLC_RESIZE_EDGE_TOP;
|
||||||
}
|
}
|
||||||
} else if (dy > 0) {
|
} else if (dy > 0) {
|
||||||
changed_floating = true;
|
changed_floating = true;
|
||||||
if (mouse_origin.y > midway_y) {
|
if (mouse_origin.y > midway_y) {
|
||||||
sway_log(L_INFO, "Upsizing to the bottom");
|
sway_log(L_INFO, "Upsizing to the bottom");
|
||||||
view->height += dy;
|
view->height += dy;
|
||||||
|
edge += WLC_RESIZE_EDGE_BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
|
edge = WLC_RESIZE_EDGE_BOTTOM;
|
||||||
sway_log(L_INFO, "Downsizing to the bottom");
|
sway_log(L_INFO, "Downsizing to the bottom");
|
||||||
view->y += dy;
|
view->y += dy;
|
||||||
view->height -= dy;
|
view->height -= dy;
|
||||||
|
edge += WLC_RESIZE_EDGE_TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -424,7 +434,17 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
|
||||||
prev_handle = handle;
|
prev_handle = handle;
|
||||||
prev_pos = mouse_origin;
|
prev_pos = mouse_origin;
|
||||||
if (changed_floating) {
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue