aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2015-01-04 18:03:36 +0000
committerSimon Tatham <anakin@pobox.com>2015-01-04 18:11:28 +0000
commit8f8333a3516bbbd266d66e72f646741fc258ff02 (patch)
tree7b9c90c5d978b9d8162c2d7235596b4c3abb2aee
parent79874f18e41cbbe796c0252dc96a85e150af1a15 (diff)
downloadpuzzles-8f8333a3516bbbd266d66e72f646741fc258ff02.zip
puzzles-8f8333a3516bbbd266d66e72f646741fc258ff02.tar.gz
puzzles-8f8333a3516bbbd266d66e72f646741fc258ff02.tar.bz2
puzzles-8f8333a3516bbbd266d66e72f646741fc258ff02.tar.xz
Fix puzzle window resize behaviour on Unity.
Unity hijacks the menu bar and prevents it from appearing in the main puzzle window. And we wait for the menu bar to appear before reducing the puzzle drawing area's size request. These two behaviours go together badly. Fixed by detecting the extra GTK property that the Unity patches invented, and using that to know whether to expect the menu bar to show up at all.
-rw-r--r--gtk.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gtk.c b/gtk.c
index 01b5ee4..3e8df06 100644
--- a/gtk.c
+++ b/gtk.c
@@ -157,6 +157,7 @@ struct frontend {
int preset_threaded;
GtkWidget *preset_custom;
GtkWidget *copy_menu_item;
+ int menubar_is_local;
};
struct blitter {
@@ -1690,7 +1691,7 @@ static gboolean not_size_allocated_yet(GtkWidget *w)
static void try_shrink_drawing_area(frontend *fe)
{
if (fe->drawing_area_shrink_pending &&
- !not_size_allocated_yet(fe->menubar) &&
+ (!fe->menubar_is_local || !not_size_allocated_yet(fe->menubar)) &&
!not_size_allocated_yet(fe->statusbar)) {
/*
* In order to permit the user to resize the window smaller as
@@ -2173,6 +2174,33 @@ static frontend *new_window(char *arg, int argtype, char **error)
midend_new_game(fe->me);
}
+ {
+ /*
+ * try_shrink_drawing_area() will do some fiddling with the
+ * window size request (see comment in that function) after
+ * all the bits and pieces such as the menu bar and status bar
+ * have appeared in the puzzle window.
+ *
+ * However, on Unity systems, the menu bar _doesn't_ appear in
+ * the puzzle window, because the Unity shell hijacks it into
+ * the menu bar at the very top of the screen. We therefore
+ * try to detect that situation here, so that we don't sit
+ * here forever waiting for a menu bar.
+ */
+ const char prop[] = "gtk-shell-shows-menubar";
+ GtkSettings *settings = gtk_settings_get_default();
+ if (!g_object_class_find_property(G_OBJECT_GET_CLASS(settings),
+ prop)) {
+ fe->menubar_is_local = TRUE;
+ } else {
+ int unity_mode;
+ g_object_get(gtk_settings_get_default(),
+ prop, &unity_mode,
+ (const gchar *)NULL);
+ fe->menubar_is_local = !unity_mode;
+ }
+ }
+
fe->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(fe->window), thegame.name);