Back to index

lightning-sunbird  0.9+nobinonly
Defines | Enumerations | Functions | Variables
nsMacEventHandler.cpp File Reference
#include "nsMacEventHandler.h"
#include "nsWindow.h"
#include "nsMacWindow.h"
#include "nsCRT.h"
#include "prinrval.h"
#include <ToolUtils.h>
#include <TextServices.h>
#include <UnicodeConverter.h>
#include "nsCarbonHelpers.h"
#include "nsIRollupListener.h"
#include "nsIMenuRollup.h"
#include "nsGfxUtils.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsIObjectFrame.h"
#include "nsIPresShell.h"
#include "nsIEventStateManager.h"
#include "nsToolkit.h"

Go to the source code of this file.

Defines

#define topLeft(r)   (((Point *) &(r))[0])
#define botRight(r)   (((Point *) &(r))[1])
#define UNICODE_BUFFER_SIZE_FOR_KEY   5

Enumerations

enum  {
  kEscapeKeyCode = 0x35, kCommandKeyCode = 0x37, kShiftKeyCode = 0x38, kCapsLockKeyCode = 0x39,
  kControlKeyCode = 0x3B, kOptionkeyCode = 0x3A, kClearKeyCode = 0x47, kF1KeyCode = 0x7A,
  kF2KeyCode = 0x78, kF3KeyCode = 0x63, kF4KeyCode = 0x76, kF5KeyCode = 0x60,
  kF6KeyCode = 0x61, kF7KeyCode = 0x62, kF8KeyCode = 0x64, kF9KeyCode = 0x65,
  kF10KeyCode = 0x6D, kF11KeyCode = 0x67, kF12KeyCode = 0x6F, kF13KeyCode = 0x69,
  kF14KeyCode = 0x6B, kF15KeyCode = 0x71, kPrintScreenKeyCode = kF13KeyCode, kScrollLockKeyCode = kF14KeyCode,
  kPauseKeyCode = kF15KeyCode, kKeypad0KeyCode = 0x52, kKeypad1KeyCode = 0x53, kKeypad2KeyCode = 0x54,
  kKeypad3KeyCode = 0x55, kKeypad4KeyCode = 0x56, kKeypad5KeyCode = 0x57, kKeypad6KeyCode = 0x58,
  kKeypad7KeyCode = 0x59, kKeypad8KeyCode = 0x5B, kKeypad9KeyCode = 0x5C, kKeypadMultiplyKeyCode = 0x43,
  kKeypadAddKeyCode = 0x45, kKeypadSubtractKeyCode = 0x4E, kKeypadDecimalKeyCode = 0x41, kKeypadDivideKeyCode = 0x4B,
  kKeypadEqualsKeyCode = 0x51, kEnterKeyCode = 0x4C, kReturnKeyCode = 0x24, kPowerbookEnterKeyCode = 0x34,
  kHelpKeyCode = 0x72, kDeleteKeyCode = 0x75, kTabKeyCode = 0x30, kBackspaceKeyCode = 0x33,
  kHomeKeyCode = 0x73, kEndKeyCode = 0x77, kPageUpKeyCode = 0x74, kPageDownKeyCode = 0x79,
  kLeftArrowKeyCode = 0x7B, kRightArrowKeyCode = 0x7C, kUpArrowKeyCode = 0x7E, kDownArrowKeyCode = 0x7D
}

Functions

static void ConvertKeyEventToContextMenuEvent (const nsKeyEvent *inKeyEvent, nsMouseEvent *outCMEvent)
static PRBool IsContextMenuKey (const nsKeyEvent &inKeyEvent)
static PRUint32 ConvertMacToRaptorKeyCode (char charCode, UInt32 keyCode, UInt32 eventModifiers)

Variables

static nsMacEventHandlersLastActive
nsIRollupListenergRollupListener
nsIWidgetgRollupWidget

Define Documentation

#define botRight (   r)    (((Point *) &(r))[1])

Definition at line 74 of file nsMacEventHandler.cpp.

#define topLeft (   r)    (((Point *) &(r))[0])

Definition at line 71 of file nsMacEventHandler.cpp.

Definition at line 982 of file nsMacEventHandler.cpp.


Enumeration Type Documentation

anonymous enum
Enumerator:
kEscapeKeyCode 
kCommandKeyCode 
kShiftKeyCode 
kCapsLockKeyCode 
kControlKeyCode 
kOptionkeyCode 
kClearKeyCode 
kF1KeyCode 
kF2KeyCode 
kF3KeyCode 
kF4KeyCode 
kF5KeyCode 
kF6KeyCode 
kF7KeyCode 
kF8KeyCode 
kF9KeyCode 
kF10KeyCode 
kF11KeyCode 
kF12KeyCode 
kF13KeyCode 
kF14KeyCode 
kF15KeyCode 
kPrintScreenKeyCode 
kScrollLockKeyCode 
kPauseKeyCode 
kKeypad0KeyCode 
kKeypad1KeyCode 
kKeypad2KeyCode 
kKeypad3KeyCode 
kKeypad4KeyCode 
kKeypad5KeyCode 
kKeypad6KeyCode 
kKeypad7KeyCode 
kKeypad8KeyCode 
kKeypad9KeyCode 
kKeypadMultiplyKeyCode 
kKeypadAddKeyCode 
kKeypadSubtractKeyCode 
kKeypadDecimalKeyCode 
kKeypadDivideKeyCode 
kKeypadEqualsKeyCode 
kEnterKeyCode 
kReturnKeyCode 
kPowerbookEnterKeyCode 
kHelpKeyCode 
kDeleteKeyCode 
kTabKeyCode 
kBackspaceKeyCode 
kHomeKeyCode 
kEndKeyCode 
kPageUpKeyCode 
kPageDownKeyCode 
kLeftArrowKeyCode 
kRightArrowKeyCode 
kUpArrowKeyCode 
kDownArrowKeyCode 

Definition at line 634 of file nsMacEventHandler.cpp.

{
       kEscapeKeyCode                     = 0x35,
       kCommandKeyCode     = 0x37,
       kShiftKeyCode                      = 0x38,
       kCapsLockKeyCode            = 0x39,
       kControlKeyCode                    = 0x3B,
       kOptionkeyCode                     = 0x3A,              // left and right option keys
       kClearKeyCode                      = 0x47,
       
       // function keys
       kF1KeyCode                                = 0x7A,
       kF2KeyCode                                = 0x78,
       kF3KeyCode                                = 0x63,
       kF4KeyCode                                = 0x76,
       kF5KeyCode                                = 0x60,
       kF6KeyCode                                = 0x61,
       kF7KeyCode                                = 0x62,
       kF8KeyCode                                = 0x64,
       kF9KeyCode                                = 0x65,
       kF10KeyCode                               = 0x6D,
       kF11KeyCode                               = 0x67,
       kF12KeyCode                               = 0x6F,
       kF13KeyCode                               = 0x69,
       kF14KeyCode                               = 0x6B,
       kF15KeyCode                               = 0x71,
       
       kPrintScreenKeyCode  = kF13KeyCode,
       kScrollLockKeyCode   = kF14KeyCode,
       kPauseKeyCode                      = kF15KeyCode,
       
       // keypad
       kKeypad0KeyCode                    = 0x52,
       kKeypad1KeyCode                    = 0x53,
       kKeypad2KeyCode                    = 0x54,
       kKeypad3KeyCode                    = 0x55,
       kKeypad4KeyCode                    = 0x56,
       kKeypad5KeyCode                    = 0x57,
       kKeypad6KeyCode                    = 0x58,
       kKeypad7KeyCode                    = 0x59,
       kKeypad8KeyCode                    = 0x5B,
       kKeypad9KeyCode                    = 0x5C,
       
       kKeypadMultiplyKeyCode      = 0x43,
       kKeypadAddKeyCode                         = 0x45,
       kKeypadSubtractKeyCode      = 0x4E,
       kKeypadDecimalKeyCode              = 0x41,
       kKeypadDivideKeyCode        = 0x4B,
       kKeypadEqualsKeyCode        = 0x51,                     // no correpsonding raptor key code
       kEnterKeyCode           = 0x4C,
       kReturnKeyCode          = 0x24,
       kPowerbookEnterKeyCode  = 0x34,     // Enter on Powerbook's keyboard is different
       
       kHelpKeyCode                                     = 0x72,                            // also insert key
       kDeleteKeyCode                                   = 0x75,                            // also forward delete key
       kTabKeyCode                                             = 0x30,
       kBackspaceKeyCode       = 0x33,
       kHomeKeyCode                                     = 0x73,       
       kEndKeyCode                                             = 0x77,
       kPageUpKeyCode                                   = 0x74,
       kPageDownKeyCode                          = 0x79,
       kLeftArrowKeyCode                         = 0x7B,
       kRightArrowKeyCode                 = 0x7C,
       kUpArrowKeyCode                                  = 0x7E,
       kDownArrowKeyCode                         = 0x7D
       
};

Function Documentation

static void ConvertKeyEventToContextMenuEvent ( const nsKeyEvent inKeyEvent,
nsMouseEvent outCMEvent 
) [static]

Definition at line 1055 of file nsMacEventHandler.cpp.

{
  *(nsInputEvent*)outCMEvent = *(nsInputEvent*)inKeyEvent;
  
  outCMEvent->eventStructType = NS_MOUSE_EVENT;
  outCMEvent->message = NS_CONTEXTMENU_KEY;
  outCMEvent->isShift = outCMEvent->isControl = outCMEvent->isAlt = outCMEvent->isMeta = PR_FALSE;
  
  outCMEvent->clickCount = 0;
  outCMEvent->acceptActivation = PR_FALSE;
}

Here is the caller graph for this function:

static PRUint32 ConvertMacToRaptorKeyCode ( char  charCode,
UInt32  keyCode,
UInt32  eventModifiers 
) [static]

Definition at line 702 of file nsMacEventHandler.cpp.

{
       PRUint32      raptorKeyCode = 0;
       
       switch (keyCode)
       {
//  case ??            :       raptorKeyCode = nsIDOMKeyEvent::DOM_VK_CANCEL;    break;     // don't know what this key means. Nor does joki

// modifiers. We don't get separate events for these
    case kShiftKeyCode:         raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SHIFT;         break;
    case kCommandKeyCode:       raptorKeyCode = nsIDOMKeyEvent::DOM_VK_META;          break;
    case kCapsLockKeyCode:      raptorKeyCode = nsIDOMKeyEvent::DOM_VK_CAPS_LOCK;     break;
    case kControlKeyCode:       raptorKeyCode = nsIDOMKeyEvent::DOM_VK_CONTROL;       break;
    case kOptionkeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_ALT;           break;

// function keys
    case kF1KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F1;            break;
    case kF2KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F2;            break;
    case kF3KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F3;            break;
    case kF4KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F4;            break;
    case kF5KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F5;            break;
    case kF6KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F6;            break;
    case kF7KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F7;            break;
    case kF8KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F8;            break;
    case kF9KeyCode:            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F9;            break;
    case kF10KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F10;           break;
    case kF11KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F11;           break;
    case kF12KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F12;           break;
//  case kF13KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F13;           break;    // clash with the 3 below
//  case kF14KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F14;           break;
//  case kF15KeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_F15;           break;
    case kPauseKeyCode:         raptorKeyCode = nsIDOMKeyEvent::DOM_VK_PAUSE;         break;
    case kScrollLockKeyCode:    raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK;   break;
    case kPrintScreenKeyCode:   raptorKeyCode = nsIDOMKeyEvent::DOM_VK_PRINTSCREEN;   break;

// keypad
    case kKeypad0KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD0;      break;
    case kKeypad1KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD1;      break;
    case kKeypad2KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD2;      break;
    case kKeypad3KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD3;      break;
    case kKeypad4KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD4;      break;
    case kKeypad5KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD5;      break;
    case kKeypad6KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD6;      break;
    case kKeypad7KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD7;      break;
    case kKeypad8KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD8;      break;
    case kKeypad9KeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_NUMPAD9;      break;

    case kKeypadMultiplyKeyCode: raptorKeyCode = nsIDOMKeyEvent::DOM_VK_MULTIPLY;     break;
    case kKeypadAddKeyCode:      raptorKeyCode = nsIDOMKeyEvent::DOM_VK_ADD;          break;
    case kKeypadSubtractKeyCode: raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SUBTRACT;     break;
    case kKeypadDecimalKeyCode:  raptorKeyCode = nsIDOMKeyEvent::DOM_VK_DECIMAL;      break;
    case kKeypadDivideKeyCode:   raptorKeyCode = nsIDOMKeyEvent::DOM_VK_DIVIDE;       break;
//  case ??             :        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SEPARATOR;    break;

// this may clash with vk_insert, but help key is more useful in mozilla
    case kHelpKeyCode:          raptorKeyCode = nsIDOMKeyEvent::DOM_VK_HELP;          break;
    case kDeleteKeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_DELETE;        break;
    case kEscapeKeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_ESCAPE;        break;
    case kClearKeyCode:         raptorKeyCode = nsIDOMKeyEvent::DOM_VK_CLEAR;         break;

    case kBackspaceKeyCode:     raptorKeyCode = nsIDOMKeyEvent::DOM_VK_BACK_SPACE;    break;
    case kTabKeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_TAB;           break;
    case kHomeKeyCode:          raptorKeyCode = nsIDOMKeyEvent::DOM_VK_HOME;          break;
    case kEndKeyCode:           raptorKeyCode = nsIDOMKeyEvent::DOM_VK_END;           break;
    case kPageUpKeyCode:        raptorKeyCode = nsIDOMKeyEvent::DOM_VK_PAGE_UP;       break;
    case kPageDownKeyCode:      raptorKeyCode = nsIDOMKeyEvent::DOM_VK_PAGE_DOWN;     break;
    case kLeftArrowKeyCode:     raptorKeyCode = nsIDOMKeyEvent::DOM_VK_LEFT;          break;
    case kRightArrowKeyCode:    raptorKeyCode = nsIDOMKeyEvent::DOM_VK_RIGHT;         break;
    case kUpArrowKeyCode:       raptorKeyCode = nsIDOMKeyEvent::DOM_VK_UP;            break;
    case kDownArrowKeyCode:     raptorKeyCode = nsIDOMKeyEvent::DOM_VK_DOWN;          break;

              default:
                            if ((eventModifiers & controlKey) != 0)
                              charCode += 64;
              
                            // if we haven't gotten the key code already, look at the char code
                            switch (charCode)
                            {
          case kReturnCharCode: raptorKeyCode = nsIDOMKeyEvent::DOM_VK_RETURN;       break;
          case kEnterCharCode:  raptorKeyCode = nsIDOMKeyEvent::DOM_VK_RETURN;       break;    // fix me!
          case ' ':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SPACE;        break;
          case ';':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SEMICOLON;    break;
          case '=':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_EQUALS;       break;
          case ',':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_COMMA;        break;
          case '.':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_PERIOD;       break;
          case '/':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_SLASH;        break;
          case '`':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_BACK_QUOTE;   break;
          case '{':
          case '[':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_OPEN_BRACKET; break;
          case '\\':            raptorKeyCode = nsIDOMKeyEvent::DOM_VK_BACK_SLASH;   break;
          case '}':
          case ']':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_CLOSE_BRACKET; break;
          case '\'':
          case '"':             raptorKeyCode = nsIDOMKeyEvent::DOM_VK_QUOTE;        break;

                                   default:
                                          
                                          if (charCode >= '0' && charCode <= '9')          // numerals
                                          {
                                                 raptorKeyCode = charCode;
                                          }
                                          else if (charCode >= 'a' && charCode <= 'z')            // lowercase
                                          {
                                                 raptorKeyCode = toupper(charCode);
                                          }
                                          else if (charCode >= 'A' && charCode <= 'Z')            // uppercase
                                          {
                                                 raptorKeyCode = charCode;
                                          }

                                          break;
                            }
       }

       return raptorKeyCode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool IsContextMenuKey ( const nsKeyEvent inKeyEvent) [inline, static]

Definition at line 1075 of file nsMacEventHandler.cpp.

{
  enum { kContextMenuKey = ' ' } ;

  return ( inKeyEvent.charCode == kContextMenuKey && inKeyEvent.isControl &&
            !inKeyEvent.isShift && !inKeyEvent.isMeta && !inKeyEvent.isAlt );
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 137 of file nsChildView.mm.

Definition at line 138 of file nsChildView.mm.

Definition at line 62 of file nsMacEventHandler.cpp.