1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef nsToolkit_h_
7 #define nsToolkit_h_
8 
9 #include "nscore.h"
10 
11 #import <Carbon/Carbon.h>
12 #import <Cocoa/Cocoa.h>
13 #import <objc/Object.h>
14 #import <IOKit/IOKitLib.h>
15 
16 class nsToolkit {
17  public:
18   nsToolkit();
19   virtual ~nsToolkit();
20 
21   static nsToolkit* GetToolkit();
22 
Shutdown()23   static void Shutdown() {
24     delete gToolkit;
25     gToolkit = nullptr;
26   }
27 
28   static void PostSleepWakeNotification(const char* aNotification);
29 
30   static nsresult SwizzleMethods(Class aClass, SEL orgMethod, SEL posedMethod,
31                                  bool classMethods = false);
32 
33   void MonitorAllProcessMouseEvents();
34   void StopMonitoringAllProcessMouseEvents();
35 
36  protected:
37   nsresult RegisterForSleepWakeNotifications();
38   void RemoveSleepWakeNotifications();
39 
40  protected:
41   static nsToolkit* gToolkit;
42 
43   CFRunLoopSourceRef mSleepWakeNotificationRLS;
44   io_object_t mPowerNotifier;
45 
46   id mAllProcessMouseMonitor;
47 };
48 
49 #endif  // nsToolkit_h_
50