// switches parent focus to c. will switch it accordingly // TODO: Everything needs a handle, so we can set front/back position properly static void update_focus(swayc_t *c) { // Handle if focus switches swayc_t *parent = c->parent; if (parent->focused != c) { switch (c->type) { case C_ROOT: return; case C_OUTPUT: wlc_output_focus(c->handle); break; // switching workspaces case C_WORKSPACE: if (parent->focused) { swayc_t *ws = parent->focused; // hide visibility of old workspace uint32_t mask = 1; container_map(ws, set_view_visibility, &mask); // set visibility of new workspace mask = 2; container_map(c, set_view_visibility, &mask); wlc_output_set_mask(parent->handle, 2); destroy_workspace(ws); } active_workspace = c; break; default: case C_VIEW: case C_CONTAINER: // TODO whatever to do when container changes // for example, stacked and tabbing change stuff. break; } } c->parent->focused = c; }
static bool handle_output_created(wlc_handle output) { swayc_t *op = new_output(output); // Visibility mask to be able to make view invisible wlc_output_set_mask(output, VISIBLE); if (!op) { return false; } // Switch to workspace if we need to if (swayc_active_workspace() == NULL) { swayc_t *ws = op->children->items[0]; workspace_switch(ws); } // Fixes issues with backgrounds and wlc wlc_handle prev = wlc_get_focused_output(); wlc_output_focus(output); wlc_output_focus(prev); return true; }
// switches parent focus to c. will switch it accordingly static void update_focus(swayc_t *c) { // Handle if focus switches swayc_t *parent = c->parent; if (!parent) return; if (parent->focused != c) { // Get previous focus swayc_t *prev = parent->focused; // Set new focus parent->focused = c; switch (c->type) { // Shouldn't happen case C_ROOT: return; // Case where output changes case C_OUTPUT: // update borders for views in prev container_map(prev, map_update_view_border, NULL); wlc_output_focus(c->handle); break; // Case where workspace changes case C_WORKSPACE: if (prev) { ipc_event_workspace(prev, c, "focus"); // if the old workspace has no children, destroy it if(prev->children->length == 0 && prev->floating->length == 0 && !suspend_workspace_cleanup) { destroy_workspace(prev); } else { // update visibility of old workspace update_visibility(prev); } } // Update visibility of newly focused workspace update_visibility(c); break; default: case C_VIEW: case C_CONTAINER: // TODO whatever to do when container changes // for example, stacked and tabbing change stuff. break; } } }
// switches parent focus to c. will switch it accordingly // TODO: Everything needs a handle, so we can set front/back position properly static void update_focus(swayc_t *c) { // Handle if focus switches swayc_t *parent = c->parent; if (parent->focused != c) { // Get previous focus swayc_t *prev = parent->focused; // Set new focus parent->focused = c; switch (c->type) { // Shouldnt happen case C_ROOT: return; // Case where output changes case C_OUTPUT: wlc_output_focus(c->handle); break; // Case where workspace changes case C_WORKSPACE: if (prev) { // update visibility of old workspace update_visibility(prev); destroy_workspace(prev); } // Update visibility of newly focused workspace update_visibility(c); break; default: case C_VIEW: case C_CONTAINER: // TODO whatever to do when container changes // for example, stacked and tabbing change stuff. break; } } }