diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 15:44:17 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 15:44:17 +0000 |
commit | b59162e1a722e72d29e48c67938f27fe051ffd15 (patch) | |
tree | b4ed3ae3dbbcc377b1441ab918d9cbace4623b8b /chrome/plugin/plugin_interpose_util_mac.mm | |
parent | ba3996771f6d19298ee655992b2f6291a314ea76 (diff) | |
download | chromium_src-b59162e1a722e72d29e48c67938f27fe051ffd15.zip chromium_src-b59162e1a722e72d29e48c67938f27fe051ffd15.tar.gz chromium_src-b59162e1a722e72d29e48c67938f27fe051ffd15.tar.bz2 |
Make Mac plugin window interposing more conservative about activating plugin
Don't switch to the plugin process for offscreen windows (like the one opened by Unity).
BUG=38996
TEST=Open a Unity sample. It shouldn't lose focus on every mouse event (although it will still lose focus once).
Review URL: http://codereview.chromium.org/1626002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/plugin_interpose_util_mac.mm')
-rw-r--r-- | chrome/plugin/plugin_interpose_util_mac.mm | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chrome/plugin/plugin_interpose_util_mac.mm b/chrome/plugin/plugin_interpose_util_mac.mm index d3c1d74..8980eb4 100644 --- a/chrome/plugin/plugin_interpose_util_mac.mm +++ b/chrome/plugin/plugin_interpose_util_mac.mm @@ -133,6 +133,25 @@ static void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) { window_info.window_id, window_info.bounds, is_modal); } +@interface NSWindow (ChromePluginUtilities) +- (BOOL)chromePlugin_isWindowOnScreen; +@end + +@implementation NSWindow (ChromePluginUtilities) + +- (BOOL)chromePlugin_isWindowOnScreen { + if (![self isVisible]) + return NO; + NSRect window_frame = [self frame]; + for (NSScreen* screen in [NSScreen screens]) { + if (NSIntersectsRect(window_frame, [screen frame])) + return YES; + } + return NO; +} + +@end + @interface NSWindow (ChromePluginInterposing) - (void)chromePlugin_orderOut:(id)sender; - (void)chromePlugin_orderFront:(id)sender; @@ -149,14 +168,16 @@ static void OnPluginWindowShown(const WindowInfo& window_info, BOOL is_modal) { } - (void)chromePlugin_orderFront:(id)sender { - mac_plugin_interposing::SwitchToPluginProcess(); [self chromePlugin_orderFront:sender]; + if ([self chromePlugin_isWindowOnScreen]) + mac_plugin_interposing::SwitchToPluginProcess(); OnPluginWindowShown(WindowInfo(self), NO); } - (void)chromePlugin_makeKeyAndOrderFront:(id)sender { - mac_plugin_interposing::SwitchToPluginProcess(); [self chromePlugin_makeKeyAndOrderFront:sender]; + if ([self chromePlugin_isWindowOnScreen]) + mac_plugin_interposing::SwitchToPluginProcess(); OnPluginWindowShown(WindowInfo(self), NO); } |