2001-11-19 03:33:36 +03:00
|
|
|
#include "CMSWindowsSecondaryScreen.h"
|
2002-07-11 17:13:37 +04:00
|
|
|
#include "IScreenReceiver.h"
|
2001-11-25 21:32:41 +03:00
|
|
|
#include "CClipboard.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CMSWindowsClipboard.h"
|
2002-06-24 01:53:31 +04:00
|
|
|
#include "CMSWindowsScreenSaver.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CPlatform.h"
|
|
|
|
#include "XScreen.h"
|
2002-06-09 01:48:00 +04:00
|
|
|
#include "CLock.h"
|
|
|
|
#include "CThread.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CLog.h"
|
|
|
|
#include <cctype>
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-20 15:13:37 +04:00
|
|
|
// these are only defined when WINVER >= 0x0500
|
|
|
|
#if !defined(SPI_GETMOUSESPEED)
|
|
|
|
#define SPI_GETMOUSESPEED 112
|
|
|
|
#endif
|
|
|
|
#if !defined(SPI_SETMOUSESPEED)
|
|
|
|
#define SPI_SETMOUSESPEED 113
|
|
|
|
#endif
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
//
|
|
|
|
// CMSWindowsSecondaryScreen
|
|
|
|
//
|
|
|
|
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsSecondaryScreen::CMSWindowsSecondaryScreen(
|
|
|
|
IScreenReceiver* receiver) :
|
|
|
|
m_receiver(receiver),
|
2002-06-11 02:06:45 +04:00
|
|
|
m_threadID(0),
|
2002-06-14 22:08:20 +04:00
|
|
|
m_lastThreadID(0),
|
2002-06-11 02:06:45 +04:00
|
|
|
m_desk(NULL),
|
|
|
|
m_deskName(),
|
|
|
|
m_window(NULL),
|
|
|
|
m_active(false),
|
|
|
|
m_nextClipboardWindow(NULL)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-11 17:13:37 +04:00
|
|
|
assert(m_receiver != NULL);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
m_is95Family = CPlatform::isWindows95Family();
|
|
|
|
|
|
|
|
// make sure this thread has a message queue
|
|
|
|
MSG dummy;
|
|
|
|
PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CMSWindowsSecondaryScreen::~CMSWindowsSecondaryScreen()
|
|
|
|
{
|
|
|
|
assert(m_window == NULL);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::run()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
assert(m_window != NULL);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// must call run() from same thread as open()
|
|
|
|
assert(m_threadID == GetCurrentThreadId());
|
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// change our priority
|
|
|
|
CThread::getCurrentThread().setPriority(-7);
|
|
|
|
|
|
|
|
// run event loop
|
2002-07-13 00:41:23 +04:00
|
|
|
try {
|
|
|
|
log((CLOG_INFO "entering event loop"));
|
|
|
|
mainLoop();
|
|
|
|
log((CLOG_INFO "exiting event loop"));
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
log((CLOG_INFO "exiting event loop"));
|
|
|
|
throw;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::stop()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
exitMainLoop();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsSecondaryScreen::open()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
assert(m_window == NULL);
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
try {
|
|
|
|
// open the display
|
|
|
|
openDisplay();
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// create and prepare our window
|
|
|
|
createWindow();
|
2002-06-09 01:48:00 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// initialize the clipboards; assume primary has all clipboards
|
|
|
|
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
|
|
|
grabClipboard(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get keyboard state
|
|
|
|
updateKeys();
|
|
|
|
updateModifiers();
|
|
|
|
|
|
|
|
// disable the screen saver
|
|
|
|
installScreenSaver();
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
close();
|
|
|
|
throw;
|
|
|
|
}
|
2002-06-24 01:53:31 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// hide the cursor
|
|
|
|
m_active = true;
|
|
|
|
leave();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::close()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
uninstallScreenSaver();
|
|
|
|
destroyWindow();
|
2001-11-19 03:33:36 +03:00
|
|
|
closeDisplay();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
2001-11-19 03:33:36 +03:00
|
|
|
assert(m_window != NULL);
|
2002-06-09 01:48:00 +04:00
|
|
|
assert(m_active == false);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-30 21:48:11 +04:00
|
|
|
log((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
syncDesktop();
|
|
|
|
|
|
|
|
// now active
|
|
|
|
m_active = true;
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// update our keyboard state to reflect the local state
|
|
|
|
updateKeys();
|
|
|
|
updateModifiers();
|
2002-04-30 21:48:11 +04:00
|
|
|
|
|
|
|
// toggle modifiers that don't match the desired state
|
|
|
|
if ((mask & KeyModifierCapsLock) != (m_mask & KeyModifierCapsLock)) {
|
|
|
|
toggleKey(VK_CAPITAL, KeyModifierCapsLock);
|
|
|
|
}
|
|
|
|
if ((mask & KeyModifierNumLock) != (m_mask & KeyModifierNumLock)) {
|
2002-05-22 21:01:17 +04:00
|
|
|
toggleKey(VK_NUMLOCK | 0x100, KeyModifierNumLock);
|
2002-04-30 21:48:11 +04:00
|
|
|
}
|
|
|
|
if ((mask & KeyModifierScrollLock) != (m_mask & KeyModifierScrollLock)) {
|
|
|
|
toggleKey(VK_SCROLL, KeyModifierScrollLock);
|
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// warp to requested location
|
|
|
|
warpCursor(x, y);
|
|
|
|
|
2002-06-20 15:13:37 +04:00
|
|
|
// show mouse
|
2002-07-13 00:41:23 +04:00
|
|
|
hideWindow();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::leave()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
2001-11-19 03:33:36 +03:00
|
|
|
assert(m_window != NULL);
|
2002-06-09 01:48:00 +04:00
|
|
|
assert(m_active == true);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
log((CLOG_INFO "leaving screen"));
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
syncDesktop();
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// hide mouse
|
2002-07-13 00:41:23 +04:00
|
|
|
showWindow();
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// not active anymore
|
|
|
|
m_active = false;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// make sure our idea of clipboard ownership is correct
|
|
|
|
checkClipboard();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::keyDown(KeyID key, KeyModifierMask mask)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-04-30 20:23:03 +04:00
|
|
|
Keystrokes keys;
|
|
|
|
UINT virtualKey;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// get the sequence of keys to simulate key press and the final
|
|
|
|
// modifier state.
|
2002-05-04 22:08:22 +04:00
|
|
|
m_mask = mapKey(keys, virtualKey, key, mask, kPress);
|
2002-06-11 02:06:45 +04:00
|
|
|
if (keys.empty()) {
|
2002-04-30 20:23:03 +04:00
|
|
|
return;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// generate key events
|
2002-05-04 22:08:22 +04:00
|
|
|
doKeystrokes(keys, 1);
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// note that key is now down
|
|
|
|
m_keys[virtualKey] |= 0x80;
|
2002-05-05 23:38:09 +04:00
|
|
|
switch (virtualKey) {
|
|
|
|
case VK_LSHIFT:
|
|
|
|
case VK_RSHIFT:
|
|
|
|
m_keys[VK_SHIFT] |= 0x80;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LCONTROL:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
m_keys[VK_CONTROL] |= 0x80;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LMENU:
|
|
|
|
case VK_RMENU:
|
|
|
|
m_keys[VK_MENU] |= 0x80;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::keyRepeat(KeyID key,
|
|
|
|
KeyModifierMask mask, SInt32 count)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-04-30 20:23:03 +04:00
|
|
|
Keystrokes keys;
|
|
|
|
UINT virtualKey;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2002-05-04 22:08:22 +04:00
|
|
|
// get the sequence of keys to simulate key repeat and the final
|
2002-04-30 20:23:03 +04:00
|
|
|
// modifier state.
|
2002-05-04 22:08:22 +04:00
|
|
|
m_mask = mapKey(keys, virtualKey, key, mask, kRepeat);
|
2002-06-11 02:06:45 +04:00
|
|
|
if (keys.empty()) {
|
2002-04-30 20:23:03 +04:00
|
|
|
return;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// generate key events
|
2002-05-04 22:08:22 +04:00
|
|
|
doKeystrokes(keys, count);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::keyUp(KeyID key, KeyModifierMask mask)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-04-30 20:23:03 +04:00
|
|
|
Keystrokes keys;
|
|
|
|
UINT virtualKey;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// get the sequence of keys to simulate key release and the final
|
|
|
|
// modifier state.
|
2002-05-04 22:08:22 +04:00
|
|
|
m_mask = mapKey(keys, virtualKey, key, mask, kRelease);
|
2002-06-11 02:06:45 +04:00
|
|
|
if (keys.empty()) {
|
2002-04-30 20:23:03 +04:00
|
|
|
return;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// generate key events
|
2002-05-04 22:08:22 +04:00
|
|
|
doKeystrokes(keys, 1);
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// note that key is now up
|
|
|
|
m_keys[virtualKey] &= ~0x80;
|
2002-05-05 23:38:09 +04:00
|
|
|
switch (virtualKey) {
|
|
|
|
case VK_LSHIFT:
|
|
|
|
if ((m_keys[VK_RSHIFT] & 0x80) == 0) {
|
|
|
|
m_keys[VK_SHIFT] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RSHIFT:
|
|
|
|
if ((m_keys[VK_LSHIFT] & 0x80) == 0) {
|
|
|
|
m_keys[VK_SHIFT] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LCONTROL:
|
|
|
|
if ((m_keys[VK_RCONTROL] & 0x80) == 0) {
|
|
|
|
m_keys[VK_CONTROL] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RCONTROL:
|
|
|
|
if ((m_keys[VK_LCONTROL] & 0x80) == 0) {
|
|
|
|
m_keys[VK_CONTROL] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LMENU:
|
|
|
|
if ((m_keys[VK_RMENU] & 0x80) == 0) {
|
|
|
|
m_keys[VK_MENU] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RMENU:
|
|
|
|
if ((m_keys[VK_LMENU] & 0x80) == 0) {
|
|
|
|
m_keys[VK_MENU] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mouseDown(ButtonID button)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// map button id to button flag
|
2002-05-04 22:08:22 +04:00
|
|
|
DWORD flags = mapButton(button, true);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// send event
|
2002-06-11 02:06:45 +04:00
|
|
|
if (flags != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
mouse_event(flags, 0, 0, 0, 0);
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mouseUp(ButtonID button)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// map button id to button flag
|
2002-05-04 22:08:22 +04:00
|
|
|
DWORD flags = mapButton(button, false);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// send event
|
2002-06-11 02:06:45 +04:00
|
|
|
if (flags != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
mouse_event(flags, 0, 0, 0, 0);
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mouseMove(SInt32 x, SInt32 y)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
2002-06-20 15:13:37 +04:00
|
|
|
warpCursor(x, y);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, delta, 0);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::setClipboard(ClipboardID /*id*/,
|
|
|
|
const IClipboard* src)
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
2001-11-25 21:32:41 +03:00
|
|
|
assert(m_window != NULL);
|
|
|
|
|
|
|
|
CMSWindowsClipboard dst(m_window);
|
|
|
|
CClipboard::copy(&dst, src);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::grabClipboard(ClipboardID /*id*/)
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
2001-11-25 21:32:41 +03:00
|
|
|
assert(m_window != NULL);
|
|
|
|
|
|
|
|
CMSWindowsClipboard clipboard(m_window);
|
2002-04-30 20:23:03 +04:00
|
|
|
if (clipboard.open(0)) {
|
2001-11-25 21:32:41 +03:00
|
|
|
clipboard.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::screenSaver(bool activate)
|
|
|
|
{
|
|
|
|
if (activate) {
|
|
|
|
getScreenSaver()->activate();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getScreenSaver()->deactivate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-19 21:03:29 +04:00
|
|
|
CMSWindowsSecondaryScreen::getMousePos(SInt32& x, SInt32& y) const
|
2002-05-24 21:54:28 +04:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
|
|
|
assert(m_window != NULL);
|
|
|
|
syncDesktop();
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
getCursorPos(x, y);
|
2002-05-24 21:54:28 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-19 21:03:29 +04:00
|
|
|
CMSWindowsSecondaryScreen::getShape(
|
|
|
|
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-19 21:03:29 +04:00
|
|
|
getScreenShape(x, y, w, h);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
SInt32
|
|
|
|
CMSWindowsSecondaryScreen::getJumpZoneSize() const
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::getClipboard(ClipboardID /*id*/,
|
|
|
|
IClipboard* dst) const
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
CLock lock(&m_mutex);
|
2001-11-25 21:32:41 +03:00
|
|
|
assert(m_window != NULL);
|
|
|
|
|
|
|
|
CMSWindowsClipboard src(m_window);
|
|
|
|
CClipboard::copy(dst, &src);
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsSecondaryScreen::onPreDispatch(const CEvent* event)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
assert(event != NULL);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
// forward to superclass
|
|
|
|
if (CMSWindowsScreen::onPreDispatch(event)) {
|
|
|
|
return true;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// handle event
|
2002-07-13 00:41:23 +04:00
|
|
|
const MSG* msg = &event->m_msg;
|
2002-06-09 01:48:00 +04:00
|
|
|
switch (msg->message) {
|
|
|
|
case WM_TIMER:
|
|
|
|
// if current desktop is not the input desktop then switch to it
|
|
|
|
if (!m_is95Family) {
|
|
|
|
HDESK desk = openInputDesktop();
|
|
|
|
if (desk != NULL) {
|
|
|
|
if (isCurrentDesktop(desk)) {
|
|
|
|
CloseDesktop(desk);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switchDesktop(desk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsSecondaryScreen::onEvent(CEvent* event)
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
assert(event != NULL);
|
|
|
|
|
|
|
|
const MSG& msg = event->msg;
|
|
|
|
switch (msg.message) {
|
2002-06-09 01:48:00 +04:00
|
|
|
case WM_QUERYENDSESSION:
|
|
|
|
if (m_is95Family) {
|
2002-07-13 00:41:23 +04:00
|
|
|
event->m_result = TRUE;
|
|
|
|
return true;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ENDSESSION:
|
|
|
|
if (m_is95Family) {
|
2002-07-13 00:41:23 +04:00
|
|
|
if (msg.wParam == TRUE && msg.lParam == 0) {
|
2002-06-09 01:48:00 +04:00
|
|
|
stop();
|
|
|
|
}
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_PAINT:
|
2002-07-13 00:41:23 +04:00
|
|
|
ValidateRect(msg.hwnd, NULL);
|
|
|
|
return true;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_ACTIVATEAPP:
|
2002-07-13 00:41:23 +04:00
|
|
|
if (msg.wParam == FALSE) {
|
2001-11-19 03:33:36 +03:00
|
|
|
// some other app activated. hide the hider window.
|
|
|
|
ShowWindow(m_window, SW_HIDE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_DRAWCLIPBOARD:
|
2001-11-25 21:32:41 +03:00
|
|
|
log((CLOG_DEBUG "clipboard was taken"));
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
// first pass it on
|
2002-07-13 00:41:23 +04:00
|
|
|
if (m_nextClipboardWindow != NULL) {
|
|
|
|
SendMessage(m_nextClipboardWindow,
|
|
|
|
msg.message, msg.wParam, msg.lParam);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
// now notify client that somebody changed the clipboard (unless
|
|
|
|
// we're now the owner, in which case it's because we took
|
2002-06-09 01:48:00 +04:00
|
|
|
// ownership, or now it's owned by nobody, which will happen if
|
|
|
|
// we owned it and switched desktops because we destroy our
|
|
|
|
// window to do that).
|
2002-07-13 00:41:23 +04:00
|
|
|
try {
|
|
|
|
m_clipboardOwner = GetClipboardOwner();
|
|
|
|
if (m_clipboardOwner != m_window && m_clipboardOwner != NULL) {
|
|
|
|
m_receiver->onGrabClipboard(kClipboardClipboard);
|
|
|
|
m_receiver->onGrabClipboard(kClipboardSelection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
// ignore. this can happen if we receive this event
|
|
|
|
// before we've fully started up.
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_CHANGECBCHAIN:
|
2002-07-13 00:41:23 +04:00
|
|
|
if (m_nextClipboardWindow == (HWND)msg.wParam) {
|
|
|
|
m_nextClipboardWindow = (HWND)msg.lParam;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-07-13 00:41:23 +04:00
|
|
|
else if (m_nextClipboardWindow != NULL) {
|
|
|
|
SendMessage(m_nextClipboardWindow,
|
|
|
|
msg.message, msg.wParam, msg.lParam);
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
2002-05-24 21:54:28 +04:00
|
|
|
|
|
|
|
case WM_DISPLAYCHANGE:
|
2002-07-13 00:41:23 +04:00
|
|
|
{
|
|
|
|
// screen resolution may have changed. get old shape.
|
|
|
|
SInt32 xOld, yOld, wOld, hOld;
|
|
|
|
getScreenShape(xOld, yOld, wOld, hOld);
|
|
|
|
|
|
|
|
// update shape
|
|
|
|
updateScreenShape();
|
|
|
|
m_multimon = isMultimon();
|
|
|
|
|
|
|
|
// collect new screen info
|
|
|
|
CClientInfo info;
|
|
|
|
getScreenShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
|
|
|
getCursorPos(info.m_mx, info.m_my);
|
|
|
|
info.m_zoneSize = getJumpZoneSize();
|
|
|
|
|
|
|
|
// do nothing if resolution hasn't changed
|
|
|
|
if (info.m_x != xOld || info.m_y != yOld ||
|
|
|
|
info.m_w != wOld || info.m_h != hOld) {
|
|
|
|
// send new screen info
|
|
|
|
m_receiver->onInfoChanged(info);
|
|
|
|
}
|
2002-07-11 17:13:37 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
return false;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
CString
|
|
|
|
CMSWindowsSecondaryScreen::getCurrentDesktopName() const
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
2002-07-13 00:41:23 +04:00
|
|
|
return m_deskName;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-13 00:41:23 +04:00
|
|
|
CMSWindowsSecondaryScreen::showWindow()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// move hider window under the mouse (rather than moving the mouse
|
|
|
|
// somewhere else on the screen)
|
2002-07-13 00:41:23 +04:00
|
|
|
SInt32 x, y;
|
|
|
|
getCursorPos(x, y);
|
|
|
|
MoveWindow(m_window, x, y, 1, 1, FALSE);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// raise and show the hider window. take activation.
|
|
|
|
ShowWindow(m_window, SW_SHOWNORMAL);
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:41:23 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::hideWindow()
|
|
|
|
{
|
|
|
|
ShowWindow(m_window, SW_HIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y)
|
|
|
|
{
|
|
|
|
// move the mouse directly to target position on NT family or if
|
|
|
|
// not using multiple monitors.
|
|
|
|
if (!m_multimon || !m_is95Family) {
|
|
|
|
SInt32 x0, y0, w, h;
|
|
|
|
getScreenShape(x0, y0, w, h);
|
|
|
|
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
|
|
|
|
(DWORD)((65535.99 * (x - x0)) / (w - 1)),
|
|
|
|
(DWORD)((65535.99 * (y - y0)) / (h - 1)),
|
|
|
|
0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// windows 98 (and Me?) is broken. you cannot set the absolute
|
|
|
|
// position of the mouse except on the primary monitor but you
|
|
|
|
// can do relative moves onto any monitor. this is, in microsoft's
|
|
|
|
// words, "by design." apparently the designers of windows 2000
|
|
|
|
// we're a little less lazy and did it right.
|
|
|
|
//
|
|
|
|
// we use the microsoft recommendation (Q193003): set the absolute
|
|
|
|
// position on the primary monitor, disable mouse acceleration,
|
|
|
|
// relative move the mouse to the final location, restore mouse
|
|
|
|
// acceleration. to avoid one kind of race condition (the user
|
|
|
|
// clicking the mouse or pressing a key between the absolute and
|
|
|
|
// relative move) we'll use SendInput() which guarantees that the
|
|
|
|
// events are delivered uninterrupted. we cannot prevent changes
|
|
|
|
// to the mouse acceleration at inopportune times, though.
|
|
|
|
//
|
|
|
|
// point-to-activate (x-mouse) doesn't seem to be bothered by the
|
|
|
|
// absolute/relative combination. a window over the absolute
|
|
|
|
// position (0,0) does *not* get activated (at least not on win2k)
|
|
|
|
// if the relative move puts the cursor elsewhere. similarly, the
|
|
|
|
// app under the final mouse position does *not* get deactivated
|
|
|
|
// by the absolute move to 0,0.
|
|
|
|
else {
|
|
|
|
// save mouse speed & acceleration
|
|
|
|
int oldSpeed[4];
|
|
|
|
bool accelChanged =
|
|
|
|
SystemParametersInfo(SPI_GETMOUSE,0, oldSpeed,0) &&
|
|
|
|
SystemParametersInfo(SPI_GETMOUSESPEED, 0, oldSpeed + 3, 0);
|
|
|
|
|
|
|
|
// use 1:1 motion
|
|
|
|
if (accelChanged) {
|
|
|
|
int newSpeed[4] = { 0, 0, 0, 1 };
|
|
|
|
accelChanged =
|
|
|
|
SystemParametersInfo(SPI_SETMOUSE, 0, newSpeed, 0) ||
|
|
|
|
SystemParametersInfo(SPI_SETMOUSESPEED, 0, newSpeed + 3, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// send events
|
|
|
|
INPUT events[2];
|
|
|
|
events[0].type = INPUT_MOUSE;
|
|
|
|
events[0].mi.dx = 0;
|
|
|
|
events[0].mi.dy = 0;
|
|
|
|
events[0].mi.mouseData = 0;
|
|
|
|
events[0].mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
events[0].mi.time = GetTickCount();
|
|
|
|
events[0].mi.dwExtraInfo = 0;
|
|
|
|
events[1].type = INPUT_MOUSE;
|
|
|
|
events[1].mi.dx = x;
|
|
|
|
events[1].mi.dy = y;
|
|
|
|
events[1].mi.mouseData = 0;
|
|
|
|
events[1].mi.dwFlags = MOUSEEVENTF_MOVE;
|
|
|
|
events[1].mi.time = events[0].mi.time;
|
|
|
|
events[1].mi.dwExtraInfo = 0;
|
|
|
|
SendInput(sizeof(events) / sizeof(events[0]),
|
|
|
|
events, sizeof(events[0]));
|
|
|
|
|
|
|
|
// restore mouse speed & acceleration
|
|
|
|
if (accelChanged) {
|
|
|
|
SystemParametersInfo(SPI_SETMOUSE, 0, oldSpeed, 0);
|
|
|
|
SystemParametersInfo(SPI_SETMOUSESPEED, 0, oldSpeed + 3, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::checkClipboard()
|
|
|
|
{
|
|
|
|
// if we think we own the clipboard but we don't then somebody
|
|
|
|
// grabbed the clipboard on this screen without us knowing.
|
|
|
|
// tell the server that this screen grabbed the clipboard.
|
|
|
|
//
|
|
|
|
// this works around bugs in the clipboard viewer chain.
|
|
|
|
// sometimes NT will simply never send WM_DRAWCLIPBOARD
|
|
|
|
// messages for no apparent reason and rebooting fixes the
|
|
|
|
// problem. since we don't want a broken clipboard until the
|
|
|
|
// next reboot we do this double check. clipboard ownership
|
|
|
|
// won't be reflected on other screens until we leave but at
|
|
|
|
// least the clipboard itself will work.
|
|
|
|
HWND clipboardOwner = GetClipboardOwner();
|
|
|
|
if (m_clipboardOwner != clipboardOwner) {
|
|
|
|
try {
|
|
|
|
m_clipboardOwner = clipboardOwner;
|
|
|
|
if (m_clipboardOwner != m_window && m_clipboardOwner != NULL) {
|
|
|
|
m_receiver->onGrabClipboard(kClipboardClipboard);
|
|
|
|
m_receiver->onGrabClipboard(kClipboardSelection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::createWindow()
|
|
|
|
{
|
|
|
|
// save thread id
|
|
|
|
m_threadID = GetCurrentThreadId();
|
|
|
|
|
|
|
|
// note if using multiple monitors
|
|
|
|
m_multimon = isMultimon();
|
|
|
|
|
|
|
|
// get the input desktop and switch to it
|
|
|
|
if (m_is95Family) {
|
|
|
|
if (!openDesktop()) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!switchDesktop(openInputDesktop())) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// poll input desktop to see if it changes (onPreDispatch()
|
|
|
|
// handles WM_TIMER)
|
|
|
|
m_timer = 0;
|
|
|
|
if (!m_is95Family) {
|
|
|
|
m_timer = SetTimer(NULL, 0, 200, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::destroyWindow()
|
|
|
|
{
|
|
|
|
// remove timer
|
|
|
|
if (m_timer != 0) {
|
|
|
|
KillTimer(NULL, m_timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// release keys that are logically pressed
|
|
|
|
releaseKeys();
|
|
|
|
|
|
|
|
// disconnect from desktop
|
|
|
|
if (m_is95Family) {
|
|
|
|
closeDesktop();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switchDesktop(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear thread id
|
|
|
|
m_threadID = 0;
|
|
|
|
|
|
|
|
assert(m_window == NULL);
|
|
|
|
assert(m_desk == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::installScreenSaver()
|
|
|
|
{
|
|
|
|
getScreenSaver()->disable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::uninstallScreenSaver()
|
|
|
|
{
|
|
|
|
getScreenSaver()->enable();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsSecondaryScreen::openDesktop()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
|
|
|
|
// initialize clipboard owner to current owner. we don't want
|
|
|
|
// to take ownership of the clipboard just by starting up.
|
|
|
|
m_clipboardOwner = GetClipboardOwner();
|
|
|
|
|
|
|
|
// create the cursor hiding window. 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.
|
|
|
|
m_window = CreateWindowEx(WS_EX_TOPMOST |
|
|
|
|
WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW,
|
|
|
|
(LPCTSTR)getClass(), "Synergy",
|
|
|
|
WS_POPUP,
|
|
|
|
0, 0, 1, 1, NULL, NULL,
|
|
|
|
getInstance(),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
// install our clipboard snooper
|
|
|
|
m_nextClipboardWindow = SetClipboardViewer(m_window);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::closeDesktop()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
|
|
|
|
if (m_window != NULL) {
|
|
|
|
// remove clipboard snooper
|
|
|
|
ChangeClipboardChain(m_window, m_nextClipboardWindow);
|
|
|
|
m_nextClipboardWindow = NULL;
|
|
|
|
|
|
|
|
// destroy window
|
|
|
|
DestroyWindow(m_window);
|
|
|
|
m_window = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::switchDesktop(HDESK desk)
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
|
|
|
|
bool ownClipboard = false;
|
|
|
|
if (m_window != NULL) {
|
|
|
|
// note if we own the clipboard
|
|
|
|
ownClipboard = (m_clipboardOwner == m_window);
|
|
|
|
|
|
|
|
// remove clipboard snooper
|
|
|
|
ChangeClipboardChain(m_window, m_nextClipboardWindow);
|
|
|
|
m_nextClipboardWindow = NULL;
|
|
|
|
|
|
|
|
// destroy window
|
|
|
|
DestroyWindow(m_window);
|
|
|
|
m_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// done with desktop
|
|
|
|
if (m_desk != NULL) {
|
|
|
|
CloseDesktop(m_desk);
|
|
|
|
m_desk = NULL;
|
|
|
|
m_deskName = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// if no new desktop then we're done
|
|
|
|
if (desk == NULL) {
|
|
|
|
log((CLOG_INFO "disconnecting desktop"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the desktop. can only do this when there are no windows
|
|
|
|
// and hooks on the current desktop owned by this thread.
|
|
|
|
if (SetThreadDesktop(desk) == 0) {
|
|
|
|
log((CLOG_ERR "failed to set desktop: %d", GetLastError()));
|
|
|
|
CloseDesktop(desk);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// initialize clipboard owner to current owner. we don't want
|
|
|
|
// to take ownership of the clipboard just by starting up.
|
|
|
|
m_clipboardOwner = GetClipboardOwner();
|
|
|
|
|
|
|
|
// create the cursor hiding window. 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.
|
|
|
|
m_window = CreateWindowEx(WS_EX_TOPMOST |
|
|
|
|
WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW,
|
|
|
|
(LPCTSTR)getClass(), "Synergy",
|
|
|
|
WS_POPUP,
|
|
|
|
0, 0, 1, 1, NULL, NULL,
|
|
|
|
getInstance(),
|
|
|
|
NULL);
|
|
|
|
if (m_window == NULL) {
|
|
|
|
log((CLOG_ERR "failed to create window: %d", GetLastError()));
|
|
|
|
CloseDesktop(desk);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// install our clipboard snooper
|
|
|
|
m_nextClipboardWindow = SetClipboardViewer(m_window);
|
|
|
|
|
|
|
|
// if we owned the desktop then set the clipboard owner
|
|
|
|
if (ownClipboard) {
|
|
|
|
m_clipboardOwner = GetClipboardOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
// save new desktop
|
|
|
|
m_desk = desk;
|
|
|
|
m_deskName = getDesktopName(m_desk);
|
|
|
|
log((CLOG_INFO "switched to desktop %s", m_deskName.c_str()));
|
|
|
|
|
|
|
|
// get desktop up to date
|
|
|
|
if (!m_active) {
|
2002-07-13 00:41:23 +04:00
|
|
|
showWindow();
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::syncDesktop() const
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// note -- mutex must be locked on entry
|
|
|
|
|
2002-06-14 22:08:20 +04:00
|
|
|
// change calling thread's desktop
|
2002-06-09 01:48:00 +04:00
|
|
|
if (!m_is95Family) {
|
2002-06-14 22:08:20 +04:00
|
|
|
if (SetThreadDesktop(m_desk) == 0) {
|
|
|
|
log((CLOG_WARN "failed to set desktop: %d", GetLastError()));
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
}
|
2002-06-14 22:08:20 +04:00
|
|
|
|
|
|
|
// attach input queues if not already attached. this has a habit
|
|
|
|
// of sucking up more and more CPU each time it's called (even if
|
|
|
|
// the threads are already attached). since we only expect one
|
|
|
|
// thread to call this more than once we can save just the last
|
|
|
|
// the attached thread.
|
|
|
|
DWORD threadID = GetCurrentThreadId();
|
|
|
|
if (threadID != m_lastThreadID && threadID != m_threadID) {
|
|
|
|
m_lastThreadID = threadID;
|
|
|
|
AttachThreadInput(threadID, m_threadID, TRUE);
|
|
|
|
}
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
|
2002-06-20 15:13:37 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsSecondaryScreen::isMultimon() const
|
|
|
|
{
|
|
|
|
SInt32 x0, y0, w, h;
|
|
|
|
getScreenShape(x0, y0, w, h);
|
|
|
|
return (w != GetSystemMetrics(SM_CXSCREEN) ||
|
|
|
|
h != GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
}
|
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// these tables map KeyID (a X windows KeySym) to virtual key codes.
|
|
|
|
// if the key is an extended key then the entry is the virtual key
|
|
|
|
// code | 0x100. keys that map to normal characters have a 0 entry
|
|
|
|
// and the conversion is done elsewhere.
|
2001-11-19 03:33:36 +03:00
|
|
|
static const UINT g_latin1[] =
|
|
|
|
{
|
|
|
|
/* 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, 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* 0x54 */ VK_DOWN|0x100, VK_PRIOR|0x100, VK_NEXT|0x100, VK_END|0x100,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0x60 */ VK_SELECT|0x100, VK_SNAPSHOT|0x100, VK_EXECUTE|0x100, VK_INSERT|0x100,
|
|
|
|
/* 0x64 */ 0, 0, 0, VK_APPS|0x100,
|
|
|
|
/* 0x68 */ 0, 0, VK_HELP|0x100, VK_CANCEL|0x100, 0, 0, 0, 0,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0x78 */ 0, 0, 0, 0, 0, 0, VK_MODECHANGE|0x100, VK_NUMLOCK|0x100,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0x80 */ VK_SPACE, 0, 0, 0, 0, 0, 0, 0,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0x88 */ 0, VK_TAB, 0, 0, 0, VK_RETURN|0x100, 0, 0,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0x90 */ 0, 0, 0, 0, 0, VK_HOME, VK_LEFT, VK_UP,
|
|
|
|
/* 0x98 */ VK_RIGHT, VK_DOWN, VK_PRIOR, VK_NEXT,
|
|
|
|
/* 0x9c */ VK_END, 0, VK_INSERT, VK_DELETE,
|
|
|
|
/* 0xa0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
/* 0xa8 */ 0, 0, VK_MULTIPLY, VK_ADD,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0xac */ VK_SEPARATOR, VK_SUBTRACT, VK_DECIMAL, VK_DIVIDE|0x100,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0xb0 */ VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3,
|
|
|
|
/* 0xb4 */ VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7,
|
|
|
|
/* 0xb8 */ VK_NUMPAD8, VK_NUMPAD9, 0, 0, 0, 0, VK_F1, VK_F2,
|
|
|
|
/* 0xc0 */ VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10,
|
|
|
|
/* 0xc8 */ VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18,
|
|
|
|
/* 0xd0 */ VK_F19, VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, 0, 0,
|
|
|
|
/* 0xd8 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
2002-05-05 23:38:09 +04:00
|
|
|
/* 0xe0 */ 0, VK_LSHIFT, VK_RSHIFT, VK_LCONTROL,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0xe4 */ VK_RCONTROL|0x100, VK_CAPITAL, 0, VK_LWIN|0x100,
|
|
|
|
/* 0xe8 */ VK_RWIN|0x100, VK_LMENU, VK_RMENU|0x100, 0, 0, 0, 0, 0,
|
2001-11-19 03:33:36 +03:00
|
|
|
/* 0xf0 */ 0, 0, 0, 0, 0, 0, 0, 0,
|
2002-05-22 21:01:17 +04:00
|
|
|
/* 0xf8 */ 0, 0, 0, 0, 0, 0, 0, VK_DELETE|0x100
|
2001-11-19 03:33:36 +03:00
|
|
|
};
|
|
|
|
static const UINT* g_katakana = NULL;
|
|
|
|
static const UINT* g_arabic = NULL;
|
|
|
|
static const UINT* g_cyrillic = NULL;
|
|
|
|
static const UINT* g_greek = NULL;
|
|
|
|
static const UINT* g_technical = NULL;
|
|
|
|
static const UINT* g_special = NULL;
|
|
|
|
static const UINT* g_publishing = NULL;
|
|
|
|
static const UINT* g_apl = NULL;
|
|
|
|
static const UINT* g_hebrew = NULL;
|
|
|
|
static const UINT* g_thai = NULL;
|
|
|
|
static const UINT* g_korean = NULL;
|
|
|
|
static const UINT* g_armenian = NULL;
|
|
|
|
static const UINT* g_georgian = NULL;
|
|
|
|
static const UINT* g_azeri = NULL;
|
|
|
|
static const UINT* g_vietnamese = NULL;
|
|
|
|
static const UINT* g_currency = NULL;
|
|
|
|
static const UINT* g_mapTable[] =
|
|
|
|
{
|
|
|
|
/* 0x00 */ g_latin1, g_latin2, g_latin3, g_latin4,
|
|
|
|
/* 0x04 */ g_katakana, g_arabic, g_cyrillic, g_greek,
|
|
|
|
/* 0x08 */ g_technical, g_special, g_publishing, g_apl,
|
|
|
|
/* 0x0c */ g_hebrew, g_thai, g_korean, NULL,
|
|
|
|
/* 0x10 */ NULL, NULL, g_latin8, g_latin9,
|
|
|
|
/* 0x14 */ g_armenian, g_georgian, g_azeri, NULL,
|
|
|
|
/* 0x18 */ NULL, NULL, NULL, NULL, NULL, NULL, g_vietnamese, NULL,
|
|
|
|
/* 0x20 */ g_currency, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x28 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x30 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x38 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x40 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x48 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x50 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x58 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x60 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x68 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x70 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x78 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x80 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x88 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x90 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0x98 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xa0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xa8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xb0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xb8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xc0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xc8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xd0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xd8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xe0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xe8 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xf0 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xf8 */ NULL, NULL, NULL, NULL,
|
|
|
|
/* 0xfc */ NULL, g_terminal, g_function, g_miscellany
|
|
|
|
};
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
DWORD
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mapButton(ButtonID button, bool press) const
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-04-30 20:23:03 +04:00
|
|
|
// map button id to button flag
|
|
|
|
switch (button) {
|
|
|
|
case kButtonLeft:
|
2002-05-04 22:08:22 +04:00
|
|
|
return press ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
case kButtonMiddle:
|
2002-05-04 22:08:22 +04:00
|
|
|
return press ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
case kButtonRight:
|
2002-05-04 22:08:22 +04:00
|
|
|
return press ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyModifierMask
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey,
|
|
|
|
KeyID id, KeyModifierMask mask, EKeyAction action) const
|
2002-04-30 20:23:03 +04:00
|
|
|
{
|
2001-11-19 03:33:36 +03:00
|
|
|
// lookup the key table
|
2002-04-30 20:23:03 +04:00
|
|
|
const UInt32 mapID = ((id >> 8) & 0xff);
|
|
|
|
const UINT* map = g_mapTable[mapID];
|
2001-11-19 03:33:36 +03:00
|
|
|
if (map == NULL) {
|
2002-04-30 20:23:03 +04:00
|
|
|
// unknown key
|
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// look up virtual key for id. default output mask carries over
|
2002-05-05 23:38:09 +04:00
|
|
|
// the current toggle modifier states and includes desired shift,
|
|
|
|
// control, alt, and meta states.
|
2002-04-30 20:23:03 +04:00
|
|
|
const UInt32 code = (id & 0xff);
|
|
|
|
virtualKey = map[code];
|
|
|
|
KeyModifierMask outMask = (m_mask &
|
|
|
|
(KeyModifierCapsLock |
|
|
|
|
KeyModifierNumLock |
|
|
|
|
KeyModifierScrollLock));
|
2002-05-05 23:38:09 +04:00
|
|
|
outMask |= (mask &
|
|
|
|
(KeyModifierShift |
|
|
|
|
KeyModifierControl |
|
|
|
|
KeyModifierAlt |
|
|
|
|
KeyModifierMeta));
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "key id %d -> virtual key %d", id, virtualKey));
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// extract extended key flag
|
|
|
|
const bool isExtended = ((virtualKey & 0x100) != 0);
|
|
|
|
virtualKey &= ~0x100;
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// if not in map then ask system to convert ascii character
|
|
|
|
if (virtualKey == 0) {
|
|
|
|
if (mapID != 0) {
|
|
|
|
// not ascii
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "not ascii"));
|
2002-04-30 20:23:03 +04:00
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// translate. return no keys if unknown key.
|
2002-05-22 21:01:17 +04:00
|
|
|
SHORT vk = VkKeyScan(static_cast<TCHAR>(code));
|
2002-04-30 20:23:03 +04:00
|
|
|
if (vk == 0xffff) {
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "no virtual key for character %d", code));
|
2002-04-30 20:23:03 +04:00
|
|
|
return m_mask;
|
|
|
|
}
|
|
|
|
|
2002-05-05 23:38:09 +04:00
|
|
|
// use whatever shift state VkKeyScan says
|
|
|
|
// FIXME -- also for control and alt, but it's more difficult
|
|
|
|
// to determine if control and alt must be off or if it just
|
|
|
|
// doesn't matter.
|
|
|
|
outMask &= ~KeyModifierShift;
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// convert system modifier mask to our mask
|
2002-06-11 02:06:45 +04:00
|
|
|
if (HIBYTE(vk) & 1) {
|
2002-04-30 20:23:03 +04:00
|
|
|
outMask |= KeyModifierShift;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if (HIBYTE(vk) & 2) {
|
2002-04-30 20:23:03 +04:00
|
|
|
outMask |= KeyModifierControl;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if (HIBYTE(vk) & 4) {
|
2002-04-30 20:23:03 +04:00
|
|
|
outMask |= KeyModifierAlt;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "character %d to virtual key %d mask 0x%04x", code, LOBYTE(vk), outMask));
|
|
|
|
|
|
|
|
// handle combination of caps-lock and shift. if caps-lock is
|
|
|
|
// off locally then use shift as necessary. if caps-lock is on
|
2002-05-22 21:01:17 +04:00
|
|
|
// locally then it reverses the meaning of shift for keys that
|
|
|
|
// are subject to case conversion.
|
|
|
|
if ((outMask & KeyModifierCapsLock) != 0) {
|
|
|
|
if (tolower(code) != toupper(code)) {
|
|
|
|
log((CLOG_DEBUG2 "flip shift"));
|
|
|
|
outMask ^= KeyModifierShift;
|
2002-05-04 22:08:22 +04:00
|
|
|
}
|
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// get virtual key
|
|
|
|
virtualKey = LOBYTE(vk);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if in map then figure out correct modifier state
|
|
|
|
else {
|
|
|
|
// check numeric keypad. note that while KeyID distinguishes
|
|
|
|
// between the keypad movement keys (e.g. Home, left arrow),
|
|
|
|
// the virtual keys do not. however, the virtual keys do
|
|
|
|
// distinguish between keypad numbers and operators (e.g.
|
|
|
|
// add, multiply) and their main keyboard counterparts.
|
|
|
|
// therefore, we can ignore the num-lock state for movement
|
|
|
|
// virtual keys but not for numeric keys.
|
|
|
|
if (virtualKey >= VK_NUMPAD0 && virtualKey <= VK_DIVIDE) {
|
|
|
|
// set required shift state based on current numlock state
|
2002-05-04 22:08:22 +04:00
|
|
|
if ((outMask & KeyModifierNumLock) == 0) {
|
|
|
|
if ((m_mask & KeyModifierNumLock) == 0) {
|
|
|
|
log((CLOG_DEBUG2 "turn on num lock for keypad key"));
|
|
|
|
outMask |= KeyModifierNumLock;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log((CLOG_DEBUG2 "turn on shift for keypad key"));
|
|
|
|
outMask |= KeyModifierShift;
|
|
|
|
}
|
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
|
2002-05-04 22:08:22 +04:00
|
|
|
// check for ISO_Left_Tab
|
|
|
|
else if (id == 0xfe20) {
|
|
|
|
outMask |= KeyModifierShift;
|
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// a list of modifier key info
|
|
|
|
class CModifierInfo {
|
|
|
|
public:
|
2002-05-05 23:38:09 +04:00
|
|
|
KeyModifierMask m_mask;
|
|
|
|
UINT m_virtualKey;
|
|
|
|
UINT m_virtualKey2;
|
|
|
|
bool m_isToggle;
|
2002-04-30 20:23:03 +04:00
|
|
|
};
|
|
|
|
static const CModifierInfo s_modifier[] = {
|
2002-05-22 21:01:17 +04:00
|
|
|
{ KeyModifierShift, VK_LSHIFT, VK_RSHIFT, false },
|
|
|
|
{ KeyModifierControl, VK_LCONTROL, VK_RCONTROL | 0x100,false },
|
|
|
|
{ KeyModifierAlt, VK_LMENU, VK_RMENU | 0x100, false },
|
|
|
|
{ KeyModifierMeta, VK_LWIN | 0x100, VK_RWIN | 0x100, false },
|
|
|
|
{ KeyModifierCapsLock, VK_CAPITAL, 0, true },
|
|
|
|
{ KeyModifierNumLock, VK_NUMLOCK | 0x100, 0, true },
|
|
|
|
{ KeyModifierScrollLock,VK_SCROLL, 0, true }
|
2002-04-30 20:23:03 +04:00
|
|
|
};
|
|
|
|
static const unsigned int s_numModifiers =
|
|
|
|
sizeof(s_modifier) / sizeof(s_modifier[0]);
|
|
|
|
|
|
|
|
// note if the key is a modifier
|
|
|
|
unsigned int modifierIndex;
|
|
|
|
switch (virtualKey) {
|
|
|
|
case VK_SHIFT:
|
|
|
|
case VK_LSHIFT:
|
|
|
|
case VK_RSHIFT:
|
|
|
|
modifierIndex = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_CONTROL:
|
|
|
|
case VK_LCONTROL:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
modifierIndex = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_MENU:
|
|
|
|
case VK_LMENU:
|
|
|
|
case VK_RMENU:
|
|
|
|
modifierIndex = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LWIN:
|
|
|
|
case VK_RWIN:
|
|
|
|
modifierIndex = 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_CAPITAL:
|
|
|
|
modifierIndex = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_NUMLOCK:
|
|
|
|
modifierIndex = 5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_SCROLL:
|
|
|
|
modifierIndex = 6;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
modifierIndex = s_numModifiers;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const bool isModifier = (modifierIndex != s_numModifiers);
|
|
|
|
|
|
|
|
// add the key events required to get to the modifier state
|
|
|
|
// necessary to generate an event yielding id. also save the
|
|
|
|
// key events required to restore the state. if the key is
|
|
|
|
// a modifier key then skip this because modifiers should not
|
|
|
|
// modify modifiers.
|
|
|
|
Keystrokes undo;
|
2002-05-04 22:08:22 +04:00
|
|
|
Keystroke keystroke;
|
2002-04-30 20:23:03 +04:00
|
|
|
if (outMask != m_mask && !isModifier) {
|
|
|
|
for (unsigned int i = 0; i < s_numModifiers; ++i) {
|
2002-05-05 23:38:09 +04:00
|
|
|
KeyModifierMask bit = s_modifier[i].m_mask;
|
2002-04-30 20:23:03 +04:00
|
|
|
if ((outMask & bit) != (m_mask & bit)) {
|
|
|
|
if ((outMask & bit) != 0) {
|
|
|
|
// modifier is not active but should be. if the
|
|
|
|
// modifier is a toggle then toggle it on with a
|
|
|
|
// press/release, otherwise activate it with a
|
|
|
|
// press.
|
2002-05-05 23:38:09 +04:00
|
|
|
keystroke.m_virtualKey = s_modifier[i].m_virtualKey;
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_press = true;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
keys.push_back(keystroke);
|
2002-05-05 23:38:09 +04:00
|
|
|
if (s_modifier[i].m_isToggle) {
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_press = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
undo.push_back(keystroke);
|
|
|
|
keystroke.m_press = true;
|
|
|
|
undo.push_back(keystroke);
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_press = false;
|
|
|
|
undo.push_back(keystroke);
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// modifier is active but should not be. if the
|
|
|
|
// modifier is a toggle then toggle it off with a
|
|
|
|
// press/release, otherwise deactivate it with a
|
|
|
|
// release. we must check each keycode for the
|
|
|
|
// modifier if not a toggle.
|
2002-05-05 23:38:09 +04:00
|
|
|
if (s_modifier[i].m_isToggle) {
|
|
|
|
keystroke.m_virtualKey = s_modifier[i].m_virtualKey;
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_press = true;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
undo.push_back(keystroke);
|
|
|
|
keystroke.m_press = true;
|
|
|
|
undo.push_back(keystroke);
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-05-05 23:38:09 +04:00
|
|
|
UINT key = s_modifier[i].m_virtualKey;
|
2002-05-22 21:01:17 +04:00
|
|
|
if ((m_keys[key & 0xff] & 0x80) != 0) {
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_virtualKey = key;
|
|
|
|
keystroke.m_press = false;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = true;
|
|
|
|
undo.push_back(keystroke);
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
2002-05-05 23:38:09 +04:00
|
|
|
key = s_modifier[i].m_virtualKey2;
|
2002-05-22 21:01:17 +04:00
|
|
|
if (key != 0 && (m_keys[key & 0xff] & 0x80) != 0) {
|
2002-05-04 22:08:22 +04:00
|
|
|
keystroke.m_virtualKey = key;
|
|
|
|
keystroke.m_press = false;
|
|
|
|
keystroke.m_repeat = false;
|
|
|
|
keys.push_back(keystroke);
|
|
|
|
keystroke.m_press = true;
|
|
|
|
undo.push_back(keystroke);
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the key event
|
2002-05-22 21:01:17 +04:00
|
|
|
keystroke.m_virtualKey = virtualKey;
|
2002-06-11 02:06:45 +04:00
|
|
|
if (isExtended) {
|
2002-05-22 21:01:17 +04:00
|
|
|
keystroke.m_virtualKey |= 0x100;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-04 22:08:22 +04:00
|
|
|
switch (action) {
|
|
|
|
case kPress:
|
2002-05-05 23:38:09 +04:00
|
|
|
keystroke.m_press = true;
|
|
|
|
keystroke.m_repeat = false;
|
2002-05-04 22:08:22 +04:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kRelease:
|
2002-05-05 23:38:09 +04:00
|
|
|
keystroke.m_press = false;
|
|
|
|
keystroke.m_repeat = false;
|
2002-05-04 22:08:22 +04:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kRepeat:
|
2002-05-05 23:38:09 +04:00
|
|
|
keystroke.m_press = true;
|
|
|
|
keystroke.m_repeat = true;
|
2002-05-04 22:08:22 +04:00
|
|
|
keys.push_back(keystroke);
|
|
|
|
break;
|
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// add key events to restore the modifier state. apply events in
|
|
|
|
// the reverse order that they're stored in undo.
|
|
|
|
while (!undo.empty()) {
|
|
|
|
keys.push_back(undo.back());
|
|
|
|
undo.pop_back();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// if the key is a modifier key then compute the modifier mask after
|
|
|
|
// this key is pressed.
|
|
|
|
mask = m_mask;
|
2002-05-04 22:08:22 +04:00
|
|
|
if (isModifier && action != kRepeat) {
|
|
|
|
// toggle keys modify the state on release. other keys set
|
|
|
|
// the bit on press and clear the bit on release.
|
2002-05-05 23:38:09 +04:00
|
|
|
const CModifierInfo& modifier = s_modifier[modifierIndex];
|
|
|
|
if (modifier.m_isToggle) {
|
2002-05-04 22:08:22 +04:00
|
|
|
if (action == kRelease) {
|
2002-05-05 23:38:09 +04:00
|
|
|
mask ^= modifier.m_mask;
|
2002-05-04 22:08:22 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
2002-05-04 22:08:22 +04:00
|
|
|
else if (action == kPress) {
|
2002-05-05 23:38:09 +04:00
|
|
|
mask |= modifier.m_mask;
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// can't reset bit until all keys that set it are released.
|
|
|
|
// scan those keys to see if any are pressed.
|
|
|
|
bool down = false;
|
2002-05-22 21:01:17 +04:00
|
|
|
if (virtualKey != (modifier.m_virtualKey & 0xff) &&
|
|
|
|
(m_keys[modifier.m_virtualKey & 0xff] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
down = true;
|
|
|
|
}
|
2002-05-05 23:38:09 +04:00
|
|
|
if (modifier.m_virtualKey2 != 0 &&
|
2002-05-22 21:01:17 +04:00
|
|
|
virtualKey != (modifier.m_virtualKey2 & 0xff) &&
|
|
|
|
(m_keys[modifier.m_virtualKey2 & 0xff] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
down = true;
|
|
|
|
}
|
|
|
|
if (!down)
|
2002-05-05 23:38:09 +04:00
|
|
|
mask &= ~modifier.m_mask;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "previous modifiers 0x%04x, final modifiers 0x%04x", m_mask, mask));
|
2002-04-30 20:23:03 +04:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::doKeystrokes(const Keystrokes& keys, SInt32 count)
|
2002-05-04 22:08:22 +04:00
|
|
|
{
|
|
|
|
// do nothing if no keys or no repeats
|
2002-06-11 02:06:45 +04:00
|
|
|
if (count < 1 || keys.empty()) {
|
2002-05-04 22:08:22 +04:00
|
|
|
return;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-04 22:08:22 +04: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) {
|
2002-05-22 21:01:17 +04:00
|
|
|
sendKeyEvent(k->m_virtualKey, k->m_press);
|
2002-05-04 22:08:22 +04: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
|
2002-05-22 21:01:17 +04:00
|
|
|
sendKeyEvent(k->m_virtualKey, k->m_press);
|
2002-05-04 22:08:22 +04:00
|
|
|
|
|
|
|
// next key
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-01 17:03:16 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::releaseKeys()
|
|
|
|
{
|
|
|
|
CLock lock(&m_mutex);
|
|
|
|
|
|
|
|
syncDesktop();
|
|
|
|
|
|
|
|
// release left/right modifier keys first. if the platform doesn't
|
|
|
|
// support them then they won't be set and the non-side-distinuishing
|
|
|
|
// key will retain its state. if the platform does support them then
|
|
|
|
// the non-side-distinguishing will be reset.
|
|
|
|
if ((m_keys[VK_LSHIFT] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_LSHIFT, false);
|
|
|
|
m_keys[VK_SHIFT] = 0;
|
|
|
|
m_keys[VK_LSHIFT] = 0;
|
|
|
|
}
|
|
|
|
if ((m_keys[VK_RSHIFT] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_RSHIFT, false);
|
|
|
|
m_keys[VK_SHIFT] = 0;
|
|
|
|
m_keys[VK_RSHIFT] = 0;
|
|
|
|
}
|
|
|
|
if ((m_keys[VK_LCONTROL] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_LCONTROL, false);
|
|
|
|
m_keys[VK_CONTROL] = 0;
|
|
|
|
m_keys[VK_LCONTROL] = 0;
|
|
|
|
}
|
|
|
|
if ((m_keys[VK_RCONTROL] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_RCONTROL, false);
|
|
|
|
m_keys[VK_CONTROL] = 0;
|
|
|
|
m_keys[VK_RCONTROL] = 0;
|
|
|
|
}
|
|
|
|
if ((m_keys[VK_LMENU] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_LMENU, false);
|
|
|
|
m_keys[VK_MENU] = 0;
|
|
|
|
m_keys[VK_LMENU] = 0;
|
|
|
|
}
|
|
|
|
if ((m_keys[VK_RMENU] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(VK_RMENU, false);
|
|
|
|
m_keys[VK_MENU] = 0;
|
|
|
|
m_keys[VK_RMENU] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now check all the other keys
|
|
|
|
for (UInt32 i = 0; i < sizeof(m_keys) / sizeof(m_keys[0]); ++i) {
|
|
|
|
if ((m_keys[i] & 0x80) != 0) {
|
|
|
|
sendKeyEvent(i, false);
|
|
|
|
m_keys[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::updateKeys()
|
2002-04-30 20:23:03 +04:00
|
|
|
{
|
2002-05-22 21:01:17 +04:00
|
|
|
// clear key state
|
2002-05-04 22:08:22 +04:00
|
|
|
memset(m_keys, 0, sizeof(m_keys));
|
2002-05-22 21:01:17 +04:00
|
|
|
|
|
|
|
// we only care about the modifier key states
|
|
|
|
m_keys[VK_LSHIFT] = static_cast<BYTE>(GetKeyState(VK_LSHIFT));
|
|
|
|
m_keys[VK_RSHIFT] = static_cast<BYTE>(GetKeyState(VK_RSHIFT));
|
|
|
|
m_keys[VK_SHIFT] = static_cast<BYTE>(GetKeyState(VK_SHIFT));
|
|
|
|
m_keys[VK_LCONTROL] = static_cast<BYTE>(GetKeyState(VK_LCONTROL));
|
|
|
|
m_keys[VK_RCONTROL] = static_cast<BYTE>(GetKeyState(VK_RCONTROL));
|
|
|
|
m_keys[VK_CONTROL] = static_cast<BYTE>(GetKeyState(VK_CONTROL));
|
|
|
|
m_keys[VK_LMENU] = static_cast<BYTE>(GetKeyState(VK_LMENU));
|
|
|
|
m_keys[VK_RMENU] = static_cast<BYTE>(GetKeyState(VK_RMENU));
|
|
|
|
m_keys[VK_MENU] = static_cast<BYTE>(GetKeyState(VK_MENU));
|
|
|
|
m_keys[VK_LWIN] = static_cast<BYTE>(GetKeyState(VK_LWIN));
|
|
|
|
m_keys[VK_RWIN] = static_cast<BYTE>(GetKeyState(VK_RWIN));
|
|
|
|
m_keys[VK_APPS] = static_cast<BYTE>(GetKeyState(VK_APPS));
|
|
|
|
m_keys[VK_CAPITAL] = static_cast<BYTE>(GetKeyState(VK_CAPITAL));
|
|
|
|
m_keys[VK_NUMLOCK] = static_cast<BYTE>(GetKeyState(VK_NUMLOCK));
|
|
|
|
m_keys[VK_SCROLL] = static_cast<BYTE>(GetKeyState(VK_SCROLL));
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsSecondaryScreen::updateModifiers()
|
2002-04-30 20:23:03 +04:00
|
|
|
{
|
|
|
|
// update active modifier mask
|
|
|
|
m_mask = 0;
|
2002-06-11 02:06:45 +04:00
|
|
|
if ((m_keys[VK_LSHIFT] & 0x80) != 0 || (m_keys[VK_RSHIFT] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierShift;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_LCONTROL] & 0x80) != 0 ||
|
|
|
|
(m_keys[VK_RCONTROL] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierControl;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_LMENU] & 0x80) != 0 || (m_keys[VK_RMENU] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierAlt;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_LWIN] & 0x80) != 0 || (m_keys[VK_RWIN] & 0x80) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierMeta;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_CAPITAL] & 0x01) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierCapsLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_NUMLOCK] & 0x01) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierNumLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_SCROLL] & 0x01) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
m_mask |= KeyModifierScrollLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-04 22:08:22 +04:00
|
|
|
log((CLOG_DEBUG2 "modifiers on update: 0x%04x", m_mask));
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
2002-04-30 21:48:11 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::toggleKey(UINT virtualKey, KeyModifierMask mask)
|
2002-04-30 21:48:11 +04:00
|
|
|
{
|
|
|
|
// send key events to simulate a press and release
|
2002-05-22 21:01:17 +04:00
|
|
|
sendKeyEvent(virtualKey, true);
|
|
|
|
sendKeyEvent(virtualKey, false);
|
2002-04-30 21:48:11 +04:00
|
|
|
|
|
|
|
// toggle shadow state
|
2002-05-22 21:01:17 +04:00
|
|
|
m_mask ^= mask;
|
|
|
|
m_keys[virtualKey & 0xff] ^= 0x01;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
UINT
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::virtualKeyToScanCode(UINT& virtualKey)
|
2002-05-22 21:01:17 +04:00
|
|
|
{
|
|
|
|
// try mapping given virtual key
|
|
|
|
UINT code = MapVirtualKey(virtualKey & 0xff, 0);
|
2002-06-11 02:06:45 +04:00
|
|
|
if (code != 0) {
|
2002-05-22 21:01:17 +04:00
|
|
|
return code;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
|
|
|
// no dice. if the virtual key distinguishes between left/right
|
|
|
|
// then try the one that doesn't distinguish sides. windows (or
|
|
|
|
// keyboard drivers) are inconsistent in their treatment of these
|
|
|
|
// virtual keys. the following behaviors have been observed:
|
|
|
|
//
|
|
|
|
// win2k (gateway desktop):
|
|
|
|
// MapVirtualKey(vk, 0):
|
|
|
|
// VK_SHIFT == VK_LSHIFT != VK_RSHIFT
|
|
|
|
// VK_CONTROL == VK_LCONTROL == VK_RCONTROL
|
|
|
|
// VK_MENU == VK_LMENU == VK_RMENU
|
|
|
|
// MapVirtualKey(sc, 3):
|
|
|
|
// VK_LSHIFT and VK_RSHIFT mapped independently
|
|
|
|
// VK_LCONTROL is mapped but not VK_RCONTROL
|
|
|
|
// VK_LMENU is mapped but not VK_RMENU
|
|
|
|
//
|
|
|
|
// win me (sony vaio laptop):
|
|
|
|
// MapVirtualKey(vk, 0):
|
|
|
|
// VK_SHIFT mapped; VK_LSHIFT, VK_RSHIFT not mapped
|
|
|
|
// VK_CONTROL mapped; VK_LCONTROL, VK_RCONTROL not mapped
|
|
|
|
// VK_MENU mapped; VK_LMENU, VK_RMENU not mapped
|
|
|
|
// MapVirtualKey(sc, 3):
|
|
|
|
// all scan codes unmapped (function apparently unimplemented)
|
|
|
|
switch (virtualKey & 0xff) {
|
|
|
|
case VK_LSHIFT:
|
|
|
|
case VK_RSHIFT:
|
|
|
|
virtualKey = VK_SHIFT;
|
|
|
|
return MapVirtualKey(VK_SHIFT, 0);
|
|
|
|
|
|
|
|
case VK_LCONTROL:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
virtualKey = VK_CONTROL;
|
|
|
|
return MapVirtualKey(VK_CONTROL, 0);
|
|
|
|
|
|
|
|
case VK_LMENU:
|
|
|
|
case VK_RMENU:
|
|
|
|
virtualKey = VK_MENU;
|
|
|
|
return MapVirtualKey(VK_MENU, 0);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::isExtendedKey(UINT virtualKey)
|
2002-05-22 21:01:17 +04:00
|
|
|
{
|
|
|
|
// see if we've already encoded the extended flag
|
2002-06-11 02:06:45 +04:00
|
|
|
if ((virtualKey & 0x100) != 0) {
|
2002-05-22 21:01:17 +04:00
|
|
|
return true;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
|
|
|
// check known virtual keys
|
|
|
|
switch (virtualKey & 0xff) {
|
|
|
|
case VK_NUMLOCK:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
case VK_RMENU:
|
|
|
|
case VK_LWIN:
|
|
|
|
case VK_RWIN:
|
|
|
|
case VK_APPS:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsSecondaryScreen::sendKeyEvent(UINT virtualKey, bool press)
|
2002-05-22 21:01:17 +04:00
|
|
|
{
|
|
|
|
DWORD flags = 0;
|
2002-06-11 02:06:45 +04:00
|
|
|
if (isExtendedKey(virtualKey)) {
|
2002-05-22 21:01:17 +04:00
|
|
|
flags |= KEYEVENTF_EXTENDEDKEY;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if (!press) {
|
2002-05-22 21:01:17 +04:00
|
|
|
flags |= KEYEVENTF_KEYUP;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
const UINT code = virtualKeyToScanCode(virtualKey);
|
|
|
|
keybd_event(static_cast<BYTE>(virtualKey & 0xff),
|
|
|
|
static_cast<BYTE>(code), flags, 0);
|
|
|
|
log((CLOG_DEBUG2 "send key %d, 0x%04x, %s%s", virtualKey & 0xff, code, ((flags & KEYEVENTF_KEYUP) ? "release" : "press"), ((flags & KEYEVENTF_EXTENDEDKEY) ? " extended" : "")));
|
2002-04-30 21:48:11 +04:00
|
|
|
}
|