summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2001-12-22 07:16:12 +0000
committerMatthias Melcher <fltk@matthiasm.com>2001-12-22 07:16:12 +0000
commitd0bdfe300dd636322dedfdc98b9edea2c5f06566 (patch)
tree38b843fb4c8d59b1ea4abb71a9603202deb4b3a3 /src
parent1eb5acf22eeacb783b950655314e142b4b5a89a6 (diff)
- 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
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx8
-rw-r--r--src/Fl_Input_.cxx8
-rw-r--r--src/Fl_get_key_mac.cxx14
-rw-r--r--src/Fl_mac.cxx87
4 files changed, 71 insertions, 46 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 9667e02b8..4c3dc6d9b 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -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 $".
//
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 09ded3191..b4ab77f48 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -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 $".
//
diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx
index 223459048..2939331b2 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.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 $".
//
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index 2b9742996..707961534 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -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 $".
//