summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-21 12:40:46 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-21 12:40:46 +0300
commite83ff095348ed3bb6173c38a8e7bff8b1aaf324c (patch)
treeef23f49350bb7caf5a1da751e2edf1c68927b5fd /src/app.c
parent09e1f89c21f9c8fbdcfbe801cc796865809161c1 (diff)
Restoring maximized windows
Window position and size are stored when move/resize events are received, not only when the window is closed.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/app.c b/src/app.c
index cb72509d..ee8bccb4 100644
--- a/src/app.c
+++ b/src/app.c
@@ -136,19 +136,31 @@ static iString *serializePrefs_App_(const iApp *d) {
136 const iSidebarWidget *sidebar = findWidget_App("sidebar"); 136 const iSidebarWidget *sidebar = findWidget_App("sidebar");
137 appendFormat_String(str, "window.retain arg:%d\n", d->retainWindowSize); 137 appendFormat_String(str, "window.retain arg:%d\n", d->retainWindowSize);
138 if (d->retainWindowSize) { 138 if (d->retainWindowSize) {
139 const iBool isMaximized = (SDL_GetWindowFlags(d->window->win) & SDL_WINDOW_MAXIMIZED) != 0;
139 int w, h, x, y; 140 int w, h, x, y;
140 SDL_GetWindowSize(d->window->win, &w, &h); 141 x = d->window->lastRect.pos.x;
141 SDL_GetWindowPosition(d->window->win, &x, &y); 142 y = d->window->lastRect.pos.y;
142#if defined (iPlatformLinux) 143 w = d->window->lastRect.size.x;
143 /* Workaround for window position being unaffected by decorations on creation. */ { 144 h = d->window->lastRect.size.y;
144 int bl, bt; 145#if 0
145 SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL); 146 SDL_GetWindowSize(d->window->win, &w, &h);
146 x -= bl; 147 SDL_GetWindowPosition(d->window->win, &x, &y);
147 y -= bt; 148#i f defined (iPlatformLinux)
149 /* Workaround for window position being unaffected by decorations on creation. */ {
150 int bl, bt;
151 SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL);
152 x -= bl;
153 y -= bt;
154 x = iMax(0, x);
155 y = iMax(0, y);
156 }
148 } 157 }
149#endif 158#endif
150 appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y); 159 appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y);
151 appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar)); 160 appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar));
161 if (isMaximized) {
162 appendFormat_String(str, "~window.maximize\n");
163 }
152 } 164 }
153 if (isVisible_Widget(sidebar)) { 165 if (isVisible_Widget(sidebar)) {
154 appendCStr_String(str, "sidebar.toggle\n"); 166 appendCStr_String(str, "sidebar.toggle\n");
@@ -802,6 +814,10 @@ iBool handleCommand_App(const char *cmd) {
802 d->retainWindowSize = arg_Command(cmd); 814 d->retainWindowSize = arg_Command(cmd);
803 return iTrue; 815 return iTrue;
804 } 816 }
817 else if (equal_Command(cmd, "window.maximize")) {
818 SDL_MaximizeWindow(d->window->win);
819 return iTrue;
820 }
805 else if (equal_Command(cmd, "downloads")) { 821 else if (equal_Command(cmd, "downloads")) {
806 setCStr_String(&d->downloadDir, suffixPtr_Command(cmd, "path")); 822 setCStr_String(&d->downloadDir, suffixPtr_Command(cmd, "path"));
807 return iTrue; 823 return iTrue;