~ubuntu-branches/ubuntu/lucid/fltk1.1/lucid

« back to all changes in this revision

Viewing changes to src/Fl_mac.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2010-01-06 22:05:04 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100106220504-nwj8m1sa90s760yt
Tags: 1.1.10-2
* src/Makefile: link libfltk.so.1.1 against -lpthread, as fluid now
  otherwise fails to link on the Hurd (with complaints that libfltk.so.1
  contains undefined references to pthread_mutexattr_*).
* debian/source.lintian-overrides: retire per Lintian 2.3.1.  (See #553264.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_mac.cxx 6033 2008-02-20 18:17:34Z matt $"
 
2
// "$Id: Fl_mac.cxx 6800 2009-06-28 21:54:59Z matt $"
3
3
//
4
4
// MacOS specific code for the Fast Light Tool Kit (FLTK).
5
5
//
150
150
/**
151
151
 * convert the current mouse chord into the FLTK modifier state
152
152
 */
153
 
static void mods_to_e_state( UInt32 mods )
 
153
static unsigned int mods_to_e_state( UInt32 mods )
154
154
{
155
155
  long state = 0;
156
156
  if ( mods & kEventKeyModifierNumLockMask ) state |= FL_NUM_LOCK;
159
159
  if ( mods & (controlKey|rightControlKey) ) state |= FL_CTRL;
160
160
  if ( mods & (shiftKey|rightShiftKey) ) state |= FL_SHIFT;
161
161
  if ( mods & alphaLock ) state |= FL_CAPS_LOCK;
162
 
  Fl::e_state = ( Fl::e_state & 0xff000000 ) | state;
163
 
  //printf( "State 0x%08x (%04x)\n", Fl::e_state, mods );
 
162
  unsigned int ret = ( Fl::e_state & 0xff000000 ) | state;
 
163
  Fl::e_state = ret;
 
164
  //printf( "State 0x%08x (%04x)\n", ret, mods );
 
165
  return ret;
164
166
}
165
167
 
166
168
 
542
544
    switch (GetEventKind( event ) )
543
545
    {
544
546
      case kEventCommandProcess:
545
 
        GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd );
546
 
        ret = HandleMenu( &cmd );
 
547
        ret = GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd );
 
548
        if (ret == noErr && (cmd.attributes & kHICommandFromMenu) != 0) 
 
549
          ret = HandleMenu( &cmd );
 
550
        else 
 
551
          ret = eventNotHandledErr;
547
552
        break;
548
553
    }
549
554
    break;
1089
1094
  Fl_Window *window = (Fl_Window*)userData;
1090
1095
  Fl::first_window(window);
1091
1096
  UInt32 mods;
1092
 
  static UInt32 prevMods = 0xffffffff;
 
1097
  static UInt32 prevMods = mods_to_e_state( GetCurrentKeyModifiers() );
1093
1098
 
1094
1099
  fl_lock_function();
1095
1100
  
1098
1103
  // get the modifiers for any of the events
1099
1104
  GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, 
1100
1105
                     NULL, sizeof(UInt32), NULL, &mods );
1101
 
  if ( prevMods == 0xffffffff ) prevMods = mods;
1102
1106
  
1103
1107
  // get the key code only for key events
1104
 
  UInt32 keyCode = 0;
 
1108
  UInt32 keyCode = 0, maskedKeyCode = 0;
1105
1109
  unsigned char key = 0;
1106
1110
  unsigned short sym = 0;
1107
1111
  if (kind!=kEventRawKeyModifiersChanged) {
1110
1114
    GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, 
1111
1115
                       NULL, sizeof(char), NULL, &key );
1112
1116
  }
 
1117
  maskedKeyCode = keyCode & 0x7f;
1113
1118
  /* output a human readbale event identifier for debugging
1114
1119
  const char *ev = "";
1115
1120
  switch (kind) {
1148
1153
    }
1149
1154
    // if the user pressed alt/option, event_key should have the keycap, 
1150
1155
    // but event_text should generate the international symbol
 
1156
    sym = macKeyLookUp[ maskedKeyCode ];
1151
1157
    if ( isalpha(key) )
1152
1158
      sym = tolower(key);
1153
 
    else if ( Fl::e_state&FL_CTRL && key<32 )
 
1159
    else if ( Fl::e_state&FL_CTRL && key<32 && sym<0xff00)
1154
1160
      sym = key+96;
1155
 
    else if ( Fl::e_state&FL_ALT ) // find the keycap of this key
1156
 
      sym = keycode_to_sym( keyCode & 0x7f, 0, macKeyLookUp[ keyCode & 0x7f ] );
1157
 
    else
1158
 
      sym = macKeyLookUp[ keyCode & 0x7f ];
 
1161
    else if ( Fl::e_state&FL_ALT && sym<0xff00) // find the keycap of this key
 
1162
      sym = keycode_to_sym( maskedKeyCode, 0, macKeyLookUp[ maskedKeyCode ] );
1159
1163
    Fl::e_keysym = Fl::e_original_keysym = sym;
1160
1164
    // Handle FL_KP_Enter on regular keyboards and on Powerbooks
1161
 
    if ( keyCode==0x4c || keyCode==0x34) key=0x0d;
 
1165
    if ( maskedKeyCode==0x4c || maskedKeyCode==0x34) key=0x0d;
1162
1166
    // Matt: the Mac has no concept of a NumLock key, or at least not visible
1163
1167
    // Matt: to Carbon. The kEventKeyModifierNumLockMask is only set when
1164
1168
    // Matt: a numeric keypad key is pressed and does not correspond with
2467
2471
}
2468
2472
 
2469
2473
//
2470
 
// End of "$Id: Fl_mac.cxx 6033 2008-02-20 18:17:34Z matt $".
 
2474
// End of "$Id: Fl_mac.cxx 6800 2009-06-28 21:54:59Z matt $".
2471
2475
//