1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

Make window maximize state persistent

Window maximize state is not persistent between windowmaker sessions.
This patch is updating the save and restore workspace state functions
to update the state in the WMSTATE file.
This commit is contained in:
David Maciejak
2023-02-21 21:40:59 +08:00
committed by Carlos R. Mafra
parent 2fb9308a67
commit f1fef40f0d
3 changed files with 18 additions and 4 deletions

View File

@@ -93,6 +93,7 @@ static WMPropList *sHost;
static WMPropList *sWorkspace;
static WMPropList *sShaded;
static WMPropList *sMiniaturized;
static WMPropList *sMaximized;
static WMPropList *sHidden;
static WMPropList *sGeometry;
static WMPropList *sShortcutMask;
@@ -112,6 +113,7 @@ static void make_keys(void)
sWorkspace = WMCreatePLString("Workspace");
sShaded = WMCreatePLString("Shaded");
sMiniaturized = WMCreatePLString("Miniaturized");
sMaximized = WMCreatePLString("Maximized");
sHidden = WMCreatePLString("Hidden");
sGeometry = WMCreatePLString("Geometry");
sDock = WMCreatePLString("Dock");
@@ -174,7 +176,7 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
unsigned mask;
char *class, *instance, *command = NULL, buffer[512];
WMPropList *win_state, *cmd, *name, *workspace;
WMPropList *shaded, *miniaturized, *hidden, *geometry;
WMPropList *shaded, *miniaturized, *maximized, *hidden, *geometry;
WMPropList *dock, *shortcut;
if (wwin->orig_main_window != None && wwin->orig_main_window != wwin->client_win)
@@ -207,6 +209,8 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
shaded = wwin->flags.shaded ? sYes : sNo;
miniaturized = wwin->flags.miniaturized ? sYes : sNo;
snprintf(buffer, sizeof(buffer), "%i", wwin->flags.maximized);
maximized = WMCreatePLString(buffer);
hidden = wwin->flags.hidden ? sYes : sNo;
snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i",
wwin->client.width, wwin->client.height, wwin->frame_x, wwin->frame_y);
@@ -226,6 +230,7 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
sWorkspace, workspace,
sShaded, shaded,
sMiniaturized, miniaturized,
sMaximized, maximized,
sHidden, hidden,
sShortcutMask, shortcut, sGeometry, geometry, NULL);
@@ -380,7 +385,7 @@ static WSavedState *getWindowState(WScreen * scr, WMPropList * win_state)
WSavedState *state = wmalloc(sizeof(WSavedState));
WMPropList *value;
char *tmp;
unsigned mask;
unsigned mask, maxf;
int i;
state->workspace = -1;
@@ -408,6 +413,12 @@ static WSavedState *getWindowState(WScreen * scr, WMPropList * win_state)
if (value != NULL)
state->miniaturized = getBool(value);
value = WMGetFromPLDictionary(win_state, sMaximized);
if (value != NULL) {
maxf = getInt(value);
state->maximized = maxf;
}
value = WMGetFromPLDictionary(win_state, sHidden);
if (value != NULL)
state->hidden = getBool(value);

View File

@@ -919,6 +919,9 @@ WWindow *wManageWindow(WScreen *scr, Window window)
if (win_state->state->miniaturized > 0 && !WFLAGP(wwin, no_miniaturizable))
wwin->flags.miniaturized = win_state->state->miniaturized;
if (win_state->state->maximized > 0)
wwin->flags.maximized = win_state->state->maximized;
if (!IS_OMNIPRESENT(wwin)) {
int w = wDefaultGetStartWorkspace(scr, wwin->wm_instance,
wwin->wm_class);
@@ -2694,7 +2697,7 @@ void wWindowUpdateGNUstepAttr(WWindow * wwin, GNUstepWMAttributes * attr)
}
WMagicNumber wWindowAddSavedState(const char *instance, const char *class,
const char *command, pid_t pid, WSavedState * state)
const char *command, pid_t pid, WSavedState *state)
{
WWindowState *wstate;

View File

@@ -309,9 +309,9 @@ typedef struct WWindow {
typedef struct WSavedState {
int workspace;
int miniaturized;
int maximized;
int shaded;
int hidden;
int maximized;
int x; /* original geometry of the */
int y; /* window if it's maximized */
unsigned int w;