goldendict-ng/src/keyboardstate.cc
Konstantin Isakov 2be1c2b375 Scan popup functionality implemented, among with other small improvements.
For now, the modifier key is hardcoded to be Ctrl.
2009-02-01 00:08:08 +00:00

22 lines
628 B
C++

/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.sf.net>
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
#include "keyboardstate.hh"
#include <QX11Info>
#include <X11/X.h>
#include <X11/XKBlib.h>
bool KeyboardState::checkModifiersPressed( int mask )
{
XkbStateRec state;
XkbGetState( QX11Info::display(), XkbUseCoreKbd, &state );
return !(
( mask & Alt && !( state.base_mods & Mod1Mask ) ) ||
( mask & Ctrl && !( state.base_mods & ControlMask ) ) ||
( mask & Shift && !( state.base_mods & ShiftMask ) ) ||
( mask & Win && !( state.base_mods & Mod4Mask ) ) );
}