Patch 8.2.2622

5 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 18, 2021, 5:29:34 PM3/18/21
to vim...@googlegroups.com

Patch 8.2.2622
Problem: GTK: error when starting up and -geometry is given. (Dominique
Pellé)
Solution: Use another function to get the monitor if the window has not been
created yet. (closes #7978)
Files: src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro, src/gui_beval.c,
src/gui_xim.c


*** ../vim-8.2.2621/src/gui_gtk_x11.c 2020-12-09 15:53:21.861279595 +0100
--- src/gui_gtk_x11.c 2021-03-18 22:25:27.980180751 +0100
***************
*** 4155,4160 ****
--- 4155,4234 ----
#endif
}

+ void
+ gui_gtk_get_screen_geom_of_win(
+ GtkWidget *wid,
+ int point_x, // x position of window if not initialized
+ int point_y, // y position of window if not initialized
+ int *screen_x,
+ int *screen_y,
+ int *width,
+ int *height)
+ {
+ GdkRectangle geometry;
+ GdkWindow *win = gtk_widget_get_window(wid);
+ #if GTK_CHECK_VERSION(3,22,0)
+ GdkDisplay *dpy = gtk_widget_get_display(wid);
+ GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
+
+ gdk_monitor_get_geometry(monitor, &geometry);
+ #else
+ GdkScreen* screen;
+ int monitor;
+
+ if (wid != NULL && gtk_widget_has_screen(wid))
+ screen = gtk_widget_get_screen(wid);
+ else
+ screen = gdk_screen_get_default();
+ if (win == NULL)
+ monitor = gdk_screen_get_monitor_at_point(screen, point_x, point_y);
+ else
+ monitor = gdk_screen_get_monitor_at_window(screen, win);
+ gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
+ #endif
+ *screen_x = geometry.x;
+ *screen_y = geometry.y;
+ *width = geometry.width;
+ *height = geometry.height;
+ }
+
+ /*
+ * The screen size is used to make sure the initial window doesn't get bigger
+ * than the screen. This subtracts some room for menubar, toolbar and window
+ * decorations.
+ */
+ static void
+ gui_gtk_get_screen_dimensions(
+ int point_x,
+ int point_y,
+ int *screen_w,
+ int *screen_h)
+ {
+ int x, y;
+
+ gui_gtk_get_screen_geom_of_win(gui.mainwin, point_x, point_y,
+ &x, &y, 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 -= p_ghr;
+
+ /*
+ * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
+ * the toolbar and menubar for GTK, we subtract them from the screen
+ * height, so that the window size can be made to fit on the screen.
+ * This should be completely changed later.
+ */
+ *screen_w -= get_menu_tool_width();
+ *screen_h -= get_menu_tool_height();
+ }
+
+ void
+ gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
+ {
+ gui_gtk_get_screen_dimensions(0, 0, screen_w, screen_h);
+ }
+

/*
* Bit of a hack to ensure we start GtkPlug windows with the correct window
***************
*** 4250,4256 ****
--- 4324,4335 ----
if (mask & (XValue | YValue))
{
int ww, hh;
+
+ #ifdef FEAT_GUI_GTK
+ gui_gtk_get_screen_dimensions(x, y, &ww, &hh);
+ #else
gui_mch_get_screen_dimensions(&ww, &hh);
+ #endif
hh += p_ghr + get_menu_tool_height();
ww += get_menu_tool_width();
if (mask & XNegative)
***************
*** 4538,4601 ****
gui_mch_update();
}

- void
- gui_gtk_get_screen_geom_of_win(
- GtkWidget *wid,
- int *screen_x,
- int *screen_y,
- int *width,
- int *height)
- {
- GdkRectangle geometry;
- GdkWindow *win = gtk_widget_get_window(wid);
- #if GTK_CHECK_VERSION(3,22,0)
- GdkDisplay *dpy = gtk_widget_get_display(wid);
- GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
-
- gdk_monitor_get_geometry(monitor, &geometry);
- #else
- GdkScreen* screen;
- int monitor;
-
- if (wid != NULL && gtk_widget_has_screen(wid))
- screen = gtk_widget_get_screen(wid);
- else
- screen = gdk_screen_get_default();
- monitor = gdk_screen_get_monitor_at_window(screen, win);
- gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
- #endif
- *screen_x = geometry.x;
- *screen_y = geometry.y;
- *width = geometry.width;
- *height = geometry.height;
- }
-
- /*
- * The screen size is used to make sure the initial window doesn't get bigger
- * than the screen. This subtracts some room for menubar, toolbar and window
- * decorations.
- */
- void
- gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
- {
- int x, y;
-
- gui_gtk_get_screen_geom_of_win(gui.mainwin, &x, &y, 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 -= p_ghr;
-
- /*
- * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
- * the toolbar and menubar for GTK, we subtract them from the screen
- * height, so that the window size can be made to fit on the screen.
- * This should be completely changed later.
- */
- *screen_w -= get_menu_tool_width();
- *screen_h -= get_menu_tool_height();
- }
-
#if defined(FEAT_TITLE) || defined(PROTO)
void
gui_mch_settitle(char_u *title, char_u *icon UNUSED)
--- 4617,4622 ----
*** ../vim-8.2.2621/src/proto/gui_gtk_x11.pro 2019-12-12 12:55:40.000000000 +0100
--- src/proto/gui_gtk_x11.pro 2021-03-18 22:25:31.176175399 +0100
***************
*** 18,23 ****
--- 18,25 ----
int gui_mch_init(void);
void gui_mch_forked(void);
void gui_mch_new_colors(void);
+ void gui_gtk_get_screen_geom_of_win(GtkWidget *wid, int point_x, int point_y, int *screen_x, int *screen_y, int *width, int *height);
+ void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
int gui_mch_open(void);
void gui_mch_exit(int rc);
int gui_mch_get_winpos(int *x, int *y);
***************
*** 26,33 ****
void gui_mch_unmaximize(void);
void gui_mch_newfont(void);
void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
- void gui_gtk_get_screen_geom_of_win(GtkWidget *wid, int *screen_x, int *screen_y, int *width, int *height);
- void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
void gui_mch_settitle(char_u *title, char_u *icon);
void gui_mch_enable_menu(int showit);
void gui_mch_show_toolbar(int showit);
--- 28,33 ----
*** ../vim-8.2.2621/src/gui_beval.c 2020-06-10 14:16:30.102988393 +0200
--- src/gui_beval.c 2021-03-18 22:18:41.988852110 +0100
***************
*** 920,926 ****
screen = gtk_widget_get_screen(beval->target);
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
# endif
! gui_gtk_get_screen_geom_of_win(beval->target,
&screen_x, &screen_y, &screen_w, &screen_h);
# if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_ensure_style(beval->balloonShell);
--- 920,926 ----
screen = gtk_widget_get_screen(beval->target);
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
# endif
! gui_gtk_get_screen_geom_of_win(beval->target, 0, 0,
&screen_x, &screen_y, &screen_w, &screen_h);
# if !GTK_CHECK_VERSION(3,0,0)
gtk_widget_ensure_style(beval->balloonShell);
*** ../vim-8.2.2621/src/gui_xim.c 2020-07-01 15:12:39.715774200 +0200
--- src/gui_xim.c 2021-03-18 22:22:19.000495431 +0100
***************
*** 207,213 ****
if (preedit_window == NULL)
return;

! gui_gtk_get_screen_geom_of_win(gui.drawarea,
&screen_x, &screen_y, &screen_width, &screen_height);
gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
gtk_window_get_size(GTK_WINDOW(preedit_window), &width, &height);
--- 207,213 ----
if (preedit_window == NULL)
return;

! gui_gtk_get_screen_geom_of_win(gui.drawarea, 0, 0,
&screen_x, &screen_y, &screen_width, &screen_height);
gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
gtk_window_get_size(GTK_WINDOW(preedit_window), &width, &height);
*** ../vim-8.2.2621/src/version.c 2021-03-18 22:15:00.589208304 +0100
--- src/version.c 2021-03-18 22:27:07.276014381 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2622,
/**/

--
A consultant is a person who takes your money and annoys your employees while
tirelessly searching for the best way to extend the consulting contract.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages