fixed container resize oddity

This commit is contained in:
taiyu 2015-08-22 22:14:59 -07:00
parent f24b78898a
commit f53ce887e8
2 changed files with 36 additions and 60 deletions

View file

@ -60,10 +60,12 @@ static struct mode_state {
struct { struct {
double x, w; double x, w;
swayc_t *ptr; swayc_t *ptr;
swayc_t *sib;
} lr; } lr;
struct { struct {
double y, h; double y, h;
swayc_t *ptr; swayc_t *ptr;
swayc_t *sib;
} tb; } tb;
} initial; } initial;
@ -72,7 +74,7 @@ static struct {
bool top; bool top;
} lock; } lock;
// Floating set/unset // initial set/unset
static void set_initial_view(swayc_t *view) { static void set_initial_view(swayc_t *view) {
initial.ptr = view; initial.ptr = view;
@ -82,6 +84,26 @@ static void set_initial_view(swayc_t *view) {
initial.h = view->height; 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) { static void reset_initial_view(void) {
initial.ptr->x = initial.x; initial.ptr->x = initial.x;
initial.ptr->y = initial.y; initial.ptr->y = initial.y;
@ -114,22 +136,8 @@ static void pointer_mode_set_right(void) {
if (initial.ptr->is_floating) { if (initial.ptr->is_floating) {
pointer_state.mode = M_RESIZING | M_FLOATING; pointer_state.mode = M_RESIZING | M_FLOATING;
} else { } else {
bool reset = true;
pointer_state.mode = M_RESIZING | M_TILING; pointer_state.mode = M_RESIZING | M_TILING;
if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { set_initial_sibling();
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;
}
} }
} }
@ -187,7 +195,6 @@ void pointer_mode_update(void) {
} }
int dx = pointer_state.origin.x; int dx = pointer_state.origin.x;
int dy = pointer_state.origin.y; int dy = pointer_state.origin.y;
bool changed = false;
switch (pointer_state.mode) { switch (pointer_state.mode) {
case M_FLOATING | M_DRAGGING: case M_FLOATING | M_DRAGGING:
@ -196,11 +203,9 @@ void pointer_mode_update(void) {
dy -= pointer_state.left.y; dy -= pointer_state.left.y;
if (initial.x + dx != initial.ptr->x) { if (initial.x + dx != initial.ptr->x) {
initial.ptr->x = initial.x + dx; initial.ptr->x = initial.x + dx;
changed = true;
} }
if (initial.y + dy != initial.ptr->y) { if (initial.y + dy != initial.ptr->y) {
initial.ptr->y = initial.y + dy; initial.ptr->y = initial.y + dy;
changed = true;
} }
update_geometry(initial.ptr); update_geometry(initial.ptr);
break; break;
@ -253,37 +258,31 @@ void pointer_mode_update(void) {
if (lock.left) { if (lock.left) {
// Check whether its fine to resize // Check whether its fine to resize
if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { 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; initial.lr.ptr->width = initial.lr.w - dx;
} }
} else { //lock.right } else { //lock.right
if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { 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; initial.lr.ptr->width = initial.lr.w + dx;
} }
changed = true;
} }
arrange_windows(initial.lr.ptr->parent, -1, -1); arrange_windows(initial.lr.ptr->parent, -1, -1);
} }
if (initial.tb.ptr) { if (initial.tb.ptr) {
if (lock.top) { if (lock.top) {
if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { 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; initial.tb.ptr->height = initial.tb.h - dy;
} }
} else { //lock.bottom } else { //lock.bottom
if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { 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; initial.tb.ptr->height = initial.tb.h + dy;
} }
changed = true;
} }
arrange_windows(initial.tb.ptr->parent, -1, -1); arrange_windows(initial.tb.ptr->parent, -1, -1);
} }
if (changed) {
arrange_windows(initial.ptr->parent, -1, -1);
}
changed = false;
default: default:
return; return;
} }

View file

@ -209,12 +209,12 @@ void update_geometry(swayc_t *container) {
} }
struct wlc_geometry geometry = { struct wlc_geometry geometry = {
.origin = { .origin = {
.x = container->x + container->gaps / 2, .x = container->x + (container->is_floating ? 0 : container->gaps / 2),
.y = container->y + container->gaps / 2 .y = container->y + (container->is_floating ? 0 : container->gaps / 2)
}, },
.size = { .size = {
.w = container->width - container->gaps, .w = container->width - (container->is_floating ? 0 : container->gaps),
.h = container->height - container->gaps .h = container->height - (container->is_floating ? 0 : container->gaps)
} }
}; };
if (swayc_is_fullscreen(container)) { if (swayc_is_fullscreen(container)) {
@ -347,39 +347,16 @@ void arrange_windows(swayc_t *container, double width, double height) {
for (i = 0; i < container->floating->length; ++i) { for (i = 0; i < container->floating->length; ++i) {
swayc_t *view = container->floating->items[i]; swayc_t *view = container->floating->items[i];
if (view->type == C_VIEW) { if (view->type == C_VIEW) {
// Set the geometry update_geometry(view);
struct wlc_geometry geometry = {
.origin = {
.x = view->x,
.y = view->y
},
.size = {
.w = view->width,
.h = view->height
}
};
if (swayc_is_fullscreen(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); wlc_view_bring_to_front(view->handle);
} else { } else if (!container->focused
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)) { || !swayc_is_fullscreen(container->focused)) {
wlc_view_bring_to_front(view->handle); wlc_view_bring_to_front(view->handle);
} }
} }
} }
} }
}
layout_log(&root_container, 0); layout_log(&root_container, 0);
} }