45#define KEYCTXT "keyboard-key-name"
46static ModInfo g_rgModInfo[4] = {
56static bool g_bInitializedKKeyLabels;
57static bool g_bMacLabels;
59static void intializeKKeyLabels()
65 g_bMacLabels = (*g_rgModInfo[2].sLabel ==
QLatin1String(
"Command"));
66 g_bInitializedKKeyLabels =
true;
73static QString modToString(uint mod,
bool bUserSpace)
75 if (bUserSpace && !g_bInitializedKKeyLabels) {
76 intializeKKeyLabels();
80 for (
int i = 3; i >= 0; i--) {
81 if (mod & g_rgModInfo[i].modQt) {
85 s += (bUserSpace) ? *g_rgModInfo[i].sLabel :
QLatin1String(g_rgModInfo[i].psName);
93 return modToString(mod,
true);
98 for (
int i = 3; i >= 0; i--) {
100 return g_rgModInfo[i].modQt;
109 keyQt &=
~Qt::KeyboardModifierMask;
319 uint sym, symVariation;
338static X11ModInfo g_rgX11ModInfo[4] = {
340 {
Qt::CTRL, X11_ONLY(ControlMask) },
341 {
Qt::ALT, X11_ONLY(Mod1Mask) },
346static const TransKey g_rgQtToSymX[] = {
449#define XF86XK_ModeLock 0x1008ff01
452#define XF86XK_MonBrightnessUp 0x1008ff02
453#define XF86XK_MonBrightnessDown 0x1008ff03
454#define XF86XK_KbdLightOnOff 0x1008ff04
455#define XF86XK_KbdBrightnessUp 0x1008ff05
456#define XF86XK_KbdBrightnessDown 0x1008ff06
457#define XF86XK_MonBrightnessCycle 0x1008ff07
462#define XF86XK_Standby 0x1008ff10
463#define XF86XK_AudioLowerVolume 0x1008ff11
464#define XF86XK_AudioMute 0x1008ff12
465#define XF86XK_AudioRaiseVolume 0x1008ff13
466#define XF86XK_AudioPlay 0x1008ff14
467#define XF86XK_AudioStop 0x1008ff15
468#define XF86XK_AudioPrev 0x1008ff16
469#define XF86XK_AudioNext 0x1008ff17
470#define XF86XK_HomePage 0x1008ff18
471#define XF86XK_Mail 0x1008ff19
472#define XF86XK_Start 0x1008ff1a
473#define XF86XK_Search 0x1008ff1b
474#define XF86XK_AudioRecord 0x1008ff1c
477#define XF86XK_Calculator 0x1008ff1d
478#define XF86XK_Memo 0x1008ff1e
479#define XF86XK_ToDoList 0x1008ff1f
480#define XF86XK_Calendar 0x1008ff20
481#define XF86XK_PowerDown 0x1008ff21
482#define XF86XK_ContrastAdjust 0x1008ff22
483#define XF86XK_RockerUp 0x1008ff23
484#define XF86XK_RockerDown 0x1008ff24
485#define XF86XK_RockerEnter 0x1008ff25
488#define XF86XK_Back 0x1008ff26
489#define XF86XK_Forward 0x1008ff27
490#define XF86XK_Stop 0x1008ff28
491#define XF86XK_Refresh 0x1008ff29
492#define XF86XK_PowerOff 0x1008ff2a
493#define XF86XK_WakeUp 0x1008ff2b
494#define XF86XK_Eject 0x1008ff2c
495#define XF86XK_ScreenSaver 0x1008ff2d
496#define XF86XK_WWW 0x1008ff2e
497#define XF86XK_Sleep 0x1008ff2f
498#define XF86XK_Favorites 0x1008ff30
499#define XF86XK_AudioPause 0x1008ff31
500#define XF86XK_AudioMedia 0x1008ff32
501#define XF86XK_MyComputer 0x1008ff33
502#define XF86XK_VendorHome 0x1008ff34
503#define XF86XK_LightBulb 0x1008ff35
504#define XF86XK_Shop 0x1008ff36
505#define XF86XK_History 0x1008ff37
506#define XF86XK_OpenURL 0x1008ff38
507#define XF86XK_AddFavorite 0x1008ff39
508#define XF86XK_HotLinks 0x1008ff3a
509#define XF86XK_BrightnessAdjust 0x1008ff3b
510#define XF86XK_Finance 0x1008ff3c
511#define XF86XK_Community 0x1008ff3d
512#define XF86XK_AudioRewind 0x1008ff3e
513#define XF86XK_BackForward 0x1008ff3f
514#define XF86XK_Launch0 0x1008ff40
515#define XF86XK_Launch1 0x1008ff41
516#define XF86XK_Launch2 0x1008ff42
517#define XF86XK_Launch3 0x1008ff43
518#define XF86XK_Launch4 0x1008ff44
519#define XF86XK_Launch5 0x1008ff45
520#define XF86XK_Launch6 0x1008ff46
521#define XF86XK_Launch7 0x1008ff47
522#define XF86XK_Launch8 0x1008ff48
523#define XF86XK_Launch9 0x1008ff49
524#define XF86XK_LaunchA 0x1008ff4a
525#define XF86XK_LaunchB 0x1008ff4b
526#define XF86XK_LaunchC 0x1008ff4c
527#define XF86XK_LaunchD 0x1008ff4d
528#define XF86XK_LaunchE 0x1008ff4e
529#define XF86XK_LaunchF 0x1008ff4f
531#define XF86XK_ApplicationLeft 0x1008ff50
532#define XF86XK_ApplicationRight 0x1008ff51
533#define XF86XK_Book 0x1008ff52
534#define XF86XK_CD 0x1008ff53
535#define XF86XK_Calculater 0x1008ff54
536#define XF86XK_Clear 0x1008ff55
537#define XF86XK_Close 0x1008ff56
538#define XF86XK_Copy 0x1008ff57
539#define XF86XK_Cut 0x1008ff58
540#define XF86XK_Display 0x1008ff59
541#define XF86XK_DOS 0x1008ff5a
542#define XF86XK_Documents 0x1008ff5b
543#define XF86XK_Excel 0x1008ff5c
544#define XF86XK_Explorer 0x1008ff5d
545#define XF86XK_Game 0x1008ff5e
546#define XF86XK_Go 0x1008ff5f
547#define XF86XK_iTouch 0x1008ff60
548#define XF86XK_LogOff 0x1008ff61
549#define XF86XK_Market 0x1008ff62
550#define XF86XK_Meeting 0x1008ff63
551#define XF86XK_MenuKB 0x1008ff65
552#define XF86XK_MenuPB 0x1008ff66
553#define XF86XK_MySites 0x1008ff67
554#define XF86XK_New 0x1008ff68
555#define XF86XK_News 0x1008ff69
556#define XF86XK_OfficeHome 0x1008ff6a
557#define XF86XK_Open 0x1008ff6b
558#define XF86XK_Option 0x1008ff6c
559#define XF86XK_Paste 0x1008ff6d
560#define XF86XK_Phone 0x1008ff6e
561#define XF86XK_Q 0x1008ff70
562#define XF86XK_Reply 0x1008ff72
563#define XF86XK_Reload 0x1008ff73
564#define XF86XK_RotateWindows 0x1008ff74
565#define XF86XK_RotationPB 0x1008ff75
566#define XF86XK_RotationKB 0x1008ff76
567#define XF86XK_Save 0x1008ff77
568#define XF86XK_ScrollUp 0x1008ff78
569#define XF86XK_ScrollDown 0x1008ff79
570#define XF86XK_ScrollClick 0x1008ff7a
571#define XF86XK_Send 0x1008ff7b
572#define XF86XK_Spell 0x1008ff7c
573#define XF86XK_SplitScreen 0x1008ff7d
574#define XF86XK_Support 0x1008ff7e
575#define XF86XK_TaskPane 0x1008ff7f
576#define XF86XK_Terminal 0x1008ff80
577#define XF86XK_Tools 0x1008ff81
578#define XF86XK_Travel 0x1008ff82
579#define XF86XK_UserPB 0x1008ff84
580#define XF86XK_User1KB 0x1008ff85
581#define XF86XK_User2KB 0x1008ff86
582#define XF86XK_Video 0x1008ff87
583#define XF86XK_WheelButton 0x1008ff88
584#define XF86XK_Word 0x1008ff89
585#define XF86XK_Xfer 0x1008ff8a
586#define XF86XK_ZoomIn 0x1008ff8b
587#define XF86XK_ZoomOut 0x1008ff8c
589#define XF86XK_Away 0x1008ff8d
590#define XF86XK_Messenger 0x1008ff8e
591#define XF86XK_WebCam 0x1008ff8f
592#define XF86XK_MailForward 0x1008ff90
593#define XF86XK_Pictures 0x1008ff91
594#define XF86XK_Music 0x1008ff92
596#define XF86XK_Battery 0x1008ff93
597#define XF86XK_Bluetooth 0x1008ff94
598#define XF86XK_WLAN 0x1008ff95
599#define XF86XK_UWB 0x1008ff96
601#define XF86XK_AudioForward 0x1008ff97
602#define XF86XK_AudioRepeat 0x1008ff98
603#define XF86XK_AudioRandomPlay 0x1008ff99
604#define XF86XK_Subtitle 0x1008ff9a
605#define XF86XK_AudioCycleTrack 0x1008ff9b
606#define XF86XK_CycleAngle 0x1008ff9c
607#define XF86XK_FrameBack 0x1008ff9d
608#define XF86XK_FrameForward 0x1008ff9e
609#define XF86XK_Time 0x1008ff9f
610#define XF86XK_Select 0x1008ffa0
611#define XF86XK_View 0x1008ffa1
612#define XF86XK_TopMenu 0x1008ffa2
614#define XF86XK_Red 0x1008ffa3
615#define XF86XK_Green 0x1008ffa4
616#define XF86XK_Yellow 0x1008ffa5
617#define XF86XK_Blue 0x1008ffa6
619#define XF86XK_Suspend 0x1008ffa7
620#define XF86XK_Hibernate 0x1008ffa8
621#define XF86XK_TouchpadToggle 0x1008ffa9
622#define XF86XK_TouchpadOn 0x1008ffb0
623#define XF86XK_TouchpadOff 0x1008ffb1
625#define XF86XK_AudioMicMute 0x1008ffb2
627#define XF86XK_Keyboard 0x1008ffb3
629#define XF86XK_WWAN 0x1008ffb4
630#define XF86XK_RFKill 0x1008ffb5
632#define XF86XK_AudioPreset 0x1008ffb6
634#define XF86XK_RotationLockToggle 0x1008ffb7
636#define XF86XK_FullScreen 0x1008ffb8
640#define XF86XK_Switch_VT_1 0x1008fe01
641#define XF86XK_Switch_VT_2 0x1008fe02
642#define XF86XK_Switch_VT_3 0x1008fe03
643#define XF86XK_Switch_VT_4 0x1008fe04
644#define XF86XK_Switch_VT_5 0x1008fe05
645#define XF86XK_Switch_VT_6 0x1008fe06
646#define XF86XK_Switch_VT_7 0x1008fe07
647#define XF86XK_Switch_VT_8 0x1008fe08
648#define XF86XK_Switch_VT_9 0x1008fe09
649#define XF86XK_Switch_VT_10 0x1008fe0a
650#define XF86XK_Switch_VT_11 0x1008fe0b
651#define XF86XK_Switch_VT_12 0x1008fe0c
653#define XF86XK_Ungrab 0x1008fe20
654#define XF86XK_ClearGrab 0x1008fe21
655#define XF86XK_Next_VMode 0x1008fe22
656#define XF86XK_Prev_VMode 0x1008fe23
657#define XF86XK_LogWindowTree 0x1008fe24
658#define XF86XK_LogGrabInfo 0x1008fe25
697#define _EVDEVK(_v) (0x10081000 + _v)
719#define XF86XK_BrightnessAuto _EVDEVK(0x0f4)
720#define XF86XK_DisplayOff _EVDEVK(0x0f5)
724#define XF86XK_Info _EVDEVK(0x166)
727#define XF86XK_AspectRatio _EVDEVK(0x177)
728#define XF86XK_DVD _EVDEVK(0x185)
729#define XF86XK_Audio _EVDEVK(0x188)
732#define XF86XK_ChannelUp _EVDEVK(0x192)
733#define XF86XK_ChannelDown _EVDEVK(0x193)
735#define XF86XK_Break _EVDEVK(0x19b)
736#define XF86XK_VideoPhone _EVDEVK(0x1a0)
740#define XF86XK_ZoomReset _EVDEVK(0x1a4)
742#define XF86XK_Editor _EVDEVK(0x1a6)
744#define XF86XK_GraphicsEditor _EVDEVK(0x1a8)
745#define XF86XK_Presentation _EVDEVK(0x1a9)
746#define XF86XK_Database _EVDEVK(0x1aa)
748#define XF86XK_Voicemail _EVDEVK(0x1ac)
749#define XF86XK_Addressbook _EVDEVK(0x1ad)
751#define XF86XK_DisplayToggle _EVDEVK(0x1af)
752#define XF86XK_SpellCheck _EVDEVK(0x1b0)
758#define XF86XK_ContextMenu _EVDEVK(0x1b6)
759#define XF86XK_MediaRepeat _EVDEVK(0x1b7)
760#define XF86XK_10ChannelsUp _EVDEVK(0x1b8)
761#define XF86XK_10ChannelsDown _EVDEVK(0x1b9)
762#define XF86XK_Images _EVDEVK(0x1ba)
763#define XF86XK_NotificationCenter _EVDEVK(0x1bc)
764#define XF86XK_PickupPhone _EVDEVK(0x1bd)
765#define XF86XK_HangupPhone _EVDEVK(0x1be)
766#define XF86XK_Fn _EVDEVK(0x1d0)
767#define XF86XK_Fn_Esc _EVDEVK(0x1d1)
768#define XF86XK_FnRightShift _EVDEVK(0x1e5)
779#define XF86XK_Numeric0 _EVDEVK(0x200)
780#define XF86XK_Numeric1 _EVDEVK(0x201)
781#define XF86XK_Numeric2 _EVDEVK(0x202)
782#define XF86XK_Numeric3 _EVDEVK(0x203)
783#define XF86XK_Numeric4 _EVDEVK(0x204)
784#define XF86XK_Numeric5 _EVDEVK(0x205)
785#define XF86XK_Numeric6 _EVDEVK(0x206)
786#define XF86XK_Numeric7 _EVDEVK(0x207)
787#define XF86XK_Numeric8 _EVDEVK(0x208)
788#define XF86XK_Numeric9 _EVDEVK(0x209)
789#define XF86XK_NumericStar _EVDEVK(0x20a)
790#define XF86XK_NumericPound _EVDEVK(0x20b)
791#define XF86XK_NumericA _EVDEVK(0x20c)
792#define XF86XK_NumericB _EVDEVK(0x20d)
793#define XF86XK_NumericC _EVDEVK(0x20e)
794#define XF86XK_NumericD _EVDEVK(0x20f)
795#define XF86XK_CameraFocus _EVDEVK(0x210)
796#define XF86XK_WPSButton _EVDEVK(0x211)
800#define XF86XK_CameraZoomIn _EVDEVK(0x215)
801#define XF86XK_CameraZoomOut _EVDEVK(0x216)
802#define XF86XK_CameraUp _EVDEVK(0x217)
803#define XF86XK_CameraDown _EVDEVK(0x218)
804#define XF86XK_CameraLeft _EVDEVK(0x219)
805#define XF86XK_CameraRight _EVDEVK(0x21a)
806#define XF86XK_AttendantOn _EVDEVK(0x21b)
807#define XF86XK_AttendantOff _EVDEVK(0x21c)
808#define XF86XK_AttendantToggle _EVDEVK(0x21d)
809#define XF86XK_LightsToggle _EVDEVK(0x21e)
810#define XF86XK_ALSToggle _EVDEVK(0x230)
812#define XF86XK_Buttonconfig _EVDEVK(0x240)
813#define XF86XK_Taskmanager _EVDEVK(0x241)
814#define XF86XK_Journal _EVDEVK(0x242)
815#define XF86XK_ControlPanel _EVDEVK(0x243)
816#define XF86XK_AppSelect _EVDEVK(0x244)
817#define XF86XK_Screensaver _EVDEVK(0x245)
818#define XF86XK_VoiceCommand _EVDEVK(0x246)
819#define XF86XK_Assistant _EVDEVK(0x247)
821#define XF86XK_EmojiPicker _EVDEVK(0x249)
822#define XF86XK_Dictate _EVDEVK(0x24a)
823#define XF86XK_CameraAccessEnable _EVDEVK(0x24b)
824#define XF86XK_CameraAccessDisable _EVDEVK(0x24c)
825#define XF86XK_CameraAccessToggle _EVDEVK(0x24d)
826#define XF86XK_BrightnessMin _EVDEVK(0x250)
827#define XF86XK_BrightnessMax _EVDEVK(0x251)
828#define XF86XK_KbdInputAssistPrev _EVDEVK(0x260)
829#define XF86XK_KbdInputAssistNext _EVDEVK(0x261)
830#define XF86XK_KbdInputAssistPrevgroup _EVDEVK(0x262)
831#define XF86XK_KbdInputAssistNextgroup _EVDEVK(0x263)
832#define XF86XK_KbdInputAssistAccept _EVDEVK(0x264)
833#define XF86XK_KbdInputAssistCancel _EVDEVK(0x265)
834#define XF86XK_RightUp _EVDEVK(0x266)
835#define XF86XK_RightDown _EVDEVK(0x267)
836#define XF86XK_LeftUp _EVDEVK(0x268)
837#define XF86XK_LeftDown _EVDEVK(0x269)
838#define XF86XK_RootMenu _EVDEVK(0x26a)
839#define XF86XK_MediaTopMenu _EVDEVK(0x26b)
840#define XF86XK_Numeric11 _EVDEVK(0x26c)
841#define XF86XK_Numeric12 _EVDEVK(0x26d)
842#define XF86XK_AudioDesc _EVDEVK(0x26e)
843#define XF86XK_3DMode _EVDEVK(0x26f)
844#define XF86XK_NextFavorite _EVDEVK(0x270)
845#define XF86XK_StopRecord _EVDEVK(0x271)
846#define XF86XK_PauseRecord _EVDEVK(0x272)
847#define XF86XK_VOD _EVDEVK(0x273)
848#define XF86XK_Unmute _EVDEVK(0x274)
849#define XF86XK_FastReverse _EVDEVK(0x275)
850#define XF86XK_SlowReverse _EVDEVK(0x276)
851#define XF86XK_Data _EVDEVK(0x277)
852#define XF86XK_OnScreenKeyboard _EVDEVK(0x278)
853#define XF86XK_PrivacyScreenToggle _EVDEVK(0x279)
854#define XF86XK_SelectiveScreenshot _EVDEVK(0x27a)
855#define XF86XK_NextElement _EVDEVK(0x27b)
856#define XF86XK_PreviousElement _EVDEVK(0x27c)
857#define XF86XK_AutopilotEngageToggle _EVDEVK(0x27d)
858#define XF86XK_MarkWaypoint _EVDEVK(0x27e)
859#define XF86XK_Sos _EVDEVK(0x27f)
860#define XF86XK_NavChart _EVDEVK(0x280)
861#define XF86XK_FishingChart _EVDEVK(0x281)
862#define XF86XK_SingleRangeRadar _EVDEVK(0x282)
863#define XF86XK_DualRangeRadar _EVDEVK(0x283)
864#define XF86XK_RadarOverlay _EVDEVK(0x284)
865#define XF86XK_TraditionalSonar _EVDEVK(0x285)
866#define XF86XK_ClearvuSonar _EVDEVK(0x286)
867#define XF86XK_SidevuSonar _EVDEVK(0x287)
868#define XF86XK_NavInfo _EVDEVK(0x288)
870#define XF86XK_Macro1 _EVDEVK(0x290)
871#define XF86XK_Macro2 _EVDEVK(0x291)
872#define XF86XK_Macro3 _EVDEVK(0x292)
873#define XF86XK_Macro4 _EVDEVK(0x293)
874#define XF86XK_Macro5 _EVDEVK(0x294)
875#define XF86XK_Macro6 _EVDEVK(0x295)
876#define XF86XK_Macro7 _EVDEVK(0x296)
877#define XF86XK_Macro8 _EVDEVK(0x297)
878#define XF86XK_Macro9 _EVDEVK(0x298)
879#define XF86XK_Macro10 _EVDEVK(0x299)
880#define XF86XK_Macro11 _EVDEVK(0x29a)
881#define XF86XK_Macro12 _EVDEVK(0x29b)
882#define XF86XK_Macro13 _EVDEVK(0x29c)
883#define XF86XK_Macro14 _EVDEVK(0x29d)
884#define XF86XK_Macro15 _EVDEVK(0x29e)
885#define XF86XK_Macro16 _EVDEVK(0x29f)
886#define XF86XK_Macro17 _EVDEVK(0x2a0)
887#define XF86XK_Macro18 _EVDEVK(0x2a1)
888#define XF86XK_Macro19 _EVDEVK(0x2a2)
889#define XF86XK_Macro20 _EVDEVK(0x2a3)
890#define XF86XK_Macro21 _EVDEVK(0x2a4)
891#define XF86XK_Macro22 _EVDEVK(0x2a5)
892#define XF86XK_Macro23 _EVDEVK(0x2a6)
893#define XF86XK_Macro24 _EVDEVK(0x2a7)
894#define XF86XK_Macro25 _EVDEVK(0x2a8)
895#define XF86XK_Macro26 _EVDEVK(0x2a9)
896#define XF86XK_Macro27 _EVDEVK(0x2aa)
897#define XF86XK_Macro28 _EVDEVK(0x2ab)
898#define XF86XK_Macro29 _EVDEVK(0x2ac)
899#define XF86XK_Macro30 _EVDEVK(0x2ad)
900#define XF86XK_MacroRecordStart _EVDEVK(0x2b0)
901#define XF86XK_MacroRecordStop _EVDEVK(0x2b1)
902#define XF86XK_MacroPresetCycle _EVDEVK(0x2b2)
903#define XF86XK_MacroPreset1 _EVDEVK(0x2b3)
904#define XF86XK_MacroPreset2 _EVDEVK(0x2b4)
905#define XF86XK_MacroPreset3 _EVDEVK(0x2b5)
906#define XF86XK_KbdLcdMenu1 _EVDEVK(0x2b8)
907#define XF86XK_KbdLcdMenu2 _EVDEVK(0x2b9)
908#define XF86XK_KbdLcdMenu3 _EVDEVK(0x2ba)
909#define XF86XK_KbdLcdMenu4 _EVDEVK(0x2bb)
910#define XF86XK_KbdLcdMenu5 _EVDEVK(0x2bc)
1066inline void checkDisplay()
1069 if (!QX11Info::display()) {
1070 qCCritical(LOG_KKEYSERVER_X11) <<
"QX11Info::display() returns 0. I'm probably going to crash now.";
1071 qCCritical(LOG_KKEYSERVER_X11) <<
"If this is a KApplication initialized without GUI stuff, change it to be "
1072 "initialized with GUI stuff.";
1076#define checkDisplay()
1083static bool g_bInitializedMods;
1084static uint g_modXNumLock, g_modXScrollLock, g_modXModeSwitch, g_alt_mask, g_meta_mask, g_super_mask, g_hyper_mask;
1090 g_modXScrollLock = 0;
1091 g_modXModeSwitch = 0;
1097 if (!QX11Info::isPlatformX11()) {
1098 qCWarning(LOG_KKEYSERVER_X11) <<
"X11 implementation of KKeyServer accessed from non-X11 platform! This is an application bug.";
1099 g_bInitializedMods =
true;
1104 xcb_key_symbols_t *symbols = xcb_key_symbols_alloc(QX11Info::connection());
1105 XModifierKeymap *xmk = XGetModifierMapping(QX11Info::display());
1109 int keysyms_per_keycode = 0;
1111 XDisplayKeycodes(QX11Info::display(), &min_keycode, &max_keycode);
1112 XFree(XGetKeyboardMapping(QX11Info::display(), min_keycode, 1, &keysyms_per_keycode));
1114 for (
int i = Mod1MapIndex; i < 8; i++) {
1115 uint mask = (1 << i);
1116 uint keySymX = NoSymbol;
1122 for (
int j = 0; j < xmk->max_keypermod; ++j) {
1123 for (
int k = 0; k < keysyms_per_keycode; ++k) {
1124 keySymX = xcb_key_symbols_get_keysym(symbols, xmk->modifiermap[xmk->max_keypermod * i + j], k);
1134 g_super_mask |= mask;
1139 g_hyper_mask |= mask;
1144 g_meta_mask |= mask;
1148 g_modXNumLock |= mask;
1150 case XK_Scroll_Lock:
1151 g_modXScrollLock |= mask;
1153 case XK_Mode_switch:
1154 g_modXModeSwitch |= mask;
1161#ifdef KKEYSERVER_DEBUG
1162 qCDebug(LOG_KKEYSERVER_X11) <<
"Alt:" << g_alt_mask;
1163 qCDebug(LOG_KKEYSERVER_X11) <<
"Meta:" << g_meta_mask;
1164 qCDebug(LOG_KKEYSERVER_X11) <<
"Super:" << g_super_mask;
1165 qCDebug(LOG_KKEYSERVER_X11) <<
"Hyper:" << g_hyper_mask;
1166 qCDebug(LOG_KKEYSERVER_X11) <<
"NumLock:" << g_modXNumLock;
1167 qCDebug(LOG_KKEYSERVER_X11) <<
"ScrollLock:" << g_modXScrollLock;
1168 qCDebug(LOG_KKEYSERVER_X11) <<
"ModeSwitch:" << g_modXModeSwitch;
1172 if (g_hyper_mask & (g_super_mask | g_meta_mask | g_alt_mask)) {
1173#ifdef KKEYSERVER_DEBUG
1174 qCDebug(LOG_KKEYSERVER_X11) <<
"Hyper conflicts with super, meta or alt.";
1177 g_hyper_mask &= ~(g_super_mask | g_meta_mask | g_alt_mask);
1181 if (g_super_mask & (g_meta_mask | g_alt_mask)) {
1182#ifdef KKEYSERVER_DEBUG
1183 qCDebug(LOG_KKEYSERVER_X11) <<
"Super conflicts with meta or alt.";
1186 g_super_mask &= ~(g_meta_mask | g_alt_mask);
1190 if (g_meta_mask | g_alt_mask) {
1191#ifdef KKEYSERVER_DEBUG
1192 qCDebug(LOG_KKEYSERVER_X11) <<
"Meta conflicts with alt.";
1195 g_meta_mask &= ~(g_alt_mask);
1199#ifdef KKEYSERVER_DEBUG
1200 qCDebug(LOG_KKEYSERVER_X11) <<
"Meta is not set or conflicted with alt.";
1203#ifdef KKEYSERVER_DEBUG
1204 qCDebug(LOG_KKEYSERVER_X11) <<
"Using super for meta";
1207 g_meta_mask = g_super_mask;
1208 }
else if (g_hyper_mask) {
1209#ifdef KKEYSERVER_DEBUG
1210 qCDebug(LOG_KKEYSERVER_X11) <<
"Using hyper for meta";
1213 g_meta_mask = g_hyper_mask;
1220#ifdef KKEYSERVER_DEBUG
1221 qCDebug(LOG_KKEYSERVER_X11) <<
"Alt:" << g_alt_mask;
1222 qCDebug(LOG_KKEYSERVER_X11) <<
"Meta:" << g_meta_mask;
1223 qCDebug(LOG_KKEYSERVER_X11) <<
"Super:" << g_super_mask;
1224 qCDebug(LOG_KKEYSERVER_X11) <<
"Hyper:" << g_hyper_mask;
1225 qCDebug(LOG_KKEYSERVER_X11) <<
"NumLock:" << g_modXNumLock;
1226 qCDebug(LOG_KKEYSERVER_X11) <<
"ScrollLock:" << g_modXScrollLock;
1227 qCDebug(LOG_KKEYSERVER_X11) <<
"ModeSwitch:" << g_modXModeSwitch;
1231 qCWarning(LOG_KKEYSERVER_X11) <<
"Your keyboard setup doesn't provide a key to use for meta. See 'xmodmap -pm' or 'xkbcomp $DISPLAY'";
1234 g_rgX11ModInfo[2].modX = g_alt_mask;
1235 g_rgX11ModInfo[3].modX = g_meta_mask;
1237 xcb_key_symbols_free(symbols);
1238 XFreeModifiermap(xmk);
1239 g_bInitializedMods =
true;
1248static bool is_keypad_key(xcb_keysym_t keysym)
1250 return keysym >= XK_KP_Space && keysym <= XK_KP_9;
1267 if (!g_bInitializedMods) {
1274 if (!g_bInitializedMods) {
1282 if (!g_bInitializedMods) {
1285 return g_modXNumLock;
1293 if (!g_bInitializedMods) {
1296 return g_modXScrollLock;
1300 if (!g_bInitializedMods) {
1303 return g_modXModeSwitch;
1311uint getModsRequired(uint sym)
1313 if (!QX11Info::isPlatformX11()) {
1314 qCWarning(LOG_KKEYSERVER_X11) <<
"X11 implementation of KKeyServer accessed from non-X11 platform! This is an application bug.";
1320 if (sym == XK_Sys_Req) {
1323 if (sym == XK_Break) {
1329 if (c.isLetter() && c.toLower() != c.toUpper() && sym == c.toUpper().unicode()) {
1334 uchar code = XKeysymToKeycode(QX11Info::display(), sym);
1339 if (sym == XKeycodeToKeysym(QX11Info::display(), code, 0)) {
1341 }
else if (sym == XKeycodeToKeysym(QX11Info::display(), code, 1)) {
1343 }
else if (sym == XKeycodeToKeysym(QX11Info::display(), code, 2)) {
1345 }
else if (sym == XKeycodeToKeysym(QX11Info::display(), code, 3)) {
1352#if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(6, 0)
1355 if (!QX11Info::isPlatformX11()) {
1356 qCWarning(LOG_KKEYSERVER_X11) <<
"X11 implementation of KKeyServer accessed from non-X11 platform! This is an application bug.";
1366 uint modExtra = getModsRequired(sym);
1373 *keyCode = XKeysymToKeycode(QX11Info::display(), sym);
1381 if (!QX11Info::isPlatformX11()) {
1382 qCWarning(LOG_KKEYSERVER_X11) <<
"X11 implementation of KKeyServer accessed from non-X11 platform! This is an application bug.";
1389 for (
int sym : syms) {
1392 uint modExtra = getModsRequired(sym);
1398 keyCodes.
append(XKeysymToKeycode(QX11Info::display(), sym));
1403#if KWINDOWSYSTEM_BUILD_DEPRECATED_SINCE(6, 0)
1406 int symQt = keyQt &
~Qt::KeyboardModifierMask;
1410 *keySym = XK_KP_0 + (symQt -
Qt::Key_0);
1414 if (symQt < 0x1000) {
1420 for (
const TransKey &tk : g_rgQtToSymX) {
1421 if (tk.keySymQt == symQt) {
1425 *keySym = tk.keySymX;
1441 int symQt = keyQt &
~Qt::KeyboardModifierMask;
1450 if (symQt < 0x1000) {
1456 for (
const TransKey &tk : g_rgQtToSymX) {
1457 if (tk.keySymQt == symQt) {
1472 if (keySym >= XK_KP_0 && keySym <= XK_KP_9) {
1474 *keyQt =
Qt::Key_0 + ((int)keySym - XK_KP_0);
1475 }
else if (keySym < 0x1000) {
1476 if (keySym >=
'a' && keySym <=
'z') {
1483 else if (keySym < 0x3000) {
1488 for (
const TransKey &tk : g_rgQtToSymX) {
1489 if (tk.keySymX == keySym) {
1490 *keyQt = tk.keySymQt;
1502 if (is_keypad_key(keySym)) {
1512 if (!g_bInitializedMods) {
1517 for (
int i = 0; i < 4; i++) {
1518 if (modQt & g_rgX11ModInfo[i].modQt) {
1519 if (g_rgX11ModInfo[i].modX) {
1520 *modX |= g_rgX11ModInfo[i].modX;
1532 if (!g_bInitializedMods) {
1537 for (
int i = 0; i < 4; i++) {
1538 if (modX & g_rgX11ModInfo[i].modX) {
1539 *modQt |= g_rgX11ModInfo[i].modQt;
1546bool codeXToSym(uchar codeX, uint modX, uint *sym)
1548 if (!QX11Info::isPlatformX11()) {
1549 qCWarning(LOG_KKEYSERVER_X11) <<
"X11 implementation of KKeyServer accessed from non-X11 platform! This is an application bug.";
1553 XKeyPressedEvent
event;
1557 event.type = KeyPress;
1558 event.display = QX11Info::display();
1560 event.keycode = codeX;
1562 XLookupString(&event,
nullptr, 0, &keySym,
nullptr);
1563 *sym = (uint)keySym;
1574 Q_ASSERT(e->type == KeyPress || e->type == KeyRelease);
1576 uchar keyCodeX = e->xkey.keycode;
1577 uint keyModX = e->xkey.state & (
accelModMaskX() | MODE_SWITCH);
1581 XLookupString((XKeyEvent *)e, buffer, 15, &keySym,
nullptr);
1582 uint keySymX = (uint)keySym;
1587 uint sym = XKeycodeToKeysym(QX11Info::display(), keyCodeX, 0);
1590 if (sym >= XK_KP_Space && sym <= XK_KP_9) {
1594 case XK_KP_Multiply:
1596 case XK_KP_Subtract:
1601 keyModX &= ~modXShift();
1614 if ((e->response_type & ~0x80) != XCB_KEY_PRESS && (e->response_type & ~0x80) != XCB_KEY_RELEASE) {
1622 const uint16_t keyModX = e->state & (
accelModMaskX() | MODE_SWITCH);
1624 xcb_key_symbols_t *symbols = xcb_key_symbols_alloc(QX11Info::connection());
1627 const xcb_keysym_t keySym0 = xcb_key_press_lookup_keysym(symbols, e, 0);
1628 const xcb_keysym_t keySym1 = xcb_key_press_lookup_keysym(symbols, e, 1);
1629 xcb_keysym_t keySymX;
1632 if ((e->state & XCB_MOD_MASK_SHIFT)) {
1645 static const int FirstLevelShift = 1;
1646 keySymX = xcb_key_symbols_get_keysym(symbols, e->detail, FirstLevelShift);
1649 *keyQt &=
~Qt::ShiftModifier;
1652 xcb_key_symbols_free(symbols);