- MacOS: more keyboard handler fixes, mainly mapping of Mac specific

keys and iBook keys, several fixes to keyboard focus.

Happy Holidays!


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1894 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2001-12-22 07:16:12 +00:00
parent 1eb5acf22e
commit d0bdfe300d
9 changed files with 230 additions and 181 deletions
+4
View File
@@ -1,5 +1,9 @@
CHANGES IN FLTK 1.1.0b8
- MacOS: improved keyboard handling, fixed keyboard
focus handling, fixed get_key, modified 'keyboard'
demo to show second mouse wheel and additional keys
'help' and FL_NK+'='
- OS/2 build fixes.
- fl_draw() didn't ignore symbol escapes properly for
the browsers...
+3 -2
View File
@@ -1,5 +1,5 @@
//
// "$Id: Enumerations.H,v 1.18.2.14.2.16 2001/12/06 18:23:29 easysw Exp $"
// "$Id: Enumerations.H,v 1.18.2.14.2.17 2001/12/22 07:16:11 matthiaswm Exp $"
//
// Enumerations for the Fast Light Tool Kit (FLTK).
//
@@ -107,6 +107,7 @@ enum Fl_When { // Fl_Widget::when():
#define FL_Print 0xff61
#define FL_Insert 0xff63
#define FL_Menu 0xff67 // the "menu/apps" key on XFree86
#define FL_Help 0xff68 // the 'help' key on Mac keyboards
#define FL_Num_Lock 0xff7f
#define FL_KP 0xff80 // use FL_KP+'x' for 'x' on numeric keypad
#define FL_KP_Enter 0xff8d // same as Fl_KP+'\r'
@@ -372,5 +373,5 @@ enum Fl_Damage {
#endif
//
// End of "$Id: Enumerations.H,v 1.18.2.14.2.16 2001/12/06 18:23:29 easysw Exp $".
// End of "$Id: Enumerations.H,v 1.18.2.14.2.17 2001/12/22 07:16:11 matthiaswm Exp $".
//
+2 -4
View File
@@ -126,12 +126,10 @@ OTHER STUFF
used for FLTK applications ('FLTK') and FLUID files
('Flid').
All applications should call exit(0) to terminate; otherwise
they may hang until killed.
Under MacOS X, all windows are double-buffered. Using
Fl_Window has the same effect as using Fl_Double_Window on
other operating systems.
other operating systems. However Fl_Overlay_Window uses one
additional buffer for the overlay plane.
FLTK 1.0.X FOR MAC
+4 -4
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx,v 1.24.2.41.2.14 2001/12/18 11:00:09 matthiaswm Exp $"
// "$Id: Fl.cxx,v 1.24.2.41.2.15 2001/12/22 07:16:12 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -696,8 +696,8 @@ void Fl_Window::hide() {
fl_gc = 0;
}
#elif defined(__APPLE__)
//++ Matt: I have not checked yet what we need to do here
Fl::handle(FL_UNFOCUS, this);
if ( x->xid == fl_window )
fl_window = 0;
#else
if (x->region) XDestroyRegion(x->region);
#endif
@@ -851,5 +851,5 @@ void Fl_Window::flush() {
}
//
// End of "$Id: Fl.cxx,v 1.24.2.41.2.14 2001/12/18 11:00:09 matthiaswm Exp $".
// End of "$Id: Fl.cxx,v 1.24.2.41.2.15 2001/12/22 07:16:12 matthiaswm Exp $".
//
+6 -2
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.4 2001/11/17 17:00:22 easysw Exp $"
// "$Id: Fl_Input_.cxx,v 1.21.2.11.2.5 2001/12/22 07:16:12 matthiaswm Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -87,7 +87,11 @@ const char* Fl_Input_::expand(const char* p, char* buf) const {
*o++ = '^';
*o++ = c ^ 0x40;
}
#ifdef __APPLE__
} else if ( 0 ) { // this is a rather complex issue on MacOS: see glyphs vs. characters in font sets...
#else
} else if (c >= 128 && c < 0xA0) {
#endif
*o++ = '\\';
*o++ = (c>>6)+'0';
*o++ = ((c>>3)&7)+'0';
@@ -855,5 +859,5 @@ Fl_Input_::~Fl_Input_() {
}
//
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.4 2001/11/17 17:00:22 easysw Exp $".
// End of "$Id: Fl_Input_.cxx,v 1.21.2.11.2.5 2001/12/22 07:16:12 matthiaswm Exp $".
//
+7 -7
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_get_key_mac.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $"
// "$Id: Fl_get_key_mac.cxx,v 1.1.2.2 2001/12/22 07:16:12 matthiaswm Exp $"
//
// MacOS keyboard state routines for the Fast Light Tool Kit (FLTK).
//
@@ -47,11 +47,11 @@ static const struct {unsigned short vk, fltk;} vktab[] = {
{ 32, 'U' }, { 9, 'V' }, { 13, 'W' }, { 7, 'X' },
{ 16, 'Y' }, { 6, 'Z' },
{ 33, '[' }, { 30, ']' }, { 50, '`' }, { 42, '|' },
{ 51, FL_BackSpace }, { 48, FL_Tab }, { 36, FL_Enter }, { 0x72, FL_Pause },
{ 127, FL_Scroll_Lock }, { 53, FL_Escape }, { 0x73, FL_Home }, { 123, FL_Left },
{ 51, FL_BackSpace }, { 48, FL_Tab }, { 36, FL_Enter }, { 127, FL_Pause },
{ 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 }, { 127, FL_End }, { 0x71, FL_Print }, { 127, FL_Insert },
{ 127, FL_Menu }, { 0x47, FL_Num_Lock },
{ 0x79, FL_Page_Down }, { 119, FL_End }, { 0x71, FL_Print }, { 127, FL_Insert },
{ 127, 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 }, { 55, FL_Control_L }, { 55, FL_Control_R },
{ 57, FL_Caps_Lock }, { 59, FL_Meta_L }, { 59, FL_Meta_R },
{ 58, FL_Alt_L }, { 58, FL_Alt_R }, // Fl_Help = 0x72
{ 58, FL_Alt_L }, { 58, FL_Alt_R },
};
static int fltk2mac(int fltk) {
@@ -100,5 +100,5 @@ int Fl::get_key(int k) {
}
//
// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $".
// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.2 2001/12/22 07:16:12 matthiaswm Exp $".
//
+54 -33
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_mac.cxx,v 1.1.2.9 2001/12/20 22:02:25 matthiaswm Exp $"
// "$Id: Fl_mac.cxx,v 1.1.2.10 2001/12/22 07:16:12 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -65,6 +65,7 @@ static Fl_Window* resize_from_system;
Fl_Window* fl_find(Window);
int fl_handle(const EventRecord &event);
void handleUpdateEvent( WindowPtr xid );
extern void fl_fix_focus();
int fl_screen;
Handle fl_system_menu;
@@ -443,6 +444,8 @@ pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, EventRef e
Fl_Window *window = (Fl_Window*)userData;
Rect currentBounds, originalBounds;
WindowClass winClass;
static Fl_Window *activeWindow = 0;
switch ( kind )
{
@@ -465,16 +468,31 @@ pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, EventRef e
}
break; }
case kEventWindowShown:
// ;;;; printf("Show %s\n", window->label());
if ( !window->parent() ) Fl::handle( FL_SHOW, window);
break;
case kEventWindowHidden:
// ;;;; printf("Hide %s\n", window->label());
if ( !window->parent() ) Fl::handle( FL_HIDE, window);
break;
case kEventWindowActivated:
if ( !window->parent() ) Fl::handle(FL_FOCUS, window);
if ( window!=activeWindow )
{
GetWindowClass( fl_xid( window ), &winClass );
if ( winClass != kHelpWindowClass ) { // help windows can't get the focus!
Fl::handle( FL_FOCUS, window);
activeWindow = window;
// ;;;; printf("Activate %s\n", window->label());
}
}
break;
case kEventWindowDeactivated:
if ( !window->parent() ) Fl::handle(FL_UNFOCUS, window);
if ( window==activeWindow )
{
Fl::handle( FL_UNFOCUS, window);
activeWindow = 0;
// ;;;; printf("Deactivate %s\n", window->label());
}
break;
case kEventWindowClose:
Fl::handle( FL_CLOSE, window ); // this might or might not close the window
@@ -562,21 +580,27 @@ pascal OSStatus carbonMouseHandler( EventHandlerCallRef nextHandler, EventRef ev
case kEventMouseUp:
// ;;;; if ( !sendEvent ) printf("Carb-win-hdlr: mouse up (x:%d, y:d)\n", pos.h, pos.v );
if ( !window ) break;
if ( !sendEvent ) sendEvent = FL_RELEASE;
if ( !sendEvent ) {
sendEvent = FL_RELEASE;
}
Fl::e_keysym = keysym[ btn ];
// fall through
case kEventMouseMoved:
// ;;;; if ( !sendEvent ) printf("Carb-win-hdlr: mouse moved (x:%d, y:d)\n", pos.h, pos.v );
if ( !sendEvent ) { sendEvent = FL_MOVE; chord = 0; }
if ( !sendEvent ) {
sendEvent = FL_MOVE; chord = 0;
}
// fall through
case kEventMouseDragged:
// ;;;; if ( !sendEvent ) printf("Carb-win-hdlr: mouse dragged (x:%d, y:d)\n", pos.h, pos.v );
if ( !sendEvent ) {
sendEvent = FL_DRAG;
if (abs(pos.h-px)>5 || abs(pos.v-py)>5) Fl::e_is_click = 0;
if (abs(pos.h-px)>5 || abs(pos.v-py)>5)
Fl::e_is_click = 0;
}
chord_to_e_state( chord );
SetPort( GetWindowPort(xid) ); SetOrigin(0, 0);
SetPort( GetWindowPort(xid) ); //++ remove this! There must be some GlobalToLocal call that has a port as an argument
SetOrigin(0, 0);
Fl::e_x_root = pos.h;
Fl::e_y_root = pos.v;
GlobalToLocal( &pos );
@@ -610,7 +634,7 @@ static void mods_to_e_state( UInt32 mods )
static void mods_to_e_keysym( UInt32 mods )
{
if ( mods & cmdKey ) Fl::e_keysym = FL_Control_L;
//else if ( mods & kEventKeyModifierNumLockMask ) Fl::e_keysym = FL_Num_Lock;
else if ( mods & kEventKeyModifierNumLockMask ) Fl::e_keysym = FL_Num_Lock;
else if ( mods & optionKey ) Fl::e_keysym = FL_Alt_L;
else if ( mods & rightOptionKey ) Fl::e_keysym = FL_Alt_R;
else if ( mods & controlKey ) Fl::e_keysym = FL_Meta_L;
@@ -630,14 +654,15 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
int sendEvent = 0;
Fl_Window *window = (Fl_Window*)userData;
UInt32 mods;
static UInt32 prevMods = 0xdeadbeef;
static UInt32 prevMods = 0xffffffff;
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
if ( prevMods == 0xdeadbeef ) prevMods = mods;
if ( prevMods == 0xffffffff ) prevMods = mods;
UInt32 keyCode;
GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
char key;
unsigned char key;
GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &key );
// ;;;; printf( "kb: %08x %08x %02x %04x\n", mods, keyCode, key, GetEventKind( event ) );
unsigned short sym;
// ;;;; printf( "kb: %08x %08x %02x %04x %04x\n", mods, keyCode, key, GetEventKind( event ), macKeyLookUp[ keyCode & 0x7f ] );
switch ( GetEventKind( event ) )
{
case kEventRawKeyDown:
@@ -646,13 +671,12 @@ pascal OSStatus carbonKeyboardHandler( EventHandlerCallRef nextHandler, EventRef
// fall through
case kEventRawKeyUp:
if ( !sendEvent ) sendEvent = FL_KEYUP;
Fl::e_keysym = macKeyLookUp[ keyCode & 0x7f ];
if ( key=='\t' || key==27 || ( key>=32 && keyCode!=0x75 ) ) {
sym = macKeyLookUp[ keyCode & 0x7f ];
Fl::e_keysym = sym;
if ( keyCode==0x4c ) key=0x0d;
if ( ( (sym>=FL_KP) && (sym<=FL_KP_Last) ) || ((sym&0xff00)==0) || (sym==FL_Tab) ) {
buffer[0] = key;
Fl::e_length = 1;
} else if ( key==3 || key==0x0d ) {
buffer[0] = 0x0d;
Fl::e_length = 1;
} else {
buffer[0] = 0;
Fl::e_length = 0;
@@ -878,9 +902,9 @@ 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_F+13, FL_F+14, 0, FL_F+10, 0, FL_F+12,
0, 0, FL_Print, FL_Scroll_Lock, 0, FL_F+10, 0, FL_F+12,
0, FL_F+15, FL_Pause, FL_Home, FL_Page_Up, FL_Delete, FL_F+4, FL_End,
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,
};
@@ -1312,8 +1336,6 @@ void Fl_X::make(Fl_Window* w)
w->handle(FL_SHOW);
w->redraw(); // force draw to happen
fl_show_iconic = 0;
//++ hmmm, this should maybe set by the activate event?!
Fl::handle(FL_FOCUS, w);
//++ if (w->modal()) { Fl::modal_ = w; fl_fix_focus(); }
// ;;;; printf("Created subwindow %08x (%08x)\n", w, x->xid );
}
@@ -1350,9 +1372,9 @@ void Fl_X::make(Fl_Window* w)
}
int xwm = xp, ywm = yp, bt, bx, by;
if (!fake_X_wm(w, xwm, ywm, bt, bx, by))
{ winclass = kHelpWindowClass; winattr = 0; }
{ winclass = kHelpWindowClass; winattr = 0; } // menu windows and tooltips
else if (w->modal())
winclass = kFloatingWindowClass; // basically fine, but not modal! The modal window however does nor show
winclass = kFloatingWindowClass; // basically fine, but not modal! The modal window however does not show
else if (w->non_modal())
winclass = kFloatingWindowClass; // we need to call 'InitFloatingWindows for OS 8, 9
if (by+bt) {
@@ -1366,7 +1388,7 @@ void Fl_X::make(Fl_Window* w)
if (xyPos>200) xyPos = 24;
} else {
if (!Fl::grab()) {
xp = xwm; yp = ywm;
xp = xwm; yp = ywm;
w->x(xp);w->y(yp);
}
xp -= bx;
@@ -1448,17 +1470,16 @@ void Fl_X::make(Fl_Window* w)
if ( err==noErr ) SetFrontProcess( &psn );
// or 'BringToFront'
}
w->handle(FL_SHOW);
w->redraw(); // force draw to happen
//TransitionWindow( x->xid, kWindowZoomTransitionEffect, kWindowShowTransitionAction, 0 );
ShowWindow( x->xid );
w->handle(FL_SHOW);
w->redraw(); // force draw to happen
fl_show_iconic = 0;
//++ hmmm, this should maybe set by the activate event?!
Fl::handle(FL_FOCUS, w);
//++ if (w->modal()) { Fl::modal_ = w; fl_fix_focus(); }
w->set_visible();
if (w->modal()) { Fl::modal_ = w; fl_fix_focus(); }
//;;;; printf("Created top level window %08x (%08x)\n", w, x->xid );
}
}
@@ -1573,7 +1594,7 @@ void Fl_Window::make_current()
fl_window = i->xid;
current_ = this;
SetPort( GetWindowPort(i->xid) );
SetPort( GetWindowPort(i->xid) ); //++ this does not handle double buffered windows!
int xp = 0, yp = 0;
Fl_Window *win = this;
@@ -1693,6 +1714,6 @@ elapsedNanoseconds = AbsoluteToNanoseconds(elapsedTime);
//++ we MUST call aglConfigure(AGL_TARGET_OS_MAC_OSX, GL_TRUE);
//
// End of "$Id: Fl_mac.cxx,v 1.1.2.9 2001/12/20 22:02:25 matthiaswm Exp $".
// End of "$Id: Fl_mac.cxx,v 1.1.2.10 2001/12/22 07:16:12 matthiaswm Exp $".
//
+7 -5
View File
@@ -1,5 +1,5 @@
//
// "$Id: keyboard.cxx,v 1.5.2.3.2.2 2001/12/21 14:35:34 easysw Exp $"
// "$Id: keyboard.cxx,v 1.5.2.3.2.3 2001/12/22 07:16:12 matthiaswm Exp $"
//
// Keyboard/event test program for the Fast Light Tool Kit (FLTK).
//
@@ -54,7 +54,7 @@ public:
// these are used to identify which buttons are which:
void key_cb(Fl_Button*, void*) {}
void shift_cb(Fl_Button*, void*) {}
void wheel_cb(Fl_Button*, void*) {}
void wheel_cb(Fl_Dial*, void*) {}
// this is used to stop Esc from exiting the program:
int handle(int e) {
@@ -64,7 +64,8 @@ int handle(int e) {
int MyWindow::handle(int msg) {
if (msg==FL_MOUSEWHEEL)
{
roller->value( roller->value() + Fl::e_dy * roller->step() );
roller_x->value( roller_x->value() + Fl::e_dx * roller_x->step() );
roller_y->value( roller_y->value() + Fl::e_dy * roller_y->step() );
return 1;
}
return 0;
@@ -98,6 +99,7 @@ struct {int n; const char* text;} table[] = {
{FL_Meta_L, "FL_Meta_L"},
{FL_Meta_R, "FL_Meta_R"},
{FL_Menu, "FL_Menu"},
{FL_Help, "FL_Help"},
{FL_Num_Lock, "FL_Num_Lock"},
{FL_KP_Enter, "FL_KP_Enter"}
};
@@ -129,7 +131,7 @@ int main(int argc, char** argv) {
keyname = "0";
else if (k < 256) {
sprintf(buffer, "'%c'", k);
} else if (k >= FL_F && k <= FL_F_Last) {
} else if (k > FL_F && k <= FL_F_Last) {
sprintf(buffer, "FL_F+%d", k - FL_F);
} else if (k >= FL_KP && k <= FL_KP_Last) {
sprintf(buffer, "FL_KP+'%c'", k-FL_KP);
@@ -148,5 +150,5 @@ int main(int argc, char** argv) {
}
//
// End of "$Id: keyboard.cxx,v 1.5.2.3.2.2 2001/12/21 14:35:34 easysw Exp $".
// End of "$Id: keyboard.cxx,v 1.5.2.3.2.3 2001/12/22 07:16:12 matthiaswm Exp $".
//
+143 -124
View File
File diff suppressed because it is too large Load Diff