summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-11-28 14:38:38 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-11-28 14:38:38 +0000
commitb317b6dbb02dba7fbc35568508ac320f8695aaff (patch)
treeb38605ec0af151f0e5b608195eb22e6b4456b63e /src
parent129c8e39ecceea036ec1ae24f9464e5074d3289f (diff)
STR #1075: After all windows in an application were hidden by the Command-H shortcut, FLTK would not be notified about the Command key beeing released. To fix this , I update the mofier keys when a window is shown again. There may be better ways to do this, but it seems to be working reliably for the apps I tested.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4664 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_mac.cxx69
1 files changed, 34 insertions, 35 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index b5779e4f1..75d1481a6 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -145,7 +145,40 @@ static unsigned short macKeyLookUp[128] =
FL_F+2, FL_Page_Down, FL_F+1, FL_Left, FL_Right, FL_Down, FL_Up, 0,
};
+/**
+ * convert the current mouse chord into the FLTK modifier state
+ */
+static void mods_to_e_state( UInt32 mods )
+{
+ long state = 0;
+ if ( mods & kEventKeyModifierNumLockMask ) state |= FL_NUM_LOCK;
+ if ( mods & cmdKey ) state |= FL_META;
+ if ( mods & (optionKey|rightOptionKey) ) state |= FL_ALT;
+ if ( mods & (controlKey|rightControlKey) ) state |= FL_CTRL;
+ if ( mods & (shiftKey|rightShiftKey) ) state |= FL_SHIFT;
+ if ( mods & alphaLock ) state |= FL_CAPS_LOCK;
+ Fl::e_state = ( Fl::e_state & 0xff000000 ) | state;
+ //printf( "State 0x%08x (%04x)\n", Fl::e_state, mods );
+}
+
+/**
+ * convert the current mouse chord into the FLTK keysym
+ */
+static void mods_to_e_keysym( UInt32 mods )
+{
+ if ( mods & cmdKey ) Fl::e_keysym = FL_Meta_L;
+ 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_Control_L;
+ else if ( mods & rightControlKey ) Fl::e_keysym = FL_Control_R;
+ else if ( mods & shiftKey ) Fl::e_keysym = FL_Shift_L;
+ 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 );
+}
// these pointers are set by the Fl::lock() function:
static void nothing() {}
void (*fl_lock_function)() = nothing;
@@ -753,6 +786,7 @@ static pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, Eve
activeWindow = window;
}
Fl::handle( FL_SHOW, window);
+ mods_to_e_state(GetCurrentKeyModifiers());
}
break;
case kEventWindowHidden:
@@ -937,41 +971,6 @@ static pascal OSStatus carbonMouseHandler( EventHandlerCallRef nextHandler, Even
/**
- * convert the current mouse chord into the FLTK modifier state
- */
-static void mods_to_e_state( UInt32 mods )
-{
- long state = 0;
- if ( mods & kEventKeyModifierNumLockMask ) state |= FL_NUM_LOCK;
- if ( mods & cmdKey ) state |= FL_META;
- if ( mods & (optionKey|rightOptionKey) ) state |= FL_ALT;
- if ( mods & (controlKey|rightControlKey) ) state |= FL_CTRL;
- if ( mods & (shiftKey|rightShiftKey) ) state |= FL_SHIFT;
- if ( mods & alphaLock ) state |= FL_CAPS_LOCK;
- Fl::e_state = ( Fl::e_state & 0xff000000 ) | state;
- //printf( "State 0x%08x (%04x)\n", Fl::e_state, mods );
-}
-
-
-/**
- * convert the current mouse chord into the FLTK keysym
- */
-static void mods_to_e_keysym( UInt32 mods )
-{
- if ( mods & cmdKey ) Fl::e_keysym = FL_Meta_L;
- 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_Control_L;
- else if ( mods & rightControlKey ) Fl::e_keysym = FL_Control_R;
- else if ( mods & shiftKey ) Fl::e_keysym = FL_Shift_L;
- 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 );
-}
-
-/**
* convert the keyboard return code into the symbol on the keycaps
*/
static unsigned short keycode_to_sym( UInt32 keyCode, UInt32 mods, unsigned short deflt )