Title: [103802] trunk/Source/WebKit2
Revision
103802
Author
carlo...@webkit.org
Date
2011-12-29 08:39:08 -0800 (Thu, 29 Dec 2011)

Log Message

[GTK] Context menu is hidden right after showing it when first menu item is not disabled
https://bugs.webkit.org/show_bug.cgi?id=75357

Reviewed by Martin Robinson.

The problem is that we are passing GDK_CURRENT_TIME (which is 0)
to gtk_popup_menu, because the events are async and
gtk_get_current_event is NULL when calling gtk_menu_popup. GtkMenu
has a timeout to decide whether the press-release was fast enough
and ignore the button release event in that case. That way, a
normal right click shows the menu while a long press hides the
menu when the button is released. So, we need to know the real time
when the right button was pressed and pass it to gtk_popup_menu.

* UIProcess/WebPageProxy.h: Make
currentlyProcessedMouseDownEvent() public.
* UIProcess/gtk/WebContextMenuProxyGtk.cpp:
(WebKit::WebContextMenuProxyGtk::showContextMenu): Use
WebPageProxy::currentlyProcessedMouseDownEvent() to get the
current mouse event and pass its button number and time to
gtk_popup_menu.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (103801 => 103802)


--- trunk/Source/WebKit2/ChangeLog	2011-12-29 16:33:38 UTC (rev 103801)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-29 16:39:08 UTC (rev 103802)
@@ -1,5 +1,29 @@
 2011-12-29  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK] Context menu is hidden right after showing it when first menu item is not disabled
+        https://bugs.webkit.org/show_bug.cgi?id=75357
+
+        Reviewed by Martin Robinson.
+
+        The problem is that we are passing GDK_CURRENT_TIME (which is 0)
+        to gtk_popup_menu, because the events are async and
+        gtk_get_current_event is NULL when calling gtk_menu_popup. GtkMenu
+        has a timeout to decide whether the press-release was fast enough
+        and ignore the button release event in that case. That way, a
+        normal right click shows the menu while a long press hides the
+        menu when the button is released. So, we need to know the real time
+        when the right button was pressed and pass it to gtk_popup_menu.
+
+        * UIProcess/WebPageProxy.h: Make
+        currentlyProcessedMouseDownEvent() public.
+        * UIProcess/gtk/WebContextMenuProxyGtk.cpp:
+        (WebKit::WebContextMenuProxyGtk::showContextMenu): Use
+        WebPageProxy::currentlyProcessedMouseDownEvent() to get the
+        current mouse event and pass its button number and time to
+        gtk_popup_menu.
+
+2011-12-29  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [GTK] Fix several conding style issues in WebKit2 GTK+ code
         https://bugs.webkit.org/show_bug.cgi?id=75339
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (103801 => 103802)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-12-29 16:33:38 UTC (rev 103801)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-12-29 16:39:08 UTC (rev 103802)
@@ -592,6 +592,9 @@
 
     void printMainFrame();
 
+    // WebPopupMenuProxy::Client
+    virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
+
 private:
     WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
 
@@ -600,7 +603,6 @@
     // WebPopupMenuProxy::Client
     virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex);
     virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index);
-    virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
 #if PLATFORM(GTK)
     virtual void failedToShowPopupMenu();
 #endif    

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp (103801 => 103802)


--- trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp	2011-12-29 16:33:38 UTC (rev 103801)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp	2011-12-29 16:39:08 UTC (rev 103802)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebContextMenuProxyGtk.h"
 
+#include "NativeWebMouseEvent.h"
 #include "WebContextMenuItemData.h"
 #include "WebPageProxy.h"
 #include <WebCore/ContextMenu.h>
@@ -81,7 +82,10 @@
     m_popupPosition = convertWidgetPointToScreenPoint(m_webView, position);
 
     // Display menu initiated by right click (mouse button pressed = 3).
-    gtk_menu_popup(m_popup, 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 3, GDK_CURRENT_TIME);
+    NativeWebMouseEvent* mouseEvent = m_page->currentlyProcessedMouseDownEvent();
+    const GdkEvent* event = mouseEvent ? mouseEvent->nativeEvent() : 0;
+    gtk_menu_popup(m_popup, 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this,
+                   event ? event->button.button : 3, event ? event->button.time : GDK_CURRENT_TIME);
 }
 
 void WebContextMenuProxyGtk::hideContextMenu()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to