2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package 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 General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-10-08 19:24:46 +00:00
|
|
|
#include "CXWindowsSecondaryScreen.h"
|
2002-05-27 16:22:59 +00:00
|
|
|
#include "CXWindowsClipboard.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "CXWindowsScreen.h"
|
2002-06-22 19:20:21 +00:00
|
|
|
#include "CXWindowsScreenSaver.h"
|
2002-05-27 16:22:59 +00:00
|
|
|
#include "CXWindowsUtil.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "IScreenReceiver.h"
|
2002-07-12 20:41:23 +00:00
|
|
|
#include "XScreen.h"
|
2001-10-08 19:24:46 +00:00
|
|
|
#include "CThread.h"
|
2001-10-23 22:41:46 +00:00
|
|
|
#include "CLog.h"
|
2002-06-19 11:23:49 +00:00
|
|
|
#if defined(X_DISPLAY_MISSING)
|
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/X.h>
|
|
|
|
# include <X11/Xutil.h>
|
|
|
|
# define XK_MISCELLANY
|
|
|
|
# define XK_XKB_KEYS
|
2003-07-01 19:35:28 +00:00
|
|
|
# define XK_LATIN1
|
|
|
|
# define XK_LATIN2
|
|
|
|
# define XK_LATIN3
|
|
|
|
# define XK_LATIN4
|
|
|
|
# define XK_LATIN8
|
|
|
|
# define XK_LATIN9
|
2002-06-19 11:23:49 +00:00
|
|
|
# include <X11/keysymdef.h>
|
|
|
|
# if defined(HAVE_X11_EXTENSIONS_XTEST_H)
|
|
|
|
# include <X11/extensions/XTest.h>
|
|
|
|
# else
|
|
|
|
# error The XTest extension is required to build synergy
|
|
|
|
# endif
|
2003-05-17 13:44:24 +00:00
|
|
|
# if HAVE_X11_EXTENSIONS_XINERAMA_H
|
|
|
|
// Xinerama.h may lack extern "C" for inclusion by C++
|
|
|
|
extern "C" {
|
|
|
|
# include <X11/extensions/Xinerama.h>
|
|
|
|
}
|
|
|
|
# endif
|
2003-05-04 21:40:42 +00:00
|
|
|
# if defined(HAVE_X11_XF86KEYSYM_H)
|
|
|
|
# include <X11/XF86keysym.h>
|
|
|
|
# endif
|
2003-05-17 12:48:32 +00:00
|
|
|
# if !defined(XF86XK_Launch0)
|
|
|
|
# define XF86XK_Launch0 0x1008FF40
|
|
|
|
# endif
|
|
|
|
# if !defined(XF86XK_Launch1)
|
|
|
|
# define XF86XK_Launch1 0x1008FF41
|
|
|
|
# endif
|
2002-06-19 11:23:49 +00:00
|
|
|
#endif
|
2001-10-08 19:24:46 +00:00
|
|
|
|
2002-09-14 12:07:02 +00:00
|
|
|
//
|
|
|
|
// utility functions
|
|
|
|
//
|
|
|
|
|
|
|
|
inline
|
|
|
|
static
|
|
|
|
unsigned int getBits(unsigned int src, unsigned int mask)
|
|
|
|
{
|
|
|
|
return src & mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
static
|
|
|
|
unsigned int setBits(unsigned int src, unsigned int mask)
|
|
|
|
{
|
|
|
|
return src | mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
static
|
|
|
|
unsigned int clearBits(unsigned int src, unsigned int mask)
|
|
|
|
{
|
|
|
|
return src & ~mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
static
|
|
|
|
unsigned int flipBits(unsigned int src, unsigned int mask)
|
|
|
|
{
|
|
|
|
return src ^ mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
static
|
|
|
|
unsigned int assignBits(unsigned int src,
|
|
|
|
unsigned int mask, unsigned int value)
|
|
|
|
{
|
|
|
|
return setBits(clearBits(src, mask), clearBits(value, ~mask));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-08 19:24:46 +00:00
|
|
|
//
|
|
|
|
// CXWindowsSecondaryScreen
|
|
|
|
//
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
CXWindowsSecondaryScreen::KeySymsMap
|
|
|
|
CXWindowsSecondaryScreen::s_decomposedKeySyms;
|
|
|
|
|
2002-07-10 21:22:28 +00:00
|
|
|
CXWindowsSecondaryScreen::CXWindowsSecondaryScreen(IScreenReceiver* receiver) :
|
2002-07-13 22:00:38 +00:00
|
|
|
CSecondaryScreen(),
|
2003-05-17 13:44:24 +00:00
|
|
|
m_window(None),
|
|
|
|
m_xtestIsXineramaUnaware(true)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
m_screen = new CXWindowsScreen(receiver, this);
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// make sure decomposed keysym table is prepared
|
|
|
|
getDecomposedKeySymTable();
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CXWindowsSecondaryScreen::~CXWindowsSecondaryScreen()
|
|
|
|
{
|
2001-11-25 18:32:41 +00:00
|
|
|
assert(m_window == None);
|
2002-07-13 22:00:38 +00:00
|
|
|
delete m_screen;
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2003-04-27 17:01:14 +00:00
|
|
|
CXWindowsSecondaryScreen::keyDown(KeyID key,
|
|
|
|
KeyModifierMask mask, KeyButton button)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2003-06-08 22:12:12 +00:00
|
|
|
// check for ctrl+alt+del emulation
|
2003-06-08 22:20:01 +00:00
|
|
|
if (key == kKeyDelete &&
|
|
|
|
(mask & (KeyModifierControl | KeyModifierAlt)) ==
|
|
|
|
(KeyModifierControl | KeyModifierAlt)) {
|
2003-06-08 22:12:12 +00:00
|
|
|
LOG((CLOG_DEBUG "ctrl+alt+del emulation"));
|
2003-06-08 22:20:01 +00:00
|
|
|
// just pass the key through
|
2003-06-08 22:12:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// get the sequence of keys to simulate key press and the final
|
|
|
|
// modifier state.
|
2003-07-05 14:49:08 +00:00
|
|
|
Keystrokes keys;
|
|
|
|
KeyCode keycode;
|
2002-05-03 11:26:44 +00:00
|
|
|
m_mask = mapKey(keys, keycode, key, mask, kPress);
|
2002-06-10 22:06:45 +00:00
|
|
|
if (keys.empty()) {
|
2003-07-05 14:49:08 +00:00
|
|
|
// do nothing if there are no associated keys (i.e. lookup failed)
|
2002-04-26 17:38:01 +00:00
|
|
|
return;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
|
|
|
// generate key events
|
2002-05-03 11:26:44 +00:00
|
|
|
doKeystrokes(keys, 1);
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-05 14:49:08 +00:00
|
|
|
// do not record button down if button is 0 (invalid)
|
|
|
|
if (button != 0) {
|
|
|
|
// note that key is now down
|
|
|
|
m_serverKeyMap[button] = keycode;
|
|
|
|
m_keys[keycode] = true;
|
|
|
|
m_fakeKeys[keycode] = true;
|
|
|
|
}
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::keyRepeat(KeyID key,
|
2003-04-27 17:01:14 +00:00
|
|
|
KeyModifierMask mask, SInt32 count, KeyButton button)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2003-04-27 17:01:14 +00:00
|
|
|
// if we haven't seen this button go down then ignore it
|
|
|
|
ServerKeyMap::iterator index = m_serverKeyMap.find(button);
|
|
|
|
if (index == m_serverKeyMap.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-03 11:26:44 +00:00
|
|
|
// get the sequence of keys to simulate key repeat and the final
|
|
|
|
// modifier state.
|
2003-07-05 14:49:08 +00:00
|
|
|
Keystrokes keys;
|
|
|
|
KeyCode keycode;
|
2002-05-03 11:26:44 +00:00
|
|
|
m_mask = mapKey(keys, keycode, key, mask, kRepeat);
|
2002-06-10 22:06:45 +00:00
|
|
|
if (keys.empty()) {
|
2002-05-03 11:26:44 +00:00
|
|
|
return;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-05-03 11:26:44 +00:00
|
|
|
|
2003-05-03 13:28:21 +00:00
|
|
|
// if this keycode shouldn't auto-repeat then ignore
|
|
|
|
if ((m_keyControl.auto_repeats[keycode >> 3] & (1 << (keycode & 7))) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-07-05 14:49:08 +00:00
|
|
|
// if the keycode for the auto-repeat is not the same as for the
|
|
|
|
// initial press then mark the initial key as released and the new
|
|
|
|
// key as pressed. this can happen when we auto-repeat after a
|
|
|
|
// dead key. for example, a dead accent followed by 'a' will
|
|
|
|
// generate an 'a with accent' followed by a repeating 'a'. the
|
|
|
|
// keycodes for the two keysyms might be different.
|
|
|
|
if (keycode != index->second) {
|
2003-04-27 17:01:14 +00:00
|
|
|
// replace key up with previous keycode but leave key down
|
|
|
|
// alone so it uses the new keycode and store that keycode
|
2003-07-05 14:49:08 +00:00
|
|
|
// in the server key map. the key up is the first keystroke
|
|
|
|
// with the keycode returned by mapKey().
|
2003-04-27 17:01:14 +00:00
|
|
|
for (Keystrokes::iterator index2 = keys.begin();
|
|
|
|
index2 != keys.end(); ++index2) {
|
2003-07-05 14:49:08 +00:00
|
|
|
if (index2->m_keycode == keycode) {
|
2003-04-27 17:01:14 +00:00
|
|
|
index2->m_keycode = index->second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// note that old key is now up
|
|
|
|
m_keys[index->second] = false;
|
|
|
|
m_fakeKeys[index->second] = false;
|
|
|
|
|
|
|
|
// map server key to new key
|
|
|
|
index->second = keycode;
|
|
|
|
|
|
|
|
// note that new key is now down
|
|
|
|
m_keys[index->second] = true;
|
|
|
|
m_fakeKeys[index->second] = true;
|
|
|
|
}
|
|
|
|
|
2002-05-03 11:26:44 +00:00
|
|
|
// generate key events
|
|
|
|
doKeystrokes(keys, count);
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2003-04-27 17:01:14 +00:00
|
|
|
CXWindowsSecondaryScreen::keyUp(KeyID key,
|
|
|
|
KeyModifierMask mask, KeyButton button)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2003-04-27 17:01:14 +00:00
|
|
|
// if we haven't seen this button go down then ignore it
|
|
|
|
ServerKeyMap::iterator index = m_serverKeyMap.find(button);
|
|
|
|
if (index == m_serverKeyMap.end()) {
|
|
|
|
return;
|
|
|
|
}
|
2003-07-05 14:49:08 +00:00
|
|
|
KeyCode keycode = index->second;
|
2003-04-27 17:01:14 +00:00
|
|
|
|
2003-06-08 22:20:01 +00:00
|
|
|
// check for ctrl+alt+del emulation
|
|
|
|
if (key == kKeyDelete &&
|
|
|
|
(mask & (KeyModifierControl | KeyModifierAlt)) ==
|
|
|
|
(KeyModifierControl | KeyModifierAlt)) {
|
|
|
|
LOG((CLOG_DEBUG "ctrl+alt+del emulation"));
|
|
|
|
// just pass the key through
|
|
|
|
}
|
|
|
|
|
2003-07-05 14:49:08 +00:00
|
|
|
// get the sequence of keys to simulate key release and the final
|
|
|
|
// modifier state.
|
|
|
|
Keystrokes keys;
|
2003-07-01 19:35:28 +00:00
|
|
|
if (!((key == kKeyCapsLock && m_capsLockHalfDuplex) ||
|
|
|
|
(key == kKeyNumLock && m_numLockHalfDuplex))) {
|
|
|
|
m_mask = mapKeyRelease(keys, keycode);
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
|
|
|
// generate key events
|
2002-05-03 11:26:44 +00:00
|
|
|
doKeystrokes(keys, 1);
|
2002-04-26 17:38:01 +00:00
|
|
|
|
|
|
|
// note that key is now up
|
2003-07-05 14:49:08 +00:00
|
|
|
m_serverKeyMap.erase(index);
|
2003-03-16 17:40:56 +00:00
|
|
|
m_keys[keycode] = false;
|
|
|
|
m_fakeKeys[keycode] = false;
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mouseDown(ButtonID button)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-08-18 17:31:48 +00:00
|
|
|
const unsigned int xButton = mapButton(button);
|
|
|
|
if (xButton != 0) {
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XTestFakeButtonEvent(display, xButton, True, CurrentTime);
|
|
|
|
XSync(display, False);
|
|
|
|
}
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mouseUp(ButtonID button)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-08-18 17:31:48 +00:00
|
|
|
const unsigned int xButton = mapButton(button);
|
|
|
|
if (xButton != 0) {
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XTestFakeButtonEvent(display, xButton, False, CurrentTime);
|
|
|
|
XSync(display, False);
|
|
|
|
}
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mouseMove(SInt32 x, SInt32 y)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-07-12 20:41:23 +00:00
|
|
|
warpCursor(x, y);
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-05-23 15:50:38 +00:00
|
|
|
// choose button depending on rotation direction
|
2003-05-04 21:40:42 +00:00
|
|
|
const unsigned int xButton = mapButton(static_cast<ButtonID>(
|
|
|
|
(delta >= 0) ? -1 : -2));
|
2002-08-18 17:31:48 +00:00
|
|
|
if (xButton == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2002-05-23 15:50:38 +00:00
|
|
|
|
|
|
|
// now use absolute value of delta
|
|
|
|
if (delta < 0) {
|
|
|
|
delta = -delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
// send as many clicks as necessary
|
2002-07-13 22:00:38 +00:00
|
|
|
CDisplayLock display(m_screen);
|
2002-05-23 15:50:38 +00:00
|
|
|
for (; delta >= 120; delta -= 120) {
|
2002-08-18 17:31:48 +00:00
|
|
|
XTestFakeButtonEvent(display, xButton, True, CurrentTime);
|
|
|
|
XTestFakeButtonEvent(display, xButton, False, CurrentTime);
|
2002-05-23 15:50:38 +00:00
|
|
|
}
|
|
|
|
XSync(display, False);
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
|
|
|
|
2002-12-23 13:55:21 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::resetOptions()
|
|
|
|
{
|
2003-05-17 13:44:24 +00:00
|
|
|
m_numLockHalfDuplex = false;
|
|
|
|
m_capsLockHalfDuplex = false;
|
|
|
|
m_xtestIsXineramaUnaware = true;
|
2003-05-03 14:38:36 +00:00
|
|
|
CSecondaryScreen::resetOptions();
|
2002-12-23 13:55:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::setOptions(const COptionsList& options)
|
|
|
|
{
|
|
|
|
for (UInt32 i = 0, n = options.size(); i < n; i += 2) {
|
|
|
|
if (options[i] == kOptionHalfDuplexCapsLock) {
|
|
|
|
m_capsLockHalfDuplex = (options[i + 1] != 0);
|
|
|
|
LOG((CLOG_DEBUG1 "half-duplex caps-lock %s", m_capsLockHalfDuplex ? "on" : "off"));
|
|
|
|
}
|
|
|
|
else if (options[i] == kOptionHalfDuplexNumLock) {
|
|
|
|
m_numLockHalfDuplex = (options[i + 1] != 0);
|
|
|
|
LOG((CLOG_DEBUG1 "half-duplex num-lock %s", m_numLockHalfDuplex ? "on" : "off"));
|
|
|
|
}
|
2003-05-17 13:44:24 +00:00
|
|
|
else if (options[i] == kOptionXTestXineramaUnaware) {
|
|
|
|
m_xtestIsXineramaUnaware = (options[i + 1] != 0);
|
|
|
|
LOG((CLOG_DEBUG1 "XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false"));
|
|
|
|
}
|
2002-12-23 13:55:21 +00:00
|
|
|
}
|
2003-05-03 14:38:36 +00:00
|
|
|
CSecondaryScreen::setOptions(options);
|
2002-12-23 13:55:21 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
IScreen*
|
|
|
|
CXWindowsSecondaryScreen::getScreen() const
|
2002-06-22 19:20:21 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
return m_screen;
|
2002-06-22 19:20:21 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-07-15 15:01:36 +00:00
|
|
|
CXWindowsSecondaryScreen::onScreensaver(bool)
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
// ignore
|
2001-11-25 18:32:41 +00:00
|
|
|
}
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
bool
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::onPreDispatch(const CEvent*)
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
return false;
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::onEvent(CEvent* event)
|
|
|
|
{
|
|
|
|
assert(event != NULL);
|
|
|
|
XEvent& xevent = event->m_event;
|
|
|
|
|
|
|
|
// handle event
|
|
|
|
switch (xevent.type) {
|
2003-03-16 17:40:56 +00:00
|
|
|
case MappingNotify: {
|
2002-07-13 22:00:38 +00:00
|
|
|
// keyboard mapping changed
|
2003-03-16 17:40:56 +00:00
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
doUpdateKeys(display);
|
2002-07-12 20:41:23 +00:00
|
|
|
return true;
|
2003-03-16 17:40:56 +00:00
|
|
|
}
|
2002-07-12 20:41:23 +00:00
|
|
|
|
|
|
|
case LeaveNotify:
|
2002-07-13 22:00:38 +00:00
|
|
|
// mouse moved out of hider window somehow. hide the window.
|
|
|
|
hideWindow();
|
2002-07-12 20:41:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-22 21:53:25 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::onOneShotTimerExpired(UInt32)
|
|
|
|
{
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
SInt32
|
|
|
|
CXWindowsSecondaryScreen::getJumpZoneSize() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-07-30 15:17:44 +00:00
|
|
|
CXWindowsSecondaryScreen::onPreMainLoop()
|
2002-05-27 16:22:59 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(m_window != None);
|
2001-10-23 22:41:46 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::onPreOpen()
|
2001-11-11 21:15:30 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(m_window == None);
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::onPostOpen()
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-12-23 13:55:21 +00:00
|
|
|
assert(m_window != None);
|
2003-05-03 13:28:21 +00:00
|
|
|
|
|
|
|
// get the keyboard control state
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XGetKeyboardControl(display, &m_keyControl);
|
2003-05-17 13:44:24 +00:00
|
|
|
|
2003-05-17 14:03:32 +00:00
|
|
|
// check if xinerama is enabled and there is more than one screen
|
2003-05-17 13:44:24 +00:00
|
|
|
m_xinerama = false;
|
|
|
|
#if HAVE_X11_EXTENSIONS_XINERAMA_H
|
|
|
|
int eventBase, errorBase;
|
|
|
|
if (XineramaQueryExtension(display, &eventBase, &errorBase)) {
|
|
|
|
if (XineramaIsActive(display)) {
|
|
|
|
int numScreens;
|
|
|
|
XineramaScreenInfo* screens;
|
|
|
|
screens = XineramaQueryScreens(display, &numScreens);
|
|
|
|
if (screens != NULL) {
|
2003-05-17 14:03:32 +00:00
|
|
|
m_xinerama = (numScreens > 1);
|
2003-05-17 13:44:24 +00:00
|
|
|
XFree(screens);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-03 13:57:52 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::onPreClose()
|
|
|
|
{
|
|
|
|
if (m_keyControl.global_auto_repeat == AutoRepeatModeOn) {
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XAutoRepeatOn(display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::onPreEnter()
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(m_window != None);
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-03 13:28:21 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::onPostEnter()
|
|
|
|
{
|
|
|
|
assert(m_window != None);
|
|
|
|
|
|
|
|
// get the keyboard control state
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XGetKeyboardControl(display, &m_keyControl);
|
|
|
|
|
|
|
|
// turn off auto-repeat. we do this so fake key press events don't
|
|
|
|
// cause the local server to generate their own auto-repeats of
|
|
|
|
// those keys.
|
|
|
|
XAutoRepeatOff(display);
|
|
|
|
}
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::onPreLeave()
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(m_window != None);
|
2003-05-03 13:28:21 +00:00
|
|
|
|
|
|
|
// restore the previous keyboard auto-repeat state. if the user
|
|
|
|
// changed the auto-repeat configuration while on the client then
|
|
|
|
// that state is lost. that's because we can't get notified by
|
|
|
|
// the X server when the auto-repeat configuration is changed so
|
|
|
|
// we can't track the desired configuration.
|
|
|
|
if (m_keyControl.global_auto_repeat == AutoRepeatModeOn) {
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XAutoRepeatOn(display);
|
|
|
|
}
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::createWindow()
|
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
2002-07-12 20:41:23 +00:00
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
// verify the availability of the XTest extension
|
|
|
|
int majorOpcode, firstEvent, firstError;
|
|
|
|
if (!XQueryExtension(display, XTestExtensionName,
|
2002-07-12 20:41:23 +00:00
|
|
|
&majorOpcode, &firstEvent, &firstError)) {
|
2002-10-15 21:29:44 +00:00
|
|
|
LOG((CLOG_ERR "XTEST extension not available"));
|
2002-07-13 22:00:38 +00:00
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
|
|
|
|
|
|
|
// cursor hider window attributes. this window is used to hide the
|
|
|
|
// cursor when it's not on the screen. the window is hidden as soon
|
|
|
|
// as the cursor enters the screen or the display's real cursor is
|
|
|
|
// moved.
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.event_mask = LeaveWindowMask;
|
|
|
|
attr.do_not_propagate_mask = 0;
|
|
|
|
attr.override_redirect = True;
|
|
|
|
attr.cursor = m_screen->getBlankCursor();
|
|
|
|
|
|
|
|
// create the cursor hider window
|
|
|
|
m_window = XCreateWindow(display, m_screen->getRoot(),
|
2002-07-12 20:41:23 +00:00
|
|
|
0, 0, 1, 1, 0, 0,
|
|
|
|
InputOnly, CopyFromParent,
|
|
|
|
CWDontPropagate | CWEventMask |
|
|
|
|
CWOverrideRedirect | CWCursor,
|
|
|
|
&attr);
|
2002-07-13 22:00:38 +00:00
|
|
|
if (m_window == None) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2002-10-15 21:29:44 +00:00
|
|
|
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
2002-07-13 22:00:38 +00:00
|
|
|
|
|
|
|
// become impervious to server grabs
|
|
|
|
XTestGrabControl(display, True);
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// tell generic screen about the window
|
2002-07-13 22:00:38 +00:00
|
|
|
m_screen->setWindow(m_window);
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::destroyWindow()
|
|
|
|
{
|
2002-07-16 16:52:26 +00:00
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
if (display != NULL) {
|
|
|
|
// release keys that are still pressed
|
2003-03-12 22:34:07 +00:00
|
|
|
doReleaseKeys(display);
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-16 16:52:26 +00:00
|
|
|
// no longer impervious to server grabs
|
|
|
|
XTestGrabControl(display, False);
|
2002-07-12 20:41:23 +00:00
|
|
|
|
2002-07-16 16:52:26 +00:00
|
|
|
// update
|
|
|
|
XSync(display, False);
|
|
|
|
}
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
// destroy window
|
|
|
|
if (m_window != None) {
|
|
|
|
m_screen->setWindow(None);
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
if (display != NULL) {
|
|
|
|
XDestroyWindow(display, m_window);
|
|
|
|
}
|
|
|
|
m_window = None;
|
|
|
|
}
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-05-03 13:50:06 +00:00
|
|
|
CXWindowsSecondaryScreen::showWindow(SInt32 x, SInt32 y)
|
2002-07-13 22:00:38 +00:00
|
|
|
{
|
2003-05-03 13:50:06 +00:00
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
|
|
|
|
// move hider window under the given position
|
|
|
|
XMoveWindow(display, m_window, x, y);
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-05-03 13:50:06 +00:00
|
|
|
// raise and show the hider window. take activation.
|
|
|
|
// FIXME -- take focus?
|
|
|
|
XMapRaised(display, m_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
// now warp the mouse. we warp after showing the window so we're
|
|
|
|
// guaranteed to get the mouse leave event and to prevent the
|
|
|
|
// keyboard focus from changing under point-to-focus policies.
|
|
|
|
warpCursor(x, y);
|
2002-07-13 22:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::hideWindow()
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(m_window != None);
|
|
|
|
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
XUnmapWindow(display, m_window);
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-13 22:00:38 +00:00
|
|
|
CXWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y)
|
2002-07-12 20:41:23 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
Display* pDisplay = display;
|
2003-05-17 13:44:24 +00:00
|
|
|
|
2003-05-17 14:03:32 +00:00
|
|
|
if (m_xinerama && m_xtestIsXineramaUnaware) {
|
|
|
|
XWarpPointer(display, None, m_screen->getRoot(), 0, 0, 0, 0, x, y);
|
2003-05-17 13:44:24 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
XTestFakeMotionEvent(display, DefaultScreen(pDisplay),
|
2003-05-17 14:03:32 +00:00
|
|
|
x, y, CurrentTime);
|
2003-05-17 13:44:24 +00:00
|
|
|
}
|
2002-07-13 22:00:38 +00:00
|
|
|
XSync(display, False);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::setToggleState(KeyModifierMask mask)
|
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
|
|
|
|
// toggle modifiers that don't match the desired state
|
2003-07-01 19:35:28 +00:00
|
|
|
ModifierMask xMask = maskToX(mask);
|
2002-07-13 22:00:38 +00:00
|
|
|
if ((xMask & m_capsLockMask) != (m_mask & m_capsLockMask)) {
|
2003-07-01 19:35:28 +00:00
|
|
|
toggleKey(display, m_capsLockKeysym, m_capsLockMask);
|
2002-07-13 22:00:38 +00:00
|
|
|
}
|
|
|
|
if ((xMask & m_numLockMask) != (m_mask & m_numLockMask)) {
|
2003-07-01 19:35:28 +00:00
|
|
|
toggleKey(display, m_numLockKeysym, m_numLockMask);
|
2002-07-13 22:00:38 +00:00
|
|
|
}
|
|
|
|
if ((xMask & m_scrollLockMask) != (m_mask & m_scrollLockMask)) {
|
2003-07-01 19:35:28 +00:00
|
|
|
toggleKey(display, m_scrollLockKeysym, m_scrollLockMask);
|
2002-07-13 22:00:38 +00:00
|
|
|
}
|
2001-11-11 21:15:30 +00:00
|
|
|
}
|
|
|
|
|
2002-12-15 22:14:49 +00:00
|
|
|
KeyModifierMask
|
|
|
|
CXWindowsSecondaryScreen::getToggleState() const
|
|
|
|
{
|
|
|
|
KeyModifierMask mask = 0;
|
|
|
|
if ((m_mask & m_capsLockMask) != 0) {
|
|
|
|
mask |= KeyModifierCapsLock;
|
|
|
|
}
|
|
|
|
if ((m_mask & m_numLockMask) != 0) {
|
|
|
|
mask |= KeyModifierNumLock;
|
|
|
|
}
|
|
|
|
if ((m_mask & m_scrollLockMask) != 0) {
|
|
|
|
mask |= KeyModifierScrollLock;
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
unsigned int
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mapButton(ButtonID id) const
|
2001-10-08 19:24:46 +00:00
|
|
|
{
|
2003-05-04 21:40:42 +00:00
|
|
|
// map button -1 to button 4 (+wheel)
|
|
|
|
if (id == static_cast<ButtonID>(-1)) {
|
|
|
|
id = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// map button -2 to button 5 (-wheel)
|
|
|
|
else if (id == static_cast<ButtonID>(-2)) {
|
|
|
|
id = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
// map buttons 4, 5, etc. to 6, 7, etc. to make room for buttons
|
|
|
|
// 4 and 5 used to simulate the mouse wheel.
|
|
|
|
else if (id >= 4) {
|
|
|
|
id += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check button is in legal range
|
2002-12-15 22:39:59 +00:00
|
|
|
if (id < 1 || id > m_buttons.size()) {
|
2002-08-18 17:31:48 +00:00
|
|
|
// out of range
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-04 21:40:42 +00:00
|
|
|
|
|
|
|
// map button
|
|
|
|
return static_cast<unsigned int>(m_buttons[id - 1]);
|
2001-10-08 19:24:46 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
CXWindowsSecondaryScreen::ModifierMask
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::mapKey(Keystrokes& keys, KeyCode& keycode,
|
|
|
|
KeyID id, KeyModifierMask mask, EKeyAction action) const
|
2002-04-26 17:38:01 +00:00
|
|
|
{
|
|
|
|
// note -- must have display locked on entry
|
|
|
|
|
|
|
|
// the system translates key events into characters depending
|
|
|
|
// on the modifier key state at the time of the event. to
|
|
|
|
// generate the right keysym we need to set the modifier key
|
|
|
|
// states appropriately.
|
|
|
|
//
|
|
|
|
// the mask passed by the caller is the desired mask. however,
|
|
|
|
// there may not be a keycode mapping to generate the desired
|
|
|
|
// keysym with that mask. we override the bits in the mask
|
|
|
|
// that cannot be accomodated.
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// ignore releases and repeats for half-duplex keys
|
2002-07-23 17:04:41 +00:00
|
|
|
const bool isHalfDuplex = ((id == kKeyCapsLock && m_capsLockHalfDuplex) ||
|
|
|
|
(id == kKeyNumLock && m_numLockHalfDuplex));
|
2002-05-03 11:26:44 +00:00
|
|
|
if (isHalfDuplex && action != kPress) {
|
2002-04-30 16:25:29 +00:00
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
2003-06-22 16:39:02 +00:00
|
|
|
// requested notes the modifiers requested by the server.
|
2003-07-01 19:35:28 +00:00
|
|
|
ModifierMask requested = maskToX(mask);
|
2003-06-22 16:39:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// convert KeyID to a KeySym
|
|
|
|
KeySym keysym = keyIDToKeySym(id, requested);
|
|
|
|
if (keysym == NoSymbol) {
|
|
|
|
// unknown key
|
|
|
|
LOG((CLOG_DEBUG2 "no keysym for id 0x%08x", id));
|
2002-04-26 17:38:01 +00:00
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// get the mapping for this keysym
|
|
|
|
KeySymIndex keyIndex = m_keysymMap.find(keysym);
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// if the mapping isn't found and keysym is caps lock sensitive
|
|
|
|
// then convert the case of the keysym and try again.
|
|
|
|
if (keyIndex == m_keysymMap.end()) {
|
|
|
|
KeySym lKey, uKey;
|
|
|
|
XConvertCase(keysym, &lKey, &uKey);
|
|
|
|
if (lKey != uKey) {
|
|
|
|
if (lKey == keysym) {
|
|
|
|
keyIndex = m_keysymMap.find(uKey);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
keyIndex = m_keysymMap.find(lKey);
|
|
|
|
}
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
if (keyIndex != m_keysymMap.end()) {
|
|
|
|
// the keysym is mapped to some keycode. if it's a modifier
|
|
|
|
// and that modifier is already in the desired state then
|
|
|
|
// ignore the request since there's nothing to do. never
|
|
|
|
// ignore a toggle modifier on press or release, though.
|
|
|
|
const KeyMapping& keyMapping = keyIndex->second;
|
|
|
|
const ModifierMask modifierBit = keyMapping.m_modifierMask;
|
|
|
|
if (modifierBit != 0) {
|
|
|
|
if (action == kRepeat) {
|
|
|
|
LOG((CLOG_DEBUG2 "ignore repeating modifier"));
|
2003-06-22 15:01:44 +00:00
|
|
|
return m_mask;
|
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
if (getBits(m_toggleModifierMask, modifierBit) == 0) {
|
|
|
|
if ((action == kPress && (m_mask & modifierBit) != 0) ||
|
|
|
|
(action == kRelease && (m_mask & modifierBit) == 0)) {
|
|
|
|
LOG((CLOG_DEBUG2 "modifier in proper state: 0x%04x", m_mask));
|
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// create the keystrokes for this keysym
|
|
|
|
ModifierMask mask;
|
|
|
|
if (!mapToKeystrokes(keys, keycode, mask, keyIndex, m_mask, action)) {
|
|
|
|
// failed to generate keystrokes
|
|
|
|
keys.clear();
|
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// success
|
|
|
|
LOG((CLOG_DEBUG2 "new mask: 0x%04x", mask));
|
|
|
|
return mask;
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// we can't find the keysym mapped to any keycode. this doesn't
|
|
|
|
// necessarily mean we can't generate the keysym, though. if the
|
|
|
|
// keysym can be created by combining keysyms then we may still
|
|
|
|
// be okay.
|
|
|
|
KeySyms decomposition;
|
|
|
|
if (decomposeKeySym(keysym, decomposition)) {
|
|
|
|
LOG((CLOG_DEBUG2 "decomposed keysym 0x%08x into %d keysyms", keysym, decomposition.size()));
|
|
|
|
|
|
|
|
// map each decomposed keysym to keystrokes. we want the mask
|
|
|
|
// and the keycode from the last keysym (which should be the
|
|
|
|
// only non-dead key). the dead keys are not sensitive to
|
|
|
|
// anything but shift and mode switch.
|
|
|
|
ModifierMask mask;
|
|
|
|
for (KeySyms::const_iterator i = decomposition.begin();
|
|
|
|
i != decomposition.end();) {
|
|
|
|
// increment the iterator
|
|
|
|
KeySyms::const_iterator next = i;
|
|
|
|
++next;
|
|
|
|
|
|
|
|
// lookup the key
|
|
|
|
keysym = *i;
|
|
|
|
keyIndex = m_keysymMap.find(keysym);
|
|
|
|
if (keyIndex == m_keysymMap.end()) {
|
|
|
|
// missing a required keysym
|
|
|
|
LOG((CLOG_DEBUG2 "no keycode for decomposed keysym 0x%08x", keysym));
|
|
|
|
keys.clear();
|
|
|
|
return m_mask;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// the keysym is mapped to some keycode
|
|
|
|
if (!mapToKeystrokes(keys, keycode, mask,
|
|
|
|
keyIndex, m_mask, action)) {
|
|
|
|
// failed to generate keystrokes
|
|
|
|
keys.clear();
|
|
|
|
return m_mask;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// on to the next keysym
|
|
|
|
i = next;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
LOG((CLOG_DEBUG2 "new mask: 0x%04x", mask));
|
|
|
|
return mask;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
LOG((CLOG_DEBUG2 "no keycode for keysym"));
|
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
CXWindowsSecondaryScreen::ModifierMask
|
|
|
|
CXWindowsSecondaryScreen::mapKeyRelease(Keystrokes& keys, KeyCode keycode) const
|
|
|
|
{
|
|
|
|
// add key release
|
|
|
|
Keystroke keystroke;
|
|
|
|
keystroke.m_keycode = keycode;
|
|
|
|
keystroke.m_press = False;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
|
|
|
|
// if this is a modifier keycode then update the current modifier mask
|
|
|
|
KeyCodeToModifierMap::const_iterator i = m_keycodeToModifier.find(keycode);
|
|
|
|
if (i != m_keycodeToModifier.end()) {
|
|
|
|
ModifierMask bit = (1 << i->second);
|
|
|
|
if (getBits(m_toggleModifierMask, bit) != 0) {
|
2003-07-05 14:49:08 +00:00
|
|
|
// toggle keys modify the state on release
|
2003-07-01 19:35:28 +00:00
|
|
|
return flipBits(m_mask, bit);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// can't reset bit until all keys that set it are released.
|
|
|
|
// scan those keys to see if any (except keycode) are pressed.
|
|
|
|
KeyCodes::const_iterator j;
|
|
|
|
const KeyCodes& keycodes = m_modifierKeycodes[i->second];
|
|
|
|
for (j = keycodes.begin(); j != keycodes.end(); ++j) {
|
|
|
|
KeyCode modKeycode = *j;
|
|
|
|
if (modKeycode != keycode && m_keys[modKeycode]) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j == keycodes.end()) {
|
|
|
|
return clearBits(m_mask, bit);
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
CXWindowsSecondaryScreen::findBestKeyIndex(KeySymIndex keyIndex,
|
|
|
|
ModifierMask /*currentMask*/) const
|
|
|
|
{
|
|
|
|
// there are up to 4 keycodes per keysym to choose from. the
|
|
|
|
// best choice is the one that requires the fewest adjustments
|
|
|
|
// to the modifier state. for example, the letter A normally
|
|
|
|
// requires shift + a. if shift isn't already down we'd have
|
|
|
|
// to synthesize a shift press before the a press. however,
|
|
|
|
// if A could also be created with some other keycode without
|
|
|
|
// shift then we'd prefer that when shift wasn't down.
|
|
|
|
//
|
|
|
|
// if the action is kRepeat or kRelease then we don't call this
|
|
|
|
// method since we just need to synthesize a key repeat/release
|
|
|
|
// on the same keycode that we pressed.
|
|
|
|
// XXX -- do this right
|
|
|
|
for (unsigned int i = 0; i < 4; ++i) {
|
|
|
|
if (keyIndex->second.m_keycode[i] != 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
assert(0 && "no keycode found for keysym");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::isShiftInverted(KeySymIndex keyIndex,
|
|
|
|
ModifierMask currentMask) const
|
|
|
|
{
|
|
|
|
// each keycode has up to 4 keysym associated with it, one each for:
|
|
|
|
// no modifiers, shift, mode switch, and shift and mode switch. if
|
|
|
|
// a keysym is modified by num lock and num lock is active then you
|
|
|
|
// get the shifted keysym when shift is not down and the unshifted
|
|
|
|
// keysym when it is. that is, num lock inverts the sense of the
|
|
|
|
// shift modifier when active. similarly for caps lock. this
|
|
|
|
// method returns true iff the sense of shift should be inverted
|
|
|
|
// for this key given a modifier state.
|
|
|
|
if (keyIndex->second.m_numLockSensitive) {
|
|
|
|
if (getBits(currentMask, m_numLockMask) != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
// if a keysym is num lock sensitive it is never caps lock
|
|
|
|
// sensitive, thus the else here.
|
|
|
|
else if (keyIndex->second.m_capsLockSensitive) {
|
|
|
|
if (getBits(currentMask, m_capsLockMask) != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
CXWindowsSecondaryScreen::ModifierMask
|
|
|
|
CXWindowsSecondaryScreen::getModifierMask(KeySym keysym) const
|
|
|
|
{
|
|
|
|
// find the keysym mapping. if it exists and there's a keycode
|
|
|
|
// for index 0 (the index we use for modifiers) then return the
|
|
|
|
// modifierMask, which might be 0. otherwise return 0.
|
|
|
|
KeySymIndex keyIndex = m_keysymMap.find(keysym);
|
|
|
|
if (keyIndex != m_keysymMap.end() && keyIndex->second.m_keycode[0] != 0) {
|
|
|
|
return keyIndex->second.m_modifierMask;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-07-01 19:35:28 +00:00
|
|
|
return 0;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::mapToKeystrokes(Keystrokes& keys,
|
|
|
|
KeyCode& keycode,
|
|
|
|
ModifierMask& finalMask,
|
|
|
|
KeySymIndex keyIndex,
|
|
|
|
ModifierMask currentMask,
|
|
|
|
EKeyAction action) const
|
|
|
|
{
|
|
|
|
// keyIndex must be valid
|
|
|
|
assert(keyIndex != m_keysymMap.end());
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// get the keysym we're trying to generate and possible keycodes
|
|
|
|
const KeySym keysym = keyIndex->first;
|
|
|
|
const KeyMapping& mapping = keyIndex->second;
|
|
|
|
LOG((CLOG_DEBUG2 "keysym = 0x%08x", keysym));
|
|
|
|
|
|
|
|
// get the best keycode index for the keysym and modifiers. note
|
|
|
|
// that (bestIndex & 1) == 0 if the keycode is a shift modifier
|
|
|
|
// and (bestIndex & 2) == 0 if the keycode is a mode switch
|
|
|
|
// modifier. this is important later because we don't want
|
|
|
|
// adjustModifiers() to adjust a modifier if that's the key we're
|
|
|
|
// mapping.
|
|
|
|
unsigned int bestIndex = findBestKeyIndex(keyIndex, currentMask);
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// get the keycode
|
|
|
|
keycode = mapping.m_keycode[bestIndex];
|
|
|
|
|
|
|
|
// flip low bit of bestIndex if shift is inverted. if there's a
|
|
|
|
// keycode for this new index then use it. otherwise use the old
|
|
|
|
// keycode. you'd think we should fail if there isn't a keycode
|
|
|
|
// for the new index but some keymaps only include the upper case
|
|
|
|
// keysyms (notably those on Sun Solaris) so to handle the missing
|
|
|
|
// lower case keysyms we just use the old keycode. note that
|
|
|
|
// isShiftInverted() will always return false for a shift modifier.
|
|
|
|
if (isShiftInverted(keyIndex, currentMask)) {
|
|
|
|
LOG((CLOG_DEBUG2 "shift is inverted"));
|
|
|
|
bestIndex ^= 1;
|
|
|
|
if (mapping.m_keycode[bestIndex] != 0) {
|
|
|
|
keycode = mapping.m_keycode[bestIndex];
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
}
|
|
|
|
LOG((CLOG_DEBUG2 "bestIndex = %d, keycode = %d", bestIndex, keycode));
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// compute desired mask. the desired mask is the one that matches
|
|
|
|
// bestIndex, except if the key being synthesized is a shift key
|
|
|
|
// where we desire what we already have or if it's the mode switch
|
|
|
|
// key where we only desire to adjust shift. also, if the keycode
|
|
|
|
// is not sensitive to shift then don't adjust it, otherwise
|
|
|
|
// something like shift+home would become just home. similiarly
|
|
|
|
// for mode switch.
|
|
|
|
ModifierMask desiredMask = currentMask;
|
|
|
|
if (keyIndex->second.m_modifierMask != m_shiftMask) {
|
|
|
|
if (keyIndex->second.m_shiftSensitive[bestIndex]) {
|
|
|
|
if ((bestIndex & 1) != 0) {
|
|
|
|
desiredMask = setBits(desiredMask, m_shiftMask);
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-07-01 19:35:28 +00:00
|
|
|
desiredMask = clearBits(desiredMask, m_shiftMask);
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
if (keyIndex->second.m_modifierMask != m_modeSwitchMask) {
|
|
|
|
if (keyIndex->second.m_modeSwitchSensitive[bestIndex]) {
|
|
|
|
if ((bestIndex & 2) != 0) {
|
|
|
|
desiredMask = setBits(desiredMask, m_modeSwitchMask);
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
2002-06-22 12:09:49 +00:00
|
|
|
else {
|
2003-07-01 19:35:28 +00:00
|
|
|
desiredMask = clearBits(desiredMask, m_modeSwitchMask);
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// adjust the modifiers to match the desired modifiers
|
|
|
|
Keystrokes undo;
|
|
|
|
ModifierMask tmpMask = currentMask;
|
|
|
|
if (!adjustModifiers(keys, undo, tmpMask, desiredMask)) {
|
|
|
|
LOG((CLOG_DEBUG2 "failed to adjust modifiers"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-04-30 16:25:29 +00:00
|
|
|
// note if the press of a half-duplex key should be treated as a release
|
2003-07-01 19:35:28 +00:00
|
|
|
const bool isHalfDuplex =
|
|
|
|
((keysym == m_capsLockKeysym && m_capsLockHalfDuplex) ||
|
|
|
|
(keysym == m_numLockKeysym && m_numLockHalfDuplex));
|
|
|
|
if (isHalfDuplex && getBits(currentMask, mapping.m_modifierMask) != 0) {
|
2002-05-03 11:26:44 +00:00
|
|
|
action = kRelease;
|
2002-04-30 16:25:29 +00:00
|
|
|
}
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// add the key event
|
2003-07-01 19:35:28 +00:00
|
|
|
Keystroke keystroke;
|
2002-05-03 11:26:44 +00:00
|
|
|
keystroke.m_keycode = keycode;
|
|
|
|
switch (action) {
|
|
|
|
case kPress:
|
|
|
|
keystroke.m_press = True;
|
2002-05-05 19:52:03 +00:00
|
|
|
keystroke.m_repeat = false;
|
2002-05-03 11:26:44 +00:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kRelease:
|
|
|
|
keystroke.m_press = False;
|
2002-05-05 19:52:03 +00:00
|
|
|
keystroke.m_repeat = false;
|
2002-05-03 11:26:44 +00:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kRepeat:
|
|
|
|
keystroke.m_press = False;
|
2002-05-05 19:52:03 +00:00
|
|
|
keystroke.m_repeat = true;
|
2002-05-03 11:26:44 +00:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = True;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// put undo keystrokes at end of keystrokes in reverse order
|
2002-04-26 17:38:01 +00:00
|
|
|
while (!undo.empty()) {
|
|
|
|
keys.push_back(undo.back());
|
|
|
|
undo.pop_back();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the key is a modifier key then compute the modifier map after
|
2002-09-14 12:07:02 +00:00
|
|
|
// this key is pressed or released.
|
2003-07-01 19:35:28 +00:00
|
|
|
finalMask = currentMask;
|
|
|
|
if (mapping.m_modifierMask != 0) {
|
2002-09-14 12:07:02 +00:00
|
|
|
// can't be repeating if we've gotten here
|
|
|
|
assert(action != kRepeat);
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2002-05-04 18:09:02 +00:00
|
|
|
// toggle keys modify the state on release. other keys set the
|
|
|
|
// bit on press and clear the bit on release. if half-duplex
|
|
|
|
// then toggle each time we get here.
|
2003-07-01 19:35:28 +00:00
|
|
|
if (getBits(m_toggleModifierMask, mapping.m_modifierMask) != 0) {
|
|
|
|
if (isHalfDuplex) {
|
|
|
|
finalMask = flipBits(finalMask, mapping.m_modifierMask);
|
2002-05-04 18:09:02 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
2002-05-03 11:26:44 +00:00
|
|
|
else if (action == kPress) {
|
2003-07-01 19:35:28 +00:00
|
|
|
finalMask = setBits(finalMask, mapping.m_modifierMask);
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::adjustModifiers(Keystrokes& keys,
|
|
|
|
Keystrokes& undo,
|
|
|
|
ModifierMask& inOutMask,
|
|
|
|
ModifierMask desiredMask) const
|
|
|
|
{
|
|
|
|
// get mode switch set correctly. do this before shift because
|
|
|
|
// mode switch may be sensitive to the shift modifier and will
|
|
|
|
// set/reset it as necessary.
|
|
|
|
const bool wantModeSwitch = ((desiredMask & m_modeSwitchMask) != 0);
|
|
|
|
const bool haveModeSwitch = ((inOutMask & m_modeSwitchMask) != 0);
|
|
|
|
if (wantModeSwitch != haveModeSwitch) {
|
|
|
|
LOG((CLOG_DEBUG2 "fix mode switch"));
|
|
|
|
|
|
|
|
// adjust shift if necessary
|
|
|
|
KeySymIndex modeSwitchIndex = m_keysymMap.find(m_modeSwitchKeysym);
|
|
|
|
assert(modeSwitchIndex != m_keysymMap.end());
|
|
|
|
if (modeSwitchIndex->second.m_shiftSensitive[0]) {
|
|
|
|
const bool wantShift = false;
|
|
|
|
const bool haveShift = ((inOutMask & m_shiftMask) != 0);
|
|
|
|
if (wantShift != haveShift) {
|
|
|
|
// add shift keystrokes
|
|
|
|
LOG((CLOG_DEBUG2 "fix shift for mode switch"));
|
|
|
|
if (!adjustModifier(keys, undo, m_shiftKeysym, wantShift)) {
|
|
|
|
return false;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
inOutMask ^= m_shiftMask;
|
2002-05-04 19:43:20 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add mode switch keystrokes
|
|
|
|
if (!adjustModifier(keys, undo, m_modeSwitchKeysym, wantModeSwitch)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
inOutMask ^= m_modeSwitchMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get shift set correctly
|
|
|
|
const bool wantShift = ((desiredMask & m_shiftMask) != 0);
|
|
|
|
const bool haveShift = ((inOutMask & m_shiftMask) != 0);
|
|
|
|
if (wantShift != haveShift) {
|
|
|
|
// add shift keystrokes
|
|
|
|
LOG((CLOG_DEBUG2 "fix shift"));
|
|
|
|
if (!adjustModifier(keys, undo, m_shiftKeysym, wantShift)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
inOutMask ^= m_shiftMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::adjustModifier(Keystrokes& keys,
|
|
|
|
Keystrokes& undo, KeySym keysym, bool desireActive) const
|
|
|
|
{
|
|
|
|
// this method generates keystrokes to change a modifier into the
|
|
|
|
// desired state. under X11, we only expect to adjust the shift
|
|
|
|
// and mode switch states. other modifiers don't affect keysym
|
|
|
|
// generation, except num lock and caps lock and we don't change
|
|
|
|
// those but instead just invert the handling of the shift key.
|
|
|
|
// we don't check here if the modifier is already in the desired
|
|
|
|
// state; the caller should do that.
|
|
|
|
|
|
|
|
// get the key mapping for keysym
|
|
|
|
KeySymIndex keyIndex = m_keysymMap.find(keysym);
|
|
|
|
if (keyIndex == m_keysymMap.end() || keyIndex->second.m_keycode[0] == 0) {
|
|
|
|
// no keycode for keysym or keycode is not a modifier
|
|
|
|
LOG((CLOG_DEBUG2 "no modifier for 0x%08x", keysym));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this had better be a modifier
|
|
|
|
assert(keyIndex->second.m_modifierMask != 0);
|
|
|
|
|
|
|
|
// we do not handle toggle modifiers here. they never need to be
|
|
|
|
// adjusted
|
|
|
|
assert((keyIndex->second.m_modifierMask & m_toggleModifierMask) == 0);
|
|
|
|
|
|
|
|
// initialize keystroke
|
|
|
|
Keystroke keystroke;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
|
|
|
|
// releasing a modifier is quite different from pressing one.
|
|
|
|
// when we release a modifier we have to release every keycode that
|
|
|
|
// is assigned to the modifier since the modifier is active if any
|
|
|
|
// one of them is down. when we press a modifier we just have to
|
|
|
|
// press one of those keycodes.
|
|
|
|
if (desireActive) {
|
|
|
|
// press
|
|
|
|
keystroke.m_keycode = keyIndex->second.m_keycode[0];
|
|
|
|
keystroke.m_press = True;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = False;
|
|
|
|
undo.push_back(keystroke);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// release
|
|
|
|
KeyCodeToModifierMap::const_iterator index =
|
|
|
|
m_keycodeToModifier.find(keyIndex->second.m_keycode[0]);
|
|
|
|
if (index != m_keycodeToModifier.end()) {
|
|
|
|
const KeyCodes& keycodes = m_modifierKeycodes[index->second];
|
|
|
|
for (KeyCodes::const_iterator j = keycodes.begin();
|
|
|
|
j != keycodes.end(); ++j) {
|
|
|
|
if (m_keys[*j]) {
|
|
|
|
keystroke.m_keycode = *j;
|
|
|
|
keystroke.m_press = False;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = True;
|
|
|
|
undo.push_back(keystroke);
|
|
|
|
}
|
2002-05-04 11:23:11 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
return true;
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::doKeystrokes(const Keystrokes& keys, SInt32 count)
|
2002-05-03 11:26:44 +00:00
|
|
|
{
|
|
|
|
// do nothing if no keys or no repeats
|
2002-06-10 22:06:45 +00:00
|
|
|
if (count < 1 || keys.empty()) {
|
2002-05-03 11:26:44 +00:00
|
|
|
return;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-05-03 11:26:44 +00:00
|
|
|
|
|
|
|
// lock display
|
2002-07-13 22:00:38 +00:00
|
|
|
CDisplayLock display(m_screen);
|
2002-05-03 11:26:44 +00:00
|
|
|
|
|
|
|
// generate key events
|
|
|
|
for (Keystrokes::const_iterator k = keys.begin(); k != keys.end(); ) {
|
|
|
|
if (k->m_repeat) {
|
|
|
|
// repeat from here up to but not including the next key
|
|
|
|
// with m_repeat == false count times.
|
|
|
|
Keystrokes::const_iterator start = k;
|
|
|
|
for (; count > 0; --count) {
|
|
|
|
// send repeating events
|
|
|
|
for (k = start; k != keys.end() && k->m_repeat; ++k) {
|
|
|
|
XTestFakeKeyEvent(display,
|
2002-05-03 11:49:30 +00:00
|
|
|
k->m_keycode, k->m_press, CurrentTime);
|
2002-05-03 11:26:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// note -- k is now on the first non-repeat key after the
|
|
|
|
// repeat keys, exactly where we'd like to continue from.
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// send event
|
2003-07-01 19:35:28 +00:00
|
|
|
LOG((CLOG_DEBUG2 "keystrokes:"));
|
|
|
|
LOG((CLOG_DEBUG2 " %d %s", k->m_keycode, k->m_press ? "down" : "up"));
|
2002-05-03 11:26:44 +00:00
|
|
|
XTestFakeKeyEvent(display, k->m_keycode, k->m_press, CurrentTime);
|
|
|
|
|
|
|
|
// next key
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update
|
|
|
|
XSync(display, False);
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
CXWindowsSecondaryScreen::ModifierMask
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::maskToX(KeyModifierMask inMask) const
|
2002-04-26 17:38:01 +00:00
|
|
|
{
|
2003-07-01 19:35:28 +00:00
|
|
|
ModifierMask outMask = 0;
|
2002-06-10 22:06:45 +00:00
|
|
|
if (inMask & KeyModifierShift) {
|
2003-07-01 19:35:28 +00:00
|
|
|
outMask |= m_shiftMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierControl) {
|
2003-07-01 19:35:28 +00:00
|
|
|
outMask |= m_ctrlMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierAlt) {
|
2002-09-01 15:30:00 +00:00
|
|
|
outMask |= m_altMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierMeta) {
|
2002-09-01 15:30:00 +00:00
|
|
|
outMask |= m_metaMask;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
if (inMask & KeyModifierSuper) {
|
|
|
|
outMask |= m_superMask;
|
|
|
|
}
|
2002-09-01 15:30:00 +00:00
|
|
|
if (inMask & KeyModifierModeSwitch) {
|
|
|
|
outMask |= m_modeSwitchMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierCapsLock) {
|
2002-04-30 17:48:11 +00:00
|
|
|
outMask |= m_capsLockMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierNumLock) {
|
2002-04-30 17:48:11 +00:00
|
|
|
outMask |= m_numLockMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
|
|
|
if (inMask & KeyModifierScrollLock) {
|
2002-04-30 17:48:11 +00:00
|
|
|
outMask |= m_scrollLockMask;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
return outMask;
|
|
|
|
}
|
|
|
|
|
2002-07-01 13:03:16 +00:00
|
|
|
void
|
2003-03-12 22:34:07 +00:00
|
|
|
CXWindowsSecondaryScreen::doReleaseKeys(Display* display)
|
2002-07-01 13:03:16 +00:00
|
|
|
{
|
2002-07-13 22:00:38 +00:00
|
|
|
assert(display != NULL);
|
2002-07-01 13:03:16 +00:00
|
|
|
|
2003-03-16 17:40:56 +00:00
|
|
|
// key release for each key that we faked a press for
|
2002-07-13 22:00:38 +00:00
|
|
|
for (UInt32 i = 0; i < 256; ++i) {
|
2003-03-16 17:40:56 +00:00
|
|
|
if (m_fakeKeys[i]) {
|
2002-07-13 22:00:38 +00:00
|
|
|
XTestFakeKeyEvent(display, i, False, CurrentTime);
|
2003-03-16 17:40:56 +00:00
|
|
|
m_fakeKeys[i] = false;
|
|
|
|
m_keys[i] = false;
|
2002-07-01 13:03:16 +00:00
|
|
|
}
|
2002-07-12 20:41:23 +00:00
|
|
|
}
|
2002-07-01 13:03:16 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2003-03-16 17:40:56 +00:00
|
|
|
CXWindowsSecondaryScreen::doUpdateKeys(Display* display)
|
2002-04-26 17:38:01 +00:00
|
|
|
{
|
2002-12-15 22:39:59 +00:00
|
|
|
// query the button mapping
|
|
|
|
UInt32 numButtons = XGetPointerMapping(display, NULL, 0);
|
|
|
|
unsigned char* tmpButtons = new unsigned char[numButtons];
|
|
|
|
XGetPointerMapping(display, tmpButtons, numButtons);
|
|
|
|
|
|
|
|
// find the largest logical button id
|
|
|
|
unsigned char maxButton = 0;
|
|
|
|
for (UInt32 i = 0; i < numButtons; ++i) {
|
|
|
|
if (tmpButtons[i] > maxButton) {
|
|
|
|
maxButton = tmpButtons[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allocate button array
|
|
|
|
m_buttons.resize(maxButton);
|
|
|
|
|
|
|
|
// fill in button array values. m_buttons[i] is the physical
|
|
|
|
// button number for logical button i+1.
|
|
|
|
for (UInt32 i = 0; i < numButtons; ++i) {
|
2002-08-18 17:31:48 +00:00
|
|
|
m_buttons[i] = 0;
|
|
|
|
}
|
|
|
|
for (UInt32 i = 0; i < numButtons; ++i) {
|
|
|
|
m_buttons[tmpButtons[i] - 1] = i + 1;
|
|
|
|
}
|
|
|
|
|
2002-12-15 22:39:59 +00:00
|
|
|
// clean up
|
|
|
|
delete[] tmpButtons;
|
|
|
|
|
2003-03-16 17:40:56 +00:00
|
|
|
// update mappings and current modifiers
|
2003-07-01 19:35:28 +00:00
|
|
|
updateKeysymMap(display);
|
2003-03-16 17:40:56 +00:00
|
|
|
updateModifiers(display);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::updateKeys()
|
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// ask server which keys are pressed
|
|
|
|
char keys[32];
|
|
|
|
XQueryKeymap(display, keys);
|
|
|
|
|
|
|
|
// transfer to our state
|
2002-07-01 13:03:16 +00:00
|
|
|
for (UInt32 i = 0, j = 0; i < 32; j += 8, ++i) {
|
2002-04-26 17:38:01 +00:00
|
|
|
m_keys[j + 0] = ((keys[i] & 0x01) != 0);
|
|
|
|
m_keys[j + 1] = ((keys[i] & 0x02) != 0);
|
|
|
|
m_keys[j + 2] = ((keys[i] & 0x04) != 0);
|
|
|
|
m_keys[j + 3] = ((keys[i] & 0x08) != 0);
|
|
|
|
m_keys[j + 4] = ((keys[i] & 0x10) != 0);
|
|
|
|
m_keys[j + 5] = ((keys[i] & 0x20) != 0);
|
|
|
|
m_keys[j + 6] = ((keys[i] & 0x40) != 0);
|
|
|
|
m_keys[j + 7] = ((keys[i] & 0x80) != 0);
|
|
|
|
}
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-03-16 17:40:56 +00:00
|
|
|
// we've fake pressed no keys
|
|
|
|
m_fakeKeys.reset();
|
|
|
|
|
|
|
|
// update mappings and current modifiers and mouse buttons
|
|
|
|
doUpdateKeys(display);
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
|
2003-03-12 22:34:07 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::releaseKeys()
|
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
if (display != NULL) {
|
|
|
|
doReleaseKeys(display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2003-07-01 19:35:28 +00:00
|
|
|
CXWindowsSecondaryScreen::updateKeysymMap(Display* display)
|
2002-04-26 17:38:01 +00:00
|
|
|
{
|
2002-09-01 15:30:00 +00:00
|
|
|
// there are up to 4 keysyms per keycode
|
2002-09-14 12:07:02 +00:00
|
|
|
static const unsigned int maxKeysyms = 4;
|
|
|
|
|
2002-04-26 17:38:01 +00:00
|
|
|
// get the number of keycodes
|
|
|
|
int minKeycode, maxKeycode;
|
|
|
|
XDisplayKeycodes(display, &minKeycode, &maxKeycode);
|
|
|
|
const int numKeycodes = maxKeycode - minKeycode + 1;
|
|
|
|
|
|
|
|
// get the keyboard mapping for all keys
|
|
|
|
int keysymsPerKeycode;
|
|
|
|
KeySym* keysyms = XGetKeyboardMapping(display,
|
|
|
|
minKeycode, numKeycodes,
|
|
|
|
&keysymsPerKeycode);
|
|
|
|
|
2002-09-04 20:17:54 +00:00
|
|
|
// we only understand up to maxKeysyms keysyms per keycodes
|
2002-09-14 12:07:02 +00:00
|
|
|
unsigned int numKeysyms = keysymsPerKeycode;
|
2002-09-04 20:17:54 +00:00
|
|
|
if (numKeysyms > maxKeysyms) {
|
|
|
|
numKeysyms = maxKeysyms;
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// get modifier map from server
|
|
|
|
XModifierKeymap* modifiers = XGetModifierMapping(display);
|
|
|
|
|
|
|
|
// determine shift and mode switch sensitivity. a keysym is shift
|
|
|
|
// or mode switch sensitive if its keycode is. a keycode is mode
|
|
|
|
// mode switch sensitive if it has keysyms for indices 2 or 3.
|
|
|
|
// it's shift sensitive if the keysym for index 1 (if any) is
|
|
|
|
// different from the keysym for index 0 and, if the keysym for
|
|
|
|
// for index 3 (if any) is different from the keysym for index 2.
|
|
|
|
// that is, if shift changes the generated keysym for the keycode.
|
|
|
|
std::vector<bool> usesShift(numKeycodes);
|
|
|
|
std::vector<bool> usesModeSwitch(numKeycodes);
|
2002-04-26 17:38:01 +00:00
|
|
|
for (int i = 0; i < numKeycodes; ++i) {
|
2003-07-01 19:35:28 +00:00
|
|
|
// check mode switch first
|
|
|
|
if (numKeysyms > 2 &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 2] != NoSymbol ||
|
|
|
|
keysyms[i * keysymsPerKeycode + 3] != NoSymbol) {
|
|
|
|
usesModeSwitch[i] = true;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// check index 0 with index 1 keysyms
|
|
|
|
if (keysyms[i * keysymsPerKeycode + 0] != NoSymbol &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 1] != NoSymbol &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 1] !=
|
|
|
|
keysyms[i * keysymsPerKeycode + 0]) {
|
|
|
|
usesShift[i] = true;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
else if (numKeysyms >= 4 &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 2] != NoSymbol &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 3] != NoSymbol &&
|
|
|
|
keysyms[i * keysymsPerKeycode + 3] !=
|
|
|
|
keysyms[i * keysymsPerKeycode + 2]) {
|
|
|
|
usesShift[i] = true;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// initialize
|
2003-07-01 19:35:28 +00:00
|
|
|
m_keysymMap.clear();
|
|
|
|
int keysPerModifier = modifiers->max_keypermod;
|
|
|
|
|
|
|
|
// for each modifier keycode, get the index 0 keycode and add it to
|
|
|
|
// the keysym map. also collect all keycodes for each modifier.
|
|
|
|
m_keycodeToModifier.clear();
|
|
|
|
for (ModifierIndex i = 0; i < 8; ++i) {
|
|
|
|
// start with no keycodes for this modifier
|
|
|
|
m_modifierKeycodes[i].clear();
|
|
|
|
|
|
|
|
// add each keycode for modifier
|
|
|
|
for (unsigned int j = 0; j < keysPerModifier; ++j) {
|
|
|
|
// get keycode and ignore unset keycodes
|
|
|
|
KeyCode keycode = modifiers->modifiermap[i * keysPerModifier + j];
|
2002-09-01 15:30:00 +00:00
|
|
|
if (keycode == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// save keycode for modifier and modifier for keycode
|
|
|
|
m_modifierKeycodes[i].push_back(keycode);
|
|
|
|
m_keycodeToModifier[keycode] = i;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// get keysym and get/create key mapping
|
|
|
|
const int keycodeIndex = keycode - minKeycode;
|
|
|
|
const KeySym keysym = keysyms[keycodeIndex *
|
|
|
|
keysymsPerKeycode + 0];
|
|
|
|
KeyMapping& mapping = m_keysymMap[keysym];
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// skip if we already have a keycode for this index
|
|
|
|
if (mapping.m_keycode[0] != 0) {
|
|
|
|
continue;
|
2002-09-01 15:30:00 +00:00
|
|
|
}
|
2002-04-26 17:38:01 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// fill in keysym info
|
|
|
|
mapping.m_keycode[0] = keycode;
|
|
|
|
mapping.m_shiftSensitive[0] = usesShift[keycodeIndex];
|
|
|
|
mapping.m_modeSwitchSensitive[0] = usesModeSwitch[keycodeIndex];
|
|
|
|
mapping.m_modifierMask = (1 << i);
|
|
|
|
mapping.m_capsLockSensitive = false;
|
|
|
|
mapping.m_numLockSensitive = false;
|
|
|
|
}
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// create a convenient NoSymbol entry (if it doesn't exist yet).
|
|
|
|
// sometimes it's useful to handle NoSymbol like a normal keysym.
|
|
|
|
// remove any entry for NoSymbol. that keysym doesn't count.
|
|
|
|
{
|
|
|
|
KeyMapping& mapping = m_keysymMap[NoSymbol];
|
|
|
|
for (unsigned int i = 0; i < numKeysyms; ++i) {
|
|
|
|
mapping.m_keycode[i] = 0;
|
|
|
|
mapping.m_shiftSensitive[i] = false;
|
|
|
|
mapping.m_modeSwitchSensitive[i] = false;
|
|
|
|
}
|
|
|
|
mapping.m_modifierMask = 0;
|
|
|
|
mapping.m_capsLockSensitive = false;
|
|
|
|
mapping.m_numLockSensitive = false;
|
|
|
|
}
|
2002-09-01 15:30:00 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// add each keysym to the map, unless we've already inserted a key
|
|
|
|
// for that keysym index.
|
|
|
|
for (int i = 0; i < numKeycodes; ++i) {
|
|
|
|
for (unsigned int j = 0; j < numKeysyms; ++j) {
|
|
|
|
// lookup keysym
|
|
|
|
const KeySym keysym = keysyms[i * keysymsPerKeycode + j];
|
|
|
|
if (keysym == NoSymbol) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
KeyMapping& mapping = m_keysymMap[keysym];
|
2002-09-01 15:30:00 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// skip if we already have a keycode for this index
|
|
|
|
if (mapping.m_keycode[j] != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2002-09-01 15:30:00 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// fill in keysym info
|
|
|
|
if (mapping.m_keycode[0] == 0) {
|
|
|
|
mapping.m_modifierMask = 0;
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
mapping.m_keycode[j] = static_cast<KeyCode>(
|
|
|
|
minKeycode + i);
|
|
|
|
mapping.m_shiftSensitive[j] = usesShift[i];
|
|
|
|
mapping.m_modeSwitchSensitive[j] = usesModeSwitch[i];
|
|
|
|
mapping.m_numLockSensitive = adjustForNumLock(keysym);
|
|
|
|
mapping.m_capsLockSensitive = adjustForCapsLock(keysym);
|
2002-04-26 17:38:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// choose the keysym to use for each modifier. if the modifier
|
|
|
|
// isn't mapped then use NoSymbol. if a modifier has both left
|
|
|
|
// and right versions then (arbitrarily) prefer the left. also
|
|
|
|
// collect the available modifier bits.
|
|
|
|
struct CModifierBitInfo {
|
|
|
|
public:
|
|
|
|
KeySym CXWindowsSecondaryScreen::*m_keysym;
|
|
|
|
KeySym m_left;
|
|
|
|
KeySym m_right;
|
|
|
|
};
|
|
|
|
static const CModifierBitInfo s_modifierBitTable[] = {
|
|
|
|
{ &CXWindowsSecondaryScreen::m_shiftKeysym, XK_Shift_L, XK_Shift_R },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_ctrlKeysym, XK_Control_L, XK_Control_R },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_altKeysym, XK_Alt_L, XK_Alt_R },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_metaKeysym, XK_Meta_L, XK_Meta_R },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_superKeysym, XK_Super_L, XK_Super_R },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_modeSwitchKeysym, XK_Mode_switch, NoSymbol },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_numLockKeysym, XK_Num_Lock, NoSymbol },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_capsLockKeysym, XK_Caps_Lock, NoSymbol },
|
|
|
|
{ &CXWindowsSecondaryScreen::m_scrollLockKeysym, XK_Scroll_Lock, NoSymbol }
|
|
|
|
};
|
|
|
|
m_modifierMask = 0;
|
|
|
|
m_toggleModifierMask = 0;
|
|
|
|
for (size_t i = 0; i < sizeof(s_modifierBitTable) /
|
|
|
|
sizeof(s_modifierBitTable[0]); ++i) {
|
|
|
|
const CModifierBitInfo& info = s_modifierBitTable[i];
|
|
|
|
|
|
|
|
// find available keysym
|
|
|
|
KeySymIndex keyIndex = m_keysymMap.find(info.m_left);
|
|
|
|
if (keyIndex == m_keysymMap.end() && info.m_right != NoSymbol) {
|
|
|
|
keyIndex = m_keysymMap.find(info.m_right);
|
|
|
|
}
|
|
|
|
if (keyIndex != m_keysymMap.end() &&
|
|
|
|
keyIndex->second.m_modifierMask != 0) {
|
|
|
|
this->*(info.m_keysym) = keyIndex->first;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this->*(info.m_keysym) = NoSymbol;
|
|
|
|
continue;
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// add modifier bit
|
|
|
|
m_modifierMask |= keyIndex->second.m_modifierMask;
|
|
|
|
if (isToggleKeysym(this->*(info.m_keysym))) {
|
|
|
|
m_toggleModifierMask |= keyIndex->second.m_modifierMask;
|
|
|
|
}
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// if there's no mode switch key mapped then remove all keycodes
|
|
|
|
// that depend on it and no keycode can be mode switch sensitive.
|
|
|
|
if (m_modeSwitchKeysym == NoSymbol) {
|
|
|
|
LOG((CLOG_DEBUG2 "no mode switch in keymap"));
|
|
|
|
for (KeySymMap::iterator i = m_keysymMap.begin();
|
|
|
|
i != m_keysymMap.end(); ) {
|
|
|
|
i->second.m_keycode[2] = 0;
|
|
|
|
i->second.m_keycode[3] = 0;
|
|
|
|
i->second.m_modeSwitchSensitive[0] = false;
|
|
|
|
i->second.m_modeSwitchSensitive[1] = false;
|
|
|
|
i->second.m_modeSwitchSensitive[2] = false;
|
|
|
|
i->second.m_modeSwitchSensitive[3] = false;
|
|
|
|
|
|
|
|
// if this keysym no has no keycodes then remove it
|
|
|
|
// except for the NoSymbol keysym mapping.
|
|
|
|
if (i->second.m_keycode[0] == 0 && i->second.m_keycode[1] == 0) {
|
|
|
|
m_keysymMap.erase(i++);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// cache the bits for the modifier
|
|
|
|
m_shiftMask = getModifierMask(m_shiftKeysym);
|
|
|
|
m_ctrlMask = getModifierMask(m_ctrlKeysym);
|
|
|
|
m_altMask = getModifierMask(m_altKeysym);
|
|
|
|
m_metaMask = getModifierMask(m_metaKeysym);
|
|
|
|
m_superMask = getModifierMask(m_superKeysym);
|
|
|
|
m_capsLockMask = getModifierMask(m_capsLockKeysym);
|
|
|
|
m_numLockMask = getModifierMask(m_numLockKeysym);
|
|
|
|
m_modeSwitchMask = getModifierMask(m_modeSwitchKeysym);
|
|
|
|
m_scrollLockMask = getModifierMask(m_scrollLockKeysym);
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// clean up
|
|
|
|
XFree(keysyms);
|
|
|
|
XFreeModifiermap(modifiers);
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
void
|
|
|
|
CXWindowsSecondaryScreen::updateModifiers(Display* display)
|
|
|
|
{
|
|
|
|
// query the pointer to get the keyboard state
|
|
|
|
Window root, window;
|
|
|
|
int xRoot, yRoot, xWindow, yWindow;
|
|
|
|
unsigned int state;
|
|
|
|
if (!XQueryPointer(display, m_window, &root, &window,
|
|
|
|
&xRoot, &yRoot, &xWindow, &yWindow, &state)) {
|
|
|
|
state = 0;
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// update active modifier mask
|
|
|
|
m_mask = 0;
|
|
|
|
for (ModifierIndex i = 0; i < 8; ++i) {
|
|
|
|
const ModifierMask bit = (1 << i);
|
|
|
|
if ((bit & m_toggleModifierMask) == 0) {
|
|
|
|
for (KeyCodes::const_iterator j = m_modifierKeycodes[i].begin();
|
|
|
|
j != m_modifierKeycodes[i].end(); ++j) {
|
|
|
|
if (m_keys[*j]) {
|
|
|
|
m_mask |= bit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((bit & state) != 0) {
|
|
|
|
// toggle is on
|
|
|
|
m_mask |= bit;
|
|
|
|
}
|
|
|
|
}
|
2003-06-22 15:01:44 +00:00
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
void
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::toggleKey(Display* display,
|
2003-07-01 19:35:28 +00:00
|
|
|
KeySym keysym, ModifierMask mask)
|
2002-04-30 17:48:11 +00:00
|
|
|
{
|
2003-07-01 19:35:28 +00:00
|
|
|
// lookup the key mapping
|
|
|
|
KeySymIndex index = m_keysymMap.find(keysym);
|
|
|
|
if (index == m_keysymMap.end()) {
|
2002-04-30 17:48:11 +00:00
|
|
|
return;
|
2002-06-10 22:06:45 +00:00
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
KeyCode keycode = index->second.m_keycode[0];
|
2002-04-30 17:48:11 +00:00
|
|
|
|
|
|
|
// toggle the key
|
2003-07-01 19:35:28 +00:00
|
|
|
if ((keysym == m_capsLockKeysym && m_capsLockHalfDuplex) ||
|
|
|
|
(keysym == m_numLockKeysym && m_numLockHalfDuplex)) {
|
2002-04-30 17:48:11 +00:00
|
|
|
// "half-duplex" toggle
|
|
|
|
XTestFakeKeyEvent(display, keycode, (m_mask & mask) == 0, CurrentTime);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// normal toggle
|
|
|
|
XTestFakeKeyEvent(display, keycode, True, CurrentTime);
|
|
|
|
XTestFakeKeyEvent(display, keycode, False, CurrentTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
// toggle shadow state
|
|
|
|
m_mask ^= mask;
|
|
|
|
}
|
|
|
|
|
2002-06-10 22:06:45 +00:00
|
|
|
bool
|
2002-06-17 13:31:21 +00:00
|
|
|
CXWindowsSecondaryScreen::isToggleKeysym(KeySym key)
|
2002-04-26 17:38:01 +00:00
|
|
|
{
|
|
|
|
switch (key) {
|
|
|
|
case XK_Caps_Lock:
|
|
|
|
case XK_Shift_Lock:
|
|
|
|
case XK_Num_Lock:
|
|
|
|
case XK_Scroll_Lock:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-05-04 21:40:42 +00:00
|
|
|
// map special KeyID keys to KeySyms
|
|
|
|
#if defined(HAVE_X11_XF86KEYSYM_H)
|
|
|
|
static const KeySym g_mapE000[] =
|
|
|
|
{
|
|
|
|
/* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x18 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x28 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x38 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x48 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x68 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x88 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0x98 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xa0 */ 0, 0, 0, 0,
|
|
|
|
/* 0xa4 */ 0, 0,
|
|
|
|
/* 0xa6 */ XF86XK_Back, XF86XK_Forward,
|
|
|
|
/* 0xa8 */ XF86XK_Refresh, XF86XK_Stop,
|
|
|
|
/* 0xaa */ XF86XK_Search, XF86XK_Favorites,
|
|
|
|
/* 0xac */ XF86XK_HomePage, XF86XK_AudioMute,
|
|
|
|
/* 0xae */ XF86XK_AudioLowerVolume, XF86XK_AudioRaiseVolume,
|
|
|
|
/* 0xb0 */ XF86XK_AudioNext, XF86XK_AudioPrev,
|
|
|
|
/* 0xb2 */ XF86XK_AudioStop, XF86XK_AudioPlay,
|
|
|
|
/* 0xb4 */ XF86XK_Mail, XF86XK_AudioMedia,
|
|
|
|
/* 0xb6 */ XF86XK_Launch0, XF86XK_Launch1,
|
|
|
|
/* 0xb8 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xc0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xc8 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xd0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xd8 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xe0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xe8 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xf0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xf8 */ 0, 0, 0, 0, 0, 0, 0, 0
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
KeySym
|
|
|
|
CXWindowsSecondaryScreen::keyIDToKeySym(KeyID id, ModifierMask mask) const
|
2002-09-14 12:07:02 +00:00
|
|
|
{
|
|
|
|
// convert id to keysym
|
|
|
|
KeySym keysym = NoSymbol;
|
2003-04-24 20:11:38 +00:00
|
|
|
if ((id & 0xfffff000) == 0xe000) {
|
|
|
|
// special character
|
|
|
|
switch (id & 0x0000ff00) {
|
2003-05-04 21:40:42 +00:00
|
|
|
#if defined(HAVE_X11_XF86KEYSYM_H)
|
|
|
|
case 0xe000:
|
2003-07-01 19:35:28 +00:00
|
|
|
return g_mapE000[id & 0xff];
|
2003-05-04 21:40:42 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 20:11:38 +00:00
|
|
|
case 0xee00:
|
|
|
|
// ISO 9995 Function and Modifier Keys
|
|
|
|
if (id == kKeyLeftTab) {
|
|
|
|
keysym = XK_ISO_Left_Tab;
|
|
|
|
}
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-04-24 20:11:38 +00:00
|
|
|
case 0xef00:
|
|
|
|
// MISCELLANY
|
|
|
|
keysym = static_cast<KeySym>(id - 0xef00 + 0xff00);
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-04-24 20:11:38 +00:00
|
|
|
}
|
|
|
|
else if ((id >= 0x0020 && id <= 0x007e) ||
|
|
|
|
(id >= 0x00a0 && id <= 0x00ff)) {
|
|
|
|
// Latin-1 maps directly
|
2003-07-01 19:35:28 +00:00
|
|
|
return static_cast<KeySym>(id);
|
2003-04-24 20:11:38 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// lookup keysym in table
|
2003-07-01 19:35:28 +00:00
|
|
|
return CXWindowsUtil::mapUCS4ToKeySym(id);
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// fail if unknown key
|
|
|
|
if (keysym == NoSymbol) {
|
2003-07-01 19:35:28 +00:00
|
|
|
return keysym;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if kKeyTab is requested with shift active then try XK_ISO_Left_Tab
|
|
|
|
// instead. if that doesn't work, we'll fall back to XK_Tab with
|
|
|
|
// shift active. this is to handle primary screens that don't map
|
|
|
|
// XK_ISO_Left_Tab sending events to secondary screens that do.
|
|
|
|
if (keysym == XK_Tab && (mask & ShiftMask) != 0) {
|
|
|
|
keysym = XK_ISO_Left_Tab;
|
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// some keysyms have emergency backups (particularly the numpad
|
|
|
|
// keys since most laptops don't have a separate numpad and the
|
|
|
|
// numpad overlaying the main keyboard may not have movement
|
|
|
|
// key bindings). figure out the emergency backup.
|
|
|
|
KeySym backupKeysym;
|
|
|
|
switch (keysym) {
|
|
|
|
case XK_KP_Home:
|
|
|
|
backupKeysym = XK_Home;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Left:
|
|
|
|
backupKeysym = XK_Left;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Up:
|
|
|
|
backupKeysym = XK_Up;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Right:
|
|
|
|
backupKeysym = XK_Right;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Down:
|
|
|
|
backupKeysym = XK_Down;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Prior:
|
|
|
|
backupKeysym = XK_Prior;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Next:
|
|
|
|
backupKeysym = XK_Next;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_End:
|
|
|
|
backupKeysym = XK_End;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Insert:
|
|
|
|
backupKeysym = XK_Insert;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_KP_Delete:
|
|
|
|
backupKeysym = XK_Delete;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
case XK_ISO_Left_Tab:
|
|
|
|
backupKeysym = XK_Tab;
|
|
|
|
break;
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
default:
|
|
|
|
backupKeysym = keysym;
|
|
|
|
break;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
// see if the keysym is assigned to any keycode. if not and the
|
|
|
|
// backup keysym is then use the backup keysym.
|
|
|
|
if (backupKeysym != keysym &&
|
|
|
|
m_keysymMap.find(keysym) == m_keysymMap.end() &&
|
|
|
|
m_keysymMap.find(backupKeysym) != m_keysymMap.end()) {
|
|
|
|
keysym = backupKeysym;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
return keysym;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::decomposeKeySym(KeySym keysym,
|
|
|
|
KeySyms& decomposed) const
|
2002-09-14 12:07:02 +00:00
|
|
|
{
|
2003-07-01 19:35:28 +00:00
|
|
|
// unfortunately, X11 doesn't appear to have any way of
|
|
|
|
// decomposing a keysym into its component keysyms. we'll
|
|
|
|
// use a lookup table for certain character sets.
|
|
|
|
const KeySymsMap& table = getDecomposedKeySymTable();
|
|
|
|
KeySymsMap::const_iterator i = table.find(keysym);
|
|
|
|
if (i == table.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
decomposed = i->second;
|
|
|
|
return true;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::adjustForNumLock(KeySym keysym) const
|
|
|
|
{
|
2003-07-01 19:35:28 +00:00
|
|
|
return (IsKeypadKey(keysym) || IsPrivateKeypadKey(keysym));
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsSecondaryScreen::adjustForCapsLock(KeySym keysym) const
|
|
|
|
{
|
|
|
|
KeySym lKey, uKey;
|
|
|
|
XConvertCase(keysym, &lKey, &uKey);
|
2003-07-01 19:35:28 +00:00
|
|
|
return (lKey != uKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
const CXWindowsSecondaryScreen::KeySymsMap&
|
|
|
|
CXWindowsSecondaryScreen::getDecomposedKeySymTable()
|
|
|
|
{
|
|
|
|
static const KeySym s_rawTable[] = {
|
|
|
|
// Latin-1 (ISO 8859-1)
|
|
|
|
XK_Agrave, XK_dead_grave, XK_A, 0,
|
|
|
|
XK_Aacute, XK_dead_acute, XK_A, 0,
|
|
|
|
XK_Acircumflex, XK_dead_circumflex, XK_A, 0,
|
|
|
|
XK_Atilde, XK_dead_tilde, XK_A, 0,
|
|
|
|
XK_Adiaeresis, XK_dead_diaeresis, XK_A, 0,
|
|
|
|
XK_Aring, XK_dead_abovering, XK_A, 0,
|
|
|
|
XK_Ccedilla, XK_dead_cedilla, XK_C, 0,
|
|
|
|
XK_Egrave, XK_dead_grave, XK_E, 0,
|
|
|
|
XK_Eacute, XK_dead_acute, XK_E, 0,
|
|
|
|
XK_Ecircumflex, XK_dead_circumflex, XK_E, 0,
|
|
|
|
XK_Ediaeresis, XK_dead_diaeresis, XK_E, 0,
|
|
|
|
XK_Igrave, XK_dead_grave, XK_I, 0,
|
|
|
|
XK_Iacute, XK_dead_acute, XK_I, 0,
|
|
|
|
XK_Icircumflex, XK_dead_circumflex, XK_I, 0,
|
|
|
|
XK_Idiaeresis, XK_dead_diaeresis, XK_I, 0,
|
|
|
|
XK_Ntilde, XK_dead_tilde, XK_N, 0,
|
|
|
|
XK_Ograve, XK_dead_grave, XK_O, 0,
|
|
|
|
XK_Oacute, XK_dead_acute, XK_O, 0,
|
|
|
|
XK_Ocircumflex, XK_dead_circumflex, XK_O, 0,
|
|
|
|
XK_Otilde, XK_dead_tilde, XK_O, 0,
|
|
|
|
XK_Odiaeresis, XK_dead_diaeresis, XK_O, 0,
|
|
|
|
XK_Ugrave, XK_dead_grave, XK_U, 0,
|
|
|
|
XK_Uacute, XK_dead_acute, XK_U, 0,
|
|
|
|
XK_Ucircumflex, XK_dead_circumflex, XK_U, 0,
|
|
|
|
XK_Udiaeresis, XK_dead_diaeresis, XK_U, 0,
|
|
|
|
XK_Yacute, XK_dead_acute, XK_Y, 0,
|
|
|
|
XK_agrave, XK_dead_grave, XK_a, 0,
|
|
|
|
XK_aacute, XK_dead_acute, XK_a, 0,
|
|
|
|
XK_acircumflex, XK_dead_circumflex, XK_a, 0,
|
|
|
|
XK_atilde, XK_dead_tilde, XK_a, 0,
|
|
|
|
XK_adiaeresis, XK_dead_diaeresis, XK_a, 0,
|
|
|
|
XK_aring, XK_dead_abovering, XK_a, 0,
|
|
|
|
XK_ccedilla, XK_dead_cedilla, XK_c, 0,
|
|
|
|
XK_egrave, XK_dead_grave, XK_e, 0,
|
|
|
|
XK_eacute, XK_dead_acute, XK_e, 0,
|
|
|
|
XK_ecircumflex, XK_dead_circumflex, XK_e, 0,
|
|
|
|
XK_ediaeresis, XK_dead_diaeresis, XK_e, 0,
|
|
|
|
XK_igrave, XK_dead_grave, XK_i, 0,
|
|
|
|
XK_iacute, XK_dead_acute, XK_i, 0,
|
|
|
|
XK_icircumflex, XK_dead_circumflex, XK_i, 0,
|
|
|
|
XK_idiaeresis, XK_dead_diaeresis, XK_i, 0,
|
|
|
|
XK_ntilde, XK_dead_tilde, XK_n, 0,
|
|
|
|
XK_ograve, XK_dead_grave, XK_o, 0,
|
|
|
|
XK_oacute, XK_dead_acute, XK_o, 0,
|
|
|
|
XK_ocircumflex, XK_dead_circumflex, XK_o, 0,
|
|
|
|
XK_otilde, XK_dead_tilde, XK_o, 0,
|
|
|
|
XK_odiaeresis, XK_dead_diaeresis, XK_o, 0,
|
|
|
|
XK_ugrave, XK_dead_grave, XK_u, 0,
|
|
|
|
XK_uacute, XK_dead_acute, XK_u, 0,
|
|
|
|
XK_ucircumflex, XK_dead_circumflex, XK_u, 0,
|
|
|
|
XK_udiaeresis, XK_dead_diaeresis, XK_u, 0,
|
|
|
|
XK_yacute, XK_dead_acute, XK_y, 0,
|
|
|
|
XK_ydiaeresis, XK_dead_diaeresis, XK_y, 0,
|
|
|
|
|
|
|
|
// Latin-2 (ISO 8859-2)
|
|
|
|
XK_Aogonek, XK_dead_ogonek, XK_A, 0,
|
|
|
|
XK_Lcaron, XK_dead_caron, XK_L, 0,
|
|
|
|
XK_Sacute, XK_dead_acute, XK_S, 0,
|
|
|
|
XK_Scaron, XK_dead_caron, XK_S, 0,
|
|
|
|
XK_Scedilla, XK_dead_cedilla, XK_S, 0,
|
|
|
|
XK_Tcaron, XK_dead_caron, XK_T, 0,
|
|
|
|
XK_Zacute, XK_dead_acute, XK_Z, 0,
|
|
|
|
XK_Zcaron, XK_dead_caron, XK_Z, 0,
|
|
|
|
XK_Zabovedot, XK_dead_abovedot, XK_Z, 0,
|
|
|
|
XK_aogonek, XK_dead_ogonek, XK_a, 0,
|
|
|
|
XK_lcaron, XK_dead_caron, XK_l, 0,
|
|
|
|
XK_sacute, XK_dead_acute, XK_s, 0,
|
|
|
|
XK_scaron, XK_dead_caron, XK_s, 0,
|
|
|
|
XK_scedilla, XK_dead_cedilla, XK_s, 0,
|
|
|
|
XK_tcaron, XK_dead_caron, XK_t, 0,
|
|
|
|
XK_zacute, XK_dead_acute, XK_z, 0,
|
|
|
|
XK_zcaron, XK_dead_caron, XK_z, 0,
|
|
|
|
XK_zabovedot, XK_dead_abovedot, XK_z, 0,
|
|
|
|
XK_Racute, XK_dead_acute, XK_R, 0,
|
|
|
|
XK_Abreve, XK_dead_breve, XK_A, 0,
|
|
|
|
XK_Lacute, XK_dead_acute, XK_L, 0,
|
|
|
|
XK_Cacute, XK_dead_acute, XK_C, 0,
|
|
|
|
XK_Ccaron, XK_dead_caron, XK_C, 0,
|
|
|
|
XK_Eogonek, XK_dead_ogonek, XK_E, 0,
|
|
|
|
XK_Ecaron, XK_dead_caron, XK_E, 0,
|
|
|
|
XK_Dcaron, XK_dead_caron, XK_D, 0,
|
|
|
|
XK_Nacute, XK_dead_acute, XK_N, 0,
|
|
|
|
XK_Ncaron, XK_dead_caron, XK_N, 0,
|
|
|
|
XK_Odoubleacute, XK_dead_doubleacute, XK_O, 0,
|
|
|
|
XK_Rcaron, XK_dead_caron, XK_R, 0,
|
|
|
|
XK_Uring, XK_dead_abovering, XK_U, 0,
|
|
|
|
XK_Udoubleacute, XK_dead_doubleacute, XK_U, 0,
|
|
|
|
XK_Tcedilla, XK_dead_cedilla, XK_T, 0,
|
|
|
|
XK_racute, XK_dead_acute, XK_r, 0,
|
|
|
|
XK_abreve, XK_dead_breve, XK_a, 0,
|
|
|
|
XK_lacute, XK_dead_acute, XK_l, 0,
|
|
|
|
XK_cacute, XK_dead_acute, XK_c, 0,
|
|
|
|
XK_ccaron, XK_dead_caron, XK_c, 0,
|
|
|
|
XK_eogonek, XK_dead_ogonek, XK_e, 0,
|
|
|
|
XK_ecaron, XK_dead_caron, XK_e, 0,
|
|
|
|
XK_dcaron, XK_dead_caron, XK_d, 0,
|
|
|
|
XK_nacute, XK_dead_acute, XK_n, 0,
|
|
|
|
XK_ncaron, XK_dead_caron, XK_n, 0,
|
|
|
|
XK_odoubleacute, XK_dead_doubleacute, XK_o, 0,
|
|
|
|
XK_rcaron, XK_dead_caron, XK_r, 0,
|
|
|
|
XK_uring, XK_dead_abovering, XK_u, 0,
|
|
|
|
XK_udoubleacute, XK_dead_doubleacute, XK_u, 0,
|
|
|
|
XK_tcedilla, XK_dead_cedilla, XK_t, 0,
|
|
|
|
|
|
|
|
// Latin-3 (ISO 8859-3)
|
|
|
|
XK_Hcircumflex, XK_dead_circumflex, XK_H, 0,
|
|
|
|
XK_Iabovedot, XK_dead_abovedot, XK_I, 0,
|
|
|
|
XK_Gbreve, XK_dead_breve, XK_G, 0,
|
|
|
|
XK_Jcircumflex, XK_dead_circumflex, XK_J, 0,
|
|
|
|
XK_hcircumflex, XK_dead_circumflex, XK_h, 0,
|
|
|
|
XK_gbreve, XK_dead_breve, XK_g, 0,
|
|
|
|
XK_jcircumflex, XK_dead_circumflex, XK_j, 0,
|
|
|
|
XK_Cabovedot, XK_dead_abovedot, XK_C, 0,
|
|
|
|
XK_Ccircumflex, XK_dead_circumflex, XK_C, 0,
|
|
|
|
XK_Gabovedot, XK_dead_abovedot, XK_G, 0,
|
|
|
|
XK_Gcircumflex, XK_dead_circumflex, XK_G, 0,
|
|
|
|
XK_Ubreve, XK_dead_breve, XK_U, 0,
|
|
|
|
XK_Scircumflex, XK_dead_circumflex, XK_S, 0,
|
|
|
|
XK_cabovedot, XK_dead_abovedot, XK_c, 0,
|
|
|
|
XK_ccircumflex, XK_dead_circumflex, XK_c, 0,
|
|
|
|
XK_gabovedot, XK_dead_abovedot, XK_g, 0,
|
|
|
|
XK_gcircumflex, XK_dead_circumflex, XK_g, 0,
|
|
|
|
XK_ubreve, XK_dead_breve, XK_u, 0,
|
|
|
|
XK_scircumflex, XK_dead_circumflex, XK_s, 0,
|
|
|
|
|
|
|
|
// Latin-4 (ISO 8859-4)
|
|
|
|
XK_scircumflex, XK_dead_circumflex, XK_s, 0,
|
|
|
|
XK_Rcedilla, XK_dead_cedilla, XK_R, 0,
|
|
|
|
XK_Itilde, XK_dead_tilde, XK_I, 0,
|
|
|
|
XK_Lcedilla, XK_dead_cedilla, XK_L, 0,
|
|
|
|
XK_Emacron, XK_dead_macron, XK_E, 0,
|
|
|
|
XK_Gcedilla, XK_dead_cedilla, XK_G, 0,
|
|
|
|
XK_rcedilla, XK_dead_cedilla, XK_r, 0,
|
|
|
|
XK_itilde, XK_dead_tilde, XK_i, 0,
|
|
|
|
XK_lcedilla, XK_dead_cedilla, XK_l, 0,
|
|
|
|
XK_emacron, XK_dead_macron, XK_e, 0,
|
|
|
|
XK_gcedilla, XK_dead_cedilla, XK_g, 0,
|
|
|
|
XK_Amacron, XK_dead_macron, XK_A, 0,
|
|
|
|
XK_Iogonek, XK_dead_ogonek, XK_I, 0,
|
|
|
|
XK_Eabovedot, XK_dead_abovedot, XK_E, 0,
|
|
|
|
XK_Imacron, XK_dead_macron, XK_I, 0,
|
|
|
|
XK_Ncedilla, XK_dead_cedilla, XK_N, 0,
|
|
|
|
XK_Omacron, XK_dead_macron, XK_O, 0,
|
|
|
|
XK_Kcedilla, XK_dead_cedilla, XK_K, 0,
|
|
|
|
XK_Uogonek, XK_dead_ogonek, XK_U, 0,
|
|
|
|
XK_Utilde, XK_dead_tilde, XK_U, 0,
|
|
|
|
XK_Umacron, XK_dead_macron, XK_U, 0,
|
|
|
|
XK_amacron, XK_dead_macron, XK_a, 0,
|
|
|
|
XK_iogonek, XK_dead_ogonek, XK_i, 0,
|
|
|
|
XK_eabovedot, XK_dead_abovedot, XK_e, 0,
|
|
|
|
XK_imacron, XK_dead_macron, XK_i, 0,
|
|
|
|
XK_ncedilla, XK_dead_cedilla, XK_n, 0,
|
|
|
|
XK_omacron, XK_dead_macron, XK_o, 0,
|
|
|
|
XK_kcedilla, XK_dead_cedilla, XK_k, 0,
|
|
|
|
XK_uogonek, XK_dead_ogonek, XK_u, 0,
|
|
|
|
XK_utilde, XK_dead_tilde, XK_u, 0,
|
|
|
|
XK_umacron, XK_dead_macron, XK_u, 0,
|
|
|
|
|
|
|
|
// Latin-8 (ISO 8859-14)
|
|
|
|
XK_Babovedot, XK_dead_abovedot, XK_B, 0,
|
|
|
|
XK_babovedot, XK_dead_abovedot, XK_b, 0,
|
|
|
|
XK_Dabovedot, XK_dead_abovedot, XK_D, 0,
|
|
|
|
XK_Wgrave, XK_dead_grave, XK_W, 0,
|
|
|
|
XK_Wacute, XK_dead_acute, XK_W, 0,
|
|
|
|
XK_dabovedot, XK_dead_abovedot, XK_d, 0,
|
|
|
|
XK_Ygrave, XK_dead_grave, XK_Y, 0,
|
|
|
|
XK_Fabovedot, XK_dead_abovedot, XK_F, 0,
|
|
|
|
XK_fabovedot, XK_dead_abovedot, XK_f, 0,
|
|
|
|
XK_Mabovedot, XK_dead_abovedot, XK_M, 0,
|
|
|
|
XK_mabovedot, XK_dead_abovedot, XK_m, 0,
|
|
|
|
XK_Pabovedot, XK_dead_abovedot, XK_P, 0,
|
|
|
|
XK_wgrave, XK_dead_grave, XK_w, 0,
|
|
|
|
XK_pabovedot, XK_dead_abovedot, XK_p, 0,
|
|
|
|
XK_wacute, XK_dead_acute, XK_w, 0,
|
|
|
|
XK_Sabovedot, XK_dead_abovedot, XK_S, 0,
|
|
|
|
XK_ygrave, XK_dead_grave, XK_y, 0,
|
|
|
|
XK_Wdiaeresis, XK_dead_diaeresis, XK_W, 0,
|
|
|
|
XK_wdiaeresis, XK_dead_diaeresis, XK_w, 0,
|
|
|
|
XK_sabovedot, XK_dead_abovedot, XK_s, 0,
|
|
|
|
XK_Wcircumflex, XK_dead_circumflex, XK_W, 0,
|
|
|
|
XK_Tabovedot, XK_dead_abovedot, XK_T, 0,
|
|
|
|
XK_Ycircumflex, XK_dead_circumflex, XK_Y, 0,
|
|
|
|
XK_wcircumflex, XK_dead_circumflex, XK_w, 0,
|
|
|
|
XK_tabovedot, XK_dead_abovedot, XK_t, 0,
|
|
|
|
XK_ycircumflex, XK_dead_circumflex, XK_y, 0,
|
|
|
|
|
|
|
|
// Latin-9 (ISO 8859-15)
|
|
|
|
XK_Ydiaeresis, XK_dead_diaeresis, XK_Y, 0,
|
|
|
|
|
|
|
|
// end of table
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
// fill table if not yet initialized
|
|
|
|
if (s_decomposedKeySyms.empty()) {
|
|
|
|
const KeySym* scan = s_rawTable;
|
|
|
|
while (*scan != 0) {
|
|
|
|
// add an entry for this keysym
|
|
|
|
KeySyms& entry = s_decomposedKeySyms[*scan];
|
|
|
|
|
|
|
|
// add the decomposed keysyms for the keysym
|
|
|
|
while (*++scan != 0) {
|
|
|
|
entry.push_back(*scan);
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip end of entry marker
|
|
|
|
++scan;
|
|
|
|
}
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
2003-07-01 19:35:28 +00:00
|
|
|
|
|
|
|
return s_decomposedKeySyms;
|
2002-09-14 12:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2003-07-01 19:35:28 +00:00
|
|
|
// CXWindowsSecondaryScreen::KeyMapping
|
2002-09-14 12:07:02 +00:00
|
|
|
//
|
|
|
|
|
2003-07-01 19:35:28 +00:00
|
|
|
CXWindowsSecondaryScreen::KeyMapping::KeyMapping()
|
2002-09-14 12:07:02 +00:00
|
|
|
{
|
|
|
|
m_keycode[0] = 0;
|
|
|
|
m_keycode[1] = 0;
|
|
|
|
m_keycode[2] = 0;
|
|
|
|
m_keycode[3] = 0;
|
|
|
|
}
|