widget/cocoa/nsToolkit.h
author Nicholas D. Matsakis <nmatsakis@mozilla.com>
Tue, 11 Mar 2014 13:23:24 -0400
changeset 206610 4903226b4f2ff4f6c44fe08e91e5dff0e163741d
parent 165800 4eaaad2e06f20b53c5229ddfb4d7f3e3a8a52c66
child 227326 802f32e18c1c0ecddb4ad8b1f92d3c4e7895f981
permissions -rw-r--r--
Bug 973238 Part 6 -- Consult prototype rather than typed object addendum r=bhackett

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsToolkit_h_
#define nsToolkit_h_

#include "nscore.h"
#include "nsCocoaFeatures.h"

#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#import <objc/Object.h>
#import <IOKit/IOKitLib.h>

class nsToolkit
{
public:
                     nsToolkit();
  virtual            ~nsToolkit();

  static nsToolkit*  GetToolkit();

  static void Shutdown() {
    delete gToolkit;
    gToolkit = nullptr;
  }

  static void        PostSleepWakeNotification(const char* aNotification);

  static nsresult    SwizzleMethods(Class aClass, SEL orgMethod, SEL posedMethod,
                                    bool classMethods = false);

  void               RegisterForAllProcessMouseEvents();
  void               UnregisterAllProcessMouseEventHandlers();

protected:

  nsresult           RegisterForSleepWakeNotifcations();
  void               RemoveSleepWakeNotifcations();

protected:

  static nsToolkit*  gToolkit;

  CFRunLoopSourceRef mSleepWakeNotificationRLS;
  io_object_t        mPowerNotifier;

  CFMachPortRef      mEventTapPort;
  CFRunLoopSourceRef mEventTapRLS;
};

#endif // nsToolkit_h_