Find out what keys are mapped to Alt and Win modifiers instead of having it hardcoded.
I fail to see why anybody would want Alt bound to anything else than Alt keys, but oh well. BUG: 106013 svn path=/trunk/KDE/kdebase/kwin/; revision=427993
This commit is contained in:
parent
cf7679b7cd
commit
170111c4e9
3 changed files with 56 additions and 8 deletions
|
@ -452,6 +452,10 @@ bool Workspace::workspaceEvent( XEvent * e )
|
|||
if( electricBorder( e ))
|
||||
return true;
|
||||
break;
|
||||
case MappingNotify:
|
||||
XRefreshKeyboardMapping( &e->xmapping );
|
||||
tab_box->updateKeyMapping();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
59
tabbox.cpp
59
tabbox.cpp
|
@ -54,6 +54,7 @@ TabBox::TabBox( Workspace *ws, const char *name )
|
|||
|
||||
no_tasks = i18n("*** No Windows ***");
|
||||
m = DesktopMode; // init variables
|
||||
updateKeyMapping();
|
||||
reconfigure();
|
||||
reset();
|
||||
connect(&delayedShowTimer, SIGNAL(timeout()), this, SLOT(show()));
|
||||
|
@ -664,6 +665,10 @@ bool areKeySymXsDepressed( bool bAll, const uint keySyms[], int nKeySyms )
|
|||
return bAll;
|
||||
}
|
||||
|
||||
static const int MAX_KEYSYMS = 4;
|
||||
static uint alt_keysyms[ MAX_KEYSYMS ];
|
||||
static uint win_keysyms[ MAX_KEYSYMS ];
|
||||
|
||||
static bool areModKeysDepressed( const KKeySequence& seq )
|
||||
{
|
||||
uint rgKeySyms[10];
|
||||
|
@ -684,17 +689,17 @@ static bool areModKeysDepressed( const KKeySequence& seq )
|
|||
}
|
||||
if( mod & KKey::ALT )
|
||||
{
|
||||
rgKeySyms[nKeySyms++] = XK_Alt_L;
|
||||
rgKeySyms[nKeySyms++] = XK_Alt_R;
|
||||
for( int i = 0;
|
||||
i < MAX_KEYSYMS && alt_keysyms[ i ] != NoSymbol;
|
||||
++i )
|
||||
rgKeySyms[nKeySyms++] = alt_keysyms[ i ];
|
||||
}
|
||||
if( mod & KKey::WIN )
|
||||
{
|
||||
// HACK: it would take a lot of code to determine whether the Win key
|
||||
// is associated with Super or Meta, so check for both
|
||||
rgKeySyms[nKeySyms++] = XK_Super_L;
|
||||
rgKeySyms[nKeySyms++] = XK_Super_R;
|
||||
rgKeySyms[nKeySyms++] = XK_Meta_L;
|
||||
rgKeySyms[nKeySyms++] = XK_Meta_R;
|
||||
for( int i = 0;
|
||||
i < MAX_KEYSYMS && win_keysyms[ i ] != NoSymbol;
|
||||
++i )
|
||||
rgKeySyms[nKeySyms++] = win_keysyms[ i ];
|
||||
}
|
||||
|
||||
return areKeySymXsDepressed( false, rgKeySyms, nKeySyms );
|
||||
|
@ -712,6 +717,44 @@ static bool areModKeysDepressed( const KShortcut& cut )
|
|||
return false;
|
||||
}
|
||||
|
||||
void TabBox::updateKeyMapping()
|
||||
{
|
||||
const int size = 6;
|
||||
uint keysyms[ size ] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R, XK_Meta_L, XK_Meta_R };
|
||||
XModifierKeymap* map = XGetModifierMapping( qt_xdisplay() );
|
||||
int altpos = 0;
|
||||
int winpos = 0;
|
||||
int winmodpos = -1;
|
||||
int winmod = KKeyNative::modX( KKey::WIN );
|
||||
while( winmod > 0 ) // get position of the set bit in winmod
|
||||
{
|
||||
winmod >>= 1;
|
||||
++winmodpos;
|
||||
}
|
||||
for( int i = 0;
|
||||
i < MAX_KEYSYMS;
|
||||
++i )
|
||||
alt_keysyms[ i ] = win_keysyms[ i ] = NoSymbol;
|
||||
for( int i = 0;
|
||||
i < size;
|
||||
++i )
|
||||
{
|
||||
KeyCode keycode = XKeysymToKeycode( qt_xdisplay(), keysyms[ i ] );
|
||||
for( int j = 0;
|
||||
j < map->max_keypermod;
|
||||
++j )
|
||||
{
|
||||
if( map->modifiermap[ 3 * map->max_keypermod + j ] == keycode ) // Alt
|
||||
if( altpos < MAX_KEYSYMS )
|
||||
alt_keysyms[ altpos++ ] = keysyms[ i ];
|
||||
if( winmodpos >= 0 && map->modifiermap[ winmodpos * map->max_keypermod + j ] == keycode )
|
||||
if( winpos < MAX_KEYSYMS )
|
||||
win_keysyms[ winpos++ ] = keysyms[ i ];
|
||||
}
|
||||
}
|
||||
XFreeModifiermap( map );
|
||||
}
|
||||
|
||||
void Workspace::slotWalkThroughWindows()
|
||||
{
|
||||
if ( root != qt_xrootwin() )
|
||||
|
|
1
tabbox.h
1
tabbox.h
|
@ -53,6 +53,7 @@ class TabBox : public QFrame
|
|||
Workspace* workspace() const;
|
||||
|
||||
void reconfigure();
|
||||
void updateKeyMapping();
|
||||
|
||||
protected:
|
||||
void showEvent( QShowEvent* );
|
||||
|
|
Loading…
Reference in a new issue