2002-08-02 23:57:46 +04: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-06 18:13:28 +04:00
|
|
|
#include "CXWindowsPrimaryScreen.h"
|
2002-07-14 02:00:38 +04:00
|
|
|
#include "CXWindowsScreen.h"
|
2002-05-27 20:22:59 +04:00
|
|
|
#include "CXWindowsUtil.h"
|
2002-07-14 02:00:38 +04:00
|
|
|
#include "IPrimaryScreenReceiver.h"
|
2002-07-11 22:58:49 +04:00
|
|
|
#include "XScreen.h"
|
2001-10-06 18:13:28 +04:00
|
|
|
#include "CThread.h"
|
2001-10-14 18:37:41 +04:00
|
|
|
#include "CLog.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CStopwatch.h"
|
2002-06-19 15:23:49 +04: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
|
2002-07-23 21:04:41 +04:00
|
|
|
# define XK_XKB_KEYS
|
2002-06-19 15:23:49 +04:00
|
|
|
# include <X11/keysymdef.h>
|
|
|
|
#endif
|
2003-01-05 01:01:32 +03:00
|
|
|
#include "CArch.h"
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// CXWindowsPrimaryScreen
|
|
|
|
//
|
|
|
|
|
2002-07-11 01:22:28 +04:00
|
|
|
CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(
|
|
|
|
IScreenReceiver* receiver,
|
|
|
|
IPrimaryScreenReceiver* primaryReceiver) :
|
2002-07-14 02:00:38 +04:00
|
|
|
CPrimaryScreen(receiver),
|
|
|
|
m_receiver(primaryReceiver),
|
2002-06-11 02:06:45 +04:00
|
|
|
m_window(None)
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
m_screen = new CXWindowsScreen(receiver, this);
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CXWindowsPrimaryScreen::~CXWindowsPrimaryScreen()
|
|
|
|
{
|
2001-11-19 03:33:36 +03:00
|
|
|
assert(m_window == None);
|
2002-07-14 02:00:38 +04:00
|
|
|
delete m_screen;
|
2002-07-11 22:58:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::reconfigure(UInt32)
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
|
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
|
|
|
// warp mouse
|
|
|
|
warpCursorNoFlush(display, x, y);
|
|
|
|
|
|
|
|
// remove all input events before and including warp
|
|
|
|
XEvent event;
|
|
|
|
while (XCheckMaskEvent(display, PointerMotionMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
KeymapStateMask,
|
|
|
|
&event)) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
// save position as last position
|
|
|
|
m_x = x;
|
|
|
|
m_y = y;
|
|
|
|
}
|
|
|
|
|
2002-12-23 16:55:21 +03:00
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::resetOptions()
|
|
|
|
{
|
|
|
|
m_numLockHalfDuplex = false;
|
|
|
|
m_capsLockHalfDuplex = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
KeyModifierMask
|
|
|
|
CXWindowsPrimaryScreen::getToggleMask() const
|
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-13 00:41:23 +04:00
|
|
|
|
|
|
|
// 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)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// convert to KeyModifierMask
|
|
|
|
KeyModifierMask mask = 0;
|
|
|
|
if (state & m_numLockMask) {
|
|
|
|
mask |= KeyModifierNumLock;
|
|
|
|
}
|
|
|
|
if (state & m_capsLockMask) {
|
|
|
|
mask |= KeyModifierCapsLock;
|
|
|
|
}
|
|
|
|
if (state & m_scrollLockMask) {
|
|
|
|
mask |= KeyModifierScrollLock;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsPrimaryScreen::isLockedToScreen() const
|
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-13 00:41:23 +04:00
|
|
|
|
|
|
|
// query the pointer to get the button state
|
|
|
|
Window root, window;
|
|
|
|
int xRoot, yRoot, xWindow, yWindow;
|
|
|
|
unsigned int state;
|
|
|
|
if (XQueryPointer(display, m_window, &root, &window,
|
|
|
|
&xRoot, &yRoot, &xWindow, &yWindow, &state)) {
|
|
|
|
if ((state & (Button1Mask | Button2Mask | Button3Mask |
|
|
|
|
Button4Mask | Button5Mask)) != 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get logical keyboard state
|
|
|
|
char keyMap[32];
|
|
|
|
memset(keyMap, 0, sizeof(keyMap));
|
|
|
|
XQueryKeymap(display, keyMap);
|
|
|
|
|
|
|
|
// locked if any key is down
|
|
|
|
for (unsigned int i = 0; i < sizeof(keyMap); ++i) {
|
|
|
|
if (keyMap[i] != 0) {
|
2002-12-16 01:17:18 +03:00
|
|
|
// if any key is half-duplex then it'll be down when
|
|
|
|
// toggled on but shouldn't count as a reason to lock
|
|
|
|
// to the screen.
|
|
|
|
if (m_numLockHalfDuplex || m_capsLockHalfDuplex) {
|
|
|
|
for (unsigned int j = 0; j < 8; ++j) {
|
|
|
|
if ((keyMap[i] & (1 << j)) != 0) {
|
|
|
|
const KeyCode keycode = 8 * i + j;
|
|
|
|
const KeySym keysym = XKeycodeToKeysym(display,
|
|
|
|
keycode, 0);
|
|
|
|
if (m_numLockHalfDuplex && keysym == XK_Num_Lock) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (m_capsLockHalfDuplex && keysym == XK_Caps_Lock) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// non-half-duplex key down
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// only half-duplex keys down
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// not locked
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
IScreen*
|
|
|
|
CXWindowsPrimaryScreen::getScreen() const
|
|
|
|
{
|
|
|
|
return m_screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::onScreensaver(bool activated)
|
|
|
|
{
|
|
|
|
m_receiver->onScreensaver(activated);
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
bool
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::onPreDispatch(const CEvent*)
|
2002-07-13 00:41:23 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
return false;
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
|
|
|
{
|
|
|
|
assert(event != NULL);
|
|
|
|
XEvent& xevent = event->m_event;
|
|
|
|
|
|
|
|
// handle event
|
|
|
|
switch (xevent.type) {
|
|
|
|
case CreateNotify:
|
|
|
|
{
|
|
|
|
// select events on new window
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-13 00:41:23 +04:00
|
|
|
selectEvents(display, xevent.xcreatewindow.window);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case MappingNotify:
|
2002-07-14 02:00:38 +04:00
|
|
|
// keyboard mapping changed
|
|
|
|
updateKeys();
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
case KeyPress:
|
|
|
|
{
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
2002-07-13 00:41:23 +04:00
|
|
|
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
|
|
|
const KeyID key = mapKey(&xevent.xkey);
|
|
|
|
if (key != kKeyNone) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyDown(key, mask);
|
2002-07-23 21:04:41 +04:00
|
|
|
if (key == kKeyCapsLock && m_capsLockHalfDuplex) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyUp(key, mask | KeyModifierCapsLock);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
2002-07-23 21:04:41 +04:00
|
|
|
else if (key == kKeyNumLock && m_numLockHalfDuplex) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyUp(key, mask | KeyModifierNumLock);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case KeyRelease:
|
|
|
|
{
|
|
|
|
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
|
|
|
const KeyID key = mapKey(&xevent.xkey);
|
|
|
|
if (key != kKeyNone) {
|
|
|
|
// check if this is a key repeat by getting the next
|
|
|
|
// KeyPress event that has the same key and time as
|
|
|
|
// this release event, if any. first prepare the
|
|
|
|
// filter info.
|
|
|
|
CKeyEventInfo filter;
|
|
|
|
filter.m_event = KeyPress;
|
|
|
|
filter.m_window = xevent.xkey.window;
|
|
|
|
filter.m_time = xevent.xkey.time;
|
|
|
|
filter.m_keycode = xevent.xkey.keycode;
|
|
|
|
|
|
|
|
// now check for event
|
2002-07-14 02:00:38 +04:00
|
|
|
bool hasPress;
|
|
|
|
{
|
|
|
|
XEvent xevent2;
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
hasPress = (XCheckIfEvent(display, &xevent2,
|
|
|
|
&CXWindowsPrimaryScreen::findKeyEvent,
|
|
|
|
(XPointer)&filter) == True);
|
|
|
|
}
|
|
|
|
if (!hasPress) {
|
2002-07-13 00:41:23 +04:00
|
|
|
// no press event follows so it's a plain release
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
2002-07-23 21:04:41 +04:00
|
|
|
if (key == kKeyCapsLock && m_capsLockHalfDuplex) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyDown(key, mask);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
2002-07-23 21:04:41 +04:00
|
|
|
else if (key == kKeyNumLock && m_numLockHalfDuplex) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyDown(key, mask);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyUp(key, mask);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// found a press event following so it's a repeat.
|
|
|
|
// we could attempt to count the already queued
|
|
|
|
// repeats but we'll just send a repeat of 1.
|
|
|
|
// note that we discard the press event.
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onKeyRepeat(key, mask, 1);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case ButtonPress:
|
|
|
|
{
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
2002-07-13 00:41:23 +04:00
|
|
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
|
|
|
if (button != kButtonNone) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseDown(button);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case ButtonRelease:
|
|
|
|
{
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
2002-07-13 00:41:23 +04:00
|
|
|
const ButtonID button = mapButton(xevent.xbutton.button);
|
|
|
|
if (button != kButtonNone) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseUp(button);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
else if (xevent.xbutton.button == 4) {
|
|
|
|
// wheel forward (away from user)
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseWheel(120);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
else if (xevent.xbutton.button == 5) {
|
|
|
|
// wheel backward (toward user)
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseWheel(-120);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case MotionNotify:
|
|
|
|
{
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "event: MotionNotify %d,%d", xevent.xmotion.x_root, xevent.xmotion.y_root));
|
2002-07-13 00:41:23 +04:00
|
|
|
|
|
|
|
// compute motion delta (relative to the last known
|
|
|
|
// mouse position)
|
|
|
|
SInt32 x = xevent.xmotion.x_root - m_x;
|
|
|
|
SInt32 y = xevent.xmotion.y_root - m_y;
|
|
|
|
|
|
|
|
// save position to compute delta of next motion
|
|
|
|
m_x = xevent.xmotion.x_root;
|
|
|
|
m_y = xevent.xmotion.y_root;
|
|
|
|
|
|
|
|
if (xevent.xmotion.send_event) {
|
|
|
|
// we warped the mouse. discard events until we
|
|
|
|
// find the matching sent event. see
|
|
|
|
// warpCursorNoFlush() for where the events are
|
|
|
|
// sent. we discard the matching sent event and
|
|
|
|
// can be sure we've skipped the warp event.
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-13 00:41:23 +04:00
|
|
|
do {
|
|
|
|
XMaskEvent(display, PointerMotionMask, &xevent);
|
|
|
|
} while (!xevent.xmotion.send_event);
|
|
|
|
}
|
2002-07-14 02:00:38 +04:00
|
|
|
else if (!isActive()) {
|
2002-07-13 00:41:23 +04:00
|
|
|
// motion on primary screen
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseMovePrimary(m_x, m_y);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// motion on secondary screen. warp mouse back to
|
|
|
|
// center.
|
|
|
|
//
|
|
|
|
// my lombard (powerbook g3) running linux and
|
|
|
|
// using the adbmouse driver has two problems:
|
|
|
|
// first, the driver only sends motions of +/-2
|
|
|
|
// pixels and, second, it seems to discard some
|
|
|
|
// physical input after a warp. the former isn't a
|
|
|
|
// big deal (we're just limited to every other
|
|
|
|
// pixel) but the latter is a PITA. to work around
|
|
|
|
// it we only warp when the mouse has moved more
|
|
|
|
// than s_size pixels from the center.
|
|
|
|
static const SInt32 s_size = 32;
|
|
|
|
if (xevent.xmotion.x_root - m_xCenter < -s_size ||
|
|
|
|
xevent.xmotion.x_root - m_xCenter > s_size ||
|
|
|
|
xevent.xmotion.y_root - m_yCenter < -s_size ||
|
|
|
|
xevent.xmotion.y_root - m_yCenter > s_size) {
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-13 00:41:23 +04:00
|
|
|
warpCursorNoFlush(display, m_xCenter, m_yCenter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// send event if mouse moved. do this after warping
|
|
|
|
// back to center in case the motion takes us onto
|
|
|
|
// the primary screen. if we sent the event first
|
|
|
|
// in that case then the warp would happen after
|
|
|
|
// warping to the primary screen's enter position,
|
|
|
|
// effectively overriding it.
|
|
|
|
if (x != 0 || y != 0) {
|
2002-07-14 02:00:38 +04:00
|
|
|
m_receiver->onMouseMoveSecondary(x, y);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
SInt32
|
|
|
|
CXWindowsPrimaryScreen::getJumpZoneSize() const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
void
|
2002-07-30 19:17:44 +04:00
|
|
|
CXWindowsPrimaryScreen::onPreMainLoop()
|
2002-07-13 00:41:23 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
assert(m_window != None);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::onPreOpen()
|
2002-07-13 00:41:23 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
assert(m_window == None);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::onPostOpen()
|
2002-07-13 00:41:23 +04:00
|
|
|
{
|
2002-12-23 16:55:21 +03:00
|
|
|
assert(m_window != None);
|
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// get cursor info
|
|
|
|
m_screen->getCursorPos(m_x, m_y);
|
|
|
|
m_screen->getCursorCenter(m_xCenter, m_yCenter);
|
2002-07-13 00:41:23 +04:00
|
|
|
}
|
|
|
|
|
2002-07-11 22:58:49 +04:00
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::onPreEnter()
|
2002-07-11 22:58:49 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
assert(m_window != None);
|
2002-07-11 22:58:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::onPreLeave()
|
2002-07-11 22:58:49 +04:00
|
|
|
{
|
|
|
|
assert(m_window != None);
|
2002-07-14 02:00:38 +04:00
|
|
|
}
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::onEnterScreenSaver()
|
|
|
|
{
|
|
|
|
CDisplayLock display(m_screen);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// set keyboard focus to root window. the screensaver should then
|
|
|
|
// pick up key events for when the user enters a password to unlock.
|
|
|
|
XSetInputFocus(display, PointerRoot, PointerRoot, CurrentTime);
|
|
|
|
}
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
void
|
|
|
|
CXWindowsPrimaryScreen::createWindow()
|
|
|
|
{
|
|
|
|
assert(m_window == None);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// get size of screen
|
|
|
|
SInt32 x, y, w, h;
|
|
|
|
m_screen->getShape(x, y, w, h);
|
|
|
|
|
|
|
|
// grab window attributes. this window is used to capture user
|
|
|
|
// input when the user is focused on another client. don't let
|
|
|
|
// the window manager mess with it.
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.event_mask = PointerMotionMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
KeymapStateMask | PropertyChangeMask;
|
|
|
|
attr.do_not_propagate_mask = 0;
|
|
|
|
attr.override_redirect = True;
|
|
|
|
attr.cursor = m_screen->getBlankCursor();
|
|
|
|
|
|
|
|
{
|
|
|
|
// create the grab window
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
m_window = XCreateWindow(display, m_screen->getRoot(),
|
|
|
|
x, y, w, h, 0, 0,
|
|
|
|
InputOnly, CopyFromParent,
|
|
|
|
CWDontPropagate | CWEventMask |
|
|
|
|
CWOverrideRedirect | CWCursor,
|
|
|
|
&attr);
|
|
|
|
if (m_window == None) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG "window is 0x%08x", m_window));
|
2002-07-14 02:00:38 +04:00
|
|
|
|
|
|
|
// start watching for events on other windows
|
|
|
|
selectEvents(display, m_screen->getRoot());
|
|
|
|
}
|
|
|
|
|
2002-07-15 19:01:36 +04:00
|
|
|
// tell generic screen about the window
|
2002-07-14 02:00:38 +04:00
|
|
|
m_screen->setWindow(m_window);
|
2002-07-11 22:58:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::destroyWindow()
|
2002-07-11 22:58:49 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
// display can be NULL if the server unexpectedly disconnected
|
|
|
|
if (m_window != None) {
|
|
|
|
m_screen->setWindow(None);
|
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
if (display != NULL) {
|
|
|
|
XDestroyWindow(display, m_window);
|
|
|
|
}
|
|
|
|
m_window = None;
|
|
|
|
}
|
2002-07-11 22:58:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CXWindowsPrimaryScreen::showWindow()
|
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
assert(m_window != None);
|
|
|
|
|
|
|
|
CDisplayLock display(m_screen);
|
2001-10-25 02:33:24 +04:00
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
// raise and show the input window
|
2001-11-12 00:15:30 +03:00
|
|
|
XMapRaised(display, m_window);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// grab the mouse and keyboard. keep trying until we get them.
|
|
|
|
// if we can't grab one after grabbing the other then ungrab
|
2002-06-03 22:53:18 +04:00
|
|
|
// and wait before retrying. give up after s_timeout seconds.
|
|
|
|
static const double s_timeout = 1.0;
|
2001-10-06 18:13:28 +04:00
|
|
|
int result;
|
2002-06-03 22:53:18 +04:00
|
|
|
CStopwatch timer;
|
2001-10-06 18:13:28 +04:00
|
|
|
do {
|
2002-06-03 22:53:18 +04:00
|
|
|
// keyboard first
|
2001-10-06 18:13:28 +04:00
|
|
|
do {
|
2002-07-19 22:12:41 +04:00
|
|
|
result = XGrabKeyboard(display, m_window, True,
|
2002-06-03 22:53:18 +04:00
|
|
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
2001-10-06 18:13:28 +04:00
|
|
|
assert(result != GrabNotViewable);
|
2001-10-14 18:37:41 +04:00
|
|
|
if (result != GrabSuccess) {
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "waiting to grab keyboard"));
|
2003-01-05 01:01:32 +03:00
|
|
|
ARCH->sleep(0.05);
|
2002-06-03 22:53:18 +04:00
|
|
|
if (timer.getTime() >= s_timeout) {
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "grab keyboard timed out"));
|
2002-06-03 22:53:18 +04:00
|
|
|
XUnmapWindow(display, m_window);
|
|
|
|
return false;
|
|
|
|
}
|
2001-10-14 18:37:41 +04:00
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
} while (result != GrabSuccess);
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "grabbed keyboard"));
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-06-03 22:53:18 +04:00
|
|
|
// now the mouse
|
|
|
|
result = XGrabPointer(display, m_window, True, 0,
|
|
|
|
GrabModeAsync, GrabModeAsync,
|
|
|
|
m_window, None, CurrentTime);
|
2001-10-06 18:13:28 +04:00
|
|
|
assert(result != GrabNotViewable);
|
|
|
|
if (result != GrabSuccess) {
|
2001-11-12 00:15:30 +03:00
|
|
|
// back off to avoid grab deadlock
|
2002-06-03 22:53:18 +04:00
|
|
|
XUngrabKeyboard(display, CurrentTime);
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "ungrabbed keyboard, waiting to grab pointer"));
|
2003-01-05 01:01:32 +03:00
|
|
|
ARCH->sleep(0.05);
|
2002-06-03 22:53:18 +04:00
|
|
|
if (timer.getTime() >= s_timeout) {
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "grab pointer timed out"));
|
2002-06-03 22:53:18 +04:00
|
|
|
XUnmapWindow(display, m_window);
|
|
|
|
return false;
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
} while (result != GrabSuccess);
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG1 "grabbed pointer and keyboard"));
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-06-03 22:53:18 +04:00
|
|
|
return true;
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-11 22:58:49 +04:00
|
|
|
CXWindowsPrimaryScreen::hideWindow()
|
2002-06-01 23:26:11 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
2002-07-11 22:58:49 +04:00
|
|
|
|
|
|
|
// unmap the grab window. this also ungrabs the mouse and keyboard.
|
|
|
|
XUnmapWindow(display, m_window);
|
2002-06-01 23:26:11 +04:00
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::warpCursorToCenter()
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
warpCursor(m_xCenter, m_yCenter);
|
2001-10-25 02:33:24 +04:00
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::warpCursorNoFlush(
|
|
|
|
Display* display, SInt32 x, SInt32 y)
|
2001-10-25 02:33:24 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
assert(display != NULL);
|
|
|
|
assert(m_window != None);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// send an event that we can recognize before the mouse warp
|
|
|
|
XEvent eventBefore;
|
|
|
|
eventBefore.type = MotionNotify;
|
|
|
|
eventBefore.xmotion.display = display;
|
|
|
|
eventBefore.xmotion.window = m_window;
|
|
|
|
eventBefore.xmotion.root = m_screen->getRoot();
|
|
|
|
eventBefore.xmotion.subwindow = m_window;
|
|
|
|
eventBefore.xmotion.time = CurrentTime;
|
|
|
|
eventBefore.xmotion.x = x;
|
|
|
|
eventBefore.xmotion.y = y;
|
|
|
|
eventBefore.xmotion.x_root = x;
|
|
|
|
eventBefore.xmotion.y_root = y;
|
|
|
|
eventBefore.xmotion.state = 0;
|
|
|
|
eventBefore.xmotion.is_hint = False;
|
|
|
|
eventBefore.xmotion.same_screen = True;
|
|
|
|
XEvent eventAfter = eventBefore;
|
|
|
|
XSendEvent(display, m_window, False, 0, &eventBefore);
|
2002-07-03 20:25:36 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// warp mouse
|
|
|
|
XWarpPointer(display, None, m_screen->getRoot(), 0, 0, 0, 0, x, y);
|
2002-07-03 20:25:36 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// send an event that we can recognize after the mouse warp
|
|
|
|
XSendEvent(display, m_window, False, 0, &eventAfter);
|
|
|
|
XSync(display, False);
|
2002-07-03 20:25:36 +04:00
|
|
|
|
2002-10-16 01:29:44 +04:00
|
|
|
LOG((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
2002-07-03 20:25:36 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::selectEvents(Display* display, Window w) const
|
2002-04-29 18:08:48 +04:00
|
|
|
{
|
2002-06-22 17:55:45 +04:00
|
|
|
// ignore errors while we adjust event masks. windows could be
|
|
|
|
// destroyed at any time after the XQueryTree() in doSelectEvents()
|
|
|
|
// so we must ignore BadWindow errors.
|
2002-06-22 23:47:27 +04:00
|
|
|
CXWindowsUtil::CErrorLock lock(display);
|
2002-05-27 22:30:13 +04:00
|
|
|
|
|
|
|
// adjust event masks
|
|
|
|
doSelectEvents(display, w);
|
2002-04-29 18:08:48 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::doSelectEvents(Display* display, Window w) const
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
|
|
|
// we want to track the mouse everywhere on the display. to achieve
|
|
|
|
// that we select PointerMotionMask on every window. we also select
|
|
|
|
// SubstructureNotifyMask in order to get CreateNotify events so we
|
|
|
|
// select events on new windows too.
|
2002-06-22 17:55:45 +04:00
|
|
|
//
|
|
|
|
// note that this can break certain clients due a design flaw of X.
|
|
|
|
// X will deliver a PointerMotion event to the deepest window in the
|
|
|
|
// hierarchy that contains the pointer and has PointerMotionMask
|
|
|
|
// selected by *any* client. if another client doesn't select
|
|
|
|
// motion events in a subwindow so the parent window will get them
|
|
|
|
// then by selecting for motion events on the subwindow we break
|
|
|
|
// that client because the parent will no longer get the events.
|
|
|
|
|
|
|
|
// FIXME -- should provide some workaround for event selection
|
|
|
|
// design flaw. perhaps only select for motion events on windows
|
|
|
|
// that already do or are top-level windows or don't propagate
|
|
|
|
// pointer events. or maybe an option to simply poll the mouse.
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// we don't want to adjust our grab window
|
2002-06-11 02:06:45 +04:00
|
|
|
if (w == m_window) {
|
2001-10-06 18:13:28 +04:00
|
|
|
return;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-06-22 17:55:45 +04:00
|
|
|
// select events of interest. do this before querying the tree so
|
|
|
|
// we'll get notifications of children created after the XQueryTree()
|
|
|
|
// so we won't miss them.
|
2002-04-29 18:08:48 +04:00
|
|
|
XSelectInput(display, w, PointerMotionMask | SubstructureNotifyMask);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// recurse on child windows
|
|
|
|
Window rw, pw, *cw;
|
|
|
|
unsigned int nc;
|
2001-11-12 00:15:30 +03:00
|
|
|
if (XQueryTree(display, w, &rw, &pw, &cw, &nc)) {
|
2002-06-11 02:06:45 +04:00
|
|
|
for (unsigned int i = 0; i < nc; ++i) {
|
2002-05-27 22:30:13 +04:00
|
|
|
doSelectEvents(display, cw[i]);
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-10-26 02:17:17 +04:00
|
|
|
XFree(cw);
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyModifierMask
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::mapModifier(unsigned int state) const
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
|
|
|
KeyModifierMask mask = 0;
|
2002-04-26 21:38:01 +04:00
|
|
|
if (state & ShiftMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierShift;
|
2002-04-26 21:38:01 +04:00
|
|
|
if (state & LockMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierCapsLock;
|
2002-04-26 21:38:01 +04:00
|
|
|
if (state & ControlMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierControl;
|
2002-09-01 19:30:00 +04:00
|
|
|
if (state & m_altMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierAlt;
|
2002-09-01 19:30:00 +04:00
|
|
|
if (state & m_metaMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierMeta;
|
2002-09-14 16:07:02 +04:00
|
|
|
if (state & m_superMask)
|
|
|
|
mask |= KeyModifierSuper;
|
2002-09-01 19:30:00 +04:00
|
|
|
if (state & m_modeSwitchMask)
|
|
|
|
mask |= KeyModifierModeSwitch;
|
|
|
|
if (state & m_numLockMask)
|
|
|
|
mask |= KeyModifierNumLock;
|
|
|
|
if (state & m_scrollLockMask)
|
2001-10-06 18:13:28 +04:00
|
|
|
mask |= KeyModifierScrollLock;
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyID
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::mapKey(XKeyEvent* event) const
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
2002-07-23 21:04:41 +04:00
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
|
|
|
|
// convert to a keysym
|
|
|
|
// FIXME -- we're not properly handling unicode
|
2002-04-26 21:38:01 +04:00
|
|
|
KeySym keysym;
|
|
|
|
char dummy[1];
|
|
|
|
XLookupString(event, dummy, 0, &keysym, NULL);
|
2002-07-23 21:04:41 +04:00
|
|
|
|
|
|
|
// convert key
|
|
|
|
switch (keysym & 0xffffff00) {
|
|
|
|
case 0x0000:
|
|
|
|
// Latin-1
|
|
|
|
return static_cast<KeyID>(keysym);
|
|
|
|
|
|
|
|
case 0xfe00:
|
|
|
|
// ISO 9995 Function and Modifier Keys
|
|
|
|
if (keysym == XK_ISO_Left_Tab) {
|
|
|
|
return kKeyLeftTab;
|
|
|
|
}
|
|
|
|
return kKeyNone;
|
|
|
|
|
|
|
|
case 0xff00:
|
|
|
|
// MISCELLANY
|
|
|
|
return static_cast<KeyID>(keysym - 0xff00 + 0xef00);
|
|
|
|
|
|
|
|
default:
|
|
|
|
// FIXME -- support unicode characters
|
|
|
|
return kKeyNone;
|
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
ButtonID
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::mapButton(unsigned int button) const
|
2001-10-06 18:13:28 +04:00
|
|
|
{
|
|
|
|
// FIXME -- should use button mapping?
|
2002-06-11 02:06:45 +04:00
|
|
|
if (button >= 1 && button <= 3) {
|
2001-10-06 18:13:28 +04:00
|
|
|
return static_cast<ButtonID>(button);
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
else {
|
2001-10-06 18:13:28 +04:00
|
|
|
return kButtonNone;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-10-06 18:13:28 +04:00
|
|
|
}
|
2002-04-30 21:48:11 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-14 02:00:38 +04:00
|
|
|
CXWindowsPrimaryScreen::updateKeys()
|
2002-04-30 21:48:11 +04:00
|
|
|
{
|
2002-07-14 02:00:38 +04:00
|
|
|
CDisplayLock display(m_screen);
|
|
|
|
|
2002-04-30 21:48:11 +04:00
|
|
|
// get modifier map from server
|
|
|
|
XModifierKeymap* keymap = XGetModifierMapping(display);
|
|
|
|
|
|
|
|
// initialize
|
2002-09-01 19:30:00 +04:00
|
|
|
m_altMask = 0;
|
|
|
|
m_metaMask = 0;
|
2002-09-14 16:07:02 +04:00
|
|
|
m_superMask = 0;
|
2002-09-01 19:30:00 +04:00
|
|
|
m_modeSwitchMask = 0;
|
2002-04-30 21:48:11 +04:00
|
|
|
m_numLockMask = 0;
|
|
|
|
m_capsLockMask = 0;
|
|
|
|
m_scrollLockMask = 0;
|
|
|
|
|
2002-09-01 20:45:44 +04:00
|
|
|
// work around for my system, which reports this state bit when
|
|
|
|
// mode switch is down, instead of the appropriate modifier bit.
|
|
|
|
// should have no effect on other systems. -crs 9/02.
|
|
|
|
m_modeSwitchMask |= (1 << 13);
|
|
|
|
|
2002-04-30 21:48:11 +04:00
|
|
|
// set keycodes and masks
|
|
|
|
for (unsigned int i = 0; i < 8; ++i) {
|
|
|
|
const unsigned int bit = (1 << i);
|
|
|
|
for (int j = 0; j < keymap->max_keypermod; ++j) {
|
|
|
|
KeyCode keycode = keymap->modifiermap[i *
|
|
|
|
keymap->max_keypermod + j];
|
|
|
|
|
2002-09-01 19:30:00 +04:00
|
|
|
// note mask for particular modifiers
|
2002-04-30 21:48:11 +04:00
|
|
|
const KeySym keysym = XKeycodeToKeysym(display, keycode, 0);
|
2002-09-01 19:30:00 +04:00
|
|
|
switch (keysym) {
|
|
|
|
case XK_Alt_L:
|
|
|
|
case XK_Alt_R:
|
|
|
|
m_altMask |= bit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Meta_L:
|
|
|
|
case XK_Meta_R:
|
|
|
|
m_metaMask |= bit;
|
|
|
|
break;
|
|
|
|
|
2002-09-14 16:07:02 +04:00
|
|
|
case XK_Super_L:
|
|
|
|
case XK_Super_R:
|
|
|
|
m_superMask |= bit;
|
|
|
|
break;
|
|
|
|
|
2002-09-01 19:30:00 +04:00
|
|
|
case XK_Mode_switch:
|
|
|
|
m_modeSwitchMask |= bit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Num_Lock:
|
|
|
|
m_numLockMask |= bit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Caps_Lock:
|
|
|
|
m_capsLockMask |= bit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Scroll_Lock:
|
2002-04-30 21:48:11 +04:00
|
|
|
m_scrollLockMask |= bit;
|
2002-09-01 19:30:00 +04:00
|
|
|
break;
|
2002-04-30 21:48:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFreeModifiermap(keymap);
|
|
|
|
}
|
2002-05-03 15:26:44 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
Bool
|
2002-06-17 17:31:21 +04:00
|
|
|
CXWindowsPrimaryScreen::findKeyEvent(Display*, XEvent* xevent, XPointer arg)
|
2002-05-03 15:26:44 +04:00
|
|
|
{
|
|
|
|
CKeyEventInfo* filter = reinterpret_cast<CKeyEventInfo*>(arg);
|
|
|
|
return (xevent->type == filter->m_event &&
|
|
|
|
xevent->xkey.window == filter->m_window &&
|
|
|
|
xevent->xkey.time == filter->m_time &&
|
|
|
|
xevent->xkey.keycode == filter->m_keycode) ? True : False;
|
|
|
|
}
|