diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 22:26:10 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 22:26:10 +0000 |
commit | 77f0c3e6fcb58da648fe81819e7028a7bd3768d1 (patch) | |
tree | 2b401e4507fca7086372167b045de9e9e9df35e5 /webkit/glue | |
parent | 520cdd71da6f80dfffdd384645792de9a61abc94 (diff) | |
download | chromium_src-77f0c3e6fcb58da648fe81819e7028a7bd3768d1.zip chromium_src-77f0c3e6fcb58da648fe81819e7028a7bd3768d1.tar.gz chromium_src-77f0c3e6fcb58da648fe81819e7028a7bd3768d1.tar.bz2 |
Fix clicking in QuickTime content on the Mac
QuickTime uses FindWindow in its click handling to get the WindowRef, so we need to interpose it to give back the plugin window (which isn't actually on screen). This makes clicks work except for the menu button in the control strip.
BUG=24952
TEST=Click/double-click in a QuickTime video to pause/play, or use the control strip (except for the menu button).
Review URL: http://codereview.chromium.org/536047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/fake_plugin_window_tracker_mac.cc | 8 | ||||
-rw-r--r-- | webkit/glue/plugins/fake_plugin_window_tracker_mac.h | 30 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 6 |
3 files changed, 44 insertions, 0 deletions
diff --git a/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc index 6f7f7ef..0ca3307 100644 --- a/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc +++ b/webkit/glue/plugins/fake_plugin_window_tracker_mac.cc @@ -47,3 +47,11 @@ void FakePluginWindowTracker::RemoveFakeWindowForDelegate( if (window) // Check just in case the initial window creation failed. DisposeWindow(window); } + +WindowRef FakePluginWindowTracker::get_active_plugin_window() { + return active_plugin_window_; +} + +void FakePluginWindowTracker::set_active_plugin_window(WindowRef window) { + active_plugin_window_ = window; +} diff --git a/webkit/glue/plugins/fake_plugin_window_tracker_mac.h b/webkit/glue/plugins/fake_plugin_window_tracker_mac.h index e06bf01..24c1d1f 100644 --- a/webkit/glue/plugins/fake_plugin_window_tracker_mac.h +++ b/webkit/glue/plugins/fake_plugin_window_tracker_mac.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/scoped_cftyperef.h" +class ScopedActivePluginWindow; class WebPluginDelegateImpl; // Serves as a bridge between plugin delegate instances and the Carbon @@ -33,10 +34,39 @@ class __attribute__((visibility("default"))) FakePluginWindowTracker { void RemoveFakeWindowForDelegate(WebPluginDelegateImpl* delegate, WindowRef window); + // Gets the window for the plugin that is currently handling an input event. + // To set the value, use ScopedActivePluginWindow. + WindowRef get_active_plugin_window(); + private: + friend class ScopedActivePluginWindow; + // Sets the window corresponding to the plugin that is currently handling an + // input event. + void set_active_plugin_window(WindowRef window); + scoped_cftyperef<CFMutableDictionaryRef> window_to_delegate_map_; + WindowRef active_plugin_window_; // weak reference + DISALLOW_COPY_AND_ASSIGN(FakePluginWindowTracker); }; +// Helper to simplify correct usage of set_active_plugin_window. +// Instantiating will set the shared plugin window tracker's active window to +// |window| for the lifetime of the object, then NULL when it goes out of scope. +class ScopedActivePluginWindow { + public: + explicit ScopedActivePluginWindow(WindowRef window) : window_(window) { + FakePluginWindowTracker::SharedInstance()->set_active_plugin_window( + window_); + } + ~ScopedActivePluginWindow() { + FakePluginWindowTracker::SharedInstance()->set_active_plugin_window( + NULL); + } +private: + WindowRef window_; // weak ref + DISALLOW_COPY_AND_ASSIGN(ScopedActivePluginWindow); +}; + #endif // WEBKIT_GLUE_PLUGINS_FAKE_PLUGIN_WINDOW_TRACKER_MAC_H_ diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 33b8c3c..abbd400 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -747,6 +747,9 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event, LOG(WARNING) << "NPEventFromWebInputEvent failed"; return false; } + // Set this plugin's window as the active one, for global Carbon calls. + ScopedActivePluginWindow active_window_scope( + reinterpret_cast<WindowRef>(cg_context_.window)); ret = instance()->NPP_HandleEvent(&np_event) != 0; break; } @@ -813,6 +816,9 @@ void WebPluginDelegateImpl::OnNullEvent() { np_event.modifiers |= btnState; np_event.where.h = last_mouse_x_; np_event.where.v = last_mouse_y_; + // Set this plugin's window as the active one, for global Carbon calls. + ScopedActivePluginWindow active_window_scope( + reinterpret_cast<WindowRef>(cg_context_.window)); instance()->NPP_HandleEvent(&np_event); } #endif |