Try to use more screen real estate by default

This commit is contained in:
Přemysl Eric Janouch 2021-11-18 21:51:12 +01:00
parent 411f0b3e91
commit b23198f675
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -518,7 +518,6 @@ main(int argc, char *argv[])
gtk_container_add(GTK_CONTAINER(g.stack), g.browser_paned);
g.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (g.window), 800, 600);
g_signal_connect(g.window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(g.window, "key-press-event",
@ -555,6 +554,23 @@ main(int argc, char *argv[])
gtk_widget_grab_focus(g.browser_scroller);
}
// Try to get half of the screen vertically, in 4:3 aspect ratio.
//
// We need the GdkMonitor before the GtkWindow has a GdkWindow (i.e.,
// before it is realized). Take the smallest dimensions, out of desperation.
GdkDisplay *display = gtk_widget_get_display(g.window);
int unit = G_MAXINT;
for (int i = gdk_display_get_n_monitors(display); i--; ) {
GdkRectangle geometry = {};
gdk_monitor_get_geometry(
gdk_display_get_monitor(display, i), &geometry);
unit = MIN(unit, MIN(geometry.width, geometry.height) / 6);
}
// Ask for at least 800x600, to cover ridiculously heterogenous setups.
unit = MAX(200, unit);
gtk_window_set_default_size(GTK_WINDOW(g.window), 4 * unit, 3 * unit);
gtk_widget_show_all(g.window);
gtk_main();
return 0;