Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
12408:587fc0ce700e | 12409:2c020bc30f62 |
---|---|
4939 * on top, while the GUI expects to be the boss. | 4939 * on top, while the GUI expects to be the boss. |
4940 */ | 4940 */ |
4941 gui_mch_update(); | 4941 gui_mch_update(); |
4942 } | 4942 } |
4943 | 4943 |
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 } | |
4944 | 4967 |
4945 /* | 4968 /* |
4946 * The screen size is used to make sure the initial window doesn't get bigger | 4969 * The screen size is used to make sure the initial window doesn't get bigger |
4947 * than the screen. This subtracts some room for menubar, toolbar and window | 4970 * than the screen. This subtracts some room for menubar, toolbar and window |
4948 * decorations. | 4971 * decorations. |
4949 */ | 4972 */ |
4950 void | 4973 void |
4951 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h) | 4974 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h) |
4952 { | 4975 { |
4953 #if GTK_CHECK_VERSION(3,22,2) | 4976 gui_gtk_get_screen_size_of_win(gui.mainwin, screen_w, screen_h); |
4954 GdkRectangle rect; | 4977 |
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 | 4978 /* Subtract 'guiheadroom' from the height to allow some room for the |
4962 * window manager (task list and window title bar). */ | 4979 * window manager (task list and window title bar). */ |
4963 *screen_h = rect.height - p_ghr; | 4980 *screen_h -= p_ghr; |
4964 #else | |
4965 GdkScreen* screen; | |
4966 | |
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); | |
4973 /* Subtract 'guiheadroom' from the height to allow some room for the | |
4974 * window manager (task list and window title bar). */ | |
4975 *screen_h = gdk_screen_get_height(screen) - p_ghr; | |
4976 #endif | |
4977 | 4981 |
4978 /* | 4982 /* |
4979 * FIXME: dirty trick: Because the gui_get_base_height() doesn't include | 4983 * FIXME: dirty trick: Because the gui_get_base_height() doesn't include |
4980 * the toolbar and menubar for GTK, we subtract them from the screen | 4984 * the toolbar and menubar for GTK, we subtract them from the screen |
4981 * height, so that the window size can be made to fit on the screen. | 4985 * height, so that the window size can be made to fit on the screen. |