void set_focused_container_for(swayc_t *a, swayc_t *c) { if (locked_container_focus || !c) { return; } swayc_t *find = c; //Ensure that a is an ancestor of c while (find != a && (find = find->parent)) { if (find == &root_container) { return; } } sway_log(L_DEBUG, "Setting focus for %p:%ld to %p:%ld", a, a->handle, c, c->handle); c->is_focused = true; swayc_t *p = c; while (p != a) { update_focus(p); p = p->parent; p->is_focused = false; } if (!locked_view_focus) { p = get_focused_view(c); // Set focus to p if (p) { wlc_view_focus(p->handle); wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); } } }
void set_focused_container(swayc_t *c) { if (locked_container_focus || !c) { return; } sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); if (c->type != C_ROOT && c->type != C_OUTPUT) { c->is_focused = true; } swayc_t *prev_view = get_focused_view(&root_container); swayc_t *p = c; while (p != &root_container) { update_focus(p); p = p->parent; p->is_focused = false; } if (!locked_view_focus) { p = get_focused_view(c); // Set focus to p if (p && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { if (prev_view) { wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false); } wlc_view_focus(p->handle); wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true); } } }
bool set_focused_container_for(swayc_t *a, swayc_t *c) { if (locked_container_focus || !c) { return false; } swayc_t *find = c; // Ensure that a is an ancestor of c while (find != a && (find = find->parent)) { if (find == &root_container) { return false; } } // 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); // if the workspace we are changing focus to has a fullscreen view return if (swayc_is_fullscreen(focused) && c != focused) { return false; } // Check if we changing a parent container that will see chnage bool effective = true; while (find != &root_container) { if (find->parent->focused != find) { effective = false; } find = find->parent; } if (effective) { // Go to set_focused_container return set_focused_container(c); } sway_log(L_DEBUG, "Setting focus for %p:%ld to %p:%ld", a, a->handle, c, c->handle); c->is_focused = true; swayc_t *p = c; while (p != a) { update_focus(p); p = p->parent; p->is_focused = false; } return true; }
bool set_focused_container(swayc_t *c) { if (locked_container_focus || !c) { return false; } swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle); // 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); // if the workspace we are changing focus to has a fullscreen view return if (swayc_is_fullscreen(focused) && focused != c) { return false; } // update container focus from here to root, making necessary changes along // the way swayc_t *p = c; if (p->type != C_OUTPUT && p->type != C_ROOT) { p->is_focused = true; } while (p != &root_container) { update_focus(p); p = p->parent; p->is_focused = false; } // 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)) { // unactivate previous focus if (focused->type == C_VIEW) { wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); } // 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); } } } return true; }
bool set_focused_container(swayc_t *c) { if (locked_container_focus || !c || !c->parent) { return false; } swayc_t *active_ws = swayc_active_workspace(); int active_ws_child_count = 0; if (active_ws) { active_ws_child_count = active_ws->children->length + active_ws->floating->length; } swayc_log(L_DEBUG, c, "Setting focus to %p:%" PRIuPTR, c, c->handle); // 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); if (swayc_is_fullscreen(focused) && focused != c) { // if switching to a workspace with a fullscreen view, // focus on the fullscreen view c = focused; } if (c->type == C_VIEW) { // dispatch a window event ipc_event_window(c, "focus"); } // update container focus from here to root, making necessary changes along // the way swayc_t *p = c; if (p->type != C_OUTPUT && p->type != C_ROOT) { p->is_focused = true; } while (p != &root_container) { update_focus(p); p = p->parent; p->is_focused = false; } // 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)) { // unactivate previous focus if (focused->type == C_VIEW) { wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); update_view_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); } } } // rearrange if parent container is tabbed/stacked swayc_t *parent = swayc_tabbed_stacked_ancestor(p); if (parent != NULL) { arrange_backgrounds(); arrange_windows(parent, -1, -1); } } else if (p->type == C_WORKSPACE) { // remove previous focus if view_focus is unlocked if (!locked_view_focus) { wlc_view_focus(0); } } if (active_ws != workspace) { // active_ws might have been destroyed by now // (focus swap away from empty ws = destroy ws) if (active_ws_child_count == 0) { active_ws = NULL; } ipc_event_workspace(active_ws, workspace, "focus"); } return true; }
/* ** list_buffers - open a special buffer with a list of open files and bookmarks, ** switch to the open buffer or (re)generate it */ int list_buffers (void) { int ri, lno_read; LINE *lp=NULL, *lx=NULL; char one_line[CMDLINESIZE*2]; int ret=1, bm_i; int origin = cnf.ring_curr; /* open or reopen? */ ret = scratch_buffer("*ring*"); if (ret==0) { /* switch to */ if (origin != cnf.ring_curr && CURR_FILE.num_lines > 0) return (0); /* generate or regenerate */ if (CURR_FILE.num_lines > 0) ret = clean_buffer(); } if (ret) { return (ret); } CURR_FILE.num_lines = 0; CURR_FILE.fflag |= (FSTAT_SPECW); if (origin != cnf.ring_curr) { CURR_FILE.origin = origin; } /* fill with data from ring */ CURR_FILE.num_lines += cnf.ring_size; lp = CURR_FILE.bottom->prev; lno_read = 0; memset(one_line, 0, sizeof(one_line)); for (ri=0; ret==0 && ri<RINGSIZE; ri++) { if (!(cnf.fdata[ri].fflag & FSTAT_OPEN)) continue; /* base data */ if (cnf.fdata[ri].fflag & (FSTAT_SPECW | FSTAT_SCRATCH)) { snprintf(one_line, sizeof(one_line)-1, "%d \"%s\" lines: %d flags: %s%s%s%s\n", ri, cnf.fdata[ri].fname, cnf.fdata[ri].num_lines, (cnf.fdata[ri].fflag & FSTAT_SPECW) ? "special " : "", (cnf.fdata[ri].fflag & FSTAT_SCRATCH) ? "scratch " : "", (cnf.fdata[ri].fflag & FSTAT_CHMASK) ? "r/o " : "", (cnf.fdata[ri].pipe_output != 0) ? "pipe " : ""); } else { snprintf(one_line, sizeof(one_line)-1, "%d \"%s\" lines: %d flags: %s%s%s%s\n", ri, cnf.fdata[ri].fname, cnf.fdata[ri].num_lines, (cnf.fdata[ri].fflag & FSTAT_RO) ? "R/O " : "R/W ", (cnf.fdata[ri].fflag & FSTAT_CHANGE) ? "Mod " : "", (cnf.fdata[ri].fflag & FSTAT_EXTCH) ? "Ext.Mod " : "", (cnf.fdata[ri].fflag & FSTAT_HIDDEN) ? "HIDDEN " : ""); } if ((lx = append_line (lp, one_line)) != NULL) { lno_read++; lp=lx; } else { ret = 2; break; } /* optional: bookmarks */ for (bm_i=1; bm_i < 10; bm_i++) { if (ri == cnf.bookmark[bm_i].ring) { snprintf(one_line, sizeof(one_line)-1, "\tbookmark %d: %s\n", bm_i, cnf.bookmark[bm_i].sample); if ((lx = append_line (lp, one_line)) != NULL) { lno_read++; lp=lx; } else { ret = 2; break; } } } }/* for ri... */ if (ret==0) { CURR_FILE.num_lines = lno_read; CURR_LINE = CURR_FILE.top->next; CURR_FILE.lineno = 1; update_focus(FOCUS_ON_2ND_LINE, cnf.ring_curr); go_home(); CURR_FILE.fflag &= ~FSTAT_CHANGE; /* disable inline editing and adding lines */ CURR_FILE.fflag |= (FSTAT_NOEDIT | FSTAT_NOADDLIN); } else { ret |= drop_file(); } return (ret); }