added platform independent clipboard transfer stuff

clipboard owner support (MS windows done, X windows partial)
added key transfer on ms windows
mutex fixes in CClient (had race conditions)
faster debug output in ms windows
changed temporary screen name to "secondary"
network fixes on ms windows (poll returned wrong result)
fixed transparent cursor on ms windows
This commit is contained in:
crs
2001-11-25 18:32:41 +00:00
parent 3f6146b15f
commit f15c9df85b
43 changed files with 1590 additions and 324 deletions

View File

@@ -1,6 +1,8 @@
#include "CMSWindowsPrimaryScreen.h"
#include "CMSWindowsClipboard.h"
#include "CServer.h"
#include "CSynergyHook.h"
#include "XSynergy.h"
#include "CThread.h"
#include "CLog.h"
#include <assert.h>
@@ -13,6 +15,8 @@ CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen() :
m_server(NULL),
m_active(false),
m_window(NULL),
m_nextClipboardWindow(NULL),
m_clipboardOwner(NULL),
m_hookLibrary(NULL),
m_mark(0),
m_markReceived(0)
@@ -26,6 +30,8 @@ CMSWindowsPrimaryScreen::~CMSWindowsPrimaryScreen()
assert(m_hookLibrary == NULL);
}
static CString s_log;
static CString s_logMore;
static HWND s_debug = NULL;
static HWND s_debugLog = NULL;
static DWORD s_thread = 0;
@@ -38,28 +44,26 @@ static BOOL CALLBACK WINAPI debugProc(HWND, UINT msg, WPARAM wParam, LPARAM lPar
case WM_CLOSE:
PostQuitMessage(0);
return TRUE;
case WM_APP:
if (!s_logMore.empty()) {
if (s_log.size() > 20000)
s_log = s_logMore;
else
s_log += s_logMore;
s_logMore = "";
SendMessage(s_debugLog, WM_SETTEXT, FALSE, (LPARAM)(LPCTSTR)s_log.c_str());
SendMessage(s_debugLog, EM_SETSEL, s_log.size(), s_log.size());
SendMessage(s_debugLog, EM_SCROLLCARET, 0, 0);
}
return TRUE;
}
return FALSE;
}
static void debugOutput(const char* msg)
{
if (s_thread != 0) {
const DWORD threadID = ::GetCurrentThreadId();
if (threadID != s_thread) {
GetDesktopWindow();
AttachThreadInput(threadID, s_thread, TRUE);
}
}
DWORD len = SendMessage(s_debugLog, WM_GETTEXTLENGTH, 0, 0);
if (len > 20000) {
SendMessage(s_debugLog, EM_SETSEL, -1, 0);
SendMessage(s_debugLog, WM_SETTEXT, FALSE, (LPARAM)(LPCTSTR)msg);
}
else {
SendMessage(s_debugLog, EM_SETSEL, -1, len);
SendMessage(s_debugLog, EM_REPLACESEL, FALSE, (LPARAM)(LPCTSTR)msg);
}
SendMessage(s_debugLog, EM_SCROLLCARET, 0, 0);
s_logMore += msg;
PostMessage(s_debug, WM_APP, 0, 0);
}
void CMSWindowsPrimaryScreen::run()
@@ -114,6 +118,13 @@ void CMSWindowsPrimaryScreen::enter(SInt32 x, SInt32 y)
void CMSWindowsPrimaryScreen::doEnter()
{
// release the capture
ReleaseCapture();
// hide our window and restore the foreground window
SetForegroundWindow(m_lastActive);
ShowWindow(m_window, SW_HIDE);
// set the zones that should cause a jump
SInt32 w, h;
getScreenSize(&w, &h);
@@ -136,6 +147,16 @@ void CMSWindowsPrimaryScreen::leave()
// all messages prior to now are invalid
nextMark();
// remember the active window before we leave
m_lastActive = GetForegroundWindow();
// show our window and put it in the foreground
ShowWindow(m_window, SW_SHOW);
SetForegroundWindow(m_window);
// capture the cursor so we don't lose keyboard input
SetCapture(m_window);
// relay all mouse and keyboard events
SetRelayFunc setRelay = (SetRelayFunc)GetProcAddress(
m_hookLibrary, "setRelay");
@@ -151,6 +172,30 @@ void CMSWindowsPrimaryScreen::leave()
// local client now active
m_active = true;
// 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_server->grabClipboard();
}
}
catch (XBadClient&) {
// ignore
}
}
}
void CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
@@ -164,18 +209,22 @@ void CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
}
void CMSWindowsPrimaryScreen::setClipboard(
const IClipboard* /*clipboard*/)
const IClipboard* src)
{
assert(m_window != NULL);
// FIXME -- should we retry until we get it?
if (!OpenClipboard(m_window))
return;
if (EmptyClipboard()) {
log((CLOG_DEBUG "grabbed clipboard"));
// FIXME -- set the clipboard data
CMSWindowsClipboard dst(m_window);
CClipboard::copy(&dst, src);
}
void CMSWindowsPrimaryScreen::grabClipboard()
{
assert(m_window != NULL);
CMSWindowsClipboard clipboard(m_window);
if (clipboard.open()) {
clipboard.close();
}
CloseClipboard();
}
void CMSWindowsPrimaryScreen::getSize(
@@ -190,11 +239,12 @@ SInt32 CMSWindowsPrimaryScreen::getJumpZoneSize() const
}
void CMSWindowsPrimaryScreen::getClipboard(
IClipboard* clipboard) const
IClipboard* dst) const
{
// FIXME -- put this in superclass?
// FIXME -- don't use CurrentTime
// getDisplayClipboard(clipboard, m_window, CurrentTime);
assert(m_window != NULL);
CMSWindowsClipboard src(m_window);
CClipboard::copy(dst, &src);
}
#include "resource.h" // FIXME
@@ -211,6 +261,10 @@ s_debugLog = ::GetDlgItem(s_debug, IDC_LOG);
CLog::setOutputter(&debugOutput);
ShowWindow(s_debug, SW_SHOWNORMAL);
// 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 window
m_window = CreateWindowEx(WS_EX_TOPMOST |
WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW,
@@ -219,6 +273,10 @@ ShowWindow(s_debug, SW_SHOWNORMAL);
0, 0, 1, 1, NULL, NULL,
getInstance(),
NULL);
assert(m_window != NULL);
// install our clipboard snooper
m_nextClipboardWindow = SetClipboardViewer(m_window);
// load the hook library
bool hooked = false;
@@ -232,6 +290,8 @@ ShowWindow(s_debug, SW_SHOWNORMAL);
}
}
if (!hooked) {
ChangeClipboardChain(m_window, m_nextClipboardWindow);
m_nextClipboardWindow = NULL;
DestroyWindow(m_window);
m_window = NULL;
// FIXME -- throw
@@ -258,6 +318,10 @@ void CMSWindowsPrimaryScreen::onCloseDisplay()
FreeLibrary(m_hookLibrary);
m_hookLibrary = NULL;
// remove clipboard snooper
ChangeClipboardChain(m_window, m_nextClipboardWindow);
m_nextClipboardWindow = NULL;
// destroy window
DestroyWindow(m_window);
m_window = NULL;
@@ -268,7 +332,7 @@ s_debug = NULL;
s_thread = 0;
}
bool CMSWindowsPrimaryScreen::onEvent(MSG* msg)
bool CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
{
if (IsDialogMessage(s_debug, msg)) {
return true;
@@ -276,11 +340,6 @@ if (IsDialogMessage(s_debug, msg)) {
// handle event
switch (msg->message) {
// FIXME -- handle display changes
case WM_PAINT:
ValidateRect(m_window, NULL);
return true;
case SYNERGY_MSG_MARK:
m_markReceived = msg->wParam;
return true;
@@ -288,7 +347,29 @@ if (IsDialogMessage(s_debug, msg)) {
case SYNERGY_MSG_KEY:
// ignore if not at current mark
if (m_mark == m_markReceived) {
// FIXME -- vk code; key data
KeyModifierMask mask;
const KeyID key = mapKey(msg->wParam, msg->lParam, &mask);
log((CLOG_DEBUG "event: key event vk=%d info=0x%08x", msg->wParam, msg->lParam));
if (key != kKeyNone) {
if ((msg->lParam & 0x80000000) == 0) {
// key press
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
if (repeat >= 2) {
log((CLOG_DEBUG "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat));
m_server->onKeyRepeat(key, mask, repeat);
}
else {
log((CLOG_DEBUG "event: key press key=%d mask=0x%04x", key, mask));
m_server->onKeyDown(key, mask);
}
}
else {
// key release
log((CLOG_DEBUG "event: key release key=%d mask=0x%04x", key, mask));
m_server->onKeyUp(key, mask);
}
}
}
return true;
@@ -357,74 +438,46 @@ if (IsDialogMessage(s_debug, msg)) {
}
return false;
/*
case WM_MOUSEMOVE: {
if (!m_active) {
// mouse entered a jump zone window
POINT p;
p.x = (short)LOWORD(msg.lParam);
p.y = (short)HIWORD(msg.lParam);
ClientToScreen(msg.hwnd, &p);
log((CLOG_DEBUG "event: WM_MOUSEMOVE %d,%d", p.x, p.y));
m_server->onMouseMovePrimary((SInt32)p.x, (SInt32)p.y);
}
LRESULT CMSWindowsPrimaryScreen::onEvent(
HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch (msg) {
// FIXME -- handle display changes
case WM_PAINT:
ValidateRect(hwnd, NULL);
return 0;
case WM_DRAWCLIPBOARD:
log((CLOG_DEBUG "clipboard was taken"));
// first pass it on
SendMessage(m_nextClipboardWindow, msg, wParam, lParam);
// now notify server that somebody changed the clipboard.
// skip that if we're the new owner.
try {
m_clipboardOwner = GetClipboardOwner();
if (m_clipboardOwner != m_window) {
m_server->grabClipboard();
}
}
break;
}
case KeyPress: {
log((CLOG_DEBUG "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(xevent.xkey.keycode, mask);
if (key != kKeyNULL) {
m_server->onKeyDown(key, mask);
catch (XBadClient&) {
// ignore. this can happen if we receive this event
// before we've fully started up.
}
break;
}
return 0;
// FIXME -- simulate key repeat. X sends press/release for
// repeat. must detect auto repeat and use kKeyRepeat.
case KeyRelease: {
log((CLOG_DEBUG "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
const KeyID key = mapKey(xevent.xkey.keycode, mask);
if (key != kKeyNULL) {
m_server->onKeyUp(key, mask);
}
break;
}
case ButtonPress: {
log((CLOG_DEBUG "event: ButtonPress button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNULL) {
m_server->onMouseDown(button);
}
break;
}
case ButtonRelease: {
log((CLOG_DEBUG "event: ButtonRelease button=%d", xevent.xbutton.button));
const ButtonID button = mapButton(xevent.xbutton.button);
if (button != kButtonNULL) {
m_server->onMouseUp(button);
}
break;
}
case SelectionClear:
target->XXX(xevent.xselectionclear.);
break;
case SelectionNotify:
target->XXX(xevent.xselection.);
break;
case SelectionRequest:
target->XXX(xevent.xselectionrequest.);
break;
case WM_CHANGECBCHAIN:
if (m_nextClipboardWindow == (HWND)wParam)
m_nextClipboardWindow = (HWND)lParam;
else
SendMessage(m_nextClipboardWindow, msg, wParam, lParam);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
*/
}
void CMSWindowsPrimaryScreen::nextMark()
@@ -434,34 +487,274 @@ void CMSWindowsPrimaryScreen::nextMark()
PostMessage(m_window, SYNERGY_MSG_MARK, ++m_mark, 0);
}
#if 0
bool CMSWindowsPrimaryScreen::keyboardHook(
int /*code*/, WPARAM wParam, LPARAM lParam)
static const KeyID g_virtualKey[] =
{
if (m_active) {
// handle keyboard events
const KeyID key = mapKey(wParam, lParam);
if (key != kKeyNone) {
const KeyModifierMask modifiers = mapModifier(wParam, lParam);
if ((lParam & KF_UP) == 0) {
log((CLOG_DEBUG "event: key press key=%d", key));
m_server->onKeyDown(key, modifiers);
}
else {
log((CLOG_DEBUG "event: key release key=%d", key));
m_server->onKeyUp(key, modifiers);
}
return true;
}
}
return false;
}
#endif
/* 0x00 */ kKeyNone, // reserved
/* 0x01 */ kKeyNone, // VK_LBUTTON
/* 0x02 */ kKeyNone, // VK_RBUTTON
/* 0x03 */ 0xff6b, // VK_CANCEL XK_Break
/* 0x04 */ kKeyNone, // VK_MBUTTON
/* 0x05 */ kKeyNone, // undefined
/* 0x06 */ kKeyNone, // undefined
/* 0x07 */ kKeyNone, // undefined
/* 0x08 */ 0xff08, // VK_BACK XK_Backspace
/* 0x09 */ 0xff09, // VK_TAB VK_Tab
/* 0x0a */ kKeyNone, // undefined
/* 0x0b */ kKeyNone, // undefined
/* 0x0c */ 0xff0b, // VK_CLEAR XK_Clear
/* 0x0d */ 0xff0d, // VK_RETURN XK_Return
/* 0x0e */ kKeyNone, // undefined
/* 0x0f */ kKeyNone, // undefined
/* 0x10 */ 0xffe1, // VK_SHIFT XK_Shift_L
/* 0x11 */ 0xffe3, // VK_CONTROL XK_Control_L
/* 0x12 */ 0xffe9, // VK_MENU XK_Alt_L
/* 0x13 */ 0xff13, // VK_PAUSE XK_Pause
/* 0x14 */ 0xffe5, // VK_CAPITAL XK_Caps_Lock
/* 0x15 */ kKeyNone, // VK_KANA
/* 0x16 */ kKeyNone, // VK_HANGUL
/* 0x17 */ kKeyNone, // VK_JUNJA
/* 0x18 */ kKeyNone, // VK_FINAL
/* 0x19 */ kKeyNone, // VK_KANJI
/* 0x1a */ kKeyNone, // undefined
/* 0x1b */ 0xff1b, // VK_ESCAPE XK_Escape
/* 0x1c */ kKeyNone, // VK_CONVERT
/* 0x1d */ kKeyNone, // VK_NONCONVERT
/* 0x1e */ kKeyNone, // VK_ACCEPT
/* 0x1f */ kKeyNone, // VK_MODECHANGE
/* 0x20 */ 0xff20, // VK_SPACE XK_space
/* 0x21 */ 0xff55, // VK_PRIOR XK_Prior
/* 0x22 */ 0xff56, // VK_NEXT XK_Next
/* 0x23 */ 0xff57, // VK_END XK_End
/* 0x24 */ 0xff50, // VK_HOME XK_Home
/* 0x25 */ 0xff51, // VK_LEFT XK_Left
/* 0x26 */ 0xff52, // VK_UP XK_Up
/* 0x27 */ 0xff53, // VK_RIGHT XK_Right
/* 0x28 */ 0xff54, // VK_DOWN XK_Down
/* 0x29 */ 0xff60, // VK_SELECT XK_Select
/* 0x2a */ kKeyNone, // VK_PRINT
/* 0x2b */ 0xff62, // VK_EXECUTE XK_Execute
/* 0x2c */ 0xff61, // VK_SNAPSHOT XK_Print
/* 0x2d */ 0xff63, // VK_INSERT XK_Insert
/* 0x2e */ 0xffff, // VK_DELETE XK_Delete
/* 0x2f */ 0xff6a, // VK_HELP XK_Help
/* 0x30 */ 0x0030, // VK_0 XK_0
/* 0x31 */ 0x0031, // VK_1 XK_1
/* 0x32 */ 0x0032, // VK_2 XK_2
/* 0x33 */ 0x0033, // VK_3 XK_3
/* 0x34 */ 0x0034, // VK_4 XK_4
/* 0x35 */ 0x0035, // VK_5 XK_5
/* 0x36 */ 0x0036, // VK_6 XK_6
/* 0x37 */ 0x0037, // VK_7 XK_7
/* 0x38 */ 0x0038, // VK_8 XK_8
/* 0x39 */ 0x0039, // VK_9 XK_9
/* 0x3a */ kKeyNone, // undefined
/* 0x3b */ kKeyNone, // undefined
/* 0x3c */ kKeyNone, // undefined
/* 0x3d */ kKeyNone, // undefined
/* 0x3e */ kKeyNone, // undefined
/* 0x3f */ kKeyNone, // undefined
/* 0x40 */ kKeyNone, // undefined
/* 0x41 */ 0x0041, // VK_A XK_A
/* 0x42 */ 0x0042, // VK_B XK_B
/* 0x43 */ 0x0043, // VK_C XK_C
/* 0x44 */ 0x0044, // VK_D XK_D
/* 0x45 */ 0x0045, // VK_E XK_E
/* 0x46 */ 0x0046, // VK_F XK_F
/* 0x47 */ 0x0047, // VK_G XK_G
/* 0x48 */ 0x0048, // VK_H XK_H
/* 0x49 */ 0x0049, // VK_I XK_I
/* 0x4a */ 0x004a, // VK_J XK_J
/* 0x4b */ 0x004b, // VK_K XK_K
/* 0x4c */ 0x004c, // VK_L XK_L
/* 0x4d */ 0x004d, // VK_M XK_M
/* 0x4e */ 0x004e, // VK_N XK_N
/* 0x4f */ 0x004f, // VK_O XK_O
/* 0x50 */ 0x0050, // VK_P XK_P
/* 0x51 */ 0x0051, // VK_Q XK_Q
/* 0x52 */ 0x0052, // VK_R XK_R
/* 0x53 */ 0x0053, // VK_S XK_S
/* 0x54 */ 0x0054, // VK_T XK_T
/* 0x55 */ 0x0055, // VK_U XK_U
/* 0x56 */ 0x0056, // VK_V XK_V
/* 0x57 */ 0x0057, // VK_W XK_W
/* 0x58 */ 0x0058, // VK_X XK_X
/* 0x59 */ 0x0059, // VK_Y XK_Y
/* 0x5a */ 0x005a, // VK_Z XK_Z
/* 0x5b */ 0xffe7, // VK_LWIN XK_Meta_L
/* 0x5c */ 0xffe8, // VK_RWIN XK_Meta_R
/* 0x5d */ 0xff67, // VK_APPS XK_Menu
/* 0x5e */ kKeyNone, // undefined
/* 0x5f */ kKeyNone, // undefined
/* 0x60 */ 0xffb0, // VK_NUMPAD0 XK_KP_0
/* 0x61 */ 0xffb1, // VK_NUMPAD1 XK_KP_1
/* 0x62 */ 0xffb2, // VK_NUMPAD2 XK_KP_2
/* 0x63 */ 0xffb3, // VK_NUMPAD3 XK_KP_3
/* 0x64 */ 0xffb4, // VK_NUMPAD4 XK_KP_4
/* 0x65 */ 0xffb5, // VK_NUMPAD5 XK_KP_5
/* 0x66 */ 0xffb6, // VK_NUMPAD6 XK_KP_6
/* 0x67 */ 0xffb7, // VK_NUMPAD7 XK_KP_7
/* 0x68 */ 0xffb8, // VK_NUMPAD8 XK_KP_8
/* 0x69 */ 0xffb9, // VK_NUMPAD9 XK_KP_9
/* 0x6a */ 0xffaa, // VK_MULTIPLY XK_KP_Multiply
/* 0x6b */ 0xffab, // VK_ADD XK_KP_Add
/* 0x6c */ 0xffac, // VK_SEPARATOR XK_KP_Separator
/* 0x6d */ 0xffad, // VK_SUBTRACT XK_KP_Subtract
/* 0x6e */ 0xffae, // VK_DECIMAL XK_KP_Decimal
/* 0x6f */ 0xffaf, // VK_DIVIDE XK_KP_Divide
/* 0x70 */ 0xffbe, // VK_F1 XK_F1
/* 0x71 */ 0xffbf, // VK_F2 XK_F2
/* 0x72 */ 0xffc0, // VK_F3 XK_F3
/* 0x73 */ 0xffc1, // VK_F4 XK_F4
/* 0x74 */ 0xffc2, // VK_F5 XK_F5
/* 0x75 */ 0xffc3, // VK_F6 XK_F6
/* 0x76 */ 0xffc4, // VK_F7 XK_F7
/* 0x77 */ 0xffc5, // VK_F8 XK_F8
/* 0x78 */ 0xffc6, // VK_F9 XK_F9
/* 0x79 */ 0xffc7, // VK_F10 XK_F10
/* 0x7a */ 0xffc8, // VK_F11 XK_F11
/* 0x7b */ 0xffc9, // VK_F12 XK_F12
/* 0x7c */ 0xffca, // VK_F13 XK_F13
/* 0x7d */ 0xffcb, // VK_F14 XK_F14
/* 0x7e */ 0xffcc, // VK_F15 XK_F15
/* 0x7f */ 0xffcd, // VK_F16 XK_F16
/* 0x80 */ 0xffce, // VK_F17 XK_F17
/* 0x81 */ 0xffcf, // VK_F18 XK_F18
/* 0x82 */ 0xffd0, // VK_F19 XK_F19
/* 0x83 */ 0xffd1, // VK_F20 XK_F20
/* 0x84 */ 0xffd2, // VK_F21 XK_F21
/* 0x85 */ 0xffd3, // VK_F22 XK_F22
/* 0x86 */ 0xffd4, // VK_F23 XK_F23
/* 0x87 */ 0xffd5, // VK_F24 XK_F24
/* 0x88 */ kKeyNone, // unassigned
/* 0x89 */ kKeyNone, // unassigned
/* 0x8a */ kKeyNone, // unassigned
/* 0x8b */ kKeyNone, // unassigned
/* 0x8c */ kKeyNone, // unassigned
/* 0x8d */ kKeyNone, // unassigned
/* 0x8e */ kKeyNone, // unassigned
/* 0x8f */ kKeyNone, // unassigned
/* 0x90 */ 0xff7f, // VK_NUMLOCK XK_Num_Lock
/* 0x91 */ 0xff14, // VK_SCROLL XK_Scroll_Lock
/* 0x92 */ kKeyNone, // unassigned
/* 0x93 */ kKeyNone, // unassigned
/* 0x94 */ kKeyNone, // unassigned
/* 0x95 */ kKeyNone, // unassigned
/* 0x96 */ kKeyNone, // unassigned
/* 0x97 */ kKeyNone, // unassigned
/* 0x98 */ kKeyNone, // unassigned
/* 0x99 */ kKeyNone, // unassigned
/* 0x9a */ kKeyNone, // unassigned
/* 0x9b */ kKeyNone, // unassigned
/* 0x9c */ kKeyNone, // unassigned
/* 0x9d */ kKeyNone, // unassigned
/* 0x9e */ kKeyNone, // unassigned
/* 0x9f */ kKeyNone, // unassigned
/* 0xa0 */ kKeyNone, // unassigned
/* 0xa1 */ kKeyNone, // unassigned
/* 0xa2 */ kKeyNone, // unassigned
/* 0xa3 */ kKeyNone, // unassigned
/* 0xa4 */ kKeyNone, // unassigned
/* 0xa5 */ kKeyNone, // unassigned
/* 0xa6 */ kKeyNone, // unassigned
/* 0xa7 */ kKeyNone, // unassigned
/* 0xa8 */ kKeyNone, // unassigned
/* 0xa9 */ kKeyNone, // unassigned
/* 0xaa */ kKeyNone, // unassigned
/* 0xab */ kKeyNone, // unassigned
/* 0xac */ kKeyNone, // unassigned
/* 0xad */ kKeyNone, // unassigned
/* 0xae */ kKeyNone, // unassigned
/* 0xaf */ kKeyNone, // unassigned
/* 0xb0 */ kKeyNone, // unassigned
/* 0xb1 */ kKeyNone, // unassigned
/* 0xb2 */ kKeyNone, // unassigned
/* 0xb3 */ kKeyNone, // unassigned
/* 0xb4 */ kKeyNone, // unassigned
/* 0xb5 */ kKeyNone, // unassigned
/* 0xb6 */ kKeyNone, // unassigned
/* 0xb7 */ kKeyNone, // unassigned
/* 0xb8 */ kKeyNone, // unassigned
/* 0xb9 */ kKeyNone, // unassigned
/* 0xba */ kKeyNone, // OEM specific
/* 0xbb */ kKeyNone, // OEM specific
/* 0xbc */ kKeyNone, // OEM specific
/* 0xbd */ kKeyNone, // OEM specific
/* 0xbe */ kKeyNone, // OEM specific
/* 0xbf */ kKeyNone, // OEM specific
/* 0xc0 */ kKeyNone, // OEM specific
/* 0xc1 */ kKeyNone, // unassigned
/* 0xc2 */ kKeyNone, // unassigned
/* 0xc3 */ kKeyNone, // unassigned
/* 0xc4 */ kKeyNone, // unassigned
/* 0xc5 */ kKeyNone, // unassigned
/* 0xc6 */ kKeyNone, // unassigned
/* 0xc7 */ kKeyNone, // unassigned
/* 0xc8 */ kKeyNone, // unassigned
/* 0xc9 */ kKeyNone, // unassigned
/* 0xca */ kKeyNone, // unassigned
/* 0xcb */ kKeyNone, // unassigned
/* 0xcc */ kKeyNone, // unassigned
/* 0xcd */ kKeyNone, // unassigned
/* 0xce */ kKeyNone, // unassigned
/* 0xcf */ kKeyNone, // unassigned
/* 0xd0 */ kKeyNone, // unassigned
/* 0xd1 */ kKeyNone, // unassigned
/* 0xd2 */ kKeyNone, // unassigned
/* 0xd3 */ kKeyNone, // unassigned
/* 0xd4 */ kKeyNone, // unassigned
/* 0xd5 */ kKeyNone, // unassigned
/* 0xd6 */ kKeyNone, // unassigned
/* 0xd7 */ kKeyNone, // unassigned
/* 0xd8 */ kKeyNone, // unassigned
/* 0xd9 */ kKeyNone, // unassigned
/* 0xda */ kKeyNone, // unassigned
/* 0xdb */ kKeyNone, // OEM specific
/* 0xdc */ kKeyNone, // OEM specific
/* 0xdd */ kKeyNone, // OEM specific
/* 0xde */ kKeyNone, // OEM specific
/* 0xdf */ kKeyNone, // OEM specific
/* 0xe0 */ kKeyNone, // OEM specific
/* 0xe1 */ kKeyNone, // OEM specific
/* 0xe2 */ kKeyNone, // OEM specific
/* 0xe3 */ kKeyNone, // OEM specific
/* 0xe4 */ kKeyNone, // OEM specific
/* 0xe5 */ kKeyNone, // unassigned
/* 0xe6 */ kKeyNone, // OEM specific
/* 0xe7 */ kKeyNone, // unassigned
/* 0xe8 */ kKeyNone, // unassigned
/* 0xe9 */ kKeyNone, // OEM specific
/* 0xea */ kKeyNone, // OEM specific
/* 0xeb */ kKeyNone, // OEM specific
/* 0xec */ kKeyNone, // OEM specific
/* 0xed */ kKeyNone, // OEM specific
/* 0xee */ kKeyNone, // OEM specific
/* 0xef */ kKeyNone, // OEM specific
/* 0xf0 */ kKeyNone, // OEM specific
/* 0xf1 */ kKeyNone, // OEM specific
/* 0xf2 */ kKeyNone, // OEM specific
/* 0xf3 */ kKeyNone, // OEM specific
/* 0xf4 */ kKeyNone, // OEM specific
/* 0xf5 */ kKeyNone, // OEM specific
/* 0xf6 */ kKeyNone, // VK_ATTN
/* 0xf7 */ kKeyNone, // VK_CRSEL
/* 0xf8 */ kKeyNone, // VK_EXSEL
/* 0xf9 */ kKeyNone, // VK_EREOF
/* 0xfa */ kKeyNone, // VK_PLAY
/* 0xfb */ kKeyNone, // VK_ZOOM
/* 0xfc */ kKeyNone, // reserved
/* 0xfd */ kKeyNone, // VK_PA1
/* 0xfe */ kKeyNone, // VK_OEM_CLEAR
/* 0xff */ kKeyNone // reserved
};
KeyModifierMask CMSWindowsPrimaryScreen::mapModifier(
WPARAM keycode, LPARAM info) const
KeyID CMSWindowsPrimaryScreen::mapKey(
WPARAM vkCode, LPARAM info,
KeyModifierMask* maskOut) const
{
// FIXME -- should be configurable
assert(maskOut != NULL);
// map modifier key
// FIXME -- should be configurable?
KeyModifierMask mask = 0;
if (GetKeyState(VK_SHIFT) < 0)
mask |= KeyModifierShift;
@@ -477,14 +770,48 @@ KeyModifierMask CMSWindowsPrimaryScreen::mapModifier(
mask |= KeyModifierMeta;
if ((GetKeyState(VK_SCROLL) & 1) != 0)
mask |= KeyModifierScrollLock;
return mask;
}
*maskOut = mask;
KeyID CMSWindowsPrimaryScreen::mapKey(
WPARAM keycode, LPARAM info) const
{
// FIXME -- must convert to X keysyms
return keycode;
KeyID id = g_virtualKey[vkCode];
if (id != kKeyNone) {
return id;
}
BYTE state[256];
GetKeyboardState(state);
WORD ascii;
int result = ToAscii(vkCode, MapVirtualKey(0, vkCode), state, &ascii, 0);
if (result > 0) {
// FIXME -- handle dead keys
return (KeyID)(ascii & 0x00ff);
}
return kKeyNone;
/*
UINT character = MapVirtualKey(2, vkCode);
if (character != 0) {
if ((character & ~0xff) != 0) {
// dead key (i.e. a key to compose with the next)
// FIXME
return kKeyNone;
}
else {
// map character
KeyID id = g_virtualKey[character & 0xff];
// uppercase to lowercase conversion
if ((mask & KeyModifierShift) == 0 && id >= 'A' && id <= 'Z')
id += 0x20;
return id;
}
}
else {
// non-ascii key
return g_virtualKey[vkCode];
}
*/
}
ButtonID CMSWindowsPrimaryScreen::mapButton(

View File

@@ -22,13 +22,15 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
virtual void leave();
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void setClipboard(const IClipboard*);
virtual void grabClipboard();
virtual void getSize(SInt32* width, SInt32* height) const;
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(IClipboard*) const;
protected:
// CMSWindowsScreen overrides
virtual bool onEvent(MSG*);
virtual bool onPreTranslate(MSG*);
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM);
virtual void onOpenDisplay();
virtual void onCloseDisplay();
@@ -37,17 +39,17 @@ class CMSWindowsPrimaryScreen : public CMSWindowsScreen, public IPrimaryScreen {
void nextMark();
// bool keyboardHook(int, WPARAM, LPARAM);
// bool mouseHook(int, WPARAM, LPARAM);
KeyModifierMask mapModifier(WPARAM keycode, LPARAM info) const;
KeyID mapKey(WPARAM keycode, LPARAM info) const;
KeyID mapKey(WPARAM keycode, LPARAM info,
KeyModifierMask* maskOut) const;
ButtonID mapButton(WPARAM button) const;
private:
CServer* m_server;
bool m_active;
HWND m_window;
HWND m_nextClipboardWindow;
HWND m_clipboardOwner;
HWND m_lastActive;
HINSTANCE m_hookLibrary;
UInt32 m_mark;
UInt32 m_markReceived;

View File

@@ -43,7 +43,9 @@ else { wait(0); exit(1); }
CServer::CServer() : m_primary(NULL),
m_active(NULL),
m_primaryInfo(NULL)
m_primaryInfo(NULL),
m_clipboardSeqNum(0),
m_clipboardReady(false)
{
m_socketFactory = NULL;
m_securityFactory = NULL;
@@ -78,7 +80,7 @@ void CServer::run()
closePrimaryScreen();
}
catch (XBase& e) {
log((CLOG_ERR "server error: %s\n", e.what()));
log((CLOG_ERR "server error: %s", e.what()));
// clean up
cleanupThreads();
@@ -148,6 +150,93 @@ void CServer::setInfo(const CString& client,
log((CLOG_NOTE "client \"%s\" size=%dx%d zone=%d", client.c_str(), w, h, zoneSize));
}
void CServer::grabClipboard()
{
grabClipboard(m_primaryInfo->m_name);
}
void CServer::grabClipboard(const CString& client)
{
CLock lock(&m_mutex);
// client must be connected
CScreenList::iterator index = m_screens.find(client);
if (index == m_screens.end()) {
throw XBadClient();
}
log((CLOG_NOTE "client \"%s\" grabbed clipboard from \"%s\"", client.c_str(), m_clipboardOwner.c_str()));
// save the clipboard owner
m_clipboardOwner = client;
// mark client as having the clipboard data
index->second->m_gotClipboard = true;
// tell all other clients to take ownership of clipboard and mark
// them as not having the data yet.
for (index = m_screens.begin(); index != m_screens.end(); ++index) {
if (index->first != client) {
CScreenInfo* info = index->second;
info->m_gotClipboard = false;
if (info->m_protocol == NULL) {
m_primary->grabClipboard();
}
else {
info->m_protocol->sendGrabClipboard();
}
}
}
// increment the clipboard sequence number so we can identify the
// clipboard query's response.
++m_clipboardSeqNum;
// begin getting the clipboard data
if (m_active->m_protocol == NULL) {
// get clipboard immediately from primary screen
m_primary->getClipboard(&m_clipboard);
m_clipboardData = m_clipboard.marshall();
m_clipboardReady = true;
}
else {
// clear out the clipboard since existing data is now out of date.
if (m_clipboard.open()) {
m_clipboard.close();
}
m_clipboardReady = false;
// send request but don't wait for reply
m_active->m_protocol->sendQueryClipboard(m_clipboardSeqNum);
}
}
void CServer::setClipboard(
UInt32 seqNum, const CString& data)
{
// update the clipboard if the sequence number matches
CLock lock(&m_mutex);
if (seqNum == m_clipboardSeqNum) {
// unmarshall into our clipboard buffer
m_clipboardData = data;
m_clipboard.unmarshall(m_clipboardData);
m_clipboardReady = true;
// if the active client doesn't have the clipboard data
// (and it won't unless the client is the one sending us
// the data) then send the data now.
if (!m_active->m_gotClipboard) {
if (m_active->m_protocol == NULL) {
m_primary->setClipboard(&m_clipboard);
}
else {
m_active->m_protocol->sendClipboard(m_clipboardData);
}
m_active->m_gotClipboard = true;
}
}
}
bool CServer::onCommandKey(KeyID /*id*/,
KeyModifierMask /*mask*/, bool /*down*/)
{
@@ -186,9 +275,10 @@ void CServer::onKeyUp(KeyID id, KeyModifierMask mask)
}
}
void CServer::onKeyRepeat(KeyID id, KeyModifierMask mask)
void CServer::onKeyRepeat(
KeyID id, KeyModifierMask mask, SInt32 count)
{
log((CLOG_DEBUG "onKeyRepeat id=%d mask=0x%04x", id, mask));
log((CLOG_DEBUG "onKeyRepeat id=%d mask=0x%04x count=%d", id, mask, count));
assert(m_active != NULL);
// handle command keys
@@ -199,7 +289,7 @@ void CServer::onKeyRepeat(KeyID id, KeyModifierMask mask)
// relay
if (m_active->m_protocol != NULL) {
m_active->m_protocol->sendKeyRepeat(id, mask);
m_active->m_protocol->sendKeyRepeat(id, mask, count);
}
}
@@ -385,11 +475,6 @@ bool CServer::isLockedToScreen() const
return false;
}
#if defined(CONFIG_PLATFORM_WIN32)
#include "CMSWindowsClipboard.h" // FIXME
#elif defined(CONFIG_PLATFORM_UNIX)
#include "CXWindowsClipboard.h" // FIXME
#endif
void CServer::switchScreen(CScreenInfo* dst,
SInt32 x, SInt32 y)
{
@@ -398,6 +483,7 @@ void CServer::switchScreen(CScreenInfo* dst,
assert(m_active != NULL);
log((CLOG_NOTE "switch from \"%s\" to \"%s\" at %d,%d", m_active->m_name.c_str(), dst->m_name.c_str(), x, y));
// FIXME -- we're not locked here but we probably should be
// wrapping means leaving the active screen and entering it again.
// since that's a waste of time we skip that and just warp the
@@ -406,14 +492,6 @@ void CServer::switchScreen(CScreenInfo* dst,
// leave active screen
if (m_active->m_protocol == NULL) {
m_primary->leave();
// FIXME -- testing
#if defined(CONFIG_PLATFORM_WIN32)
CMSWindowsClipboard clipboard;
#elif defined(CONFIG_PLATFORM_UNIX)
CXWindowsClipboard clipboard;
#endif
m_primary->getClipboard(&clipboard);
}
else {
m_active->m_protocol->sendLeave();
@@ -429,6 +507,17 @@ void CServer::switchScreen(CScreenInfo* dst,
else {
m_active->m_protocol->sendEnter(x, y);
}
// send the clipboard data if we haven't done so yet
if (m_clipboardReady && !m_active->m_gotClipboard) {
if (m_active->m_protocol == NULL) {
m_primary->setClipboard(&m_clipboard);
}
else {
m_active->m_protocol->sendClipboard(m_clipboardData);
}
m_active->m_gotClipboard = true;
}
}
else {
if (m_active->m_protocol == NULL) {
@@ -827,6 +916,13 @@ void CServer::openPrimaryScreen()
m_active->m_zoneSize = m_primary->getJumpZoneSize();
log((CLOG_NOTE "server size=%dx%d zone=%d", m_active->m_width, m_active->m_height, m_active->m_zoneSize));
// FIXME -- need way for primary screen to call us back
// set the clipboard owner to the primary screen and then get the
// current clipboard data.
m_primary->getClipboard(&m_clipboard);
m_clipboardData = m_clipboard.marshall();
m_clipboardReady = true;
m_clipboardOwner = m_active->m_name;
}
void CServer::closePrimaryScreen()
@@ -979,7 +1075,8 @@ CServer::CScreenInfo::CScreenInfo(const CString& name,
m_name(name),
m_protocol(protocol),
m_width(0), m_height(0),
m_zoneSize(0)
m_zoneSize(0),
m_gotClipboard(false)
{
// do nothing
}

View File

@@ -4,6 +4,7 @@
#include "KeyTypes.h"
#include "MouseTypes.h"
#include "CScreenMap.h"
#include "CClipboard.h"
#include "CMutex.h"
#include "CString.h"
#include "XBase.h"
@@ -36,16 +37,19 @@ class CServer {
// true iff the mouse enters a jump zone and jumps.
void onKeyDown(KeyID, KeyModifierMask);
void onKeyUp(KeyID, KeyModifierMask);
void onKeyRepeat(KeyID, KeyModifierMask);
void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
void onMouseDown(ButtonID);
void onMouseUp(ButtonID);
bool onMouseMovePrimary(SInt32 x, SInt32 y);
void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
void onMouseWheel(SInt32 delta);
void grabClipboard();
// handle messages from clients
void setInfo(const CString& clientName,
SInt32 w, SInt32 h, SInt32 zoneSize);
void grabClipboard(const CString& clientName);
void setClipboard(UInt32 seqNum, const CString& data);
// accessors
@@ -91,6 +95,7 @@ class CServer {
IServerProtocol* m_protocol;
SInt32 m_width, m_height;
SInt32 m_zoneSize;
bool m_gotClipboard;
};
// change the active screen
@@ -159,6 +164,12 @@ class CServer {
SInt32 m_x, m_y;
CScreenMap m_screenMap;
CClipboard m_clipboard;
CString m_clipboardData;
CString m_clipboardOwner;
UInt32 m_clipboardSeqNum;
bool m_clipboardReady;
};
#endif

View File

@@ -33,11 +33,12 @@ class CServerProtocol : public IServerProtocol {
virtual void sendClose() = 0;
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs) = 0;
virtual void sendLeave() = 0;
virtual void sendClipboard(const CString&) = 0;
virtual void sendGrabClipboard() = 0;
virtual void sendQueryClipboard() = 0;
virtual void sendQueryClipboard(UInt32 seqNum) = 0;
virtual void sendScreenSaver(bool on) = 0;
virtual void sendKeyDown(KeyID, KeyModifierMask) = 0;
virtual void sendKeyRepeat(KeyID, KeyModifierMask) = 0;
virtual void sendKeyRepeat(KeyID, KeyModifierMask, SInt32 count) = 0;
virtual void sendKeyUp(KeyID, KeyModifierMask) = 0;
virtual void sendMouseDown(ButtonID) = 0;
virtual void sendMouseUp(ButtonID) = 0;
@@ -47,6 +48,8 @@ class CServerProtocol : public IServerProtocol {
protected:
//IServerProtocol overrides
virtual void recvInfo() = 0;
virtual void recvClipboard() = 0;
virtual void recvGrabClipboard() = 0;
private:
CServer* m_server;

View File

@@ -1,5 +1,6 @@
#include "CServerProtocol1_0.h"
#include "CServer.h"
#include "CClipboard.h"
#include "CProtocolUtil.h"
#include "ProtocolTypes.h"
#include "IInputStream.h"
@@ -49,6 +50,12 @@ void CServerProtocol1_0::run()
if (memcmp(code, kMsgDInfo, 4) == 0) {
recvInfo();
}
else if (memcmp(code, kMsgCClipboard, 4) == 0) {
recvGrabClipboard();
}
else if (memcmp(code, kMsgDClipboard, 4) == 0) {
recvClipboard();
}
// FIXME -- more message here
else {
log((CLOG_ERR "unknown message from client \"%s\"", getClient().c_str()));
@@ -96,16 +103,22 @@ void CServerProtocol1_0::sendLeave()
CProtocolUtil::writef(getOutputStream(), kMsgCLeave);
}
void CServerProtocol1_0::sendClipboard(const CString& data)
{
log((CLOG_INFO "send clipboard to \"%s\" size=%d", getClient().c_str(), data.size()));
CProtocolUtil::writef(getOutputStream(), kMsgDClipboard, 0, &data);
}
void CServerProtocol1_0::sendGrabClipboard()
{
log((CLOG_INFO "send grab clipboard to \"%s\"", getClient().c_str()));
CProtocolUtil::writef(getOutputStream(), kMsgCClipboard);
}
void CServerProtocol1_0::sendQueryClipboard()
void CServerProtocol1_0::sendQueryClipboard(UInt32 seqNum)
{
log((CLOG_INFO "query clipboard to \"%s\"", getClient().c_str()));
CProtocolUtil::writef(getOutputStream(), kMsgQClipboard);
CProtocolUtil::writef(getOutputStream(), kMsgQClipboard, seqNum);
}
void CServerProtocol1_0::sendScreenSaver(bool on)
@@ -122,10 +135,10 @@ void CServerProtocol1_0::sendKeyDown(
}
void CServerProtocol1_0::sendKeyRepeat(
KeyID key, KeyModifierMask mask)
KeyID key, KeyModifierMask mask, SInt32 count)
{
log((CLOG_INFO "send key repeat to \"%s\" id=%d, mask=0x%04x", getClient().c_str(), key, mask));
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask);
CProtocolUtil::writef(getOutputStream(), kMsgDKeyRepeat, key, mask, count);
}
void CServerProtocol1_0::sendKeyUp(
@@ -179,3 +192,17 @@ void CServerProtocol1_0::recvInfo()
getServer()->setInfo(getClient(), w, h, zoneInfo);
}
void CServerProtocol1_0::recvClipboard()
{
UInt32 seqNum;
CString data;
CProtocolUtil::readf(getInputStream(), kMsgDClipboard + 4, &seqNum, &data);
log((CLOG_INFO "received client \"%s\" clipboard seqnum=%d, size=%d", getClient().c_str(), seqNum, data.size()));
getServer()->setClipboard(seqNum, data);
}
void CServerProtocol1_0::recvGrabClipboard()
{
log((CLOG_INFO "received client \"%s\" grabbed clipboard", getClient().c_str()));
getServer()->grabClipboard(getClient());
}

View File

@@ -18,11 +18,12 @@ class CServerProtocol1_0 : public CServerProtocol {
virtual void sendClose();
virtual void sendEnter(SInt32 xAbs, SInt32 yAbs);
virtual void sendLeave();
virtual void sendClipboard(const CString&);
virtual void sendGrabClipboard();
virtual void sendQueryClipboard();
virtual void sendQueryClipboard(UInt32 seqNum);
virtual void sendScreenSaver(bool on);
virtual void sendKeyDown(KeyID, KeyModifierMask);
virtual void sendKeyRepeat(KeyID, KeyModifierMask);
virtual void sendKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
virtual void sendKeyUp(KeyID, KeyModifierMask);
virtual void sendMouseDown(ButtonID);
virtual void sendMouseUp(ButtonID);
@@ -32,6 +33,8 @@ class CServerProtocol1_0 : public CServerProtocol {
protected:
// IServerProtocol overrides
virtual void recvInfo();
virtual void recvClipboard();
virtual void recvGrabClipboard();
};
#endif

View File

@@ -56,7 +56,10 @@ static void restoreCursor()
static LRESULT CALLBACK keyboardHook(int code, WPARAM wParam, LPARAM lParam)
{
if (code >= 0) {
// FIXME
if (g_relay) {
PostMessage(g_hwnd, SYNERGY_MSG_KEY, wParam, lParam);
return 1;
}
}
return CallNextHookEx(g_keyboard, code, wParam, lParam);

View File

@@ -14,10 +14,10 @@
#define CSYNERGYHOOK_API
#endif
#define SYNERGY_MSG_MARK WM_APP + 0x0001 // mark id; <unused>
#define SYNERGY_MSG_KEY WM_APP + 0x0002 // vk code; key data
#define SYNERGY_MSG_MOUSE_BUTTON WM_APP + 0x0003 // button msg; <unused>
#define SYNERGY_MSG_MOUSE_MOVE WM_APP + 0x0004 // x; y
#define SYNERGY_MSG_MARK WM_APP + 0x0011 // mark id; <unused>
#define SYNERGY_MSG_KEY WM_APP + 0x0012 // vk code; key data
#define SYNERGY_MSG_MOUSE_BUTTON WM_APP + 0x0013 // button msg; <unused>
#define SYNERGY_MSG_MOUSE_MOVE WM_APP + 0x0014 // x; y
typedef int (*InstallFunc)(HWND);
typedef int (*UninstallFunc)(void);

View File

@@ -117,19 +117,46 @@ void CXWindowsPrimaryScreen::run()
break;
}
/*
case SelectionClear:
target->XXX(xevent.xselectionclear.);
// we just lost the selection. that means someone else
// grabbed the selection so this screen is now the
// selection owner. report that to the server.
m_server->grabClipboard();
break;
case SelectionNotify:
target->XXX(xevent.xselection.);
// notification of selection transferred. we shouldn't
// get this here because we handle them in the selection
// retrieval methods. we'll just delete the property
// with the data (satisfying the usual ICCCM protocol).
if (xevent.xselection.property != None) {
CDisplayLock display(this);
XDeleteProperty(display, m_window, xevent.xselection.property);
}
break;
case SelectionRequest:
target->XXX(xevent.xselectionrequest.);
// somebody is asking for clipboard data
if (xevent.xselectionrequest.owner == m_window) {
addClipboardRequest(m_window,
xevent.xselectionrequest.requestor,
xevent.xselectionrequest.selection,
xevent.xselectionrequest.target,
xevent.xselectionrequest.property,
xevent.xselectionrequest.time);
}
break;
case PropertyNotify:
// clipboard transfers involve property changes so forward
// the event to the superclass. we only care about the
// deletion of properties.
if (xevent.xproperty.state == PropertyDelete) {
processClipboardRequest(xevent.xproperty.window,
xevent.xproperty.atom,
xevent.xproperty.time);
}
break;
*/
}
}
}
@@ -267,19 +294,17 @@ void CXWindowsPrimaryScreen::warpCursorNoLock(
}
}
#include <X11/Xatom.h> // FIXME
void CXWindowsPrimaryScreen::setClipboard(
const IClipboard* /*clipboard*/)
const IClipboard* clipboard)
{
// FIXME -- put this in superclass?
// FIXME -- don't use CurrentTime
CDisplayLock display(this);
XSetSelectionOwner(display, XA_PRIMARY, m_window, CurrentTime);
if (XGetSelectionOwner(display, XA_PRIMARY) == m_window) {
// we got the selection
log((CLOG_DEBUG "grabbed clipboard"));
}
// FIXME -- need to copy or adopt the clipboard to serve future requests
setDisplayClipboard(clipboard, m_window, CurrentTime);
}
void CXWindowsPrimaryScreen::grabClipboard()
{
// FIXME -- don't use CurrentTime
setDisplayClipboard(NULL, m_window, CurrentTime);
}
void CXWindowsPrimaryScreen::getSize(
@@ -296,7 +321,6 @@ SInt32 CXWindowsPrimaryScreen::getJumpZoneSize() const
void CXWindowsPrimaryScreen::getClipboard(
IClipboard* clipboard) const
{
// FIXME -- put this in superclass?
// FIXME -- don't use CurrentTime
getDisplayClipboard(clipboard, m_window, CurrentTime);
}

View File

@@ -20,6 +20,7 @@ class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
virtual void leave();
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute);
virtual void setClipboard(const IClipboard*);
virtual void grabClipboard();
virtual void getSize(SInt32* width, SInt32* height) const;
virtual SInt32 getJumpZoneSize() const;
virtual void getClipboard(IClipboard*) const;

View File

@@ -23,8 +23,8 @@ CFG=makehook - Win32 Debug
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
# PROP Scc_ProjName "millpond"
# PROP Scc_LocalPath "."
MTL=midl.exe
!IF "$(CFG)" == "makehook - Win32 Release"

View File

@@ -10,9 +10,9 @@ void realMain()
CScreenMap screenMap;
screenMap.addScreen("primary");
screenMap.addScreen("ingrid");
screenMap.connect("primary", CScreenMap::kRight, "ingrid");
screenMap.connect("ingrid", CScreenMap::kLeft, "primary");
screenMap.addScreen("secondary");
screenMap.connect("primary", CScreenMap::kRight, "secondary");
screenMap.connect("secondary", CScreenMap::kLeft, "primary");
CServer* server = NULL;
try {

View File

@@ -38,7 +38,7 @@ RSC=rc.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Output_Dir "../Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
@@ -64,7 +64,7 @@ LINK32=link.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Output_Dir "../Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c

View File

@@ -38,8 +38,8 @@ RSC=rc.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Output_Dir "../Release"
# PROP Intermediate_Dir "ReleaseHook"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\base" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /c
@@ -64,8 +64,8 @@ LINK32=link.exe
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Output_Dir "../Debug"
# PROP Intermediate_Dir "DebugHook"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\base" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SYNRGYHK_EXPORTS" /FD /GZ /c