diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/border.c | 38 | ||||
-rw-r--r-- | sway/commands.c | 26 | ||||
-rw-r--r-- | sway/focus.c | 34 | ||||
-rw-r--r-- | sway/handlers.c | 14 | ||||
-rw-r--r-- | sway/layout.c | 8 |
5 files changed, 75 insertions, 45 deletions
diff --git a/sway/border.c b/sway/border.c index c1a62bc6..46343d61 100644 --- a/sway/border.c +++ b/sway/border.c @@ -201,12 +201,6 @@ static void render_title_bar(swayc_t *view, cairo_t *cr, struct wlc_geometry *b, } } -void map_update_view_border(swayc_t *view, void *data) { - if (view->type == C_VIEW) { - update_view_border(view); - } -} - /** * Generate nested container title for tabbed/stacked layouts */ @@ -239,6 +233,10 @@ static char *generate_container_title(swayc_t *container) { title = generate_container_title(child); } + if (!title) { + title = "(null)"; + } + len = strlen(name) + strlen(title) + 1; if (i < container->children->length-1) { len++; @@ -293,7 +291,7 @@ void update_tabbed_stacked_titlebars(swayc_t *c, cairo_t *cr, struct wlc_geometr } } -void update_view_border(swayc_t *view) { +static void update_view_border(swayc_t *view) { if (!view->visible) { return; } @@ -308,6 +306,9 @@ void update_view_border(swayc_t *view) { swayc_t *focused = get_focused_view(&root_container); swayc_t *container = swayc_parent_by_type(view, C_CONTAINER); swayc_t *focused_inactive = NULL; + + bool is_child_of_focused = swayc_is_parent_of(get_focused_container(&root_container), view); + if (container) { focused_inactive = swayc_focus_by_type(container, C_VIEW); } else { @@ -334,7 +335,7 @@ void update_view_border(swayc_t *view) { cr = create_border_buffer(view, g, &surface); bool render_top = !should_hide_top_border(view, view->y); - if (view == focused) { + if (view == focused || is_child_of_focused) { render_borders(view, cr, &config->border_colors.focused, render_top); } else { render_borders(view, cr, &config->border_colors.focused_inactive, render_top); @@ -360,7 +361,7 @@ void update_view_border(swayc_t *view) { break; } - if (focused == view) { + if (focused == view || is_child_of_focused) { render_borders(view, cr, &config->border_colors.focused, true); } else if (focused_inactive == view) { render_borders(view, cr, &config->border_colors.focused_inactive, true); @@ -375,7 +376,7 @@ void update_view_border(swayc_t *view) { break; } - if (focused == view) { + if (focused == view || is_child_of_focused) { render_borders(view, cr, &config->border_colors.focused, false); render_title_bar(view, cr, &view->border_geometry, &config->border_colors.focused); @@ -403,6 +404,23 @@ void update_view_border(swayc_t *view) { } } +void update_container_border(swayc_t *container) { + if (container->type == C_VIEW) { + update_view_border(container); + return; + } else { + for (int i = 0; i < container->children->length; ++i) { + update_container_border(container->children->items[i]); + } + } +} + +void map_update_view_border(swayc_t *view, void *data) { + if (view->type == C_VIEW) { + update_view_border(view); + } +} + void render_view_borders(wlc_handle view) { swayc_t *c = swayc_by_handle(view); diff --git a/sway/commands.c b/sway/commands.c index 28dcc996..f73bd21c 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -2340,7 +2340,7 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) { // update container title if tabbed/stacked if (swayc_tabbed_stacked_ancestor(focused)) { - update_view_border(focused); + update_container_border(focused); swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); // schedule render to make changes take effect right away, // otherwise we would have to wait for the view to render, @@ -2501,6 +2501,30 @@ static struct cmd_results *cmd_fullscreen(int argc, char **argv) { swayc_t *workspace = swayc_parent_by_type(container, C_WORKSPACE); bool current = swayc_is_fullscreen(container); wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current); + + if (container->is_floating) { + if (current) { + // set dimensions back to what they were before we fullscreened this + container->x = container->cached_geometry.origin.x; + container->y = container->cached_geometry.origin.y; + container->width = container->cached_geometry.size.w; + container->height = container->cached_geometry.size.h; + } else { + // cache dimensions so we can reset them after we "unfullscreen" this + struct wlc_geometry geo = { + .origin = { + .x = container->x, + .y = container->y + }, + .size = { + .w = container->width, + .h = container->height + } + }; + container->cached_geometry = geo; + } + } + // Resize workspace if going from fullscreen -> notfullscreen // otherwise just resize container if (!current) { diff --git a/sway/focus.c b/sway/focus.c index 0f629e1e..6583f802 100644 --- a/sway/focus.c +++ b/sway/focus.c @@ -10,7 +10,6 @@ #include "border.h" bool locked_container_focus = false; -bool locked_view_focus = false; bool suspend_workspace_cleanup = false; // switches parent focus to c. will switch it accordingly @@ -115,7 +114,7 @@ bool set_focused_container(swayc_t *c) { // Get workspace for c, get that workspaces current focused container. swayc_t *workspace = swayc_active_workspace_for(c); - swayc_t *focused = get_focused_view(workspace); + swayc_t *focused = get_focused_container(workspace); if (swayc_is_fullscreen(focused) && focused != c) { // if switching to a workspace with a fullscreen view, @@ -140,37 +139,32 @@ bool set_focused_container(swayc_t *c) { } // get new focused view and set focus to it. - p = get_focused_view(c); - if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { + if (c->type == C_CONTAINER || (c->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP))) { // unactivate previous focus if (focused->type == C_VIEW) { wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); - update_view_border(focused); } + update_container_border(focused); // activate current focus - if (p->type == C_VIEW) { - wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); - // set focus if view_focus is unlocked - if (!locked_view_focus) { - wlc_view_focus(p->handle); - if (p->parent->layout != L_TABBED - && p->parent->layout != L_STACKED) { - update_view_border(p); - } - } + if (c->type == C_VIEW) { + wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); + } + // set focus if view_focus is unlocked + wlc_view_focus(c->handle); + if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { + update_container_border(c); } // rearrange if parent container is tabbed/stacked - swayc_t *parent = swayc_tabbed_stacked_ancestor(p); + swayc_t *parent = swayc_tabbed_stacked_ancestor(c); if (parent != NULL) { arrange_backgrounds(); arrange_windows(parent, -1, -1); } - } else if (p->type == C_WORKSPACE) { + } else if (c->type == C_WORKSPACE) { // remove previous focus if view_focus is unlocked - if (!locked_view_focus) { - wlc_view_focus(0); - } + update_container_border(c); + wlc_view_focus(0); } if (active_ws != workspace) { diff --git a/sway/handlers.c b/sway/handlers.c index bdcdcaa4..6d35f8a2 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -226,7 +226,7 @@ static void handle_output_focused(wlc_handle output, bool focus) { handle_output_created(output); } if (focus) { - set_focused_container(c); + set_focused_container(get_focused_container(c)); } } @@ -343,7 +343,6 @@ static bool handle_view_created(wlc_handle handle) { // Dmenu keeps viewfocus, but others with this flag don't, for now simulate // dmenu case WLC_BIT_OVERRIDE_REDIRECT: - // locked_view_focus = true; wlc_view_focus(handle); wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); wlc_view_bring_to_front(handle); @@ -415,7 +414,7 @@ static bool handle_view_created(wlc_handle handle) { // we were on one workspace, switched to another to add this view, // now let's return to where we were workspace_switch(current_ws); - set_focused_container(current_ws->focused); + set_focused_container(get_focused_container(current_ws)); } suspend_workspace_cleanup = false; @@ -437,7 +436,6 @@ static void handle_view_destroyed(wlc_handle handle) { // DMENU has this flag, and takes view_focus, but other things with this // flag don't case WLC_BIT_OVERRIDE_REDIRECT: -// locked_view_focus = false; break; case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED: locked_container_focus = false; @@ -553,9 +551,9 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) { swayc_t *p = swayc_tabbed_stacked_ancestor(c); if (p) { // TODO: we only got the topmost tabbed/stacked container, update borders of all containers on the path - update_view_border(get_focused_view(p)); + update_container_border(get_focused_view(p)); } else if (c->border_type == B_NORMAL) { - update_view_border(c); + update_container_border(c); } ipc_event_window(c, "title"); } @@ -646,10 +644,6 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier return EVENT_PASSTHROUGH; } - if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { - return EVENT_PASSTHROUGH; - } - // reset pointer mode on keypress if (state == WLC_KEY_STATE_PRESSED && pointer_state.mode) { pointer_mode_reset(); diff --git a/sway/layout.c b/sway/layout.c index 6502d930..42954ebc 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -441,7 +441,7 @@ static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geo c->border_geometry = g; *geometry = c->actual_geometry; - update_view_border(c); + update_container_border(c); } void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) { @@ -688,7 +688,7 @@ void update_geometry(swayc_t *container) { container->actual_geometry = geometry; if (container->type == C_VIEW) { - update_view_border(container); + update_container_border(container); } } @@ -867,7 +867,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { // update focused view border last because it may // depend on the title bar geometry of its siblings. if (focused && container->children->length > 1) { - update_view_border(focused); + update_container_border(focused); } } break; @@ -911,7 +911,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { // update focused view border last because it may // depend on the title bar geometry of its siblings. if (focused && container->children->length > 1) { - update_view_border(focused); + update_container_border(focused); } } break; |