Changeset 80429 in webkit


Ignore:
Timestamp:
Mar 5, 2011 2:32:57 PM (13 years ago)
Author:
Martin Robinson
Message:

2011-03-01 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Windowless plugins override the view cursor
https://bugs.webkit.org/show_bug.cgi?id=55531

manual test: manual-tests/plugins/windowless.html

  • platform/gtk/WidgetGtk.cpp: (WebCore::Widget::setCursor): Call into the ChromeClient implementation now.
  • plugins/gtk/PluginViewGtk.cpp: (WebCore::PluginView::initXEvent): Instead of setting the window for windowless plugin events, set the window value to none. This method is also used to send focus in / focus out events to windowed plugins, but this is not one of the plugin types where the window parameter matters. This matches what Mozilla does. Also pass in the display of the widget itself, not the default display. (WebCore::PluginView::handleMouseEvent): When the cursor leaves the plugin area, reset the cursor. (WebCore::PluginView::platformGetValue): Clean up this section slightly. Give the widget the top-level window explicitly. This matches Mozilla.

2011-03-01 Martin Robinson <mrobinson@igalia.com>

Reviewed by Xan Lopez.

[GTK] Windowless plugins override the view cursor
https://bugs.webkit.org/show_bug.cgi?id=55531

  • WebCoreSupport/ChromeClientGtk.cpp: (WebKit::ChromeClient::setCursor): Moved the implementation of setCursor here which is more fitting since it sets the cursor for the entire window.
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80428 r80429  
     12011-03-01  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Windowless plugins override the view cursor
     6        https://bugs.webkit.org/show_bug.cgi?id=55531
     7
     8        manual test: manual-tests/plugins/windowless.html
     9
     10        * platform/gtk/WidgetGtk.cpp:
     11        (WebCore::Widget::setCursor): Call into the ChromeClient implementation now.
     12        * plugins/gtk/PluginViewGtk.cpp:
     13        (WebCore::PluginView::initXEvent): Instead of setting the window for windowless
     14        plugin events, set the window value to none. This method is also used to send
     15        focus in / focus out events to windowed plugins, but this is not one of the plugin
     16        types where the window parameter matters. This matches what Mozilla does. Also
     17        pass in the display of the widget itself, not the default display.
     18        (WebCore::PluginView::handleMouseEvent): When the cursor leaves the plugin area,
     19        reset the cursor.
     20        (WebCore::PluginView::platformGetValue): Clean up this section slightly. Give the
     21        widget the top-level window explicitly. This matches Mozilla.
     22
    1232011-03-05  Martin Robinson  <mrobinson@igalia.com>
    224
  • trunk/Source/WebCore/platform/gtk/WidgetGtk.cpp

    r73330 r80429  
    6868void Widget::setCursor(const Cursor& cursor)
    6969{
    70     GdkCursor* platformCursor = cursor.platformCursor().get();
    71 
    72     // http://bugs.webkit.org/show_bug.cgi?id=16388
    73     // [GTK] Widget::setCursor() gets called frequently
    74     //
    75     // gdk_window_set_cursor() in certain GDK backends seems to be an
    76     // expensive operation, so avoid it if possible.
    77 
    78     if (platformCursor == lastSetCursor)
     70    ScrollView* view = root();
     71    if (!view)
    7972        return;
    80 
    81     gdk_window_set_cursor(gdkWindow(platformWidget()) ? gdkWindow(platformWidget()) : gtk_widget_get_window(GTK_WIDGET(root()->hostWindow()->platformPageClient())), platformCursor);
    82     lastSetCursor = platformCursor;
     73    view->hostWindow()->setCursor(cursor);
    8374}
    8475
  • trunk/Source/WebCore/plugins/gtk/PluginViewGtk.cpp

    r80428 r80429  
    323323    xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server
    324324    xEvent->xany.send_event = false;
    325     xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
    326     // NOTE: event->xany.window doesn't always correspond to the .window property of other XEvent's
    327     // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify
    328     // events; thus, this is right:
    329325    GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient();
    330     xEvent->xany.window = widget ? GDK_WINDOW_XWINDOW(gtk_widget_get_window(widget)) : 0;
     326    xEvent->xany.display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget));
     327
     328    // Mozilla also sends None here for windowless plugins. See nsObjectFrame.cpp in the Mozilla sources.
     329    // This method also sets up FocusIn and FocusOut events for windows plugins, but Mozilla doesn't
     330    // even send these types of events to windowed plugins. In the future, it may be good to only
     331    // send them to windowless plugins.
     332    xEvent->xany.window = None;
    331333}
    332334
     
    416418    else if (event->type() == eventNames().mousemoveEvent)
    417419        setXMotionEventSpecificFields(&xEvent, event, postZoomPos, m_parentFrame.get());
    418     else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent)
     420    else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent) {
    419421        setXCrossingEventSpecificFields(&xEvent, event, postZoomPos, m_parentFrame.get());
     422
     423        // This is a work-around for plugins which change the cursor. When that happens we
     424        // get out of sync with GDK somehow. Resetting the cursor here seems to fix the issue.
     425        if (event->type() == eventNames().mouseoutEvent)
     426            gdk_window_set_cursor(gtk_widget_get_window(m_parentFrame->view()->hostWindow()->platformPageClient()), 0);
     427    }
    420428    else
    421429        return;
     
    650658
    651659        case NPNVnetscapeWindow: {
    652 #if defined(XP_UNIX)
    653             void* w = reinterpret_cast<void*>(value);
    654             GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient();
    655             *((XID *)w) = GDK_WINDOW_XWINDOW(gtk_widget_get_window(widget));
    656 #endif
    657 #ifdef GDK_WINDOWING_WIN32
    658             HGDIOBJ* w = reinterpret_cast<HGDIOBJ*>(value);
    659             GtkWidget* widget = m_parentFrame->view()->hostWindow()->platformPageClient();
    660             *w = GDK_WINDOW_HWND(gtk_widget_get_window(widget));
     660            GdkWindow* gdkWindow = gtk_widget_get_window(m_parentFrame->view()->hostWindow()->platformPageClient());
     661#if defined(XP_UNIX)
     662            *static_cast<Window*>(value) = GDK_WINDOW_XWINDOW(gdk_window_get_toplevel(gdkWindow));
     663#elif defined(GDK_WINDOWING_WIN32)
     664            *static_cast<HGIOBJ*>(value) = GDK_WINDOW_HWND(gdkWindow);
    661665#endif
    662666            *result = NPERR_NO_ERROR;
  • trunk/Source/WebKit/gtk/ChangeLog

    r80299 r80429  
     12011-03-01  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [GTK] Windowless plugins override the view cursor
     6        https://bugs.webkit.org/show_bug.cgi?id=55531
     7
     8        * WebCoreSupport/ChromeClientGtk.cpp:
     9        (WebKit::ChromeClient::setCursor): Moved the implementation of setCursor here
     10        which is more fitting since it sets the cursor for the entire window.
     11
    1122011-03-03  Brady Eidson  <beidson@apple.com>
    213
  • trunk/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp

    r80279 r80429  
    653653}
    654654
    655 void ChromeClient::setCursor(const Cursor&)
    656 {
    657     notImplemented();
     655void ChromeClient::setCursor(const Cursor& cursor)
     656{
     657    // [GTK] Widget::setCursor() gets called frequently
     658    // http://bugs.webkit.org/show_bug.cgi?id=16388
     659    // Setting the cursor may be an expensive operation in some backends,
     660    // so don't re-set the cursor if it's already set to the target value.
     661    GdkWindow* window = gtk_widget_get_window(platformPageClient());
     662    GdkCursor* currentCursor = gdk_window_get_cursor(window);
     663    GdkCursor* newCursor = cursor.platformCursor().get();
     664    if (currentCursor != newCursor)
     665        gdk_window_set_cursor(window, newCursor);
    658666}
    659667
Note: See TracChangeset for help on using the changeset viewer.