summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-09-22 09:41:01 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-09-22 09:41:01 -0700
commit6c33f8122a3c4bb8fc22129d1d2ad03f535885f7 (patch)
tree443f1c25df9193c0533710df78be0d7e7d0816ed
parentMerge pull request #183 from mikkeloscar/wlc-dep (diff)
downloadsway-6c33f8122a3c4bb8fc22129d1d2ad03f535885f7.tar.gz
sway-6c33f8122a3c4bb8fc22129d1d2ad03f535885f7.tar.zst
sway-6c33f8122a3c4bb8fc22129d1d2ad03f535885f7.zip
-rw-r--r--sway/handlers.c4
-rw-r--r--sway/layout.c39
2 files changed, 25 insertions, 18 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 096df53c..cef4a980 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -253,8 +253,8 @@ static void handle_view_focus(wlc_handle view, bool focus) {
253} 253}
254 254
255static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) { 255static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geometry *geometry) {
256 sway_log(L_DEBUG, "geometry request %d x %d : %d x %d", 256 sway_log(L_DEBUG, "geometry request for %ld %dx%d : %dx%d",
257 geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h); 257 handle, geometry->origin.x, geometry->origin.y, geometry->size.w, geometry->size.h);
258 // If the view is floating, then apply the geometry. 258 // If the view is floating, then apply the geometry.
259 // Otherwise save the desired width/height for the view. 259 // Otherwise save the desired width/height for the view.
260 // This will not do anything for the time being as WLC improperly sends geometry requests 260 // This will not do anything for the time being as WLC improperly sends geometry requests
diff --git a/sway/layout.c b/sway/layout.c
index bef1b88d..086dc542 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -280,7 +280,6 @@ void move_container(swayc_t *container, enum movement_direction dir) {
280 // Dirty hack to fix a certain case 280 // Dirty hack to fix a certain case
281 arrange_windows(parent, -1, -1); 281 arrange_windows(parent, -1, -1);
282 arrange_windows(parent->parent, -1, -1); 282 arrange_windows(parent->parent, -1, -1);
283 update_visibility(parent->parent);
284 set_focused_container_for(parent->parent, container); 283 set_focused_container_for(parent->parent, container);
285} 284}
286 285
@@ -319,31 +318,34 @@ void update_geometry(swayc_t *container) {
319 if (container->type != C_VIEW) { 318 if (container->type != C_VIEW) {
320 return; 319 return;
321 } 320 }
322 int gap = swayc_gap(container); 321 swayc_t *ws = swayc_parent_by_type(container, C_WORKSPACE);
322 swayc_t *op = ws->parent;
323 int gap = container->is_floating ? 0 : swayc_gap(container);
324
323 struct wlc_geometry geometry = { 325 struct wlc_geometry geometry = {
324 .origin = { 326 .origin = {
325 .x = container->x + (container->is_floating ? 0 : gap / 2), 327 .x = container->x + gap/2 < op->width ? container->x + gap/2 : op->width-1,
326 .y = container->y + (container->is_floating ? 0 : gap / 2) 328 .y = container->y + gap/2 < op->height ? container->y + gap/2 : op->height-1
327 }, 329 },
328 .size = { 330 .size = {
329 .w = container->width > (container->is_floating ? 0 : gap) ? 331 .w = container->width > gap ? container->width - gap : 1,
330 container->width - (container->is_floating ? 0 : gap) : 0, 332 .h = container->height > gap ? container->height - gap : 1,
331 .h = container->height > (container->is_floating ? 0 : gap) ?
332 container->height - (container->is_floating ? 0 : gap) : 0,
333 } 333 }
334 }; 334 };
335 if (swayc_is_fullscreen(container)) { 335 if (swayc_is_fullscreen(container)) {
336 swayc_t *parent = swayc_parent_by_type(container, C_OUTPUT);
337 geometry.origin.x = 0; 336 geometry.origin.x = 0;
338 geometry.origin.y = 0; 337 geometry.origin.y = 0;
339 geometry.size.w = parent->width; 338 geometry.size.w = op->width;
340 geometry.size.h = parent->height; 339 geometry.size.h = op->height;
340 if (op->focused == ws) {
341 wlc_view_bring_to_front(container->handle);
342 }
341 } 343 }
342 wlc_view_set_geometry(container->handle, 0, &geometry); 344 wlc_view_set_geometry(container->handle, 0, &geometry);
343 return; 345 return;
344} 346}
345 347
346void arrange_windows(swayc_t *container, double width, double height) { 348static void arrange_windows_r(swayc_t *container, double width, double height) {
347 int i; 349 int i;
348 if (width == -1 || height == -1) { 350 if (width == -1 || height == -1) {
349 sway_log(L_DEBUG, "Arranging layout for %p", container); 351 sway_log(L_DEBUG, "Arranging layout for %p", container);
@@ -357,7 +359,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
357 for (i = 0; i < container->children->length; ++i) { 359 for (i = 0; i < container->children->length; ++i) {
358 swayc_t *child = container->children->items[i]; 360 swayc_t *child = container->children->items[i];
359 sway_log(L_DEBUG, "Arranging output at %d", x); 361 sway_log(L_DEBUG, "Arranging output at %d", x);
360 arrange_windows(child, -1, -1); 362 arrange_windows_r(child, -1, -1);
361 x += child->width; 363 x += child->width;
362 } 364 }
363 return; 365 return;
@@ -373,7 +375,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
373 child->width = width - gap * 2; 375 child->width = width - gap * 2;
374 child->height = height - gap * 2; 376 child->height = height - gap * 2;
375 sway_log(L_DEBUG, "Arranging workspace #%d at %f, %f", i, child->x, child->y); 377 sway_log(L_DEBUG, "Arranging workspace #%d at %f, %f", i, child->x, child->y);
376 arrange_windows(child, -1, -1); 378 arrange_windows_r(child, -1, -1);
377 } 379 }
378 return; 380 return;
379 case C_VIEW: 381 case C_VIEW:
@@ -417,7 +419,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
417 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale); 419 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, width, scale);
418 child->x = x + container->x; 420 child->x = x + container->x;
419 child->y = y + container->y; 421 child->y = y + container->y;
420 arrange_windows(child, child->width * scale, height); 422 arrange_windows_r(child, child->width * scale, height);
421 x += child->width; 423 x += child->width;
422 } 424 }
423 } 425 }
@@ -444,7 +446,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
444 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale); 446 sway_log(L_DEBUG, "Calculating arrangement for %p:%d (will scale %f by %f)", child, child->type, height, scale);
445 child->x = x + container->x; 447 child->x = x + container->x;
446 child->y = y + container->y; 448 child->y = y + container->y;
447 arrange_windows(child, width, child->height * scale); 449 arrange_windows_r(child, width, child->height * scale);
448 y += child->height; 450 y += child->height;
449 } 451 }
450 } 452 }
@@ -466,6 +468,11 @@ void arrange_windows(swayc_t *container, double width, double height) {
466 } 468 }
467 } 469 }
468 } 470 }
471}
472
473void arrange_windows(swayc_t *container, double width, double height) {
474 update_visibility(container);
475 arrange_windows_r(container, width, height);
469 layout_log(&root_container, 0); 476 layout_log(&root_container, 0);
470} 477}
471 478