=> e83ff095348ed3bb6173c38a8e7bff8b1aaf324c
[1mdiff --git a/res/about/version.gmi b/res/about/version.gmi[m [1mindex 46e36302..5c80b5f2 100644[m [1m--- a/res/about/version.gmi[m [1m+++ b/res/about/version.gmi[m [36m@@ -8,6 +8,7 @@[m [m ## 0.2.1[m * Windows: Fixed text disappearing when window is resized.[m [32m+[m[32m* Windows: Fixed window size/state restoration issues when launching.[m [m ## 0.2[m * Added an icon for quote paragraphs.[m [1mdiff --git a/src/app.c b/src/app.c[m [1mindex cb72509d..ee8bccb4 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -136,19 +136,31 @@[m [mstatic iString *serializePrefs_App_(const iApp *d) {[m const iSidebarWidget *sidebar = findWidget_App("sidebar");[m appendFormat_String(str, "window.retain arg:%d\n", d->retainWindowSize);[m if (d->retainWindowSize) {[m [32m+[m[32m const iBool isMaximized = (SDL_GetWindowFlags(d->window->win) & SDL_WINDOW_MAXIMIZED) != 0;[m int w, h, x, y;[m [31m- SDL_GetWindowSize(d->window->win, &w, &h);[m [31m- SDL_GetWindowPosition(d->window->win, &x, &y);[m [31m-#if defined (iPlatformLinux)[m [31m- /* Workaround for window position being unaffected by decorations on creation. */ {[m [31m- int bl, bt;[m [31m- SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL);[m [31m- x -= bl;[m [31m- y -= bt;[m [32m+[m[32m x = d->window->lastRect.pos.x;[m [32m+[m[32m y = d->window->lastRect.pos.y;[m [32m+[m[32m w = d->window->lastRect.size.x;[m [32m+[m[32m h = d->window->lastRect.size.y;[m [32m+[m[32m#if 0[m [32m+[m[32m SDL_GetWindowSize(d->window->win, &w, &h);[m [32m+[m[32m SDL_GetWindowPosition(d->window->win, &x, &y);[m [32m+[m[32m#i f defined (iPlatformLinux)[m [32m+[m[32m /* Workaround for window position being unaffected by decorations on creation. */ {[m [32m+[m[32m int bl, bt;[m [32m+[m[32m SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL);[m [32m+[m[32m x -= bl;[m [32m+[m[32m y -= bt;[m [32m+[m[32m x = iMax(0, x);[m [32m+[m[32m y = iMax(0, y);[m [32m+[m[32m }[m }[m #endif[m appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y);[m appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar));[m [32m+[m[32m if (isMaximized) {[m [32m+[m[32m appendFormat_String(str, "~window.maximize\n");[m [32m+[m[32m }[m }[m if (isVisible_Widget(sidebar)) {[m appendCStr_String(str, "sidebar.toggle\n");[m [36m@@ -802,6 +814,10 @@[m [miBool handleCommand_App(const char *cmd) {[m d->retainWindowSize = arg_Command(cmd);[m return iTrue;[m }[m [32m+[m[32m else if (equal_Command(cmd, "window.maximize")) {[m [32m+[m[32m SDL_MaximizeWindow(d->window->win);[m [32m+[m[32m return iTrue;[m [32m+[m[32m }[m else if (equal_Command(cmd, "downloads")) {[m setCStr_String(&d->downloadDir, suffixPtr_Command(cmd, "path"));[m return iTrue;[m [1mdiff --git a/src/ui/window.c b/src/ui/window.c[m [1mindex a7ec37dd..6c7775ee 100644[m [1m--- a/src/ui/window.c[m [1m+++ b/src/ui/window.c[m [36m@@ -507,6 +507,7 @@[m [mvoid init_Window(iWindow *d, iRect rect) {[m theWindow_ = d;[m iZap(d->cursors);[m d->initialPos = rect.pos;[m [32m+[m[32m d->lastRect = rect;[m d->pendingCursor = NULL;[m d->isDrawFrozen = iTrue;[m uint32_t flags = 0;[m [36m@@ -525,7 +526,7 @@[m [mvoid init_Window(iWindow *d, iRect rect) {[m exit(-2);[m }[m }[m [31m- if (left_Rect(rect) >= 0) {[m [32m+[m[32m if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) {[m SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));[m }[m SDL_SetWindowMinimumSize(d->win, 400, 250);[m [36m@@ -608,11 +609,22 @@[m [mstatic iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {[m }[m return iFalse;[m #endif[m [31m- case SDL_WINDOWEVENT_MOVED:[m [31m- /* No need to do anything. */[m [32m+[m[32m case SDL_WINDOWEVENT_MOVED: {[m [32m+[m[32m if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {[m [32m+[m[32m d->lastRect.pos = init_I2(ev->data1, ev->data2);[m [32m+[m[32m iInt2 border = zero_I2();[m [32m+[m[32m#if defined (iPlatformMsys) || defined (iPlatformLinux)[m [32m+[m[32m SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL);[m [32m+[m[32m#endif[m [32m+[m[32m d->lastRect.pos = max_I2(zero_I2(), sub_I2(d->lastRect.pos, border));[m [32m+[m[32m }[m return iTrue;[m [32m+[m[32m }[m case SDL_WINDOWEVENT_RESIZED:[m case SDL_WINDOWEVENT_SIZE_CHANGED:[m [32m+[m[32m if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {[m [32m+[m[32m d->lastRect.size = init_I2(ev->data1, ev->data2);[m [32m+[m[32m }[m updateRootSize_Window_(d);[m return iTrue;[m case SDL_WINDOWEVENT_LEAVE:[m [1mdiff --git a/src/ui/window.h b/src/ui/window.h[m [1mindex b067d30e..da4a2123 100644[m [1m--- a/src/ui/window.h[m [1m+++ b/src/ui/window.h[m [36m@@ -35,6 +35,7 @@[m [miDeclareTypeConstructionArgs(Window, iRect rect)[m struct Impl_Window {[m SDL_Window * win;[m iInt2 initialPos;[m [32m+[m[32m iRect lastRect; /* updated when window is moved/resized */[m iBool isDrawFrozen; /* avoids premature draws while restoring window state */[m SDL_Renderer *render;[m iWidget * root;[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).