From ce928050f3f48db8c1dc46030f36fefc705de987 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Mon, 21 Sep 2020 13:52:13 +0300
Subject: [PATCH 1/1] macOS: Window size/mode restoration tweaks
Don't bother with maximized mode, it causes a needless animation at launch.
src/app.c | 18 ++++--------------
src/ui/window.c | 15 ++++++++++++---
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/app.c b/src/app.c
index ee8bccb4..04928b84 100644
--- a/src/app.c
+++ b/src/app.c
@@ -142,25 +142,15 @@ static iString *serializePrefs_App_(const iApp *d) {
y = d->window->lastRect.pos.y;
w = d->window->lastRect.size.x;
h = d->window->lastRect.size.y;
-#if 0
SDL_GetWindowSize(d->window->win, &w, &h);
SDL_GetWindowPosition(d->window->win, &x, &y);
-#i f defined (iPlatformLinux)
/* Workaround for window position being unaffected by decorations on creation. */ {
int bl, bt;
SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL);
x -= bl;
y -= bt;
x = iMax(0, x);
y = iMax(0, y);
}
}
-#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));
/* On macOS, maximization should be applied at creation time or the window will take
a moment to animate to its maximized size. */
+#if !defined (iPlatformApple)
if (isMaximized) {
appendFormat_String(str, "~window.maximize\n");
}
+#endif
}
if (isVisible_Widget(sidebar)) {
appendCStr_String(str, "sidebar.toggle\n");
diff --git a/src/ui/window.c b/src/ui/window.c
index 6c7775ee..19432691 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -597,6 +597,15 @@ SDL_Renderer *renderer_Window(const iWindow *d) {
return d->render;
}
+static iBool isMaximized_Window_(const iWindow *d) {
+#if !defined (iPlatformApple)
+#else
+#endif
+}
static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
switch (ev->event) {
#if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX)
@@ -610,10 +619,10 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
return iFalse;
#endif
case SDL_WINDOWEVENT_MOVED: {
if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
if (!isMaximized_Window_(d)) {
d->lastRect.pos = init_I2(ev->data1, ev->data2);
iInt2 border = zero_I2();
-#if defined (iPlatformMsys) || defined (iPlatformLinux)
+#if !defined (iPlatformApple)
SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL);
#endif
d->lastRect.pos = max_I2(zero_I2(), sub_I2(d->lastRect.pos, border));
@@ -622,7 +631,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
}
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED:
if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
if (!isMaximized_Window_(d)) {
d->lastRect.size = init_I2(ev->data1, ev->data2);
}
updateRootSize_Window_(d);
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).