session: save/restore window state for Wayland native clients (match by app_id)

This commit is contained in:
Ollie 2026-05-28 22:14:32 +02:00
parent 05b66c2b5c
commit 0abaf1fefa
2 changed files with 9 additions and 5 deletions

View File

@ -203,8 +203,10 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
if (wapp->app_icon && wapp->app_icon->command) {
command = wmalloc(strlen(wapp->app_icon->command) + 1);
strcpy(command, wapp->app_icon->command);
} else
return NULL;
}
/* If still no command (e.g. Wayland native client launched
* externally), continue with app_id as Name so the window
* state is saved and can be restored by app_id matching. */
}
if (PropGetWMClass(win, &class, &instance)) {
@ -568,6 +570,10 @@ void wSessionRestoreState(WScreen *scr)
wDockLaunchWithState(btn, state);
} else if ((pid = execCommand(scr, command)) > 0) {
wWindowAddSavedState(instance, class, command, pid, state);
} else if (instance || class) {
/* No command (Wayland native client) but we have a name.
* Store state for matching when the window appears. */
wWindowAddSavedState(instance, class, NULL, 0, state);
} else {
wfree(state);
}

View File

@ -2446,14 +2446,12 @@ WMagicNumber wWindowGetSavedState(WNativeWindow win)
return NULL;
command = GetCommandForWindow(win);
if (!command)
return NULL;
if (PropGetWMClass(win, &class, &instance)) {
while (wstate) {
if (is_same(instance, wstate->instance) &&
is_same(class, wstate->class) &&
is_same(command, wstate->command)) {
(command == NULL || is_same(command, wstate->command))) {
break;
}
wstate = wstate->next;