summaryrefslogtreecommitdiffstats
path: root/sway/input_state.c
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-08-22 22:14:59 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-08-22 22:14:59 -0700
commitf53ce887e854dba1db327ae8e18b12dd385e2743 (patch)
tree61efa126fd93c1dda6dd7603453441379d8ea648 /sway/input_state.c
parentdont swap view with workspace... (diff)
downloadsway-f53ce887e854dba1db327ae8e18b12dd385e2743.tar.gz
sway-f53ce887e854dba1db327ae8e18b12dd385e2743.tar.zst
sway-f53ce887e854dba1db327ae8e18b12dd385e2743.zip
fixed container resize oddity
Diffstat (limited to 'sway/input_state.c')
-rw-r--r--sway/input_state.c57
1 files changed, 28 insertions, 29 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 {
60 struct { 60 struct {
61 double x, w; 61 double x, w;
62 swayc_t *ptr; 62 swayc_t *ptr;
63 swayc_t *sib;
63 } lr; 64 } lr;
64 struct { 65 struct {
65 double y, h; 66 double y, h;
66 swayc_t *ptr; 67 swayc_t *ptr;
68 swayc_t *sib;
67 } tb; 69 } tb;
68} initial; 70} initial;
69 71
@@ -72,7 +74,7 @@ static struct {
72 bool top; 74 bool top;
73} lock; 75} lock;
74 76
75// Floating set/unset 77// initial set/unset
76 78
77static void set_initial_view(swayc_t *view) { 79static void set_initial_view(swayc_t *view) {
78 initial.ptr = view; 80 initial.ptr = view;
@@ -82,6 +84,26 @@ static void set_initial_view(swayc_t *view) {
82 initial.h = view->height; 84 initial.h = view->height;
83} 85}
84 86
87static void set_initial_sibling(void) {
88 bool reset = true;
89 if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) {
90 initial.lr.sib = get_swayc_in_direction(initial.lr.ptr, lock.left ? MOVE_LEFT : MOVE_RIGHT);
91 initial.lr.x = initial.lr.ptr->x;
92 initial.lr.w = initial.lr.ptr->width;
93 reset = false;
94 }
95 if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) {
96 initial.tb.sib = get_swayc_in_direction(initial.tb.ptr, lock.top ? MOVE_UP : MOVE_DOWN);
97 initial.tb.y = initial.tb.ptr->y;
98 initial.tb.h = initial.tb.ptr->height;
99 reset = false;
100 }
101 // If nothing changes just undo the mode
102 if (reset) {
103 pointer_state.mode = 0;
104 }
105}
106
85static void reset_initial_view(void) { 107static void reset_initial_view(void) {
86 initial.ptr->x = initial.x; 108 initial.ptr->x = initial.x;
87 initial.ptr->y = initial.y; 109 initial.ptr->y = initial.y;
@@ -114,22 +136,8 @@ static void pointer_mode_set_right(void) {
114 if (initial.ptr->is_floating) { 136 if (initial.ptr->is_floating) {
115 pointer_state.mode = M_RESIZING | M_FLOATING; 137 pointer_state.mode = M_RESIZING | M_FLOATING;
116 } else { 138 } else {
117 bool reset = true;
118 pointer_state.mode = M_RESIZING | M_TILING; 139 pointer_state.mode = M_RESIZING | M_TILING;
119 if ((initial.lr.ptr = get_swayc_in_direction(initial.ptr, lock.left ? MOVE_RIGHT: MOVE_LEFT))) { 140 set_initial_sibling();
120 initial.lr.x = initial.lr.ptr->x;
121 initial.lr.w = initial.lr.ptr->width;
122 reset = false;
123 }
124 if ((initial.tb.ptr = get_swayc_in_direction(initial.ptr, lock.top ? MOVE_DOWN: MOVE_UP))) {
125 initial.tb.y = initial.tb.ptr->y;
126 initial.tb.h = initial.tb.ptr->height;
127 reset = false;
128 }
129 // If nothing changes just undo the mode
130 if (reset) {
131 pointer_state.mode = 0;
132 }
133 } 141 }
134} 142}
135 143
@@ -187,7 +195,6 @@ void pointer_mode_update(void) {
187 } 195 }
188 int dx = pointer_state.origin.x; 196 int dx = pointer_state.origin.x;
189 int dy = pointer_state.origin.y; 197 int dy = pointer_state.origin.y;
190 bool changed = false;
191 198
192 switch (pointer_state.mode) { 199 switch (pointer_state.mode) {
193 case M_FLOATING | M_DRAGGING: 200 case M_FLOATING | M_DRAGGING:
@@ -196,11 +203,9 @@ void pointer_mode_update(void) {
196 dy -= pointer_state.left.y; 203 dy -= pointer_state.left.y;
197 if (initial.x + dx != initial.ptr->x) { 204 if (initial.x + dx != initial.ptr->x) {
198 initial.ptr->x = initial.x + dx; 205 initial.ptr->x = initial.x + dx;
199 changed = true;
200 } 206 }
201 if (initial.y + dy != initial.ptr->y) { 207 if (initial.y + dy != initial.ptr->y) {
202 initial.ptr->y = initial.y + dy; 208 initial.ptr->y = initial.y + dy;
203 changed = true;
204 } 209 }
205 update_geometry(initial.ptr); 210 update_geometry(initial.ptr);
206 break; 211 break;
@@ -253,37 +258,31 @@ void pointer_mode_update(void) {
253 if (lock.left) { 258 if (lock.left) {
254 // Check whether its fine to resize 259 // Check whether its fine to resize
255 if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) { 260 if (initial.w + dx > min_sane_w && initial.lr.w - dx > min_sane_w) {
256 initial.ptr->width = initial.w + dx; 261 initial.lr.sib->width = initial.w + dx;
257 initial.lr.ptr->width = initial.lr.w - dx; 262 initial.lr.ptr->width = initial.lr.w - dx;
258 } 263 }
259 } else { //lock.right 264 } else { //lock.right
260 if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) { 265 if (initial.w - dx > min_sane_w && initial.lr.w + dx > min_sane_w) {
261 initial.ptr->width = initial.w - dx; 266 initial.lr.sib->width = initial.w - dx;
262 initial.lr.ptr->width = initial.lr.w + dx; 267 initial.lr.ptr->width = initial.lr.w + dx;
263 } 268 }
264 changed = true;
265 } 269 }
266 arrange_windows(initial.lr.ptr->parent, -1, -1); 270 arrange_windows(initial.lr.ptr->parent, -1, -1);
267 } 271 }
268 if (initial.tb.ptr) { 272 if (initial.tb.ptr) {
269 if (lock.top) { 273 if (lock.top) {
270 if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) { 274 if (initial.h + dy > min_sane_h && initial.tb.h - dy > min_sane_h) {
271 initial.ptr->height = initial.h + dy; 275 initial.tb.sib->height = initial.h + dy;
272 initial.tb.ptr->height = initial.tb.h - dy; 276 initial.tb.ptr->height = initial.tb.h - dy;
273 } 277 }
274 } else { //lock.bottom 278 } else { //lock.bottom
275 if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) { 279 if (initial.h - dy > min_sane_h && initial.tb.h + dy > min_sane_h) {
276 initial.ptr->height = initial.h - dy; 280 initial.tb.sib->height = initial.h - dy;
277 initial.tb.ptr->height = initial.tb.h + dy; 281 initial.tb.ptr->height = initial.tb.h + dy;
278 } 282 }
279 changed = true;
280 } 283 }
281 arrange_windows(initial.tb.ptr->parent, -1, -1); 284 arrange_windows(initial.tb.ptr->parent, -1, -1);
282 } 285 }
283 if (changed) {
284 arrange_windows(initial.ptr->parent, -1, -1);
285 }
286 changed = false;
287 default: 286 default:
288 return; 287 return;
289 } 288 }