From: Daniel Boles Date: Wed, 23 Aug 2017 20:44:10 +0000 (+0100) Subject: Popover: Include window shadows in overshoot calcs X-Git-Tag: archive/raspbian/3.24.39-1+rpi1~1^2~65^2~39^2~328 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=947bca195cddd645e36eb5fa040bd6bc57bde395;p=gtk%2B3.0.git Popover: Include window shadows in overshoot calcs .update_position() enforces that non-Wayland platforms must position a Popover within its parent Window. We use the allocation of the Window to translate the position and check for overshoot on each of its sides. Calling Widget.get_allocation() of a CSD Window includes its shadows. But shadows were not excluded from the area in which we can position. Thus, Popovers could get positioned in the shadow of CSD windows, where, at least on X11, no input is received. Therefore, positioning a Popover over a shadow meant its child widgets within that area became unusable. Fix by calling Window.get_shadow() and including it in the overshoot on each side. This adjusts for how the allocation includes shadows, making overshoots with and without shadows the same. Thus, we avoid considering shadows as viable for positioning, favouring a side where input works. https://bugzilla.gnome.org/show_bug.cgi?id=786209 --- diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 005adc7f2f..b8818fe33b 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -1042,6 +1042,7 @@ gtk_popover_update_position (GtkPopover *popover) GtkPopoverPrivate *priv = popover->priv; GtkWidget *widget = GTK_WIDGET (popover); GtkAllocation window_alloc; + GtkBorder window_shadow; GdkRectangle rect; GtkRequisition req; GtkPositionType pos; @@ -1054,6 +1055,7 @@ gtk_popover_update_position (GtkPopover *popover) gtk_widget_get_preferred_size (widget, NULL, &req); gtk_widget_get_allocation (GTK_WIDGET (priv->window), &window_alloc); + _gtk_window_get_shadow_width (priv->window, &window_shadow); priv->final_position = priv->preferred_position; gtk_popover_get_pointing_to (popover, &rect); @@ -1062,10 +1064,12 @@ gtk_popover_update_position (GtkPopover *popover) pos = get_effective_position (popover, priv->preferred_position); - overshoot[GTK_POS_TOP] = req.height - rect.y; - overshoot[GTK_POS_BOTTOM] = rect.y + rect.height + req.height - window_alloc.height; - overshoot[GTK_POS_LEFT] = req.width - rect.x; - overshoot[GTK_POS_RIGHT] = rect.x + rect.width + req.width - window_alloc.width; + overshoot[GTK_POS_TOP] = req.height - rect.y + window_shadow.top; + overshoot[GTK_POS_BOTTOM] = rect.y + rect.height + req.height - window_alloc.height + + window_shadow.bottom; + overshoot[GTK_POS_LEFT] = req.width - rect.x + window_shadow.left; + overshoot[GTK_POS_RIGHT] = rect.x + rect.width + req.width - window_alloc.width + + window_shadow.right; #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (widget)) &&