25 #include <tqnamespace.h>
26 #include <tqwindowdefs.h>
28 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MACX) // Only compile this module if we're compiling for X11, mac or win32
30 #include "kkeyserver_x11.h"
31 #include "kkeynative.h"
32 #include "tdeshortcut.h"
34 #include <tdeconfig.h>
36 #include <tdeglobal.h>
40 # define XK_MISCELLANY
43 # include <X11/Xlib.h>
44 # include <X11/Xutil.h>
45 # include <X11/XKBlib.h>
46 # include <X11/keysymdef.h>
47 # define X11_ONLY(arg) arg, //allows to omit an argument
50 # define X11_ONLY(arg)
51 # define XK_ISO_Left_Tab Qt::Key_Backtab
52 # define XK_BackSpace Qt::Key_Backspace
53 # define XK_Sys_Req Qt::Key_SysReq
54 # define XK_Caps_Lock Qt::Key_CapsLock
55 # define XK_Num_Lock Qt::Key_NumLock
56 # define XK_Scroll_Lock Qt::Key_ScrollLock
57 # define XK_Prior Qt::Key_Prior
58 # define XK_Next Qt::Key_Next
90 uint sym, symVariation;
109 static ModInfo g_rgModInfo[KKey::MOD_FLAG_COUNT] =
111 { KKey::SHIFT, Qt::SHIFT, X11_ONLY(ShiftMask) I18N_NOOP("Shift"), TQString() },
112 { KKey::CTRL, Qt::CTRL, X11_ONLY(ControlMask) I18N_NOOP("Ctrl"), TQString() },
113 { KKey::ALT, Qt::ALT, X11_ONLY(Mod1Mask) I18N_NOOP("Alt"), TQString() },
114 { KKey::WIN, KKey::QtWIN, X11_ONLY(Mod4Mask) I18N_NOOP("Win"), TQString() }
118 static const SymName g_rgSymNames[] = {
119 { XK_ISO_Left_Tab,
"Backtab" },
120 { XK_BackSpace, I18N_NOOP(
"Backspace") },
121 { XK_Sys_Req, I18N_NOOP(
"SysReq") },
122 { XK_Caps_Lock, I18N_NOOP(
"CapsLock") },
123 { XK_Num_Lock, I18N_NOOP(
"NumLock") },
124 { XK_Scroll_Lock, I18N_NOOP(
"ScrollLock") },
125 { XK_Prior, I18N_NOOP(
"PageUp") },
126 { XK_Next, I18N_NOOP(
"PageDown") },
128 { XK_F11, I18N_NOOP(
"Stop") },
129 { XK_F12, I18N_NOOP(
"Again") },
130 { XK_F13, I18N_NOOP(
"Props") },
131 { XK_F14, I18N_NOOP(
"Undo") },
132 { XK_F15, I18N_NOOP(
"Front") },
133 { XK_F16, I18N_NOOP(
"Copy") },
134 { XK_F17, I18N_NOOP(
"Open") },
135 { XK_F18, I18N_NOOP(
"Paste") },
136 { XK_F19, I18N_NOOP(
"Find") },
137 { XK_F20, I18N_NOOP(
"Cut") },
138 { XK_F22, I18N_NOOP(
"Print") },
144 static SymVariation g_rgSymVariation[] =
146 {
'/', XK_KP_Divide,
false },
147 {
'*', XK_KP_Multiply,
false },
148 {
'-', XK_KP_Subtract,
false },
149 {
'+', XK_KP_Add,
false },
150 { XK_Return, XK_KP_Enter,
false },
157 static const TransKey g_rgQtToSymX[] =
159 { Qt::Key_Escape, XK_Escape },
160 { Qt::Key_Tab, XK_Tab },
161 { Qt::Key_Backtab, XK_ISO_Left_Tab },
162 { Qt::Key_Backspace, XK_BackSpace },
163 { Qt::Key_Return, XK_Return },
164 { Qt::Key_Enter, XK_KP_Enter },
165 { Qt::Key_Insert, XK_Insert },
166 { Qt::Key_Delete, XK_Delete },
167 { Qt::Key_Pause, XK_Pause },
169 { Qt::Key_Print, XK_F22 },
171 { Qt::Key_Print, XK_Print },
173 { Qt::Key_SysReq, XK_Sys_Req },
174 { Qt::Key_Home, XK_Home },
175 { Qt::Key_End, XK_End },
176 { Qt::Key_Left, XK_Left },
177 { Qt::Key_Up, XK_Up },
178 { Qt::Key_Right, XK_Right },
179 { Qt::Key_Down, XK_Down },
180 { TQt::Key_Prior, XK_Prior },
181 { TQt::Key_Next, XK_Next },
186 { Qt::Key_CapsLock, XK_Caps_Lock },
187 { Qt::Key_NumLock, XK_Num_Lock },
188 { Qt::Key_ScrollLock, XK_Scroll_Lock },
189 { Qt::Key_F1, XK_F1 },
190 { Qt::Key_F2, XK_F2 },
191 { Qt::Key_F3, XK_F3 },
192 { Qt::Key_F4, XK_F4 },
193 { Qt::Key_F5, XK_F5 },
194 { Qt::Key_F6, XK_F6 },
195 { Qt::Key_F7, XK_F7 },
196 { Qt::Key_F8, XK_F8 },
197 { Qt::Key_F9, XK_F9 },
198 { Qt::Key_F10, XK_F10 },
199 { Qt::Key_F11, XK_F11 },
200 { Qt::Key_F12, XK_F12 },
201 { Qt::Key_F13, XK_F13 },
202 { Qt::Key_F14, XK_F14 },
203 { Qt::Key_F15, XK_F15 },
204 { Qt::Key_F16, XK_F16 },
205 { Qt::Key_F17, XK_F17 },
206 { Qt::Key_F18, XK_F18 },
207 { Qt::Key_F19, XK_F19 },
208 { Qt::Key_F20, XK_F20 },
209 { Qt::Key_F21, XK_F21 },
210 { Qt::Key_F22, XK_F22 },
211 { Qt::Key_F23, XK_F23 },
212 { Qt::Key_F24, XK_F24 },
213 { Qt::Key_F25, XK_F25 },
214 { Qt::Key_F26, XK_F26 },
215 { Qt::Key_F27, XK_F27 },
216 { Qt::Key_F28, XK_F28 },
217 { Qt::Key_F29, XK_F29 },
218 { Qt::Key_F30, XK_F30 },
219 { Qt::Key_F31, XK_F31 },
220 { Qt::Key_F32, XK_F32 },
221 { Qt::Key_F33, XK_F33 },
222 { Qt::Key_F34, XK_F34 },
223 { Qt::Key_F35, XK_F35 },
224 { Qt::Key_Super_L, XK_Super_L },
225 { Qt::Key_Super_R, XK_Super_R },
226 { Qt::Key_Menu, XK_Menu },
227 { Qt::Key_Hyper_L, XK_Hyper_L },
228 { Qt::Key_Hyper_R, XK_Hyper_R },
229 { Qt::Key_Help, XK_Help },
233 {
'/', XK_KP_Divide },
234 {
'*', XK_KP_Multiply },
235 {
'-', XK_KP_Subtract },
237 { Qt::Key_Return, XK_KP_Enter }
238 #if TQT_VERSION >= 0x030100
242 #define XF86XK_Standby 0x1008FF10
243 #define XF86XK_AudioLowerVolume 0x1008FF11
244 #define XF86XK_AudioMute 0x1008FF12
245 #define XF86XK_AudioRaiseVolume 0x1008FF13
246 #define XF86XK_AudioPlay 0x1008FF14
247 #define XF86XK_AudioStop 0x1008FF15
248 #define XF86XK_AudioPrev 0x1008FF16
249 #define XF86XK_AudioNext 0x1008FF17
250 #define XF86XK_HomePage 0x1008FF18
251 #define XF86XK_Calculator 0x1008FF1D
252 #define XF86XK_Mail 0x1008FF19
253 #define XF86XK_Start 0x1008FF1A
254 #define XF86XK_Search 0x1008FF1B
255 #define XF86XK_AudioRecord 0x1008FF1C
256 #define XF86XK_Back 0x1008FF26
257 #define XF86XK_Forward 0x1008FF27
258 #define XF86XK_Stop 0x1008FF28
259 #define XF86XK_Refresh 0x1008FF29
260 #define XF86XK_Favorites 0x1008FF30
261 #define XF86XK_AudioPause 0x1008FF31
262 #define XF86XK_AudioMedia 0x1008FF32
263 #define XF86XK_MyComputer 0x1008FF33
264 #define XF86XK_OpenURL 0x1008FF38
265 #define XF86XK_Launch0 0x1008FF40
266 #define XF86XK_Launch1 0x1008FF41
267 #define XF86XK_Launch2 0x1008FF42
268 #define XF86XK_Launch3 0x1008FF43
269 #define XF86XK_Launch4 0x1008FF44
270 #define XF86XK_Launch5 0x1008FF45
271 #define XF86XK_Launch6 0x1008FF46
272 #define XF86XK_Launch7 0x1008FF47
273 #define XF86XK_Launch8 0x1008FF48
274 #define XF86XK_Launch9 0x1008FF49
275 #define XF86XK_LaunchA 0x1008FF4A
276 #define XF86XK_LaunchB 0x1008FF4B
277 #define XF86XK_LaunchC 0x1008FF4C
278 #define XF86XK_LaunchD 0x1008FF4D
279 #define XF86XK_LaunchE 0x1008FF4E
280 #define XF86XK_LaunchF 0x1008FF4F
281 #define XF86XK_MonBrightnessUp 0x1008FF02
282 #define XF86XK_MonBrightnessDown 0x1008FF03
283 #define XF86XK_KbdLightOnOff 0x1008FF04
284 #define XF86XK_KbdBrightnessUp 0x1008FF05
285 #define XF86XK_KbdBrightnessDown 0x1008FF06
288 { Qt::Key_Standby, XF86XK_Standby },
289 { Qt::Key_VolumeDown, XF86XK_AudioLowerVolume },
290 { Qt::Key_VolumeMute, XF86XK_AudioMute },
291 { Qt::Key_VolumeUp, XF86XK_AudioRaiseVolume },
292 { Qt::Key_MediaPlay, XF86XK_AudioPlay },
293 { Qt::Key_MediaStop, XF86XK_AudioStop },
294 { TQt::Key_MediaPrev, XF86XK_AudioPrev },
295 { Qt::Key_MediaNext, XF86XK_AudioNext },
296 { Qt::Key_HomePage, XF86XK_HomePage },
297 { Qt::Key_LaunchMail, XF86XK_Mail },
298 { Qt::Key_Search, XF86XK_Search },
299 { Qt::Key_MediaRecord, XF86XK_AudioRecord },
300 { Qt::Key_LaunchMedia, XF86XK_AudioMedia },
301 { Qt::Key_Launch1, XF86XK_Calculator },
302 { Qt::Key_Back, XF86XK_Back },
303 { Qt::Key_Forward, XF86XK_Forward },
304 { Qt::Key_Stop, XF86XK_Stop },
305 { Qt::Key_Refresh, XF86XK_Refresh },
306 { Qt::Key_Favorites, XF86XK_Favorites },
307 { Qt::Key_Launch0, XF86XK_MyComputer },
308 { Qt::Key_OpenUrl, XF86XK_OpenURL },
309 { Qt::Key_Launch2, XF86XK_Launch0 },
310 { Qt::Key_Launch3, XF86XK_Launch1 },
311 { Qt::Key_Launch4, XF86XK_Launch2 },
312 { Qt::Key_Launch5, XF86XK_Launch3 },
313 { Qt::Key_Launch6, XF86XK_Launch4 },
314 { Qt::Key_Launch7, XF86XK_Launch5 },
315 { Qt::Key_Launch8, XF86XK_Launch6 },
316 { Qt::Key_Launch9, XF86XK_Launch7 },
317 { Qt::Key_LaunchA, XF86XK_Launch8 },
318 { Qt::Key_LaunchB, XF86XK_Launch9 },
319 { Qt::Key_LaunchC, XF86XK_LaunchA },
320 { Qt::Key_LaunchD, XF86XK_LaunchB },
321 { Qt::Key_LaunchE, XF86XK_LaunchC },
322 { Qt::Key_LaunchF, XF86XK_LaunchD },
323 { Qt::Key_MonBrightnessUp, XF86XK_MonBrightnessUp },
324 { Qt::Key_MonBrightnessDown, XF86XK_MonBrightnessDown },
325 { Qt::Key_KeyboardLightOnOff, XF86XK_KbdLightOnOff },
326 { Qt::Key_KeyboardBrightnessUp, XF86XK_KbdBrightnessUp },
327 { Qt::Key_KeyboardBrightnessDown, XF86XK_KbdBrightnessDown },
335 static bool g_bInitializedMods, g_bInitializedVariations, g_bInitializedKKeyLabels;
336 static bool g_bMacLabels;
338 static uint g_modXNumLock, g_modXScrollLock, g_modXModeSwitch;
342 XModifierKeymap* xmk = XGetModifierMapping( tqt_xdisplay() );
344 g_rgModInfo[3].modX = g_modXNumLock = g_modXScrollLock = g_modXModeSwitch = 0;
346 int min_keycode, max_keycode;
347 int keysyms_per_keycode = 0;
348 XDisplayKeycodes( tqt_xdisplay(), &min_keycode, &max_keycode );
349 XFree( XGetKeyboardMapping( tqt_xdisplay(), min_keycode, 1, &keysyms_per_keycode ));
351 for(
int i = Mod2MapIndex; i < 8; i++ ) {
352 uint mask = (1 << i);
353 uint keySymX = NoSymbol;
358 for(
int j = 0; j < xmk->max_keypermod && keySymX == NoSymbol; ++j )
359 for(
int k = 0; k < keysyms_per_keycode && keySymX == NoSymbol; ++k )
360 keySymX = XkbKeycodeToKeysym( tqt_xdisplay(), xmk->modifiermap[xmk->max_keypermod * i + j], 0, k );
362 case XK_Num_Lock: g_modXNumLock = mask;
break;
364 case XK_Super_R: g_rgModInfo[3].modX = mask;
break;
366 case XK_Meta_R:
if( !g_rgModInfo[3].
modX ) g_rgModInfo[3].modX = mask;
break;
367 case XK_Scroll_Lock: g_modXScrollLock = mask;
break;
368 case XK_Mode_switch: g_modXModeSwitch = mask;
break;
372 XFreeModifiermap( xmk );
377 g_bInitializedMods =
true;
379 kdDebug(125) <<
"KKeyServer::initializeMods(): Win Mod = 0x" << TQString::number(g_rgModInfo[3].
modX, 16) <<
endl;
383 static void initializeVariations()
385 for(
int i = 0; g_rgSymVariation[i].sym != 0; i++ )
386 g_rgSymVariation[i].bActive = (XKeysymToKeycode( tqt_xdisplay(), g_rgSymVariation[i].symVariation ) != 0);
387 g_bInitializedVariations =
true;
391 static void intializeKKeyLabels()
398 g_bMacLabels = (g_rgModInfo[2].sLabel ==
"Command");
399 g_bInitializedKKeyLabels =
true;
417 int symQt = keyQt & 0xffff;
419 if( (keyQt & Qt::UNICODE_ACCEL) || symQt < 0x1000 ) {
420 m_sym = TQChar(symQt).lower().unicode();
427 #elif defined(Q_WS_X11)
428 for( uint i = 0; i <
sizeof(g_rgQtToSymX)/
sizeof(TransKey); i++ ) {
429 if( g_rgQtToSymX[i].keySymQt == symQt ) {
430 m_sym = g_rgQtToSymX[i].keySymX;
436 if( symQt != Qt::Key_Shift && symQt != Qt::Key_Control && symQt != Qt::Key_Alt &&
437 symQt != Qt::Key_Meta && symQt != Qt::Key_Direction_L && symQt != Qt::Key_Direction_R )
438 kdDebug(125) <<
"Sym::initQt( " << TQString::number(keyQt,16) <<
" ): failed to convert key." <<
endl;
440 #elif defined(Q_WS_MACX)
449 if( s.length() == 1 ) {
450 m_sym = s[0].lower().unicode();
455 for(
int i = 0; g_rgSymNames[i].sym != 0; i++ ) {
456 if( tqstricmp( s.latin1(), g_rgSymNames[i].psName ) == 0 ) {
457 m_sym = g_rgSymNames[i].sym;
464 for ( KKeys
const *pKey = kde_KKEYS; pKey->code != 0xffff; pKey++) {
465 if( tqstricmp( s.latin1(), pKey->name ) == 0 ) {
471 #elif defined(Q_WS_X11)
473 m_sym = XStringToKeysym( s.latin1() );
475 m_sym = XStringToKeysym( s.lower().latin1() );
478 s2[0] = s2[0].upper();
479 m_sym = XStringToKeysym( s2.latin1() );
488 if(
m_sym < 0x1000 ) {
490 return TQChar(
m_sym).upper();
496 #elif defined(Q_WS_X11)
498 return m_sym | Qt::UNICODE_ACCEL;
500 for( uint i = 0; i <
sizeof(g_rgQtToSymX)/
sizeof(TransKey); i++ )
501 if( g_rgQtToSymX[i].keySymX ==
m_sym )
502 return g_rgQtToSymX[i].keySymQt;
504 return TQt::Key_unknown;
510 return TQString::null;
515 else if(
m_sym < 0x1000 ) {
517 else if(
m_sym < 0x3000 ) {
519 TQChar c = TQChar(
m_sym).upper();
522 if( (c.latin1() && c.isLetterOrNumber())
523 || (bUserSpace && !c.isSpace()) ) {
529 for(
int i = 0; g_rgSymNames[i].sym != 0; i++ ) {
530 if(
m_sym == g_rgSymNames[i].sym ) {
531 return bUserSpace ? i18n(g_rgSymNames[i].psName) : TQString(g_rgSymNames[i].psName);
537 s = TQKeySequence(
m_sym );
538 #elif defined(Q_WS_X11)
540 s = XKeysymToString(
m_sym );
542 capitalizeKeyname( s );
543 return bUserSpace ? i18n(
"TQAccel", s.latin1()) : s;
546 TQString Sym::toStringInternal()
const {
return toString(
false ); }
554 if(
m_sym == XK_Sys_Req )
return KKey::ALT;
555 if(
m_sym == XK_Break )
return KKey::CTRL;
557 if(
m_sym < 0x3000 ) {
559 if( c.isLetter() && c.lower() != c.upper() &&
m_sym == c.upper().unicode() )
563 uchar code = XKeysymToKeycode( tqt_xdisplay(),
m_sym );
568 if(
m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 0 ) )
570 else if(
m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 1 ) )
572 else if(
m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 2 ) )
573 mod = KKeyServer::MODE_SWITCH;
574 else if(
m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 3 ) )
575 mod = KKey::SHIFT | KKeyServer::MODE_SWITCH;
584 if( !g_bInitializedVariations )
585 initializeVariations();
586 for(
int i = 0; g_rgSymVariation[i].sym != 0; i++ )
587 if( g_rgSymVariation[i].sym ==
m_sym && g_rgSymVariation[i].bActive )
588 return g_rgSymVariation[i].symVariation;
593 void Sym::capitalizeKeyname( TQString& s )
596 int len = s.length();
597 if( s.endsWith(
"left" ) ) s[len-4] =
'L';
598 else if( s.endsWith(
"right" ) ) s[len-5] =
'R';
599 else if( s ==
"Sysreq" ) s[len-3] =
'R';
609 if( mod == KKey::WIN && !g_bInitializedMods )
612 for( uint i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) {
613 if( g_rgModInfo[i].mod == mod )
614 return g_rgModInfo[i].modX;
621 uint
modXLock() {
return LockMask; }
622 uint
modXCtrl() {
return ControlMask; }
623 uint
modXAlt() {
return Mod1Mask; }
631 if( !g_bInitializedMods )
633 return ShiftMask | ControlMask | Mod1Mask | g_rgModInfo[3].modX;
640 if( sym.initQt( keyQt ) ) {
651 if( keyQt & Qt::SHIFT ) mod |= KKey::SHIFT;
652 if( keyQt & Qt::CTRL ) mod |= KKey::CTRL;
653 if( keyQt & Qt::ALT ) mod |= KKey::ALT;
654 if( keyQt & Qt::META ) mod |= KKey::WIN;
663 return (keyQt != TQt::Key_unknown);
669 for(
int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) {
670 if( mod & g_rgModInfo[i].mod ) {
671 if( !g_rgModInfo[i].modQt ) {
675 modQt |= g_rgModInfo[i].modQt;
691 if (s & Qt::ShiftButton) modQt |= KKey::SHIFT;
692 if (s & Qt::ControlButton) modQt |= KKey::CTRL;
693 if (s & Qt::AltButton) modQt |= KKey::ALT;
702 #elif defined(Q_WS_MACX)
718 #elif defined(Q_WS_X11)
722 if( !g_bInitializedMods )
726 for(
int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) {
727 if( mod & g_rgModInfo[i].mod ) {
728 if( !g_rgModInfo[i].modX ) {
729 kdDebug(125) <<
"Invalid modifier flag." <<
endl;
733 modX |= g_rgModInfo[i].modX;
744 if( !g_bInitializedMods )
748 for(
int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) {
749 if( modX & g_rgModInfo[i].modX ) {
750 if( !g_rgModInfo[i].modQt ) {
754 modQt |= g_rgModInfo[i].modQt;
762 if( !g_bInitializedMods )
766 for(
int i = 0; i < KKey::MOD_FLAG_COUNT; i++ ) {
767 if( modX & g_rgModInfo[i].modX )
768 mod |= g_rgModInfo[i].mod;
773 bool codeXToSym( uchar codeX, uint modX, uint& sym )
776 XKeyPressedEvent
event;
778 event.type = KeyPress;
779 event.display = tqt_xdisplay();
781 event.keycode = codeX;
784 XLookupString( &event, buffer, 63, &keySym, NULL );
790 static TQString modToString( uint mod,
bool bUserSpace )
792 if( bUserSpace && !g_bInitializedKKeyLabels )
793 intializeKKeyLabels();
796 for(
int i = KKey::MOD_FLAG_COUNT-1; i >= 0; i-- ) {
797 if( mod & g_rgModInfo[i].mod ) {
801 ? g_rgModInfo[i].sLabel
802 : TQString(g_rgModInfo[i].psName);
808 TQString modToStringInternal( uint mod ) {
return modToString( mod,
false ); }
809 TQString
modToStringUser( uint mod ) {
return modToString( mod,
true ); }
813 if( !g_bInitializedKKeyLabels )
814 intializeKKeyLabels();
817 for(
int i = KKey::MOD_FLAG_COUNT-1; i >= 0; i-- ) {
818 if( mod.lower() == g_rgModInfo[i].sLabel.lower())
819 return g_rgModInfo[i].mod;
943 m_code = CODE_FOR_QT;
954 if( m_code == CODE_FOR_QT )
955 return KKey( keyCodeQt() );
957 #if defined(Q_WS_WIN) || defined(Q_WS_MACX)
975 if( m_code == CODE_FOR_QT )
976 return m_sym - b.m_sym;
977 if(
m_sym != b.m_sym )
return m_sym - b.m_sym;
978 if( m_mod != b.m_mod )
return m_mod - b.m_mod;
979 return m_code - b.m_code;
987 void Variations::init(
const KKey& key,
bool bQt )
998 uint modReq =
Sym(m_rgkey[0].sym()).getModsRequired();
999 uint modReqVar =
Sym(symVar).getModsRequired();
1002 if( (key.modFlags() & modReq) == (key.modFlags() & modReqVar) ) {
1009 uint nVariations = 0;
1010 for( uint i = 0; i < m_nVariations; i++ ) {
1011 int keyQt =
KKeyNative( m_rgkey[i].code(), m_rgkey[i].mod(), m_rgkey[i].sym() ).
keyCodeQt();
1013 m_rgkey[nVariations++].setKeycodeQt( keyQt );
1016 m_nVariations = nVariations;
1020 for( uint i = 1; i < m_nVariations; i++ ) {
1021 for( uint j = 0; j < i; j++ ) {
1023 if( m_rgkey[i].keyCodeQt() == m_rgkey[j].keyCodeQt() ) {
1024 for( uint k = i; k < m_nVariations - 1; k++ ) {
1025 m_rgkey[k].setKeycodeQt( m_rgkey[k+1].keyCodeQt() );
1044 void KKey::simplify()
1047 if( m_sym == XK_Sys_Req ) {
1050 }
else if( m_sym == XK_ISO_Left_Tab ) {
1059 if( m_sym < 0x3000 && TQChar(m_sym).isLetter() ) {
1060 m_sym = TQChar(m_sym).lower().unicode();
1065 m_mod &= ~
KKeyServer::Sym(m_sym).getModsRequired();
1069 #endif //Q_WS_X11 || Q_WS_WIN
ModFlag
Flags to represent the modifiers.
int event(const TQString &message, const TQString &text=TQString::null) KDE_DEPRECATED
bool codeXToSym(uchar codeX, uint modX, uint &symX)
Converts a X11 key code and a mask of ORed X11 modifiers into a X11 symbol.
KKey key() const
Converts this Key to a KKey.
Key & operator=(const KKeyNative &key)
Initializes this key with a KKeyNative.
Helper class to facilitate working with TDEConfig / KSimpleConfig groups.
uint getModsRequired() const
Returns the mods that are required for this symbol as ORed KKey::ModFlag's.
A collection of functions for the conversion of key presses and their modifiers from the window syste...
bool symToKeyQt(uint sym, int &keyQt)
Converts the given symbol to a Qt key code.
uint modXNumLock()
Returns the X11 NumLock modifier mask/flag.
uint modXScrollLock()
Returns the X11 ScrollLock modifier mask/flag.
uint modXAlt()
Returns the X11 Alt (Mod1) modifier mask/flag.
uint modXModeSwitch()
Returns the X11 Mode_switch modifier mask/flag.
uint modXShift()
Returns the X11 Shift modifier mask/flag.
TQString toString() const
Returns the string representation of the symbol.
bool isNull() const
Returns true if the key is null (after clear() or empty constructor).
bool keyboardHasWinKey()
Returns true if the current keyboard layout supports the Win key.
bool init(const TQString &s)
Initializes the key with the given string description.
bool keyQtToMod(int keyQt, uint &mod)
Extracts the modifiers from the given Qt key and converts them in a mask of ORed KKey::ModFlag modifi...
int keyCodeQt() const
Returns the qt key code.
uint mod() const
The native modifier flags of the key.
uint m_sym
the actual value of the symbol
bool initializeMods()
TODO: please document.
uint code() const
The native keycode of the key.
bool modToModQt(uint mod, int &modQt)
Converts the mask of ORed KKey::ModFlag modifiers to a mask of ORed Qt key code modifiers.
uint modX(KKey::ModFlag modFlag)
Returns the equivalent X modifier mask of the given modifier flag.
bool modXToMod(uint modX, uint &mod)
Converts the mask of ORed X11 modifiers to a mask of ORed KKey::ModFlag modifiers.
uint modXWin()
Returns the X11 Win (Mod3) modifier mask/flag.
int qt() const
Returns the qt key code of the symbol.
uint modXLock()
Returns the X11 Lock modifier mask/flag.
Sym()
Creates a null symbol.
int qtButtonStateToMod(TQ_ButtonState s)
Converts the Qt-compatible button state to x11 modifier.
bool modToModX(uint mod, uint &modX)
Converts the mask of ORed KKey::ModFlag modifiers to a mask of ORed X11 modifiers.
Representation of a key in the format native of the windowing system (eg.
bool initQt(int keyQt)
Initializes the symbol with the given Qt key code.
bool init(const KKey &key, bool bQt)
Initializes the key with a KKey.
uint stringUserToMod(const TQString &mod)
Converts the modifier given as user-readable string to KKey::ModFlag modifier, or 0...
TQString modToStringUser(uint mod)
Converts the mask of ORed KKey::ModFlag modifiers to a user-readable string.
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
int keyCodeQt() const
Returns the qt key code.
bool modXToModQt(uint modX, int &modQt)
Converts the mask of ORed X11 modifiers to a mask of ORed Qt key code modifiers.
uint modXCtrl()
Returns the X11 Ctrl modifier mask/flag.
static TDEConfig * config()
Returns the general config object.
kndbgstream & endl(kndbgstream &s)
Does nothing.
uint sym() const
The native symbol (KeySym) of the key.
TQString readEntry(const TQString &pKey, const TQString &aDefault=TQString::null) const
Reads the value of an entry specified by pKey in the current group.
uint getSymVariation() const
TODO: please find out what this method does and document it.
int compare(const Key &key) const
Compares this key with the given Key object.
uint accelModMaskX()
Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and Win (if available).
bool keyQtToSym(int keyQt, uint &sym)
Extracts the symbol from the given Qt key and converts it to a symbol.