aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-17 11:37:19 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-17 11:37:19 -0400
commitb48e8d1b178f2c713579dc532ff4be6edfccc5bc (patch)
treef9da3981625cd2235961f8efee7c4f3a94649241 /sway/layout.c
parentbe2635daa6b041de4dfb24952e96779a505b1b09 (diff)
parentc9ce8bf1bd0f4cfb459bcb7d3ec45429c0a81293 (diff)
Merge pull request #54 from Luminarys/master
Added in basic floating support
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/sway/layout.c b/sway/layout.c
index 4407742a..1bc65050 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -65,10 +65,20 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
int i;
- for (i = 0; i < parent->children->length; ++i) {
- if (parent->children->items[i] == child) {
- list_del(parent->children, i);
- break;
+ // Special case for floating views
+ if (child->is_floating) {
+ for (i = 0; i < parent->floating->length; ++i) {
+ if (parent->floating->items[i] == child) {
+ list_del(parent->floating, i);
+ break;
+ }
+ }
+ } else {
+ for (i = 0; i < parent->children->length; ++i) {
+ if (parent->children->items[i] == child) {
+ list_del(parent->children, i);
+ break;
+ }
}
}
if (parent->focused == child) {
@@ -192,6 +202,33 @@ void arrange_windows(swayc_t *container, int width, int height) {
}
break;
}
+
+ // Arrage floating layouts for workspaces last
+ if (container->type == C_WORKSPACE) {
+ for (i = 0; i < container->floating->length; ++i) {
+ swayc_t *view = ((swayc_t *)container->floating->items[i]);
+ // Set the geometry
+ struct wlc_geometry geometry = {
+ .origin = {
+ .x = view->x,
+ .y = view->y
+ },
+ .size = {
+ .w = view->width,
+ .h = view->height
+ }
+ };
+ wlc_view_set_geometry(view->handle, &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 (!(wlc_view_get_state(container->focused->handle) & WLC_BIT_FULLSCREEN)) {
+ wlc_view_bring_to_front(view->handle);
+ }
+ }
+ }
layout_log(&root_container, 0);
}
@@ -199,7 +236,18 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
if (parent->children == NULL) {
return NULL;
}
+
+ // Search for floating workspaces
int i;
+ if (parent->type == C_WORKSPACE) {
+ for (i = 0; i < parent->floating->length; ++i) {
+ swayc_t *child = parent->floating->items[i];
+ if (child->handle == handle) {
+ return child;
+ }
+ }
+ }
+
for (i = 0; i < parent->children->length; ++i) {
swayc_t *child = parent->children->items[i];
if (child->handle == handle) {