This commit is contained in:
Andrew Laucius 2026-04-12 16:05:05 +01:00 committed by GitHub
commit 2bd2bfdd73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 3 deletions

View file

@ -3,6 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h>
#include "list.h" #include "list.h"
#ifdef __GNUC__ #ifdef __GNUC__

View file

@ -39,6 +39,8 @@ struct sway_output {
struct wlr_scene_rect *fullscreen_background; struct wlr_scene_rect *fullscreen_background;
struct wlr_output *wlr_output; struct wlr_output *wlr_output;
char *previous_output_name;
struct wlr_scene_output *scene_output; struct wlr_scene_output *scene_output;
struct sway_server *server; struct sway_server *server;
struct wl_list link; struct wl_list link;

View file

@ -46,6 +46,7 @@ struct sway_workspace {
struct side_gaps gaps_outer; struct side_gaps gaps_outer;
struct sway_output *output; // NULL if no outputs are connected struct sway_output *output; // NULL if no outputs are connected
char *previous_output_name; // NULL if no previous output
list_t *floating; // struct sway_container list_t *floating; // struct sway_container
list_t *tiling; // struct sway_container list_t *tiling; // struct sway_container
list_t *output_priority; list_t *output_priority;

View file

@ -29,6 +29,7 @@ enum wlr_direction opposite_direction(enum wlr_direction d) {
} }
static void restore_workspaces(struct sway_output *output) { static void restore_workspaces(struct sway_output *output) {
sway_log(SWAY_DEBUG, "Restore Workspaces: restoring workspaces for output %s", output->wlr_output->name);
// Workspace output priority // Workspace output priority
for (int i = 0; i < root->outputs->length; i++) { for (int i = 0; i < root->outputs->length; i++) {
struct sway_output *other = root->outputs->items[i]; struct sway_output *other = root->outputs->items[i];
@ -38,9 +39,13 @@ static void restore_workspaces(struct sway_output *output) {
for (int j = 0; j < other->workspaces->length; j++) { for (int j = 0; j < other->workspaces->length; j++) {
struct sway_workspace *ws = other->workspaces->items[j]; struct sway_workspace *ws = other->workspaces->items[j];
struct sway_output *highest = struct sway_output *highest =
workspace_output_get_highest_available(ws); workspace_output_get_highest_available(ws);
if (highest == output) { if (highest == output ||
(ws->previous_output_name != NULL &&
!strcmp(ws->previous_output_name, output->wlr_output->name)))
{
workspace_detach(ws); workspace_detach(ws);
output_add_workspace(output, ws); output_add_workspace(output, ws);
ipc_event_workspace(NULL, ws, "move"); ipc_event_workspace(NULL, ws, "move");

View file

@ -215,6 +215,7 @@ struct sway_workspace *workspace_create(struct sway_output *output,
} }
ws->name = strdup(name); ws->name = strdup(name);
ws->previous_output_name = NULL;
ws->prev_split_layout = L_NONE; ws->prev_split_layout = L_NONE;
ws->layout = output_get_default_layout(output); ws->layout = output_get_default_layout(output);
ws->floating = create_list(); ws->floating = create_list();
@ -287,6 +288,7 @@ void workspace_destroy(struct sway_workspace *workspace) {
wlr_scene_node_destroy(&workspace->layers.fullscreen->node); wlr_scene_node_destroy(&workspace->layers.fullscreen->node);
free(workspace->name); free(workspace->name);
free(workspace->previous_output_name);
free(workspace->representation); free(workspace->representation);
list_free_items_and_destroy(workspace->output_priority); list_free_items_and_destroy(workspace->output_priority);
list_free(workspace->floating); list_free(workspace->floating);
@ -434,8 +436,6 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
} }
char *workspace_next_name(const char *output_name) { char *workspace_next_name(const char *output_name) {
sway_log(SWAY_DEBUG, "Workspace: Generating new workspace name for output %s",
output_name);
// Scan for available workspace names by looking through output-workspace // Scan for available workspace names by looking through output-workspace
// assignments primarily, falling back to bindings and numbers. // assignments primarily, falling back to bindings and numbers.
struct sway_mode *mode = config->current_mode; struct sway_mode *mode = config->current_mode;
@ -930,6 +930,12 @@ void workspace_detach(struct sway_workspace *workspace) {
if (index != -1) { if (index != -1) {
list_del(output->workspaces, index); list_del(output->workspaces, index);
} }
if (workspace->previous_output_name) {
free(workspace->previous_output_name);
workspace->previous_output_name = NULL;
}
workspace->previous_output_name = strdup(output->wlr_output->name);
workspace->output = NULL; workspace->output = NULL;
node_set_dirty(&workspace->node); node_set_dirty(&workspace->node);