mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Fix switching between focused outputs
This commit is contained in:
parent
868cb3ca71
commit
a64b10df83
3 changed files with 32 additions and 1 deletions
|
@ -37,6 +37,10 @@ static void free_swayc(swayc_t *c) {
|
|||
|
||||
/* New containers */
|
||||
|
||||
static bool workspace_test(swayc_t *view, void *name) {
|
||||
return strcasecmp(view->name, (char *)name);
|
||||
}
|
||||
|
||||
swayc_t *new_output(wlc_handle handle) {
|
||||
const struct wlc_size* size = wlc_output_get_resolution(handle);
|
||||
const char *name = wlc_output_get_name(handle);
|
||||
|
@ -58,6 +62,10 @@ swayc_t *new_output(wlc_handle handle) {
|
|||
struct workspace_output *wso = config->workspace_outputs->items[i];
|
||||
if (strcasecmp(wso->output, name) == 0) {
|
||||
sway_log(L_DEBUG, "Matched workspace to output: %s for %s", wso->workspace, wso->output);
|
||||
// Check if any other workspaces are using this name
|
||||
if (find_container(&root_container, workspace_test, wso->workspace)) {
|
||||
break;
|
||||
}
|
||||
ws_name = strdup(wso->workspace);
|
||||
break;
|
||||
}
|
||||
|
@ -206,6 +214,18 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
|
|||
// NOTE: This is called from elsewhere without checking children length
|
||||
// TODO move containers to other workspaces?
|
||||
// for now just dont delete
|
||||
|
||||
// Do not destroy this if it's the last workspace on this output
|
||||
swayc_t *output = workspace->parent;
|
||||
while (output && output->type != C_OUTPUT) {
|
||||
output = output->parent;
|
||||
}
|
||||
if (output) {
|
||||
if (output->children->length == 1) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (workspace->children->length == 0) {
|
||||
sway_log(L_DEBUG, "Workspace: Destroying workspace '%s'", workspace->name);
|
||||
swayc_t *parent = workspace->parent;
|
||||
|
|
|
@ -16,7 +16,7 @@ static void update_focus(swayc_t *c) {
|
|||
switch (c->type) {
|
||||
case C_ROOT: return;
|
||||
case C_OUTPUT:
|
||||
wlc_output_focus(c->parent->handle);
|
||||
wlc_output_focus(c->handle);
|
||||
break;
|
||||
// switching workspaces
|
||||
case C_WORKSPACE:
|
||||
|
|
|
@ -174,6 +174,17 @@ void workspace_prev() {
|
|||
}
|
||||
|
||||
void workspace_switch(swayc_t *workspace) {
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name);
|
||||
|
||||
// Remove focus from current view
|
||||
swayc_t *current = get_focused_view(&root_container);
|
||||
if (current && current->type == C_VIEW) {
|
||||
wlc_view_set_state(current->handle, WLC_BIT_ACTIVATED, false);
|
||||
}
|
||||
|
||||
set_focused_container(workspace);
|
||||
active_workspace = workspace;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue