comparison src/gui_gtk_x11.c @ 11474:621e41f6dcc2 v8.0.0620

patch 8.0.0620: checking for HAVE_GTK_MULTIHEAD is not needed commit https://github.com/vim/vim/commit/b463e8d999ec812d656876f313efbeaeed663b45 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 5 15:07:09 2017 +0200 patch 8.0.0620: checking for HAVE_GTK_MULTIHEAD is not needed Problem: Since we only support GTK versions that have it, the ckeck for HAVE_GTK_MULTIHEAD is no longer needed. Solution: Remove HAVE_GTK_MULTIHEAD. (Kazunobu Kuriyama)
author Christian Brabandt <cb@256bit.org>
date Mon, 05 Jun 2017 15:15:03 +0200
parents f4ea50924c6d
children 5a5709918a98
comparison
equal deleted inserted replaced
11473:bd6ff5246c71 11474:621e41f6dcc2
100 #endif 100 #endif
101 101
102 /* 102 /*
103 * Easy-to-use macro for multihead support. 103 * Easy-to-use macro for multihead support.
104 */ 104 */
105 #ifdef HAVE_GTK_MULTIHEAD 105 #define GET_X_ATOM(atom) gdk_x11_atom_to_xatom_for_display( \
106 # define GET_X_ATOM(atom) gdk_x11_atom_to_xatom_for_display( \
107 gtk_widget_get_display(gui.mainwin), atom) 106 gtk_widget_get_display(gui.mainwin), atom)
108 #else
109 # define GET_X_ATOM(atom) ((Atom)(atom))
110 #endif
111 107
112 /* Selection type distinguishers */ 108 /* Selection type distinguishers */
113 enum 109 enum
114 { 110 {
115 TARGET_TYPE_NONE, 111 TARGET_TYPE_NONE,
2844 else 2840 else
2845 { 2841 {
2846 /* 2842 /*
2847 * Cannot handle "XLib-only" windows with gtk event routines, we'll 2843 * Cannot handle "XLib-only" windows with gtk event routines, we'll
2848 * have to change the "server" registration to that of the main window 2844 * have to change the "server" registration to that of the main window
2849 * If we have not registered a name yet, remember the window 2845 * If we have not registered a name yet, remember the window.
2850 */ 2846 */
2851 # if GTK_CHECK_VERSION(3,0,0) 2847 # if GTK_CHECK_VERSION(3,0,0)
2852 serverChangeRegisteredWindow(GDK_WINDOW_XDISPLAY(mainwin_win), 2848 serverChangeRegisteredWindow(GDK_WINDOW_XDISPLAY(mainwin_win),
2853 GDK_WINDOW_XID(mainwin_win)); 2849 GDK_WINDOW_XID(mainwin_win));
2854 # else 2850 # else
2882 #else 2878 #else
2883 GdkColor color = { 0, 0, 0, 0 }; 2879 GdkColor color = { 0, 0, 0, 0 };
2884 char blank_data[] = { 0x0 }; 2880 char blank_data[] = { 0x0 };
2885 #endif 2881 #endif
2886 2882
2887 #ifdef HAVE_GTK_MULTIHEAD 2883 #if GTK_CHECK_VERSION(3,12,0)
2888 # if GTK_CHECK_VERSION(3,12,0)
2889 { 2884 {
2890 GdkWindow * const win = gtk_widget_get_window(gui.mainwin); 2885 GdkWindow * const win = gtk_widget_get_window(gui.mainwin);
2891 GdkScreen * const scrn = gdk_window_get_screen(win); 2886 GdkScreen * const scrn = gdk_window_get_screen(win);
2892 root_window = gdk_screen_get_root_window(scrn); 2887 root_window = gdk_screen_get_root_window(scrn);
2893 } 2888 }
2894 # else 2889 #else
2895 root_window = gtk_widget_get_root_window(gui.mainwin); 2890 root_window = gtk_widget_get_root_window(gui.mainwin);
2896 # endif
2897 #endif 2891 #endif
2898 2892
2899 /* Create a pseudo blank pointer, which is in fact one pixel by one pixel 2893 /* Create a pseudo blank pointer, which is in fact one pixel by one pixel
2900 * in size. */ 2894 * in size. */
2901 #if GTK_CHECK_VERSION(3,0,0) 2895 #if GTK_CHECK_VERSION(3,0,0)
2930 #endif 2924 #endif
2931 2925
2932 return cursor; 2926 return cursor;
2933 } 2927 }
2934 2928
2935 #ifdef HAVE_GTK_MULTIHEAD
2936 static void 2929 static void
2937 mainwin_screen_changed_cb(GtkWidget *widget, 2930 mainwin_screen_changed_cb(GtkWidget *widget,
2938 GdkScreen *previous_screen UNUSED, 2931 GdkScreen *previous_screen UNUSED,
2939 gpointer data UNUSED) 2932 gpointer data UNUSED)
2940 { 2933 {
2943 2936
2944 /* 2937 /*
2945 * Recreate the invisible mouse cursor. 2938 * Recreate the invisible mouse cursor.
2946 */ 2939 */
2947 if (gui.blank_pointer != NULL) 2940 if (gui.blank_pointer != NULL)
2948 # if GTK_CHECK_VERSION(3,0,0) 2941 #if GTK_CHECK_VERSION(3,0,0)
2949 g_object_unref(G_OBJECT(gui.blank_pointer)); 2942 g_object_unref(G_OBJECT(gui.blank_pointer));
2950 # else 2943 #else
2951 gdk_cursor_unref(gui.blank_pointer); 2944 gdk_cursor_unref(gui.blank_pointer);
2952 # endif 2945 #endif
2953 2946
2954 gui.blank_pointer = create_blank_pointer(); 2947 gui.blank_pointer = create_blank_pointer();
2955 2948
2956 # if GTK_CHECK_VERSION(3,0,0) 2949 #if GTK_CHECK_VERSION(3,0,0)
2957 if (gui.pointer_hidden && gtk_widget_get_window(gui.drawarea) != NULL) 2950 if (gui.pointer_hidden && gtk_widget_get_window(gui.drawarea) != NULL)
2958 gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea), 2951 gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea),
2959 gui.blank_pointer); 2952 gui.blank_pointer);
2960 # else 2953 #else
2961 if (gui.pointer_hidden && gui.drawarea->window != NULL) 2954 if (gui.pointer_hidden && gui.drawarea->window != NULL)
2962 gdk_window_set_cursor(gui.drawarea->window, gui.blank_pointer); 2955 gdk_window_set_cursor(gui.drawarea->window, gui.blank_pointer);
2963 # endif 2956 #endif
2964 2957
2965 /* 2958 /*
2966 * Create a new PangoContext for this screen, and initialize it 2959 * Create a new PangoContext for this screen, and initialize it
2967 * with the current font if necessary. 2960 * with the current font if necessary.
2968 */ 2961 */
2976 { 2969 {
2977 gui_mch_init_font(p_guifont, FALSE); 2970 gui_mch_init_font(p_guifont, FALSE);
2978 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH); 2971 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
2979 } 2972 }
2980 } 2973 }
2981 #endif /* HAVE_GTK_MULTIHEAD */
2982 2974
2983 /* 2975 /*
2984 * After the drawing area comes up, we calculate all colors and create the 2976 * After the drawing area comes up, we calculate all colors and create the
2985 * dummy blank cursor. 2977 * dummy blank cursor.
2986 * 2978 *
3905 if (gtk_socket_id != 0) 3897 if (gtk_socket_id != 0)
3906 { 3898 {
3907 GtkWidget *plug; 3899 GtkWidget *plug;
3908 3900
3909 /* Use GtkSocket from another app. */ 3901 /* Use GtkSocket from another app. */
3910 #ifdef HAVE_GTK_MULTIHEAD
3911 plug = gtk_plug_new_for_display(gdk_display_get_default(), 3902 plug = gtk_plug_new_for_display(gdk_display_get_default(),
3912 gtk_socket_id); 3903 gtk_socket_id);
3913 #else
3914 plug = gtk_plug_new(gtk_socket_id);
3915 #endif
3916 #if GTK_CHECK_VERSION(3,0,0) 3904 #if GTK_CHECK_VERSION(3,0,0)
3917 if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL) 3905 if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL)
3918 #else 3906 #else
3919 if (plug != NULL && GTK_PLUG(plug)->socket_window != NULL) 3907 if (plug != NULL && GTK_PLUG(plug)->socket_window != NULL)
3920 #endif 3908 #endif
3970 GTK_SIGNAL_FUNC(&delete_event_cb), NULL); 3958 GTK_SIGNAL_FUNC(&delete_event_cb), NULL);
3971 3959
3972 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "realize", 3960 gtk_signal_connect(GTK_OBJECT(gui.mainwin), "realize",
3973 GTK_SIGNAL_FUNC(&mainwin_realize), NULL); 3961 GTK_SIGNAL_FUNC(&mainwin_realize), NULL);
3974 #endif 3962 #endif
3975 #ifdef HAVE_GTK_MULTIHEAD 3963
3976 g_signal_connect(G_OBJECT(gui.mainwin), "screen_changed", 3964 g_signal_connect(G_OBJECT(gui.mainwin), "screen-changed",
3977 G_CALLBACK(&mainwin_screen_changed_cb), NULL); 3965 G_CALLBACK(&mainwin_screen_changed_cb), NULL);
3978 #endif 3966
3979 gui.accel_group = gtk_accel_group_new(); 3967 gui.accel_group = gtk_accel_group_new();
3980 gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group); 3968 gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group);
3981 3969
3982 /* A vertical box holds the menubar, toolbar and main text window. */ 3970 /* A vertical box holds the menubar, toolbar and main text window. */
3983 #if GTK_CHECK_VERSION(3,2,0) 3971 #if GTK_CHECK_VERSION(3,2,0)
4990 * decorations. 4978 * decorations.
4991 */ 4979 */
4992 void 4980 void
4993 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h) 4981 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
4994 { 4982 {
4995 #ifdef HAVE_GTK_MULTIHEAD 4983 #if GTK_CHECK_VERSION(3,22,2)
4996 # if GTK_CHECK_VERSION(3,22,2)
4997 GdkRectangle rect; 4984 GdkRectangle rect;
4998 GdkMonitor * const mon = gdk_display_get_monitor_at_window( 4985 GdkMonitor * const mon = gdk_display_get_monitor_at_window(
4999 gtk_widget_get_display(gui.mainwin), 4986 gtk_widget_get_display(gui.mainwin),
5000 gtk_widget_get_window(gui.mainwin)); 4987 gtk_widget_get_window(gui.mainwin));
5001 gdk_monitor_get_geometry(mon, &rect); 4988 gdk_monitor_get_geometry(mon, &rect);
5002 4989
5003 *screen_w = rect.width; 4990 *screen_w = rect.width;
4991 /* Subtract 'guiheadroom' from the height to allow some room for the
4992 * window manager (task list and window title bar). */
5004 *screen_h = rect.height - p_ghr; 4993 *screen_h = rect.height - p_ghr;
5005 # else 4994 #else
5006 GdkScreen* screen; 4995 GdkScreen* screen;
5007 4996
5008 if (gui.mainwin != NULL && gtk_widget_has_screen(gui.mainwin)) 4997 if (gui.mainwin != NULL && gtk_widget_has_screen(gui.mainwin))
5009 screen = gtk_widget_get_screen(gui.mainwin); 4998 screen = gtk_widget_get_screen(gui.mainwin);
5010 else 4999 else
5011 screen = gdk_screen_get_default(); 5000 screen = gdk_screen_get_default();
5012 5001
5013 *screen_w = gdk_screen_get_width(screen); 5002 *screen_w = gdk_screen_get_width(screen);
5014 *screen_h = gdk_screen_get_height(screen) - p_ghr;
5015 # endif
5016 #else
5017 *screen_w = gdk_screen_width();
5018 /* Subtract 'guiheadroom' from the height to allow some room for the 5003 /* Subtract 'guiheadroom' from the height to allow some room for the
5019 * window manager (task list and window title bar). */ 5004 * window manager (task list and window title bar). */
5020 *screen_h = gdk_screen_height() - p_ghr; 5005 *screen_h = gdk_screen_get_height(screen) - p_ghr;
5021 #endif 5006 #endif
5022 5007
5023 /* 5008 /*
5024 * FIXME: dirty trick: Because the gui_get_base_height() doesn't include 5009 * FIXME: dirty trick: Because the gui_get_base_height() doesn't include
5025 * the toolbar and menubar for GTK, we subtract them from the screen 5010 * the toolbar and menubar for GTK, we subtract them from the screen
6333 #endif 6318 #endif
6334 6319
6335 void 6320 void
6336 gui_mch_beep(void) 6321 gui_mch_beep(void)
6337 { 6322 {
6338 #ifdef HAVE_GTK_MULTIHEAD
6339 GdkDisplay *display; 6323 GdkDisplay *display;
6340 6324
6341 # if GTK_CHECK_VERSION(3,0,0) 6325 #if GTK_CHECK_VERSION(3,0,0)
6342 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) 6326 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin))
6343 # else 6327 #else
6344 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) 6328 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin))
6345 # endif 6329 #endif
6346 display = gtk_widget_get_display(gui.mainwin); 6330 display = gtk_widget_get_display(gui.mainwin);
6347 else 6331 else
6348 display = gdk_display_get_default(); 6332 display = gdk_display_get_default();
6349 6333
6350 if (display != NULL) 6334 if (display != NULL)
6351 gdk_display_beep(display); 6335 gdk_display_beep(display);
6352 #else
6353 gdk_beep();
6354 #endif
6355 } 6336 }
6356 6337
6357 void 6338 void
6358 gui_mch_flash(int msec) 6339 gui_mch_flash(int msec)
6359 { 6340 {
6696 6677
6697 /* Flush any output to the screen */ 6678 /* Flush any output to the screen */
6698 void 6679 void
6699 gui_mch_flush(void) 6680 gui_mch_flush(void)
6700 { 6681 {
6701 #ifdef HAVE_GTK_MULTIHEAD 6682 #if GTK_CHECK_VERSION(3,0,0)
6702 # if GTK_CHECK_VERSION(3,0,0)
6703 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin)) 6683 if (gui.mainwin != NULL && gtk_widget_get_realized(gui.mainwin))
6704 # else 6684 #else
6705 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin)) 6685 if (gui.mainwin != NULL && GTK_WIDGET_REALIZED(gui.mainwin))
6706 # endif 6686 #endif
6707 gdk_display_flush(gtk_widget_get_display(gui.mainwin)); 6687 gdk_display_flush(gtk_widget_get_display(gui.mainwin));
6708 #else
6709 gdk_flush(); /* historical misnomer: calls XSync(), not XFlush() */
6710 #endif
6711 } 6688 }
6712 6689
6713 /* 6690 /*
6714 * Clear a rectangular region of the screen from text pos (row1, col1) to 6691 * Clear a rectangular region of the screen from text pos (row1, col1) to
6715 * (row2, col2) inclusive. 6692 * (row2, col2) inclusive.
7296 } 7273 }
7297 else if (shape < (int)(sizeof(mshape_ids) / sizeof(int))) 7274 else if (shape < (int)(sizeof(mshape_ids) / sizeof(int)))
7298 id = mshape_ids[shape]; 7275 id = mshape_ids[shape];
7299 else 7276 else
7300 return; 7277 return;
7301 # ifdef HAVE_GTK_MULTIHEAD
7302 c = gdk_cursor_new_for_display( 7278 c = gdk_cursor_new_for_display(
7303 gtk_widget_get_display(gui.drawarea), (GdkCursorType)id); 7279 gtk_widget_get_display(gui.drawarea), (GdkCursorType)id);
7304 # else
7305 c = gdk_cursor_new((GdkCursorType)id);
7306 # endif
7307 # if GTK_CHECK_VERSION(3,0,0) 7280 # if GTK_CHECK_VERSION(3,0,0)
7308 gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea), c); 7281 gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea), c);
7309 # else 7282 # else
7310 gdk_window_set_cursor(gui.drawarea->window, c); 7283 gdk_window_set_cursor(gui.drawarea->window, c);
7311 # endif 7284 # endif