summaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2015-08-19 07:14:03 -0400
committerDrew DeVault <[email protected]>2015-08-19 07:14:03 -0400
commit8fb2e7e34e279a005a4d42e224f71f9b35ddf918 (patch)
treea04cc657974f755360c5102a88c908a5160f61cd /sway/commands.c
parentae367c5af496828cf326f55597db26fcbfefe6d0 (diff)
parentc5a69828934bf07db9062bd5f24bb2ff94b45b4a (diff)
Merge pull request #79 from taiyu-len/master
fixed floating_modifier related things
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/sway/commands.c b/sway/commands.c
index ab24f6ae..cc51717b 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -186,43 +186,28 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
if (view->type != C_VIEW) {
return true;
}
- int i;
// Change from nonfloating to floating
if (!view->is_floating) {
- view->is_floating = true;
- for (i = 0; i < view->parent->children->length; i++) {
- if (view->parent->children->items[i] == view) {
- // Try to use desired geometry to set w/h
- if (view->desired_width != -1) {
- view->width = view->desired_width;
- }
- if (view->desired_height != -1) {
- view->height = view->desired_height;
- }
-
- // Swap from the list of whatever container the view was in
- // to the workspace->floating list
- list_del(view->parent->children, i);
- list_add(active_workspace->floating, view);
- destroy_container(view->parent);
-
- // Set the new position of the container and arrange windows
- view->x = (active_workspace->width - view->width)/2;
- view->y = (active_workspace->height - view->height)/2;
- sway_log(L_INFO, "Setting container %p to floating at coordinates X:%d Y:%d, W:%d, H:%d", view, view->x, view->y, view->width, view->height);
- // Change parent to active_workspace
- view->parent = active_workspace;
- arrange_windows(active_workspace, -1, -1);
- return true;
- }
+ //Remove view from its current location
+ destroy_container(remove_child(view));
+
+ //and move it into workspace floating
+ add_floating(active_workspace,view);
+ view->x = (active_workspace->width - view->width)/2;
+ view->y = (active_workspace->height - view->height)/2;
+ if (view->desired_width != -1) {
+ view->width = view->desired_width;
+ }
+ if (view->desired_height != -1) {
+ view->height = view->desired_height;
}
+ arrange_windows(active_workspace, -1, -1);
} else {
// Delete the view from the floating list and unset its is_floating flag
// Using length-1 as the index is safe because the view must be the currently
// focused floating output
- list_del(active_workspace->floating, active_workspace->floating->length - 1);
+ remove_child(view);
view->is_floating = false;
- active_workspace->focused = NULL;
// Get the properly focused container, and add in the view there
swayc_t *focused = container_under_pointer();
// If focused is null, it's because the currently focused container is a workspace
@@ -242,10 +227,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
add_sibling(focused, view);
}
// Refocus on the view once its been put back into the layout
- set_focused_container(view);
arrange_windows(active_workspace, -1, -1);
return true;
}
+ set_focused_container(view);
}
return true;