aboutsummaryrefslogtreecommitdiff
path: root/fiv.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-07-23 21:22:39 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-07-23 21:26:24 +0200
commit31f428f4ec7f2967472018ea0a8f61c34690b0ac (patch)
treecc1d9c98e66ba49a73589ab0e600e1bfd185f671 /fiv.c
parent4b4e24e71af4d7ae5b062954acf60b79e4273715 (diff)
downloadfiv-31f428f4ec7f2967472018ea0a8f61c34690b0ac.tar.gz
fiv-31f428f4ec7f2967472018ea0a8f61c34690b0ac.tar.xz
fiv-31f428f4ec7f2967472018ea0a8f61c34690b0ac.zip
Make the window assume a centred position on macOS
Windows and Linux applications are more likely to not bother, and their desktop environments don't place windows right in the corner, which is what happens with GTK+/macOS.
Diffstat (limited to 'fiv.c')
-rw-r--r--fiv.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fiv.c b/fiv.c
index 6e67ad2..d5d2871 100644
--- a/fiv.c
+++ b/fiv.c
@@ -18,6 +18,9 @@
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_QUARTZ
+#include <gdk/gdkquartz.h>
+#endif // GDK_WINDOWING_QUARTZ
#include <errno.h>
#include <math.h>
@@ -2009,6 +2012,13 @@ main(int argc, char *argv[])
unit = MAX(200, unit);
gtk_window_set_default_size(GTK_WINDOW(g.window), 4 * unit, 3 * unit);
+#ifdef GDK_WINDOWING_QUARTZ
+ // Otherwise the window simply opens at (0, 0),
+ // while other macOS applications are more likely to start centered.
+ if (GDK_IS_QUARTZ_DISPLAY(display))
+ gtk_window_set_position(GTK_WINDOW(g.window), GTK_WIN_POS_CENTER);
+#endif // GDK_WINDOWING_QUARTZ
+
// XXX: The widget wants to read the display's profile. The realize is ugly.
gtk_widget_realize(g.view);