Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: base/message_loop/message_pump_mac.mm

Issue 2118883002: [Mac] Add MessagePumpMac callouts to com.apple.hitoolbox.windows.windowfadingmode. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NSUnhighlightMenuRunLoopMode Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "base/message_loop/message_pump_mac.h" 5 #import "base/message_loop/message_pump_mac.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include <limits> 10 #include <limits>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/call_with_eh_frame.h" 13 #include "base/mac/call_with_eh_frame.h"
14 #include "base/mac/scoped_cftyperef.h" 14 #include "base/mac/scoped_cftyperef.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/message_loop/timer_slack.h" 16 #include "base/message_loop/timer_slack.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 20
21 #if !defined(OS_IOS) 21 #if !defined(OS_IOS)
22 #import <AppKit/AppKit.h> 22 #import <AppKit/AppKit.h>
23 #endif // !defined(OS_IOS) 23 #endif // !defined(OS_IOS)
24 24
25 namespace base { 25 namespace base {
26 26
27 namespace { 27 namespace {
28 28
29 const CFStringRef kAllModes[] = {
30 kCFRunLoopCommonModes,
31 kMessageLoopExclusiveRunLoopMode,
32
33 // Process work when NSMenus are fading out.
34 CFSTR("com.apple.hitoolbox.windows.windowfadingmode"),
35
36 // Process work when AppKit is highlighting an item on the main menubar.
37 CFSTR("NSUnhighlightMenuRunLoopMode"),
38
39 // Other modes that aren't strictly necessary:
40 //CFSTR("com.apple.hitoolbox.windows.transitionmode"),
41 //CFSTR("com.apple.hitoolbox.windows.flushmode"),
42 };
43
29 void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) { 44 void CFRunLoopAddSourceToAllModes(CFRunLoopRef rl, CFRunLoopSourceRef source) {
30 CFRunLoopAddSource(rl, source, kCFRunLoopCommonModes); 45 for (const auto& mode : kAllModes)
31 CFRunLoopAddSource(rl, source, kMessageLoopExclusiveRunLoopMode); 46 CFRunLoopAddSource(rl, source, mode);
32 } 47 }
33 48
34 void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl, 49 void CFRunLoopRemoveSourceFromAllModes(CFRunLoopRef rl,
35 CFRunLoopSourceRef source) { 50 CFRunLoopSourceRef source) {
36 CFRunLoopRemoveSource(rl, source, kCFRunLoopCommonModes); 51 for (const auto& mode : kAllModes)
37 CFRunLoopRemoveSource(rl, source, kMessageLoopExclusiveRunLoopMode); 52 CFRunLoopRemoveSource(rl, source, mode);
38 } 53 }
39 54
40 void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) { 55 void CFRunLoopAddTimerToAllModes(CFRunLoopRef rl, CFRunLoopTimerRef timer) {
41 CFRunLoopAddTimer(rl, timer, kCFRunLoopCommonModes); 56 for (const auto& mode : kAllModes)
42 CFRunLoopAddTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); 57 CFRunLoopAddTimer(rl, timer, mode);
43 } 58 }
44 59
45 void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl, 60 void CFRunLoopRemoveTimerFromAllModes(CFRunLoopRef rl,
46 CFRunLoopTimerRef timer) { 61 CFRunLoopTimerRef timer) {
47 CFRunLoopRemoveTimer(rl, timer, kCFRunLoopCommonModes); 62 for (const auto& mode : kAllModes)
48 CFRunLoopRemoveTimer(rl, timer, kMessageLoopExclusiveRunLoopMode); 63 CFRunLoopRemoveTimer(rl, timer, mode);
49 } 64 }
50 65
51 void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl, 66 void CFRunLoopAddObserverToAllModes(CFRunLoopRef rl,
52 CFRunLoopObserverRef observer) { 67 CFRunLoopObserverRef observer) {
53 CFRunLoopAddObserver(rl, observer, kCFRunLoopCommonModes); 68 for (const auto& mode : kAllModes)
54 CFRunLoopAddObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); 69 CFRunLoopAddObserver(rl, observer, mode);
55 } 70 }
56 71
57 void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl, 72 void CFRunLoopRemoveObserverFromAllModes(CFRunLoopRef rl,
58 CFRunLoopObserverRef observer) { 73 CFRunLoopObserverRef observer) {
59 CFRunLoopRemoveObserver(rl, observer, kCFRunLoopCommonModes); 74 for (const auto& mode : kAllModes)
60 CFRunLoopRemoveObserver(rl, observer, kMessageLoopExclusiveRunLoopMode); 75 CFRunLoopRemoveObserver(rl, observer, mode);
61 } 76 }
62 77
63 void NoOp(void* info) { 78 void NoOp(void* info) {
64 } 79 }
65 80
66 const CFTimeInterval kCFTimeIntervalMax = 81 const CFTimeInterval kCFTimeIntervalMax =
67 std::numeric_limits<CFTimeInterval>::max(); 82 std::numeric_limits<CFTimeInterval>::max();
68 83
69 #if !defined(OS_IOS) 84 #if !defined(OS_IOS)
70 // Set to true if MessagePumpMac::Create() is called before NSApp is 85 // Set to true if MessagePumpMac::Create() is called before NSApp is
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 [NSApplication sharedApplication]; 799 [NSApplication sharedApplication];
785 g_not_using_cr_app = true; 800 g_not_using_cr_app = true;
786 return new MessagePumpNSApplication; 801 return new MessagePumpNSApplication;
787 #endif 802 #endif
788 } 803 }
789 804
790 return new MessagePumpNSRunLoop; 805 return new MessagePumpNSRunLoop;
791 } 806 }
792 807
793 } // namespace base 808 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698