Merge branch 'gtk-launch-keys'

Generate events for GDK_KEY_LaunchX keys too in wxGTK.

See https://github.com/wxWidgets/wxWidgets/pull/2575
This commit is contained in:
Vadim Zeitlin 2021-11-05 13:51:40 +01:00
commit de3d95a7b3
4 changed files with 103 additions and 21 deletions

View File

@ -2433,8 +2433,30 @@ enum wxKeyCode
WXK_MEDIA_STOP,
WXK_MEDIA_PLAY_PAUSE,
WXK_LAUNCH_MAIL,
WXK_LAUNCH_APP1,
WXK_LAUNCH_APP2
// Events for these keys are currently only generated by wxGTK, with the
// exception of WXK_LAUNCH_{A,B}, see WXK_LAUNCH_APP{1,2} below.
WXK_LAUNCH_0,
WXK_LAUNCH_1,
WXK_LAUNCH_2,
WXK_LAUNCH_3,
WXK_LAUNCH_4,
WXK_LAUNCH_5,
WXK_LAUNCH_6,
WXK_LAUNCH_7,
WXK_LAUNCH_8,
WXK_LAUNCH_9,
WXK_LAUNCH_A,
WXK_LAUNCH_B,
WXK_LAUNCH_C,
WXK_LAUNCH_D,
WXK_LAUNCH_E,
WXK_LAUNCH_F,
// These constants are the same as the corresponding GTK keys, so give them
// the same value, but they are also generated by wxMSW.
WXK_LAUNCH_APP1 = WXK_LAUNCH_A,
WXK_LAUNCH_APP2 = WXK_LAUNCH_B
};
/* This enum contains bit mask constants used in wxKeyEvent */

View File

@ -1064,23 +1064,55 @@ enum wxKeyCode
WXK_SPECIAL19,
WXK_SPECIAL20,
WXK_BROWSER_BACK = 501,
WXK_BROWSER_FORWARD,
WXK_BROWSER_REFRESH,
WXK_BROWSER_STOP,
WXK_BROWSER_SEARCH,
WXK_BROWSER_FAVORITES,
WXK_BROWSER_HOME,
WXK_VOLUME_MUTE,
WXK_VOLUME_DOWN,
WXK_VOLUME_UP,
WXK_MEDIA_NEXT_TRACK,
WXK_MEDIA_PREV_TRACK,
WXK_MEDIA_STOP,
WXK_MEDIA_PLAY_PAUSE,
WXK_LAUNCH_MAIL,
WXK_BROWSER_BACK = 501, ///< Since wxWidgets 3.1.0
WXK_BROWSER_FORWARD, ///< Since wxWidgets 3.1.0
WXK_BROWSER_REFRESH, ///< Since wxWidgets 3.1.0
WXK_BROWSER_STOP, ///< Since wxWidgets 3.1.0
WXK_BROWSER_SEARCH, ///< Since wxWidgets 3.1.0
WXK_BROWSER_FAVORITES, ///< Since wxWidgets 3.1.0
WXK_BROWSER_HOME, ///< Since wxWidgets 3.1.0
WXK_VOLUME_MUTE, ///< Since wxWidgets 3.1.0
WXK_VOLUME_DOWN, ///< Since wxWidgets 3.1.0
WXK_VOLUME_UP, ///< Since wxWidgets 3.1.0
WXK_MEDIA_NEXT_TRACK, ///< Since wxWidgets 3.1.0
WXK_MEDIA_PREV_TRACK, ///< Since wxWidgets 3.1.0
WXK_MEDIA_STOP, ///< Since wxWidgets 3.1.0
WXK_MEDIA_PLAY_PAUSE, ///< Since wxWidgets 3.1.0
WXK_LAUNCH_MAIL, ///< Since wxWidgets 3.1.0
/**
First application launch key.
Note that this constant has the same value as WXK_LAUNCH_A.
@since 3.1.0
*/
WXK_LAUNCH_APP1,
WXK_LAUNCH_APP2
/**
Second application launch key.
Note that this constant has the same value as WXK_LAUNCH_B.
@since 3.1.0
*/
WXK_LAUNCH_APP2,
WXK_LAUNCH_0, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_1, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_2, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_3, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_4, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_5, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_6, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_7, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_8, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_9, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_A, ///< Available since wxWidgets 3.1.6, generated by wxGTK and wxMSW.
WXK_LAUNCH_B, ///< Available since wxWidgets 3.1.6, generated by wxGTK and wxMSW.
WXK_LAUNCH_C, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_D, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_E, ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
WXK_LAUNCH_F ///< Available since wxWidgets 3.1.6 and only generated by wxGTK.
};
/**

View File

@ -493,6 +493,21 @@ const char* GetVirtualKeyCodeName(int keycode)
WXK_(LAUNCH_MAIL)
WXK_(LAUNCH_APP1)
WXK_(LAUNCH_APP2)
WXK_(LAUNCH_0)
WXK_(LAUNCH_1)
WXK_(LAUNCH_2)
WXK_(LAUNCH_3)
WXK_(LAUNCH_4)
WXK_(LAUNCH_5)
WXK_(LAUNCH_6)
WXK_(LAUNCH_7)
WXK_(LAUNCH_8)
WXK_(LAUNCH_9)
// skip A/B which are duplicate cases of APP1/2
WXK_(LAUNCH_C)
WXK_(LAUNCH_D)
WXK_(LAUNCH_E)
WXK_(LAUNCH_F)
#undef WXK_
default:

View File

@ -870,11 +870,24 @@ static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar)
case GDK_KEY_Mail:
key_code = WXK_LAUNCH_MAIL;
break;
case GDK_KEY_Launch0:
case GDK_KEY_Launch1:
case GDK_KEY_Launch2:
case GDK_KEY_Launch3:
case GDK_KEY_Launch4:
case GDK_KEY_Launch5:
case GDK_KEY_Launch6:
case GDK_KEY_Launch7:
case GDK_KEY_Launch8:
case GDK_KEY_Launch9:
case GDK_KEY_LaunchA:
key_code = WXK_LAUNCH_APP1;
break;
case GDK_KEY_LaunchB:
key_code = WXK_LAUNCH_APP2;
case GDK_KEY_LaunchC:
case GDK_KEY_LaunchD:
case GDK_KEY_LaunchE:
case GDK_KEY_LaunchF:
key_code = WXK_LAUNCH_0 + (keysym - GDK_KEY_Launch0);
break;
#endif // GTK_CHECK_VERSION(2,18,0)