summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_get_key_mac.cxx8
-rw-r--r--src/Fl_mac.cxx98
2 files changed, 53 insertions, 53 deletions
diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx
index f92bf921c..d992a2554 100644
--- a/src/Fl_get_key_mac.cxx
+++ b/src/Fl_get_key_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_get_key_mac.cxx,v 1.1.2.8 2004/04/11 04:38:59 easysw Exp $"
+// "$Id: Fl_get_key_mac.cxx,v 1.1.2.9 2004/06/19 01:50:31 matthiaswm Exp $"
//
// MacOS keyboard state routines for the Fast Light Tool Kit (FLTK).
//
@@ -51,7 +51,7 @@ static const struct {unsigned short vk, fltk;} vktab[] = {
{ 107, FL_Scroll_Lock }, { 53, FL_Escape }, { 0x73, FL_Home }, { 123, FL_Left },
{ 126, FL_Up }, { 124, FL_Right }, { 125, FL_Down }, { 0x74, FL_Page_Up },
{ 0x79, FL_Page_Down }, { 119, FL_End }, { 0x71, FL_Print }, { 127, FL_Insert },
- { 127, FL_Menu }, { 114, FL_Help }, { 0x47, FL_Num_Lock },
+ { 0x6e, FL_Menu }, { 114, FL_Help }, { 0x47, FL_Num_Lock },
{ 76, FL_KP_Enter }, { 67, FL_KP+'*' }, { 69, FL_KP+'+'}, { 78, FL_KP+'-' }, { 65, FL_KP+'.' }, { 75, FL_KP+'/' },
{ 82, FL_KP+'0' }, { 83, FL_KP+'1' }, { 84, FL_KP+'2' }, { 85, FL_KP+'3' },
{ 86, FL_KP+'4' }, { 87, FL_KP+'5' }, { 88, FL_KP+'6' }, { 89, FL_KP+'7' },
@@ -61,7 +61,7 @@ static const struct {unsigned short vk, fltk;} vktab[] = {
{ 0x65, FL_F+9 }, { 0x6D, FL_F+10 }, { 0x67, FL_F+11 }, { 0x6f, FL_F+12 },
{ 56, FL_Shift_L }, { 56, FL_Shift_R }, { 59, FL_Control_L }, { 59, FL_Control_R },
{ 57, FL_Caps_Lock }, { 55, FL_Meta_L }, { 55, FL_Meta_R },
- { 58, FL_Alt_L }, { 58, FL_Alt_R },
+ { 58, FL_Alt_L }, { 58, FL_Alt_R }, { 0x75, FL_Delete },
};
static int fltk2mac(int fltk) {
@@ -99,5 +99,5 @@ int Fl::get_key(int k) {
}
//
-// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.8 2004/04/11 04:38:59 easysw Exp $".
+// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.9 2004/06/19 01:50:31 matthiaswm Exp $".
//
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index b869b41cc..a0b1a6746 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_mac.cxx,v 1.1.2.55 2004/06/01 01:08:50 easysw Exp $"
+// "$Id: Fl_mac.cxx,v 1.1.2.56 2004/06/19 01:50:31 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -131,7 +131,7 @@ static unsigned short macKeyLookUp[128] =
FL_KP+'6', FL_KP+'7', 0, FL_KP+'8', FL_KP+'9', 0, 0, 0,
FL_F+5, FL_F+6, FL_F+7, FL_F+3, FL_F+8, FL_F+9, 0, FL_F+11,
- 0, 0, FL_Print, FL_Scroll_Lock, 0, FL_F+10, 0, FL_F+12,
+ 0, 0, FL_Print, FL_Scroll_Lock, 0, FL_F+10, FL_Menu, FL_F+12,
0, FL_Pause, FL_Help, FL_Home, FL_Page_Up, FL_Delete, FL_F+4, FL_End,
FL_F+2, FL_Page_Down, FL_F+1, FL_Left, FL_Right, FL_Down, FL_Up, 0,
@@ -936,6 +936,7 @@ static void mods_to_e_keysym( UInt32 mods )
else if ( mods & rightShiftKey ) Fl::e_keysym = FL_Shift_R;
else if ( mods & alphaLock ) Fl::e_keysym = FL_Caps_Lock;
else Fl::e_keysym = 0;
+ //printf( "to sym 0x%08x (%04x)\n", Fl::e_keysym, mods );
}
/**
@@ -960,7 +961,8 @@ static unsigned short keycode_to_sym( UInt32 keyCode, UInt32 mods, unsigned shor
/**
* handle carbon keyboard events
*/
-pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef event, void *userData )
+pascal OSStatus carbonKeyboardHandler(
+ EventHandlerCallRef nextHandler, EventRef event, void *userData )
{
static char buffer[5];
int sendEvent = 0;
@@ -970,15 +972,35 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
fl_lock_function();
- GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
+ int kind = GetEventKind(event);
+
+ // get the modifiers for any of the events
+ GetEventParameter( event, kEventParamKeyModifiers, typeUInt32,
+ NULL, sizeof(UInt32), NULL, &mods );
if ( prevMods == 0xffffffff ) prevMods = mods;
- UInt32 keyCode;
- GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
- unsigned char key;
- GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &key );
- unsigned short sym;
-
- switch ( GetEventKind( event ) )
+
+ // get the key code only for key events
+ UInt32 keyCode = 0;
+ unsigned char key = 0;
+ unsigned short sym = 0;
+ if (kind!=kEventRawKeyModifiersChanged) {
+ GetEventParameter( event, kEventParamKeyCode, typeUInt32,
+ NULL, sizeof(UInt32), NULL, &keyCode );
+ GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar,
+ NULL, sizeof(char), NULL, &key );
+ }
+ /* output a human readbale event identifier for debugging
+ const char *ev = "";
+ switch (kind) {
+ case kEventRawKeyDown: ev = "kEventRawKeyDown"; break;
+ case kEventRawKeyRepeat: ev = "kEventRawKeyRepeat"; break;
+ case kEventRawKeyUp: ev = "kEventRawKeyUp"; break;
+ case kEventRawKeyModifiersChanged: ev = "kEventRawKeyModifiersChanged"; break;
+ default: ev = "unknown";
+ }
+ printf("%08x %08x %08x '%c' %s \n", mods, keyCode, key, key, ev);
+ */
+ switch (kind)
{
case kEventRawKeyDown:
case kEventRawKeyRepeat:
@@ -986,20 +1008,24 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
// fall through
case kEventRawKeyUp:
if ( !sendEvent ) sendEvent = FL_KEYUP;
- // if the user pressed alt/option, event_key should have the keycap, but event_text should generate the international symbol
+ // if the user pressed alt/option, event_key should have the keycap,
+ // but event_text should generate the international symbol
if ( isalpha(key) )
sym = tolower(key);
else if ( Fl::e_state&FL_CTRL && key<32 )
sym = key+96;
- else if ( Fl::e_state&FL_ALT )
- sym = keycode_to_sym( keyCode & 0x7f, 0, macKeyLookUp[ keyCode & 0x7f ] ); // find the keycap of this key
+ else if ( Fl::e_state&FL_ALT ) // find the keycap of this key
+ sym = keycode_to_sym( keyCode & 0x7f, 0, macKeyLookUp[ keyCode & 0x7f ] );
else
sym = macKeyLookUp[ keyCode & 0x7f ];
Fl::e_keysym = sym;
if ( keyCode==0x4c ) key=0x0d;
- if ((Fl::e_state & FL_NUM_LOCK) &&
- ((sym >= FL_KP && sym <= FL_KP_Last) || !(sym & 0xff00) ||
- sym == FL_Tab || sym == FL_Enter)) {
+ // Matt: the Mac has no concept of a NumLock key, or at least not visible
+ // Matt: to Carbon. The kEventKeyModifierNumLockMask is only set when
+ // Matt: a numeric keypad key is pressed and does not correspond with
+ // Matt: the NumLock light in PowerBook keyboards.
+ if ( (sym >= FL_KP && sym <= FL_KP_Last) || !(sym & 0xff00) ||
+ sym == FL_Tab || sym == FL_Enter) {
buffer[0] = key;
Fl::e_length = 1;
} else {
@@ -1025,13 +1051,14 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
}
while (window->parent()) window = window->window();
if (sendEvent && Fl::handle(sendEvent,window)) {
- fl_unlock_function();
-
+ fl_unlock_function();
return noErr; // return noErr if FLTK handled the event
} else {
fl_unlock_function();
-
- return CallNextEventHandler( nextHandler, event );;
+ //return CallNextEventHandler( nextHandler, event );;
+ // Matt: I had better results (no duplicate events) always returning
+ // Matt: 'noErr'. System keyboard events still seem to work just fine.
+ return noErr;
}
}
@@ -1322,33 +1349,6 @@ static int FSSpec2UnixPath( FSSpec *fs, char *dst )
FSpMakeFSRef( fs, &fsRef );
FSRefMakePath( &fsRef, (UInt8*)dst, 1024 );
return strlen(dst);
-/* keep the code below. The above function is only implemented in OS X, so we might need the other code for OS 9 and friends
- short offset = 0;
- if ( fs->parID != fsRtParID )
- {
- FSSpec parent;
- OSErr ret = FSMakeFSSpec( fs->vRefNum, fs->parID, 0, &parent );
- if ( ret != noErr ) return 0;
- offset = FSSpec2UnixPath( &parent, dst );
- }
-
- if ( fs->parID == fsRtParID && fs->vRefNum == -100 ) //+ bad hack: we assume that volume -100 is mounted as root
- {
- memcpy( dst, "/", 2 );
- return 1; // don't add anything to the filename - we are fine already
- }
-
- short len = fs->name[0];
- if ( fs->parID == fsRtParID ) { // assume tat all other volumes are in this directory (international name WILL vary!)
- memcpy( dst, "/Volumes", 8 );
- offset = 8;
- }
-
- if ( offset!=1 ) dst[ offset++ ] = '/'; // avoid double '/'
- memcpy( dst+offset, fs->name+1, len );
- dst[ len+offset ] = 0;
- return len+offset;
-*/
}
Fl_Window *fl_dnd_target_window = 0;
@@ -1922,6 +1922,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
//
-// End of "$Id: Fl_mac.cxx,v 1.1.2.55 2004/06/01 01:08:50 easysw Exp $".
+// End of "$Id: Fl_mac.cxx,v 1.1.2.56 2004/06/19 01:50:31 matthiaswm Exp $".
//