@@ -3076,10 +3076,16 @@ drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED)
3076
3076
gui .blank_pointer = NULL ;
3077
3077
}
3078
3078
3079
+ #if GTK_CHECK_VERSION (3 ,22 ,2 )
3080
+ static void
3081
+ drawarea_style_updated_cb (GtkWidget * widget UNUSED ,
3082
+ gpointer data UNUSED )
3083
+ #else
3079
3084
static void
3080
3085
drawarea_style_set_cb (GtkWidget * widget UNUSED ,
3081
3086
GtkStyle * previous_style UNUSED ,
3082
3087
gpointer data UNUSED )
3088
+ #endif
3083
3089
{
3084
3090
gui_mch_new_colors ();
3085
3091
}
@@ -3096,6 +3102,31 @@ drawarea_configure_event_cb(GtkWidget *widget,
3096
3102
g_return_val_if_fail (event
3097
3103
&& event -> width >= 1 && event -> height >= 1 , TRUE);
3098
3104
3105
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
3106
+ /* As of 3.22.2, GdkWindows have started distributing configure events to
3107
+ * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
3108
+ *
3109
+ * As can be seen from the implementation of move_native_children() and
3110
+ * configure_native_child() in gdkwindow.c, those functions actually
3111
+ * propagate configure events to every child, failing to distinguish
3112
+ * "native" one from non-native one.
3113
+ *
3114
+ * Naturally, configure events propagated to here like that are fallacious
3115
+ * and, as a matter of fact, they trigger a geometric collapse of
3116
+ * gui.drawarea in fullscreen and miximized modes.
3117
+ *
3118
+ * To filter out such nuisance events, we are making use of the fact that
3119
+ * the field send_event of such GdkEventConfigures is set to FALSE in
3120
+ * configure_native_child().
3121
+ *
3122
+ * Obviously, this is a terrible hack making GVim depend on GTK's
3123
+ * implementation details. Therefore, watch out any relevant internal
3124
+ * changes happening in GTK in the feature (sigh).
3125
+ */
3126
+ if (event -> send_event == FALSE)
3127
+ return TRUE;
3128
+ # endif
3129
+
3099
3130
if (event -> width == cur_width && event -> height == cur_height )
3100
3131
return TRUE;
3101
3132
@@ -3519,8 +3550,12 @@ on_tabline_menu(GtkWidget *widget, GdkEvent *event)
3519
3550
/* If the event was generated for 3rd button popup the menu. */
3520
3551
if (bevent -> button == 3 )
3521
3552
{
3553
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
3554
+ gtk_menu_popup_at_pointer (GTK_MENU (widget ), event );
3555
+ # else
3522
3556
gtk_menu_popup (GTK_MENU (widget ), NULL , NULL , NULL , NULL ,
3523
3557
bevent -> button , bevent -> time );
3558
+ # endif
3524
3559
/* We handled the event. */
3525
3560
return TRUE;
3526
3561
}
@@ -4116,6 +4151,9 @@ gui_mch_init(void)
4116
4151
#endif
4117
4152
4118
4153
gui .drawarea = gtk_drawing_area_new ();
4154
+ #if GTK_CHECK_VERSION (3 ,22 ,2 )
4155
+ gtk_widget_set_name (gui .drawarea , "vim-gui-drawarea" );
4156
+ #endif
4119
4157
#if GTK_CHECK_VERSION (3 ,0 ,0 )
4120
4158
gui .surface = NULL ;
4121
4159
gui .by_signal = FALSE;
@@ -4167,8 +4205,13 @@ gui_mch_init(void)
4167
4205
G_CALLBACK (drawarea_unrealize_cb ), NULL );
4168
4206
g_signal_connect (G_OBJECT (gui .drawarea ), "configure-event" ,
4169
4207
G_CALLBACK (drawarea_configure_event_cb ), NULL );
4208
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
4209
+ g_signal_connect_after (G_OBJECT (gui .drawarea ), "style-updated" ,
4210
+ G_CALLBACK (& drawarea_style_updated_cb ), NULL );
4211
+ # else
4170
4212
g_signal_connect_after (G_OBJECT (gui .drawarea ), "style-set" ,
4171
4213
G_CALLBACK (& drawarea_style_set_cb ), NULL );
4214
+ # endif
4172
4215
#else
4173
4216
gtk_signal_connect (GTK_OBJECT (gui .drawarea ), "realize" ,
4174
4217
GTK_SIGNAL_FUNC (drawarea_realize_cb ), NULL );
@@ -4384,14 +4427,34 @@ set_cairo_source_rgba_from_color(cairo_t *cr, guicolor_T color)
4384
4427
gui_mch_new_colors (void )
4385
4428
{
4386
4429
#if GTK_CHECK_VERSION (3 ,0 ,0 )
4430
+ # if !GTK_CHECK_VERSION (3 ,22 ,2 )
4387
4431
GdkWindow * const da_win = gtk_widget_get_window (gui .drawarea );
4432
+ # endif
4388
4433
4389
4434
if (gui .drawarea != NULL && gtk_widget_get_window (gui .drawarea ) != NULL )
4390
4435
#else
4391
4436
if (gui .drawarea != NULL && gui .drawarea -> window != NULL )
4392
4437
#endif
4393
4438
{
4394
- #if GTK_CHECK_VERSION (3 ,4 ,0 )
4439
+ #if GTK_CHECK_VERSION (3 ,22 ,2 )
4440
+ GtkStyleContext * const context
4441
+ = gtk_widget_get_style_context (gui .drawarea );
4442
+ GtkCssProvider * const provider = gtk_css_provider_new ();
4443
+ gchar * const css = g_strdup_printf (
4444
+ "widget#vim-gui-drawarea {\n"
4445
+ " background-color: #%.2lx%.2lx%.2lx;\n"
4446
+ "}\n" ,
4447
+ (gui .back_pixel >> 16 ) & 0xff ,
4448
+ (gui .back_pixel >> 8 ) & 0xff ,
4449
+ gui .back_pixel & 0xff );
4450
+
4451
+ gtk_css_provider_load_from_data (provider , css , -1 , NULL );
4452
+ gtk_style_context_add_provider (context ,
4453
+ GTK_STYLE_PROVIDER (provider ), G_MAXUINT );
4454
+
4455
+ g_free (css );
4456
+ g_object_unref (provider );
4457
+ #elif GTK_CHECK_VERSION (3 ,4 ,0 ) /* !GTK_CHECK_VERSION(3,22,2) */
4395
4458
GdkRGBA rgba ;
4396
4459
4397
4460
rgba = color_to_rgba (gui .back_pixel );
@@ -4415,7 +4478,7 @@ gui_mch_new_colors(void)
4415
4478
# else
4416
4479
gdk_window_set_background (gui .drawarea -> window , & color );
4417
4480
# endif
4418
- #endif /* !GTK_CHECK_VERSION(3,4,0 ) */
4481
+ #endif /* !GTK_CHECK_VERSION(3,22,2 ) */
4419
4482
}
4420
4483
}
4421
4484
@@ -4429,6 +4492,26 @@ form_configure_event(GtkWidget *widget UNUSED,
4429
4492
{
4430
4493
int usable_height = event -> height ;
4431
4494
4495
+ #if GTK_CHECK_VERSION (3 ,22 ,2 )
4496
+ /* As of 3.22.2, GdkWindows have started distributing configure events to
4497
+ * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
4498
+ *
4499
+ * As can be seen from the implementation of move_native_children() and
4500
+ * configure_native_child() in gdkwindow.c, those functions actually
4501
+ * propagate configure events to every child, failing to distinguish
4502
+ * "native" one from non-native one.
4503
+ *
4504
+ * Naturally, configure events propagated to here like that are fallacious
4505
+ * and, as a matter of fact, they trigger a geometric collapse of
4506
+ * gui.formwin.
4507
+ *
4508
+ * To filter out such fallacious events, check if the given event is the
4509
+ * one that was sent out to the right place. Ignore it if not.
4510
+ */
4511
+ if (event -> window != gtk_widget_get_window (gui .formwin ))
4512
+ return TRUE;
4513
+ #endif
4514
+
4432
4515
/* When in a GtkPlug, we can't guarantee valid heights (as a round
4433
4516
* no. of char-heights), so we have to manually sanitise them.
4434
4517
* Widths seem to sort themselves out, don't ask me why.
@@ -4890,6 +4973,16 @@ gui_mch_set_shellsize(int width, int height,
4890
4973
gui_mch_get_screen_dimensions (int * screen_w , int * screen_h )
4891
4974
{
4892
4975
#ifdef HAVE_GTK_MULTIHEAD
4976
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
4977
+ GdkRectangle rect ;
4978
+ GdkMonitor * const mon = gdk_display_get_monitor_at_window (
4979
+ gtk_widget_get_display (gui .mainwin ),
4980
+ gtk_widget_get_window (gui .mainwin ));
4981
+ gdk_monitor_get_geometry (mon , & rect );
4982
+
4983
+ * screen_w = rect .width ;
4984
+ * screen_h = rect .height - p_ghr ;
4985
+ # else
4893
4986
GdkScreen * screen ;
4894
4987
4895
4988
if (gui .mainwin != NULL && gtk_widget_has_screen (gui .mainwin ))
@@ -4899,6 +4992,7 @@ gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
4899
4992
4900
4993
* screen_w = gdk_screen_get_width (screen );
4901
4994
* screen_h = gdk_screen_get_height (screen ) - p_ghr ;
4995
+ # endif
4902
4996
#else
4903
4997
* screen_w = gdk_screen_width ();
4904
4998
/* Subtract 'guiheadroom' from the height to allow some room for the
@@ -6626,11 +6720,15 @@ gui_mch_clear_block(int row1, int col1, int row2, int col2)
6626
6720
};
6627
6721
GdkWindow * const win = gtk_widget_get_window (gui .drawarea );
6628
6722
cairo_t * const cr = cairo_create (gui .surface );
6723
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
6724
+ set_cairo_source_rgba_from_color (cr , gui .back_pixel );
6725
+ # else
6629
6726
cairo_pattern_t * const pat = gdk_window_get_background_pattern (win );
6630
6727
if (pat != NULL )
6631
6728
cairo_set_source (cr , pat );
6632
6729
else
6633
6730
set_cairo_source_rgba_from_color (cr , gui .back_pixel );
6731
+ # endif
6634
6732
gdk_cairo_rectangle (cr , & rect );
6635
6733
cairo_fill (cr );
6636
6734
cairo_destroy (cr );
@@ -6659,11 +6757,15 @@ gui_gtk_window_clear(GdkWindow *win)
6659
6757
0 , 0 , gdk_window_get_width (win ), gdk_window_get_height (win )
6660
6758
};
6661
6759
cairo_t * const cr = cairo_create (gui .surface );
6760
+ # if GTK_CHECK_VERSION (3 ,22 ,2 )
6761
+ set_cairo_source_rgba_from_color (cr , gui .back_pixel );
6762
+ # else
6662
6763
cairo_pattern_t * const pat = gdk_window_get_background_pattern (win );
6663
6764
if (pat != NULL )
6664
6765
cairo_set_source (cr , pat );
6665
6766
else
6666
6767
set_cairo_source_rgba_from_color (cr , gui .back_pixel );
6768
+ # endif
6667
6769
gdk_cairo_rectangle (cr , & rect );
6668
6770
cairo_fill (cr );
6669
6771
cairo_destroy (cr );
0 commit comments