aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sway/input_state.c57
-rw-r--r--sway/layout.c39
2 files changed, 36 insertions, 60 deletions
diff --git a/sway/input_state.c b/sway/input_state.c
index cb8632de..ece75bf4 100644
--- a/sway/input_state.c
+++ b/sway/input_state.c
@@ -60,10 +60,12 @@ static struct mode_state {
struct {
double x, w;
swayc_t *ptr;
+ swayc_t *sib;
} lr;
struct {
double y, h;
swayc_t *ptr;
+ swayc_t *sib;
} tb;
} initial;
@@ -72,7 +74,7 @@ static struct {
bool top;
} lock;
-// Floating set/unset
+// initial set/unset
static void set_initial_view(swayc_t *view) {
initial.ptr = view;
@@ -82,6 +84,26 @@ static void set_initial_view(swayc_t *view) {
initial.h = view->height;
}
+static void set_initial_sibling(void) {
+ bool reset = true;
+ if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) {
+ initial.lr.sib = get_swayc_in_direction(initial.lr.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT);
+ initial.lr.x = initial.lr.ptr->x;
+ initial.lr.w = initial.lr.ptr->width;
+ reset = false;
+ }
+ if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) {
+ initial.tb.sib = get_swayc_in_direction(initial.tb.ptr, lock.top ? MOVE_UP : MOVE_DOWN);
+ initial.tb.y = initial.tb.ptr->y;
+ initial.tb.h = initial.tb.ptr->height;
+ reset = false;
+ }
+ // If nothing changes just undo the mode
+ if (reset) {
+ pointer_state.mode = 0;
+ }
+}
+
static void reset_initial_view(void) {
initial.ptr->x = initial.x;
initial.ptr->y = initial.y;
@@ -114,22 +136,8 @@ static void pointer_mode_set_right(void) {
if (initial.ptr->is_floating) {
pointer_state.mode = M_RESIZING | M_FLOATING;
} else {
- bool reset = true;
pointer_state.mode = M_RESIZING | M_TILING;
- if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) {
- initial.lr.x = initial.lr.ptr->x;
- initial.lr.w = initial.lr.ptr->width;
- reset = false;
- }
- if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) {
- initial.tb.y = initial.tb.ptr->y;
- initial.tb.h = initial.tb.ptr->height;
- reset = false;
- }
- // If nothing changes just undo the mode
- if (reset) {
- pointer_state.mode = 0;
- }
+ set_initial_sibling();
}
}
@@ -187,7 +195,6 @@ void pointer_mode_update(void) {
}
int dx = pointer_state.origin.x;
int dy = pointer_state.origin.y;
- bool changed = false;
switch (pointer_state.mode) {
case M_FLOATING | M_DRAGGING:
@@ -196,11 +203,9 @@ void pointer_mode_update(void) {
dy -= pointer_state.left.y;
if (initial.x + dx != initial.ptr->x) {
initial.ptr->x = initial.x + dx;
- changed = true;
}
if (initial.y + dy != initial.ptr->y) {
initial.ptr->y = initial.y + dy;
- changed = true;
}
update_geometry(initial.ptr);
break;
@@ -253,37 +258,31 @@ void pointer_mode_update(void) {
if (lock.left) {
// Check whether its fine to resize
if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) {
- initial.ptr->width = initial.w + dx;
+ initial.lr.sib->width = initial.w + dx;
initial.lr.ptr->width = initial.lr.w - dx;
}
} else { //lock.right
if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) {
- initial.ptr->width = initial.w - dx;
+ initial.lr.sib->width = initial.w - dx;
initial.lr.ptr->width = initial.lr.w + dx;
}
- changed = true;
}
arrange_windows(initial.lr.ptr->parent, -1, -1);
}
if (initial.tb.ptr) {
if (lock.top) {
if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) {
- initial.ptr->height = initial.h + dy;
+ initial.tb.sib->height = initial.h + dy;
initial.tb.ptr->height = initial.tb.h - dy;
}
} else { //lock.bottom
if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) {
- initial.ptr->height = initial.h - dy;
+ initial.tb.sib->height = initial.h - dy;
initial.tb.ptr->height = initial.tb.h + dy;
}
- changed = true;
}
arrange_windows(initial.tb.ptr->parent, -1, -1);
}
- if (changed) {
- arrange_windows(initial.ptr->parent, -1, -1);
- }
- changed = false;
default:
return;
}
diff --git a/sway/layout.c b/sway/layout.c
index fd2e80fe..4d738433 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -209,12 +209,12 @@ void update_geometry(swayc_t *container) {
}
struct wlc_geometry geometry = {
.origin = {
- .x = container->x + container->gaps / 2,
- .y = container->y + container->gaps / 2
+ .x = container->x + (container->is_floating ? 0 : container->gaps / 2),
+ .y = container->y + (container->is_floating ? 0 : container->gaps / 2)
},
.size = {
- .w = container->width - container->gaps,
- .h = container->height - container->gaps
+ .w = container->width - (container->is_floating ? 0 : container->gaps),
+ .h = container->height - (container->is_floating ? 0 : container->gaps)
}
};
if (swayc_is_fullscreen(container)) {
@@ -347,35 +347,12 @@ void arrange_windows(swayc_t *container, double width, double height) {
for (i = 0; i < container->floating->length; ++i) {
swayc_t *view = container->floating->items[i];
if (view->type == C_VIEW) {
- // Set the geometry
- struct wlc_geometry geometry = {
- .origin = {
- .x = view->x,
- .y = view->y
- },
- .size = {
- .w = view->width,
- .h = view->height
- }
- };
+ update_geometry(view);
if (swayc_is_fullscreen(view)) {
- swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT);
- geometry.origin.x = 0;
- geometry.origin.y = 0;
- geometry.size.w = parent->width;
- geometry.size.h = parent->height;
- wlc_view_set_geometry(view->handle, 0, &geometry);
wlc_view_bring_to_front(view->handle);
- } else {
- wlc_view_set_geometry(view->handle, 0, &geometry);
- // 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
- // This is conditional on there not being a fullscreen view in the workspace
- if (!container->focused
- || !swayc_is_fullscreen(container->focused)) {
- wlc_view_bring_to_front(view->handle);
- }
+ } else if (!container->focused
+ || !swayc_is_fullscreen(container->focused)) {
+ wlc_view_bring_to_front(view->handle);
}
}
}