[gtk+] menu: Properly clip child menuitems
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] menu: Properly clip child menuitems
- Date: Sat, 5 Nov 2016 12:52:39 +0000 (UTC)
commit a5b967ed31acabcea586d26e943c63f6038e23ca
Author: Timm Bäder <mail baedert org>
Date: Sat Nov 5 13:37:26 2016 +0100
menu: Properly clip child menuitems
Now that GtkMenu isn't a windowed widget anymore, we have to
differentiate between the (0, 0) of the cairo_t and the position of
priv0->view_window.
gtk/gtkmenu.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index c7e65af..f7ac5b2 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -2942,21 +2942,20 @@ gtk_menu_draw (GtkWidget *widget,
GtkMenu *menu;
GtkMenuPrivate *priv;
GtkStyleContext *context;
- gint width, height;
+ GtkAllocation allocation;
menu = GTK_MENU (widget);
priv = menu->priv;
context = gtk_widget_get_style_context (widget);
- width = gtk_widget_get_allocated_width (widget);
- height = gtk_widget_get_allocated_height (widget);
+ gtk_widget_get_allocation (widget, &allocation);
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
gtk_render_background (context, cr, 0, 0,
- width, height);
+ allocation.width, allocation.height);
gtk_render_frame (context, cr, 0, 0,
- width, height);
+ allocation.width, allocation.height);
if (priv->upper_arrow_visible)
gtk_css_gadget_draw (priv->top_arrow_gadget, cr);
@@ -2970,8 +2969,9 @@ gtk_menu_draw (GtkWidget *widget,
int x, y;
gdk_window_get_position (priv->view_window, &x, &y);
+
cairo_rectangle (cr,
- x, y,
+ x - allocation.x, y - allocation.y,
gdk_window_get_width (priv->view_window),
gdk_window_get_height (priv->view_window));
cairo_clip (cr);
@@ -4611,22 +4611,24 @@ gtk_menu_scroll_to (GtkMenu *menu,
GtkCssNode *top_arrow_node, *bottom_arrow_node;
GtkBorder padding;
GtkWidget *widget;
+ GtkAllocation allocation;
gint x, y;
gint view_width, view_height;
widget = GTK_WIDGET (menu);
+ gtk_widget_get_allocation (widget, &allocation);
/* Move/resize the viewport according to arrows: */
- view_width = gtk_widget_get_allocated_width (widget);
- view_height = gtk_widget_get_allocated_height (widget);
+ view_width = allocation.width;
+ view_height = allocation.height;
get_menu_padding (widget, &padding);
view_width -= padding.left + padding.right;
view_height -= padding.top + padding.bottom;
- x = padding.left;
- y = padding.top;
+ x = allocation.x + padding.left;
+ y = allocation.y + padding.top;
top_arrow_node = gtk_css_gadget_get_node (priv->top_arrow_gadget);
gtk_css_node_set_visible (top_arrow_node, priv->upper_arrow_visible);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]