diff options
author | Benjamin Otte <otte@redhat.com> | 2016-11-02 17:50:12 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-11-02 22:00:29 +0100 |
commit | bb8b24da47bda36d277282bab46a7eb87dc02167 (patch) | |
tree | c436aee88c9f5a627adac57cbc4970a5aa93a0b0 /gtk/gtkmenubar.c | |
parent | 633a93f418ce029bc3cb6665a648235183cec731 (diff) | |
download | gtk+-bb8b24da47bda36d277282bab46a7eb87dc02167.tar.gz |
menu: Don't set widget->window
Instead, create an input window for the menubar and omit the window for
the menu itself.
Diffstat (limited to 'gtk/gtkmenubar.c')
-rw-r--r-- | gtk/gtkmenubar.c | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index c1feaff8a3..76af5377b2 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -72,6 +72,7 @@ struct _GtkMenuBarPrivate GtkPackDirection pack_direction; GtkPackDirection child_pack_direction; + GdkWindow *input_window; GtkCssGadget *gadget; }; @@ -96,6 +97,8 @@ static void gtk_menu_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gint gtk_menu_bar_draw (GtkWidget *widget, cairo_t *cr); +static void gtk_menu_bar_realize (GtkWidget *widget); +static void gtk_menu_bar_unrealize (GtkWidget *widget); static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget, GtkWidget *old_toplevel); static gint gtk_menu_bar_get_popup_delay (GtkMenuShell *menu_shell); @@ -144,7 +147,11 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class) widget_class->measure = gtk_menu_bar_measure_; widget_class->size_allocate = gtk_menu_bar_size_allocate; + widget_class->size_allocate = gtk_menu_bar_size_allocate; + widget_class->size_allocate = gtk_menu_bar_size_allocate; widget_class->draw = gtk_menu_bar_draw; + widget_class->realize = gtk_menu_bar_realize; + widget_class->unrealize = gtk_menu_bar_unrealize; widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed; menu_shell_class->submenu_placement = GTK_TOP_BOTTOM; @@ -318,6 +325,42 @@ gtk_menu_bar_get_property (GObject *object, } static void +gtk_menu_bar_realize (GtkWidget *widget) +{ + GtkMenuBar *menubar = GTK_MENU_BAR (widget); + GtkMenuBarPrivate *priv = menubar->priv; + GtkAllocation allocation; + + GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->realize (widget); + + gtk_widget_get_allocation (widget, &allocation); + + priv->input_window = gdk_window_new_input (gtk_widget_get_window (widget), + gtk_widget_get_events (widget) + | GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK + | GDK_KEY_PRESS_MASK + | GDK_ENTER_NOTIFY_MASK + | GDK_LEAVE_NOTIFY_MASK, + &allocation); + gtk_widget_register_window (widget, priv->input_window); +} + +static void +gtk_menu_bar_unrealize (GtkWidget *widget) +{ + GtkMenuBar *menubar = GTK_MENU_BAR (widget); + GtkMenuBarPrivate *priv = menubar->priv; + + gtk_widget_unregister_window (widget, priv->input_window); + gdk_window_destroy (priv->input_window); + priv->input_window = NULL; + + GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->unrealize (widget); +} + +static void gtk_menu_bar_measure (GtkCssGadget *gadget, GtkOrientation orientation, int size, @@ -556,20 +599,18 @@ static void gtk_menu_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - GtkMenuBar *menu_bar; + GtkMenuBar *menu_bar = GTK_MENU_BAR (widget); + GtkMenuBarPrivate *priv = menu_bar->priv; GtkAllocation clip, content_allocation; - menu_bar = GTK_MENU_BAR (widget); gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), + gdk_window_move_resize (priv->input_window, allocation->x, allocation->y, allocation->width, allocation->height); - content_allocation = *allocation; - content_allocation.x = content_allocation.y = 0; - gtk_css_gadget_allocate (menu_bar->priv->gadget, + gtk_css_gadget_allocate (priv->gadget, &content_allocation, gtk_widget_get_allocated_baseline (widget), &clip); |