Update calls to deprecated XKeycodeToKeysym function

pull/16/head
Timothy Pearson 13 years ago
parent a5fb7a1230
commit 5df549ce8d

@ -237,7 +237,7 @@ bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent )
// e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left. // e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left.
if( pEvent->xkey.state & KKeyServer::modXNumLock() ) { if( pEvent->xkey.state & KKeyServer::modXNumLock() ) {
// TODO: what's the xor operator in c++? // TODO: what's the xor operator in c++?
uint sym = XKeycodeToKeysym( tqt_xdisplay(), codemod.code, 0 ); uint sym = XkbKeycodeToKeysym( tqt_xdisplay(), codemod.code, 0, 0 );
// If this is a keypad key, // If this is a keypad key,
if( sym >= XK_KP_Space && sym <= XK_KP_9 ) { if( sym >= XK_KP_Space && sym <= XK_KP_9 ) {
switch( sym ) { switch( sym ) {

@ -41,6 +41,7 @@
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <fixx11h.h> #include <fixx11h.h>
@ -172,7 +173,7 @@ bool KGlobalAccelPrivate::grabKey( const KKeyServer::Key& key, bool bGrab, KAcce
// HACK: make Alt+Print work // HACK: make Alt+Print work
// only do this for the Xorg default keyboard keycodes, // only do this for the Xorg default keyboard keycodes,
// other mappings (e.g. evdev) don't need or want it // other mappings (e.g. evdev) don't need or want it
if( key.sym() == XK_Sys_Req && XKeycodeToKeysym( tqt_xdisplay(), 111, 0 ) == XK_Print ) { if( key.sym() == XK_Sys_Req && XkbKeycodeToKeysym( tqt_xdisplay(), 111, 0, 0 ) == XK_Print ) {
keyModX |= KKeyServer::modXAlt(); keyModX |= KKeyServer::modXAlt();
keyCodeX = 111; keyCodeX = 111;
} }
@ -332,7 +333,7 @@ bool KGlobalAccelPrivate::x11KeyPress( const XEvent *pEvent )
// e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left. // e.g., KP_4 => Shift+KP_Left, and Shift+KP_4 => KP_Left.
if( pEvent->xkey.state & KKeyServer::modXNumLock() ) { if( pEvent->xkey.state & KKeyServer::modXNumLock() ) {
// TODO: what's the xor operator in c++? // TODO: what's the xor operator in c++?
uint sym = XKeycodeToKeysym( tqt_xdisplay(), codemod.code, 0 ); uint sym = XkbKeycodeToKeysym( tqt_xdisplay(), codemod.code, 0, 0 );
// If this is a keypad key, // If this is a keypad key,
if( sym >= XK_KP_Space && sym <= XK_KP_9 ) { if( sym >= XK_KP_Space && sym <= XK_KP_9 ) {
switch( sym ) { switch( sym ) {

@ -40,6 +40,7 @@
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include <ctype.h> #include <ctype.h>
#endif #endif
@ -111,10 +112,10 @@ bool KKeyNative::init( const KKey& key )
// Only do this for the default Xorg layout, other keycode mappings // Only do this for the default Xorg layout, other keycode mappings
// (e.g. evdev) don't need or want it. // (e.g. evdev) don't need or want it.
if( m_sym == XK_Print && !(m_mod & Mod1Mask) && if( m_sym == XK_Print && !(m_mod & Mod1Mask) &&
XKeycodeToKeysym( tqt_xdisplay(), 111, 0 ) == XK_Print ) XkbKeycodeToKeysym( tqt_xdisplay(), 111, 0, 0 ) == XK_Print )
m_code = 111; // code for Print m_code = 111; // code for Print
else if( m_sym == XK_Break || (m_sym == XK_Pause && (m_mod & ControlMask)) && else if( m_sym == XK_Break || (m_sym == XK_Pause && (m_mod & ControlMask)) &&
XKeycodeToKeysym( tqt_xdisplay(), 114, 0 ) == XK_Pause ) XkbKeycodeToKeysym( tqt_xdisplay(), 114, 0, 0 ) == XK_Pause )
m_code = 114; m_code = 114;
else else
m_code = XKeysymToKeycode( tqt_xdisplay(), m_sym ); m_code = XKeysymToKeycode( tqt_xdisplay(), m_sym );

@ -42,6 +42,7 @@
# include <X11/X.h> # include <X11/X.h>
# include <X11/Xlib.h> # include <X11/Xlib.h>
# include <X11/Xutil.h> # include <X11/Xutil.h>
# include <X11/XKBlib.h>
# include <X11/keysymdef.h> # include <X11/keysymdef.h>
# define X11_ONLY(arg) arg, //allows to omit an argument # define X11_ONLY(arg) arg, //allows to omit an argument
#else #else
@ -340,13 +341,13 @@ bool initializeMods()
for( int i = Mod2MapIndex; i < 8; i++ ) { for( int i = Mod2MapIndex; i < 8; i++ ) {
uint mask = (1 << i); uint mask = (1 << i);
uint keySymX = NoSymbol; uint keySymX = NoSymbol;
// This used to be only XKeycodeToKeysym( ... , 0 ), but that fails with XFree4.3.99 // This used to be only XkbKeycodeToKeysym( ... , 0, 0 ), but that fails with XFree4.3.99
// and X.org R6.7 , where for some reason only ( ... , 1 ) works. I have absolutely no // and X.org R6.7 , where for some reason only ( ... , 0, 1 ) works. I have absolutely no
// idea what the problem is, but searching all posibilities until something valid is // idea what the problem is, but searching all posibilities until something valid is
// found fixes the problem. // found fixes the problem.
for( int j = 0; j < xmk->max_keypermod && keySymX == NoSymbol; ++j ) for( int j = 0; j < xmk->max_keypermod && keySymX == NoSymbol; ++j )
for( int k = 0; k < keysyms_per_keycode && keySymX == NoSymbol; ++k ) for( int k = 0; k < keysyms_per_keycode && keySymX == NoSymbol; ++k )
keySymX = XKeycodeToKeysym( tqt_xdisplay(), xmk->modifiermap[xmk->max_keypermod * i + j], k ); keySymX = XkbKeycodeToKeysym( tqt_xdisplay(), xmk->modifiermap[xmk->max_keypermod * i + j], 0, k );
switch( keySymX ) { switch( keySymX ) {
case XK_Num_Lock: g_modXNumLock = mask; break; // Normally Mod2Mask case XK_Num_Lock: g_modXNumLock = mask; break; // Normally Mod2Mask
case XK_Super_L: case XK_Super_L:
@ -551,13 +552,13 @@ uint Sym::getModsRequired() const
// need to check index 0 before the others, so that a null-mod // need to check index 0 before the others, so that a null-mod
// can take precedence over the others, in case the modified // can take precedence over the others, in case the modified
// key produces the same symbol. // key produces the same symbol.
if( m_sym == XKeycodeToKeysym( tqt_xdisplay(), code, 0 ) ) if( m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 0 ) )
; ;
else if( m_sym == XKeycodeToKeysym( tqt_xdisplay(), code, 1 ) ) else if( m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 1 ) )
mod = KKey::SHIFT; mod = KKey::SHIFT;
else if( m_sym == XKeycodeToKeysym( tqt_xdisplay(), code, 2 ) ) else if( m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 2 ) )
mod = KKeyServer::MODE_SWITCH; mod = KKeyServer::MODE_SWITCH;
else if( m_sym == XKeycodeToKeysym( tqt_xdisplay(), code, 3 ) ) else if( m_sym == XkbKeycodeToKeysym( tqt_xdisplay(), code, 0, 3 ) )
mod = KKey::SHIFT | KKeyServer::MODE_SWITCH; mod = KKey::SHIFT | KKeyServer::MODE_SWITCH;
} }
#endif #endif
@ -887,8 +888,8 @@ uint stringUserToMod( const TQString& mod )
// keycode 111 & 92: Print Sys_Req -> Sys_Req = Alt+Print // keycode 111 & 92: Print Sys_Req -> Sys_Req = Alt+Print
// keycode 110 & 114: Pause Break -> Break = Ctrl+Pause // keycode 110 & 114: Pause Break -> Break = Ctrl+Pause
if( (keyCodeX == 92 || keyCodeX == 111) && if( (keyCodeX == 92 || keyCodeX == 111) &&
XKeycodeToKeysym( tqt_xdisplay(), 92, 0 ) == XK_Print && XkbKeycodeToKeysym( tqt_xdisplay(), 92, 0, 0 ) == XK_Print &&
XKeycodeToKeysym( tqt_xdisplay(), 111, 0 ) == XK_Print ) XkbKeycodeToKeysym( tqt_xdisplay(), 111, 0, 0 ) == XK_Print )
{ {
// If Alt is pressed, then we need keycode 92, keysym XK_Sys_Req // If Alt is pressed, then we need keycode 92, keysym XK_Sys_Req
if( keyModX & keyModXAlt() ) { if( keyModX & keyModXAlt() ) {
@ -902,8 +903,8 @@ uint stringUserToMod( const TQString& mod )
} }
} }
else if( (keyCodeX == 110 || keyCodeX == 114) && else if( (keyCodeX == 110 || keyCodeX == 114) &&
XKeycodeToKeysym( tqt_xdisplay(), 110, 0 ) == XK_Pause && XkbKeycodeToKeysym( tqt_xdisplay(), 110, 0, 0 ) == XK_Pause &&
XKeycodeToKeysym( tqt_xdisplay(), 114, 0 ) == XK_Pause ) XkbKeycodeToKeysym( tqt_xdisplay(), 114, 0, 0 ) == XK_Pause )
{ {
if( keyModX & keyModXCtrl() ) { if( keyModX & keyModXCtrl() ) {
keyCodeX = 114; keyCodeX = 114;

Loading…
Cancel
Save