@@ -4155,6 +4155,80 @@ mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED)
41554155#endif
41564156}
41574157
4158+ void
4159+ gui_gtk_get_screen_geom_of_win (
4160+ GtkWidget * wid ,
4161+ int point_x , // x position of window if not initialized
4162+ int point_y , // y position of window if not initialized
4163+ int * screen_x ,
4164+ int * screen_y ,
4165+ int * width ,
4166+ int * height )
4167+ {
4168+ GdkRectangle geometry ;
4169+ GdkWindow * win = gtk_widget_get_window (wid );
4170+ #if GTK_CHECK_VERSION (3 ,22 ,0 )
4171+ GdkDisplay * dpy = gtk_widget_get_display (wid );
4172+ GdkMonitor * monitor = gdk_display_get_monitor_at_window (dpy , win );
4173+
4174+ gdk_monitor_get_geometry (monitor , & geometry );
4175+ #else
4176+ GdkScreen * screen ;
4177+ int monitor ;
4178+
4179+ if (wid != NULL && gtk_widget_has_screen (wid ))
4180+ screen = gtk_widget_get_screen (wid );
4181+ else
4182+ screen = gdk_screen_get_default ();
4183+ if (win == NULL )
4184+ monitor = gdk_screen_get_monitor_at_point (screen , point_x , point_y );
4185+ else
4186+ monitor = gdk_screen_get_monitor_at_window (screen , win );
4187+ gdk_screen_get_monitor_geometry (screen , monitor , & geometry );
4188+ #endif
4189+ * screen_x = geometry .x ;
4190+ * screen_y = geometry .y ;
4191+ * width = geometry .width ;
4192+ * height = geometry .height ;
4193+ }
4194+
4195+ /*
4196+ * The screen size is used to make sure the initial window doesn't get bigger
4197+ * than the screen. This subtracts some room for menubar, toolbar and window
4198+ * decorations.
4199+ */
4200+ static void
4201+ gui_gtk_get_screen_dimensions (
4202+ int point_x ,
4203+ int point_y ,
4204+ int * screen_w ,
4205+ int * screen_h )
4206+ {
4207+ int x , y ;
4208+
4209+ gui_gtk_get_screen_geom_of_win (gui .mainwin , point_x , point_y ,
4210+ & x , & y , screen_w , screen_h );
4211+
4212+ // Subtract 'guiheadroom' from the height to allow some room for the
4213+ // window manager (task list and window title bar).
4214+ * screen_h -= p_ghr ;
4215+
4216+ /*
4217+ * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
4218+ * the toolbar and menubar for GTK, we subtract them from the screen
4219+ * height, so that the window size can be made to fit on the screen.
4220+ * This should be completely changed later.
4221+ */
4222+ * screen_w -= get_menu_tool_width ();
4223+ * screen_h -= get_menu_tool_height ();
4224+ }
4225+
4226+ void
4227+ gui_mch_get_screen_dimensions (int * screen_w , int * screen_h )
4228+ {
4229+ gui_gtk_get_screen_dimensions (0 , 0 , screen_w , screen_h );
4230+ }
4231+
41584232
41594233/*
41604234 * Bit of a hack to ensure we start GtkPlug windows with the correct window
@@ -4250,7 +4324,12 @@ gui_mch_open(void)
42504324 if (mask & (XValue | YValue ))
42514325 {
42524326 int ww , hh ;
4327+
4328+ #ifdef FEAT_GUI_GTK
4329+ gui_gtk_get_screen_dimensions (x , y , & ww , & hh );
4330+ #else
42534331 gui_mch_get_screen_dimensions (& ww , & hh );
4332+ #endif
42544333 hh += p_ghr + get_menu_tool_height ();
42554334 ww += get_menu_tool_width ();
42564335 if (mask & XNegative )
@@ -4538,64 +4617,6 @@ gui_mch_set_shellsize(int width, int height,
45384617 gui_mch_update ();
45394618}
45404619
4541- void
4542- gui_gtk_get_screen_geom_of_win (
4543- GtkWidget * wid ,
4544- int * screen_x ,
4545- int * screen_y ,
4546- int * width ,
4547- int * height )
4548- {
4549- GdkRectangle geometry ;
4550- GdkWindow * win = gtk_widget_get_window (wid );
4551- #if GTK_CHECK_VERSION (3 ,22 ,0 )
4552- GdkDisplay * dpy = gtk_widget_get_display (wid );
4553- GdkMonitor * monitor = gdk_display_get_monitor_at_window (dpy , win );
4554-
4555- gdk_monitor_get_geometry (monitor , & geometry );
4556- #else
4557- GdkScreen * screen ;
4558- int monitor ;
4559-
4560- if (wid != NULL && gtk_widget_has_screen (wid ))
4561- screen = gtk_widget_get_screen (wid );
4562- else
4563- screen = gdk_screen_get_default ();
4564- monitor = gdk_screen_get_monitor_at_window (screen , win );
4565- gdk_screen_get_monitor_geometry (screen , monitor , & geometry );
4566- #endif
4567- * screen_x = geometry .x ;
4568- * screen_y = geometry .y ;
4569- * width = geometry .width ;
4570- * height = geometry .height ;
4571- }
4572-
4573- /*
4574- * The screen size is used to make sure the initial window doesn't get bigger
4575- * than the screen. This subtracts some room for menubar, toolbar and window
4576- * decorations.
4577- */
4578- void
4579- gui_mch_get_screen_dimensions (int * screen_w , int * screen_h )
4580- {
4581- int x , y ;
4582-
4583- gui_gtk_get_screen_geom_of_win (gui .mainwin , & x , & y , screen_w , screen_h );
4584-
4585- // Subtract 'guiheadroom' from the height to allow some room for the
4586- // window manager (task list and window title bar).
4587- * screen_h -= p_ghr ;
4588-
4589- /*
4590- * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
4591- * the toolbar and menubar for GTK, we subtract them from the screen
4592- * height, so that the window size can be made to fit on the screen.
4593- * This should be completely changed later.
4594- */
4595- * screen_w -= get_menu_tool_width ();
4596- * screen_h -= get_menu_tool_height ();
4597- }
4598-
45994620#if defined(FEAT_TITLE ) || defined(PROTO )
46004621 void
46014622gui_mch_settitle (char_u * title , char_u * icon UNUSED )
0 commit comments