From e83ff095348ed3bb6173c38a8e7bff8b1aaf324c Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi

Date: Mon, 21 Sep 2020 12:40:46 +0300

Subject: [PATCH 1/1] Restoring maximized windows

Window position and size are stored when move/resize events are received, not only when the window is closed.


res/about/version.gmi | 1 +

src/app.c | 32 ++++++++++++++++++++++++--------

src/ui/window.c | 18 +++++++++++++++---

src/ui/window.h | 1 +

4 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/res/about/version.gmi b/res/about/version.gmi

index 46e36302..5c80b5f2 100644

--- a/res/about/version.gmi

+++ b/res/about/version.gmi

@@ -8,6 +8,7 @@

0.2.1

+* Windows: Fixed window size/state restoration issues when launching.

0.2

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) {

 const iSidebarWidget *sidebar = findWidget_App("sidebar");

 appendFormat_String(str, "window.retain arg:%d\n", d->retainWindowSize);

 if (d->retainWindowSize) {

     int w, h, x, y;

-#if defined (iPlatformLinux)

+#if 0

+#i f defined (iPlatformLinux)

     }

#endif

     appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y);

     appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar));

 }

 if (isVisible_Widget(sidebar)) {

     appendCStr_String(str, "sidebar.toggle\n");

@@ -802,6 +814,10 @@ iBool handleCommand_App(const char *cmd) {

     d->retainWindowSize = arg_Command(cmd);

     return iTrue;

 }

 else if (equal_Command(cmd, "downloads")) {

     setCStr_String(&d->downloadDir, suffixPtr_Command(cmd, "path"));

     return iTrue;

diff --git a/src/ui/window.c b/src/ui/window.c

index a7ec37dd..6c7775ee 100644

--- a/src/ui/window.c

+++ b/src/ui/window.c

@@ -507,6 +507,7 @@ void init_Window(iWindow *d, iRect rect) {

 theWindow_ = d;

 iZap(d->cursors);

 d->initialPos = rect.pos;

 d->pendingCursor = NULL;

 d->isDrawFrozen = iTrue;

 uint32_t flags = 0;

@@ -525,7 +526,7 @@ void init_Window(iWindow *d, iRect rect) {

         exit(-2);

     }

 }

     SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));

 }

 SDL_SetWindowMinimumSize(d->win, 400, 250);

@@ -608,11 +609,22 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {

         }

         return iFalse;

#endif

+#if defined (iPlatformMsys) || defined (iPlatformLinux)

+#endif

         return iTrue;

     case SDL_WINDOWEVENT_RESIZED:

     case SDL_WINDOWEVENT_SIZE_CHANGED:

         updateRootSize_Window_(d);

         return iTrue;

     case SDL_WINDOWEVENT_LEAVE:

diff --git a/src/ui/window.h b/src/ui/window.h

index b067d30e..da4a2123 100644

--- a/src/ui/window.h

+++ b/src/ui/window.h

@@ -35,6 +35,7 @@ iDeclareTypeConstructionArgs(Window, iRect rect)

struct Impl_Window {

 SDL_Window *  win;

 iInt2         initialPos;

 iBool         isDrawFrozen; /* avoids premature draws while restoring window state */

 SDL_Renderer *render;

 iWidget *     root;

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.8/patch/e83ff095348ed3bb6173c38a8e7bff8b1aaf324c.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
141.283409 milliseconds
Gemini-to-HTML Time
2.581511 milliseconds

This content has been proxied by September (ba2dc).