diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 23:49:53 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 23:49:53 +0000 |
commit | 8b520f6a9fe0aeb4fa671c803d6d5d1f6aa487f1 (patch) | |
tree | 63faf4b06e438198daabe722f5aa29b1da74a0fa /o3d | |
parent | 43beaabb2b4c4da7fed9f115e2844613cb12c1e1 (diff) | |
download | chromium_src-8b520f6a9fe0aeb4fa671c803d6d5d1f6aa487f1.zip chromium_src-8b520f6a9fe0aeb4fa671c803d6d5d1f6aa487f1.tar.gz chromium_src-8b520f6a9fe0aeb4fa671c803d6d5d1f6aa487f1.tar.bz2 |
Fixed problems with Cocoa full-screen code:
- Squelch mouse-up events coming from the browser while in
full-screen mode. This avoids immediately falling out of
full-screen mode in apps which have an icon which toggles between
full-screen and windowed mode.
- Squelch focus transfer events coming from the browser while in
full-screen mode. This avoids immediately falling out of
full-screen mode upon entry in some situations. Focus transfers
away from the full-screen window continue to work.
BUG=none
TEST=various full-screen tests
Review URL: http://codereview.chromium.org/2837006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r-- | o3d/plugin/mac/fullscreen_window_mac.mm | 6 | ||||
-rw-r--r-- | o3d/plugin/mac/main_mac.mm | 27 | ||||
-rw-r--r-- | o3d/plugin/mac/plugin_mac.h | 6 |
3 files changed, 32 insertions, 7 deletions
diff --git a/o3d/plugin/mac/fullscreen_window_mac.mm b/o3d/plugin/mac/fullscreen_window_mac.mm index 717c65e..e2ba86c 100644 --- a/o3d/plugin/mac/fullscreen_window_mac.mm +++ b/o3d/plugin/mac/fullscreen_window_mac.mm @@ -618,7 +618,7 @@ void CocoaFullscreenWindowMac::DispatchKeyEvent(NPCocoaEventType kind, (NPNSString*) [event charactersIgnoringModifiers]; cocoa_event.data.key.isARepeat = [event isARepeat]; cocoa_event.data.key.keyCode = [event keyCode]; - HandleCocoaEvent(obj_->npp(), &cocoa_event); + HandleCocoaEvent(obj_->npp(), &cocoa_event, false); } void CocoaFullscreenWindowMac::DispatchMouseEvent(NPCocoaEventType kind, @@ -637,7 +637,7 @@ void CocoaFullscreenWindowMac::DispatchMouseEvent(NPCocoaEventType kind, cocoa_event.data.mouse.deltaX = [event deltaX]; cocoa_event.data.mouse.deltaY = [event deltaY]; cocoa_event.data.mouse.deltaZ = [event deltaZ]; - HandleCocoaEvent(obj_->npp(), &cocoa_event); + HandleCocoaEvent(obj_->npp(), &cocoa_event, false); } void CocoaFullscreenWindowMac::DispatchFocusLostEvent() { @@ -646,7 +646,7 @@ void CocoaFullscreenWindowMac::DispatchFocusLostEvent() { cocoa_event.type = NPCocoaEventFocusChanged; // cocoa_event.data.focus.hasFocus is already false. // We aren't testing this in HandleCocoaEvent anyway. - HandleCocoaEvent(obj_->npp(), &cocoa_event); + HandleCocoaEvent(obj_->npp(), &cocoa_event, false); } //---------------------------------------------------------------------- diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm index 3e05180..6f3a15d 100644 --- a/o3d/plugin/mac/main_mac.mm +++ b/o3d/plugin/mac/main_mac.mm @@ -817,7 +817,8 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) { // The principle advantages are that we can get scrollwheel messages, // mouse-moved messages, and can tell which mouse button was pressed. // This API will also be required for a carbon-free 64 bit version for 10.6. -bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event) { +bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event, + bool initiated_from_browser) { PluginObject* obj = static_cast<PluginObject*>(instance->pdata); FullscreenWindowMac* fullscreen_window = obj->GetFullscreenMacWindow(); bool handled = false; @@ -848,6 +849,21 @@ bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event) { case NPCocoaEventMouseEntered: case NPCocoaEventMouseExited: case NPCocoaEventScrollWheel: + if (the_event->type == NPCocoaEventMouseUp && + initiated_from_browser && fullscreen_window) { + // The mouse-up event associated with the mouse-down that caused + // the app to go full-screen is dispatched against the browser + // window rather than the full-screen window. Apps that have an + // icon which toggles full-screen and windowed mode therefore come + // out of full-screen immediately when the icon is clicked, since + // the mouse-up occurs at the same location as the mouse-down. Work + // around this by squelching this mouse up event. This seems to + // work acceptably for known apps. We could do better by + // redispatching all mouse events through the full-screen window + // until the first mouse up. + break; + } + HandleCocoaMouseEvent(obj, the_event); break; case NPCocoaEventKeyDown: @@ -901,7 +917,12 @@ bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event) { // because another app has been called to the front. // TODO: We'll have problems with this when dealing with e.g. // Japanese text input IME windows. - if (fullscreen_window && !fullscreen_window->IsActive()) { + // Note that we ignore focus transfer events coming from the + // browser while in full-screen mode, because otherwise we + // frequently disable full-screen mode almost immediately after + // entering it. + if (fullscreen_window && !fullscreen_window->IsActive() && + !initiated_from_browser) { obj->CancelFullscreenDisplay(); } @@ -1331,7 +1352,7 @@ int16 NPP_HandleEvent(NPP instance, void* event) { EventRecord* theEvent = static_cast<EventRecord*>(event); return HandleMacEvent(theEvent, instance) ? 1 : 0; } else if (obj->event_model_ == NPEventModelCocoa){ - return HandleCocoaEvent(instance, (NPCocoaEvent*)event) ? 1 : 0; + return HandleCocoaEvent(instance, (NPCocoaEvent*)event, true) ? 1 : 0; } return 0; } diff --git a/o3d/plugin/mac/plugin_mac.h b/o3d/plugin/mac/plugin_mac.h index 2e349cf..f5196de 100644 --- a/o3d/plugin/mac/plugin_mac.h +++ b/o3d/plugin/mac/plugin_mac.h @@ -97,7 +97,11 @@ char* CreatePosixFilePathFromHFSFilePath(const char* hfsPath); bool HandleMacEvent(EventRecord* the_event, NPP instance); -bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event); +// initiated_from_browser indicates whether the event came from the +// browser's window. It will be false if the event originated from the +// full-screen window. +bool HandleCocoaEvent(NPP instance, NPCocoaEvent* the_event, + bool initiated_from_browser); o3d::Event::Button MacOSMouseButtonNumberToO3DButton(int inButton); |