From 1a1ac64662a603fdeb7025bed3822e24f9158076 Mon Sep 17 00:00:00 2001 From: taiyu Date: Fri, 21 Aug 2015 10:28:37 -0700 Subject: bugfixes, renames --- sway/commands.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index e90a40a3..e485cdb5 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -208,16 +208,16 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { 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; + add_floating(swayc_active_workspace(),view); + view->x = (swayc_active_workspace()->width - view->width)/2; + view->y = (swayc_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); + arrange_windows(swayc_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 @@ -228,7 +228,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { swayc_t *focused = container_under_pointer(); // If focused is null, it's because the currently focused container is a workspace if (focused == NULL) { - focused = active_workspace; + focused = swayc_active_workspace(); } set_focused_container(focused); @@ -244,7 +244,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { } // Refocus on the view once its been put back into the layout view->width = view->height = 0; - arrange_windows(active_workspace, -1, -1); + arrange_windows(swayc_active_workspace(), -1, -1); } set_focused_container(view); } @@ -293,37 +293,38 @@ static bool cmd_focus(struct sway_config *config, int argc, char **argv) { return move_focus(MOVE_PARENT); } else if (strcasecmp(argv[0], "mode_toggle") == 0) { int i; - swayc_t *focused = get_focused_view(active_workspace); + swayc_t *workspace = swayc_active_workspace(); + swayc_t *focused = get_focused_view(workspace); if (focused->is_floating) { - if (active_workspace->children->length > 0) { - for (i = 0;i < active_workspace->floating->length; i++) { - if (active_workspace->floating->items[i] == focused) { + if (workspace->children->length > 0) { + for (i = 0;i < workspace->floating->length; i++) { + if (workspace->floating->items[i] == focused) { floating_toggled_index = i; break; } } - if (active_workspace->children->length > tiled_toggled_index) { - set_focused_container(get_focused_view(active_workspace->children->items[tiled_toggled_index])); + if (workspace->children->length > tiled_toggled_index) { + set_focused_container(get_focused_view(workspace->children->items[tiled_toggled_index])); } else { - set_focused_container(get_focused_view(active_workspace->children->items[0])); + set_focused_container(get_focused_view(workspace->children->items[0])); tiled_toggled_index = 0; } } } else { - if (active_workspace->floating->length > 0) { - for (i = 0;i < active_workspace->children->length; i++) { - if (active_workspace->children->items[i] == focused) { + if (workspace->floating->length > 0) { + for (i = 0;i < workspace->children->length; i++) { + if (workspace->children->items[i] == focused) { tiled_toggled_index = i; break; } } - if (active_workspace->floating->length > floating_toggled_index) { - swayc_t *floating = active_workspace->floating->items[floating_toggled_index]; + if (workspace->floating->length > floating_toggled_index) { + swayc_t *floating = workspace->floating->items[floating_toggled_index]; set_focused_container(get_focused_view(floating)); } else { - swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length - 1]; + swayc_t *floating = workspace->floating->items[workspace->floating->length - 1]; set_focused_container(get_focused_view(floating)); - tiled_toggled_index = active_workspace->floating->length - 1; + tiled_toggled_index = workspace->floating->length - 1; } } } @@ -459,7 +460,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { amount *= -1; } - swayc_t *parent = get_focused_view(active_workspace); + swayc_t *parent = get_focused_view(swayc_active_workspace()); swayc_t *focused = parent; swayc_t *sibling; if (!parent) { @@ -529,7 +530,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { } // Recursive resize does not handle positions, let arrange_windows // take care of that. - arrange_windows(active_workspace, -1, -1); + arrange_windows(swayc_active_workspace(), -1, -1); return true; } else if (strcmp(argv[1], "height") == 0) { int tnumber = 0; @@ -589,7 +590,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) { } } } - arrange_windows(active_workspace, -1, -1); + arrange_windows(swayc_active_workspace(), -1, -1); return true; } return true; @@ -616,8 +617,12 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay } swayc_t *focused = get_focused_container(&root_container); + // Case of floating window, dont split + if (focused->is_floating) { + return true; + } + /* Case that focus is on an workspace with 0/1 children.change its layout */ if (focused->type == C_WORKSPACE && focused->children->length <= 1) { - /* Case that focus is on an workspace with 0/1 children.change its layout */ sway_log(L_DEBUG, "changing workspace layout"); focused->layout = layout; } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { @@ -632,7 +637,6 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay set_focused_container(focused); arrange_windows(parent, -1, -1); } - return true; } @@ -721,7 +725,7 @@ static bool cmd_workspace(struct sway_config *config, int argc, char **argv) { return true; } - swayc_t *workspace = workspace_find_by_name(argv[0]); + swayc_t *workspace = workspace_by_name(argv[0]); if (!workspace) { workspace = workspace_create(argv[0]); } -- cgit v1.2.3 From d2e1c660b19e8bb24e496b3dd52d4696456863f0 Mon Sep 17 00:00:00 2001 From: taiyu Date: Fri, 21 Aug 2015 10:45:18 -0700 Subject: swayc_is_fullscreen --- sway/commands.c | 2 +- sway/handlers.c | 4 ++-- sway/layout.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index e485cdb5..efaa7472 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -684,7 +684,7 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) { } swayc_t *container = get_focused_view(&root_container); - bool current = (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) > 0; + bool current = swayc_is_fullscreen(container); wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current); // Resize workspace if going from fullscreen -> notfullscreen // otherwise just resize container diff --git a/sway/handlers.c b/sway/handlers.c index 3dda3e43..98809958 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -568,7 +568,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct if (config->focus_follows_mouse && prev_handle != handle) { // Dont change focus if fullscreen swayc_t *focused = get_focused_view(view); - if (!(focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) + if (!swayc_is_fullscreen(focused) && !(pointer_state.l_held || pointer_state.r_held)) { set_focused_container(container_under_pointer()); } @@ -600,7 +600,7 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w uint32_t button, enum wlc_button_state state, const struct wlc_origin *origin) { swayc_t *focused = get_focused_container(&root_container); // dont change focus if fullscreen - if (focused->type == C_VIEW && wlc_view_get_state(focused->handle) & WLC_BIT_FULLSCREEN) { + if (swayc_is_fullscreen(focused)) { return false; } if (state == WLC_BUTTON_STATE_PRESSED) { diff --git a/sway/layout.c b/sway/layout.c index 446ad066..70d9eb21 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -204,7 +204,7 @@ void arrange_windows(swayc_t *container, double width, double height) { .h = height - container->gaps } }; - if (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) { + if (swayc_is_fullscreen(container)) { swayc_t *parent = swayc_parent_by_type(container, C_OUTPUT); geometry.origin.x = 0; geometry.origin.y = 0; @@ -303,7 +303,7 @@ void arrange_windows(swayc_t *container, double width, double height) { .h = view->height } }; - if (wlc_view_get_state(view->handle) & WLC_BIT_FULLSCREEN) { + if (swayc_is_fullscreen(view)) { swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT); geometry.origin.x = 0; geometry.origin.y = 0; @@ -318,7 +318,7 @@ void arrange_windows(swayc_t *container, double width, double height) { // have higher indexes // This is conditional on there not being a fullscreen view in the workspace if (!container->focused - || !(wlc_view_get_state(container->focused->handle) & WLC_BIT_FULLSCREEN)) { + || !swayc_is_fullscreen(container->focused)) { wlc_view_bring_to_front(view->handle); } } -- cgit v1.2.3