Skip to content

Commit 7be9b50

Browse files
committed
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)
1 parent 5b5adf5 commit 7be9b50

5 files changed

Lines changed: 33 additions & 35 deletions

File tree

src/gui_beval.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,23 +1177,15 @@ drawBalloon(BalloonEval *beval)
11771177
int x_offset = EVAL_OFFSET_X;
11781178
int y_offset = EVAL_OFFSET_Y;
11791179
PangoLayout *layout;
1180-
# if GTK_CHECK_VERSION(3,22,2)
1181-
GdkRectangle rect;
1182-
GdkMonitor * const mon = gdk_display_get_monitor_at_window(
1183-
gtk_widget_get_display(beval->balloonShell),
1184-
gtk_widget_get_window(beval->balloonShell));
1185-
gdk_monitor_get_geometry(mon, &rect);
1186-
1187-
screen_w = rect.width;
1188-
screen_h = rect.height;
1189-
# else
1180+
1181+
# if !GTK_CHECK_VERSION(3,22,2)
11901182
GdkScreen *screen;
11911183

11921184
screen = gtk_widget_get_screen(beval->target);
11931185
gtk_window_set_screen(GTK_WINDOW(beval->balloonShell), screen);
1194-
screen_w = gdk_screen_get_width(screen);
1195-
screen_h = gdk_screen_get_height(screen);
11961186
# endif
1187+
gui_gtk_get_screen_size_of_win(beval->balloonShell,
1188+
&screen_w, &screen_h);
11971189
# if !GTK_CHECK_VERSION(3,0,0)
11981190
gtk_widget_ensure_style(beval->balloonShell);
11991191
gtk_widget_ensure_style(beval->balloonLabel);

src/gui_gtk_x11.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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
49514974
gui_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

src/mbyte.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4871,8 +4871,7 @@ im_preedit_window_set_position(void)
48714871
if (preedit_window == NULL)
48724872
return;
48734873

4874-
sw = gdk_screen_get_width(gtk_widget_get_screen(preedit_window));
4875-
sh = gdk_screen_get_height(gtk_widget_get_screen(preedit_window));
4874+
gui_gtk_get_screen_size_of_win(preedit_window, &sw, &sh);
48764875
#if GTK_CHECK_VERSION(3,0,0)
48774876
gdk_window_get_origin(gtk_widget_get_window(gui.drawarea), &x, &y);
48784877
#else

src/proto/gui_gtk_x11.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ int gui_mch_maximized(void);
2525
void gui_mch_unmaximize(void);
2626
void gui_mch_newfont(void);
2727
void gui_mch_set_shellsize(int width, int height, int min_width, int min_height, int base_width, int base_height, int direction);
28+
void gui_gtk_get_screen_size_of_win(GtkWidget *win, int *width, int *height);
2829
void gui_mch_get_screen_dimensions(int *screen_w, int *screen_h);
2930
void gui_mch_settitle(char_u *title, char_u *icon);
3031
void gui_mch_enable_menu(int showit);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1084,
772774
/**/
773775
1083,
774776
/**/

0 commit comments

Comments
 (0)