diff src/gui_gtk_x11.c @ 12409:2c020bc30f62 v8.0.1084

patch 8.0.1084: GTK build has compiler warnings commit https://github.com/vim/vim/commit/7be9b50fd7e238722c9ba5c0ef1d2a7e7e52b9e3 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 9 18:45:26 2017 +0200 patch 8.0.1084: GTK build has compiler warnings Problem: GTK build has compiler warnings. (Christian Brabandt) Solution: Get screen size with a different function. (Ken Takata, Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Sat, 09 Sep 2017 19:00:04 +0200
parents 2a8890b80923
children ca7f2685e339
line wrap: on
line diff
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -4941,6 +4941,29 @@ gui_mch_set_shellsize(int width, int hei
     gui_mch_update();
 }
 
+    void
+gui_gtk_get_screen_size_of_win(GtkWidget *win, int *width, int *height)
+{
+#if GTK_CHECK_VERSION(3,22,0)
+    GdkDisplay *dpy = gtk_widget_get_display(win);
+    GdkWindow *win = gtk_widget_get_window(win);
+    GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
+    GdkRectangle geometry;
+
+    gdk_monitor_get_geometry(monitor, &geometry);
+    *width = geometry.width;
+    *height = geometry.height;
+#else
+    GdkScreen* screen;
+
+    if (win != NULL && gtk_widget_has_screen(win))
+	screen = gtk_widget_get_screen(win);
+    else
+	screen = gdk_screen_get_default();
+    *width = gdk_screen_get_width(screen);
+    *height = gdk_screen_get_height(screen);
+#endif
+}
 
 /*
  * The screen size is used to make sure the initial window doesn't get bigger
@@ -4950,30 +4973,11 @@ gui_mch_set_shellsize(int width, int hei
     void
 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
 {
-#if GTK_CHECK_VERSION(3,22,2)
-    GdkRectangle rect;
-    GdkMonitor * const mon = gdk_display_get_monitor_at_window(
-	    gtk_widget_get_display(gui.mainwin),
-	    gtk_widget_get_window(gui.mainwin));
-    gdk_monitor_get_geometry(mon, &rect);
-
-    *screen_w = rect.width;
+    gui_gtk_get_screen_size_of_win(gui.mainwin, screen_w, screen_h);
+
     /* Subtract 'guiheadroom' from the height to allow some room for the
      * window manager (task list and window title bar). */
-    *screen_h = rect.height - p_ghr;
-#else
-    GdkScreen* screen;
-
-    if (gui.mainwin != NULL && gtk_widget_has_screen(gui.mainwin))
-	screen = gtk_widget_get_screen(gui.mainwin);
-    else
-	screen = gdk_screen_get_default();
-
-    *screen_w = gdk_screen_get_width(screen);
-    /* Subtract 'guiheadroom' from the height to allow some room for the
-     * window manager (task list and window title bar). */
-    *screen_h = gdk_screen_get_height(screen) - p_ghr;
-#endif
+    *screen_h -= p_ghr;
 
     /*
      * FIXME: dirty trick: Because the gui_get_base_height() doesn't include