kkeyserver_x11.h
/*
Copyright (C) 2001 Ellis Whitehead <ellis@kde.org>
Win32 port:
Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KKEYSERVER_X11_H
#define _KKEYSERVER_X11_H
#include "kshortcut.h"
#include "kkeynative.h"
namespace KKeyServer
{
enum ExtraModFlag { MODE_SWITCH = 0x2000 };
struct KDECORE_EXPORT Sym
{
public:
uint m_sym;
Sym()
{ m_sym = 0; }
Sym( uint sym )
{ m_sym = sym; }
Sym( const QString& s )
{ init( s ); }
bool initQt( int keyQt );
bool init( const QString &s );
int qt() const;
QString toStringInternal() const;
QString toString() const;
uint getModsRequired() const;
uint getSymVariation() const;
operator uint() const { return m_sym; }
Sym& operator =( uint sym ) { m_sym = sym; return *this; }
private:
QString toString( bool bUserSpace ) const;
static void capitalizeKeyname( QString& );
};
struct KDECORE_EXPORT Key
{
enum { CODE_FOR_QT = 256 };
uint m_code;
uint m_mod;
uint m_sym;
bool init( const KKey& key, bool bQt );
bool isNative() const { return m_code != CODE_FOR_QT; }
uint code() const { return m_code; }
uint mod() const { return m_mod; }
uint sym() const { return m_sym; }
int keyCodeQt() const { return (int) m_sym; }
void setKeycodeQt( int keyQt )
{ m_code = CODE_FOR_QT; m_sym = keyQt; }
Key& operator =( const KKeyNative& key );
int compare( const Key& key ) const;
bool operator ==( const Key& b ) const
{ return compare( b ) == 0; }
bool operator <( const Key& b ) const
{ return compare( b ) < 0; }
KKey key() const;
};
struct KDECORE_EXPORT Variations
{
enum { MAX_VARIATIONS = 4 };
Key m_rgkey[MAX_VARIATIONS];
uint m_nVariations;
Variations() { m_nVariations = 0; }
void init( const KKey&, bool bQt );
uint count() const { return m_nVariations; }
const Key& key( uint i ) const { return m_rgkey[i]; }
};
KDECORE_EXPORT bool initializeMods();
KDECORE_EXPORT uint modX( KKey::ModFlag modFlag );
KDECORE_EXPORT bool keyboardHasWinKey();
KDECORE_EXPORT uint modXShift();
KDECORE_EXPORT uint modXLock();
KDECORE_EXPORT uint modXCtrl();
KDECORE_EXPORT uint modXAlt();
KDECORE_EXPORT uint modXNumLock();
KDECORE_EXPORT uint modXWin();
KDECORE_EXPORT uint modXScrollLock();
KDECORE_EXPORT uint modXModeSwitch();
KDECORE_EXPORT uint accelModMaskX();
KDECORE_EXPORT bool keyQtToSym( int keyQt, uint& sym );
KDECORE_EXPORT bool keyQtToMod( int keyQt, uint& mod );
KDECORE_EXPORT bool symToKeyQt( uint sym, int& keyQt );
KDECORE_EXPORT bool modToModQt( uint mod, int& modQt );
KDECORE_EXPORT bool modToModX( uint mod, uint& modX );
//wrapped for win32
KDECORE_EXPORT bool modXToModQt( uint modX, int& modQt );
KDECORE_EXPORT int qtButtonStateToMod( Qt::ButtonState s );
KDECORE_EXPORT bool modXToMod( uint modX, uint& mod );
KDECORE_EXPORT bool codeXToSym( uchar codeX, uint modX, uint& symX );
KDECORE_EXPORT QString modToStringInternal( uint mod );
KDECORE_EXPORT QString modToStringUser( uint mod );
KDECORE_EXPORT uint stringUserToMod( const QString& mod );
KDECORE_EXPORT bool stringToSymMod( const QString&, uint& sym, uint& mod );
KDECORE_EXPORT void keyQtToKeyX( uint keyCombQt, unsigned char *pKeyCodeX, uint *pKeySymX, uint *pKeyModX );
}
#endif // !_KKEYSERVER_X11_H
KKey::ModFlag
ModFlag
Flags to represent the modifiers.
Definition: kshortcut.h:53
KKeyServer::Key::isNative
bool isNative() const
Checks whether the key code is a native code.
Definition: kkeyserver_x11.h:168
KKeyServer::Sym
Represents a key symbol.
Definition: kkeyserver_x11.h:47
KKeyServer::codeXToSym
bool codeXToSym(uchar codeX, uint modX, uint &symX)
Converts a X11 key code and a mask of ORed X11 modifiers into a X11 symbol.
KKeyServer::Sym::Sym
Sym(const QString &s)
Creates a symbol from the given string description.
Definition: kkeyserver_x11.h:67
KKeyServer::Key::m_mod
uint m_mod
The modifiers of the key.
Definition: kkeyserver_x11.h:146
KKeyServer::Key::keyCodeQt
int keyCodeQt() const
Returns the qt key code.
Definition: kkeyserver_x11.h:192
KKeyServer::symToKeyQt
bool symToKeyQt(uint sym, int &keyQt)
Converts the given symbol to a Qt key code.
KKeyServer::modXNumLock
uint modXNumLock()
Returns the X11 NumLock modifier mask/flag.
KKeyServer::modXScrollLock
uint modXScrollLock()
Returns the X11 ScrollLock modifier mask/flag.
KKeyServer::Variations
TODO: please document this class.
Definition: kkeyserver_x11.h:244
KKeyServer::modXAlt
uint modXAlt()
Returns the X11 Alt (Mod1) modifier mask/flag.
KKeyServer::qtButtonStateToMod
int qtButtonStateToMod(Qt::ButtonState s)
Converts the Qt-compatible button state to x11 modifier.
KKeyServer::modXModeSwitch
uint modXModeSwitch()
Returns the X11 Mode_switch modifier mask/flag.
KKeyServer::modXShift
uint modXShift()
Returns the X11 Shift modifier mask/flag.
KKeyServer::Key::m_code
uint m_code
The code of the key.
Definition: kkeyserver_x11.h:143
KKeyServer::keyboardHasWinKey
bool keyboardHasWinKey()
Returns true if the current keyboard layout supports the Win key.
KKeyServer::keyQtToMod
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...
KKeyServer::Key::m_sym
uint m_sym
The symbol of the key.
Definition: kkeyserver_x11.h:149
KKeyServer::Sym::m_sym
uint m_sym
the actual value of the symbol
Definition: kkeyserver_x11.h:51
KKeyServer::initializeMods
bool initializeMods()
TODO: please document.
KKeyServer::Key::sym
uint sym() const
Returns the symbol of the key.
Definition: kkeyserver_x11.h:186
KKeyServer::modToModQt
bool modToModQt(uint mod, int &modQt)
Converts the mask of ORed KKey::ModFlag modifiers to a mask of ORed Qt key code modifiers.
KKeyServer::modX
uint modX(KKey::ModFlag modFlag)
Returns the equivalent X modifier mask of the given modifier flag.
KKeyServer::modXToMod
bool modXToMod(uint modX, uint &mod)
Converts the mask of ORed X11 modifiers to a mask of ORed KKey::ModFlag modifiers.
KKeyServer::modXWin
uint modXWin()
Returns the X11 Win (Mod3) modifier mask/flag.
KKeyServer::modXLock
uint modXLock()
Returns the X11 Lock modifier mask/flag.
KKeyServer::Sym::Sym
Sym()
Creates a null symbol.
Definition: kkeyserver_x11.h:54
KKeyServer::modToModX
bool modToModX(uint mod, uint &modX)
Converts the mask of ORed KKey::ModFlag modifiers to a mask of ORed X11 modifiers.
KKeyNative
Representation of a key in the format native of the windowing system (eg.
Definition: kkeynative.h:37
KKeyServer::Sym::Sym
Sym(uint sym)
Creates asymbol with the given value.
Definition: kkeyserver_x11.h:60
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: kshortcut.h:40
KKeyServer::modXToModQt
bool modXToModQt(uint modX, int &modQt)
Converts the mask of ORed X11 modifiers to a mask of ORed Qt key code modifiers.
KKeyServer::modXCtrl
uint modXCtrl()
Returns the X11 Ctrl modifier mask/flag.
KKeyServer::Key::mod
uint mod() const
Returns the modifiers of the key.
Definition: kkeyserver_x11.h:180
KKeyServer::ExtraModFlag
ExtraModFlag
Supplement enum KKey::ModFlag.
Definition: kkeyserver_x11.h:40
KKeyServer::stringUserToMod
uint stringUserToMod(const QString &mod)
Converts the modifier given as user-readable string to KKey::ModFlag modifier, or 0...
KKeyServer::Key
Represents a key press.
Definition: kkeyserver_x11.h:137
KKeyServer::Key::code
uint code() const
Returns the code of the key.
Definition: kkeyserver_x11.h:174
KKeyServer::accelModMaskX
uint accelModMaskX()
Returns bitwise OR'ed mask containing Shift, Ctrl, Alt, and Win (if available).
KKeyServer::Key::setKeycodeQt
void setKeycodeQt(int keyQt)
Sets the qt key code.
Definition: kkeyserver_x11.h:198
KKeyServer::modToStringUser
QString modToStringUser(uint mod)
Converts the mask of ORed KKey::ModFlag modifiers to a user-readable string.
KKeyServer::keyQtToSym
bool keyQtToSym(int keyQt, uint &sym)
Extracts the symbol from the given Qt key and converts it to a symbol.

KDE Home | KDE Accessibility Home | Description of Access Keys