@@ -4941,6 +4941,29 @@ gui_mch_set_shellsize(int width, int height,
49414941 gui_mch_update ();
49424942}
49434943
4944+ void
4945+ gui_gtk_get_screen_size_of_win (GtkWidget * win , int * width , int * height )
4946+ {
4947+ #if GTK_CHECK_VERSION (3 ,22 ,0 )
4948+ GdkDisplay * dpy = gtk_widget_get_display (win );
4949+ GdkWindow * win = gtk_widget_get_window (win );
4950+ GdkMonitor * monitor = gdk_display_get_monitor_at_window (dpy , win );
4951+ GdkRectangle geometry ;
4952+
4953+ gdk_monitor_get_geometry (monitor , & geometry );
4954+ * width = geometry .width ;
4955+ * height = geometry .height ;
4956+ #else
4957+ GdkScreen * screen ;
4958+
4959+ if (win != NULL && gtk_widget_has_screen (win ))
4960+ screen = gtk_widget_get_screen (win );
4961+ else
4962+ screen = gdk_screen_get_default ();
4963+ * width = gdk_screen_get_width (screen );
4964+ * height = gdk_screen_get_height (screen );
4965+ #endif
4966+ }
49444967
49454968/*
49464969 * 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 height,
49504973 void
49514974gui_mch_get_screen_dimensions (int * screen_w , int * screen_h )
49524975{
4953- #if GTK_CHECK_VERSION (3 ,22 ,2 )
4954- GdkRectangle rect ;
4955- GdkMonitor * const mon = gdk_display_get_monitor_at_window (
4956- gtk_widget_get_display (gui .mainwin ),
4957- gtk_widget_get_window (gui .mainwin ));
4958- gdk_monitor_get_geometry (mon , & rect );
4959-
4960- * screen_w = rect .width ;
4961- /* Subtract 'guiheadroom' from the height to allow some room for the
4962- * window manager (task list and window title bar). */
4963- * screen_h = rect .height - p_ghr ;
4964- #else
4965- GdkScreen * screen ;
4976+ gui_gtk_get_screen_size_of_win (gui .mainwin , screen_w , screen_h );
49664977
4967- if (gui .mainwin != NULL && gtk_widget_has_screen (gui .mainwin ))
4968- screen = gtk_widget_get_screen (gui .mainwin );
4969- else
4970- screen = gdk_screen_get_default ();
4971-
4972- * screen_w = gdk_screen_get_width (screen );
49734978 /* Subtract 'guiheadroom' from the height to allow some room for the
49744979 * window manager (task list and window title bar). */
4975- * screen_h = gdk_screen_get_height (screen ) - p_ghr ;
4976- #endif
4980+ * screen_h -= p_ghr ;
49774981
49784982 /*
49794983 * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
0 commit comments