Comment 2 for bug 1184708

Revision history for this message
André Auzi (aauzi) wrote :

I traced the issue down to the function: midori_browser_menu_button_press_event_cb

It implements a code that relay the 'button-press-event' if the 'button-press-event' is handled by the menubar handler.

    /* GtkMenuBar catches button events on children with submenus,
       so we need to see if the actual widget is the menubar, and if
       it is an item, we forward it to the actual widget. */
    if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
    {
        midori_browser_toolbar_popup_context_menu_cb (
            GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
                gtk_widget_get_parent (toolitem) : toolitem,
            event->x, event->y, event->button, browser);
        return TRUE;
    }
    else if (GTK_IS_MENU_ITEM (toolitem))
    {
        gboolean handled;
        g_signal_emit_by_name (toolitem, "button-press-event", event, &handled);
        return handled;
    }

This code does not work in my environment (See version description previously attached)

I managed to avoid this misbehaviour by checking the inclusion of the 'button-press-event' in the bounding box of the menubar widget.

like this:

      /* GtkMenuBar catches button events on children with submenus,
         so we need to see if the actual widget is the menubar, and if
         it is an item, we forward it to the actual widget. */
      if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
      {
! gboolean event_in_window = TRUE;
! gint ex, ey, x, y, width, height;
!
! gdk_window_get_origin (toolitem->window, &x, &y);
! gdk_drawable_get_size (GDK_DRAWABLE (toolitem->window), &width, &height);
! ex = event->x_root; ey = event->y_root;;
!
! if ((ex < x) || (ey < y)
! || (ex > x+width) || (ey > y+height))
! event_in_window = FALSE;
!
! g_print (" evt: x=%d, y=%d\n", ex, ey);
! g_print (" wnd: x=%d, y=%d, w=%d, h=%d\n", x, y, width, height);
! g_print ("popup: is_box=%d, is_menu_bar=%d,"
! " is_menu_item=%d, is_browser_menubar=%d,"
! " event_in_window=%d\n",
! GTK_IS_BOX (toolitem), GTK_IS_MENU_BAR (toolitem),
! GTK_IS_MENU_ITEM (toolitem),
! toolitem == (GtkWidget*)browser->menubar,
! event_in_window);
!
! if ((ex < x) || (ey < y)
! || (ex > x+width) || (ey > y+height))
! return FALSE;
!
! midori_browser_toolbar_popup_context_menu_cb (