diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 23:33:42 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 23:33:42 +0000 |
commit | f1e9818859a3926f203eaeccbd4fc59d47513775 (patch) | |
tree | aa187d63d608882f17e219357f183e2d5da17a50 /remoting | |
parent | d45e37db5719b0b2faceab7e909f91abbff0771e (diff) | |
download | chromium_src-f1e9818859a3926f203eaeccbd4fc59d47513775.zip chromium_src-f1e9818859a3926f203eaeccbd4fc59d47513775.tar.gz chromium_src-f1e9818859a3926f203eaeccbd4fc59d47513775.tar.bz2 |
Fixed slowdown due to local input monitoring.
BUG=105070
TEST=Manual
Review URL: http://codereview.chromium.org/8670005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/local_input_monitor_mac.mm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/remoting/host/local_input_monitor_mac.mm b/remoting/host/local_input_monitor_mac.mm index 356d098..2077a96 100644 --- a/remoting/host/local_input_monitor_mac.mm +++ b/remoting/host/local_input_monitor_mac.mm @@ -28,6 +28,7 @@ typedef std::set<remoting::ChromotingHost*> Hosts; @private GTMCarbonHotKey* hotKey_; CFRunLoopSourceRef mouseRunLoopSource_; + base::mac::ScopedCFTypeRef<CFMachPortRef> mouseMachPort_; base::Lock hostsLock_; Hosts hosts_; } @@ -78,18 +79,18 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, if (!hotKey_) { LOG(ERROR) << "registerHotKey failed."; } - base::mac::ScopedCFTypeRef<CFMachPortRef> mouseMachPort(CGEventTapCreate( + mouseMachPort_.reset(CGEventTapCreate( kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly, 1 << kCGEventMouseMoved, LocalMouseMoved, self)); - if (mouseMachPort) { + if (mouseMachPort_) { mouseRunLoopSource_ = CFMachPortCreateRunLoopSource( - NULL, mouseMachPort, 0); + NULL, mouseMachPort_, 0); CFRunLoopAddSource( CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes); } else { LOG(ERROR) << "CGEventTapCreate failed."; } - if (!hotKey_ && !mouseMachPort) { + if (!hotKey_ && !mouseMachPort_) { [self release]; return nil; } @@ -119,9 +120,11 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, hotKey_ = NULL; } if (mouseRunLoopSource_) { + CFMachPortInvalidate(mouseMachPort_); CFRunLoopRemoveSource( CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes); CFRelease(mouseRunLoopSource_); + mouseMachPort_.reset(0); mouseRunLoopSource_ = NULL; } } |