2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
#ifndef CMSWINDOWSPRIMARYSCREEN_H
|
|
|
|
#define CMSWINDOWSPRIMARYSCREEN_H
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
#include "CPrimaryScreen.h"
|
|
|
|
#include "IMSWindowsScreenEventHandler.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include "CSynergyHook.h"
|
2002-06-08 21:48:00 +00:00
|
|
|
#include "MouseTypes.h"
|
|
|
|
#include "CString.h"
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsScreen;
|
2002-07-11 13:13:37 +00:00
|
|
|
class IScreenReceiver;
|
|
|
|
class IPrimaryScreenReceiver;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Microsoft windows primary screen implementation
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsPrimaryScreen :
|
|
|
|
public CPrimaryScreen, public IMSWindowsScreenEventHandler {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2001-11-19 00:33:36 +00:00
|
|
|
typedef bool (CMSWindowsPrimaryScreen::*HookMethod)(int, WPARAM, LPARAM);
|
|
|
|
|
2002-07-11 13:13:37 +00:00
|
|
|
CMSWindowsPrimaryScreen(IScreenReceiver*, IPrimaryScreenReceiver*);
|
2001-11-19 00:33:36 +00:00
|
|
|
virtual ~CMSWindowsPrimaryScreen();
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// CPrimaryScreen overrides
|
2002-07-11 13:13:37 +00:00
|
|
|
virtual void reconfigure(UInt32 activeSides);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
2002-12-23 13:55:21 +00:00
|
|
|
virtual void resetOptions();
|
|
|
|
virtual void setOptions(const COptionsList& options);
|
2003-03-12 22:34:07 +00:00
|
|
|
virtual UInt32 addOneShotTimer(double timeout);
|
2002-04-30 17:48:11 +00:00
|
|
|
virtual KeyModifierMask getToggleMask() const;
|
2002-05-24 14:37:12 +00:00
|
|
|
virtual bool isLockedToScreen() const;
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual IScreen* getScreen() const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// IMSWindowsScreenEventHandler overrides
|
|
|
|
virtual void onScreensaver(bool activated);
|
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2003-03-12 22:34:07 +00:00
|
|
|
virtual void onOneShotTimerExpired(UInt32 id);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
|
|
|
virtual void postCreateWindow(HWND);
|
|
|
|
virtual void preDestroyWindow(HWND);
|
2003-05-17 20:58:27 +00:00
|
|
|
virtual void onAccessibleDesktop();
|
2002-07-11 13:13:37 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
protected:
|
|
|
|
// CPrimaryScreen overrides
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPostOpen();
|
|
|
|
virtual void onPostClose();
|
|
|
|
virtual void onPreEnter();
|
|
|
|
virtual void onPostEnter();
|
|
|
|
virtual void onPreLeave();
|
|
|
|
virtual void onPostLeave(bool);
|
|
|
|
|
|
|
|
virtual void createWindow();
|
|
|
|
virtual void destroyWindow();
|
|
|
|
virtual bool showWindow();
|
|
|
|
virtual void hideWindow();
|
|
|
|
virtual void warpCursorToCenter();
|
|
|
|
|
|
|
|
virtual void updateKeys();
|
2002-06-19 20:24:35 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
private:
|
2002-07-12 20:41:23 +00:00
|
|
|
void enterNoWarp();
|
2002-06-08 21:48:00 +00:00
|
|
|
|
2002-07-17 17:27:41 +00:00
|
|
|
// warp cursor without discarding queued events
|
|
|
|
void warpCursorNoFlush(SInt32 x, SInt32 y);
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// discard posted messages
|
|
|
|
void nextMark();
|
|
|
|
|
2002-07-17 17:27:41 +00:00
|
|
|
// test if event should be ignored
|
|
|
|
bool ignore() const;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// key and button queries
|
2001-11-25 18:32:41 +00:00
|
|
|
KeyID mapKey(WPARAM keycode, LPARAM info,
|
2003-07-08 18:40:46 +00:00
|
|
|
KeyModifierMask* maskOut, bool* altgr);
|
2003-05-04 21:40:42 +00:00
|
|
|
ButtonID mapButton(WPARAM msg, LPARAM button) const;
|
2002-04-30 16:23:03 +00:00
|
|
|
void updateKey(UINT vkCode, bool press);
|
Fixed several win32 bugs. First, synergy wasn't forwarding mouse
events to other hook functions, which broke some tools like objectbar.
Second, windows key processing was fixed. Previously pressing and
release the key would only send a press event, locking the user onto
the client window; also, the win32 server treated as a Meta modifier
instead of a Super modifier, which broke any use of it as any kind of
modifier key. Third, added hacks to support several key combinations
on windows 95/98/me that are treated specially by windows, including
Alt+Tab, Alt+Shift+Tab, Alt+Esc, Alt+Shift+Esc, Ctrl+Esc, and any
combination using the windows key like Win+E and Win+F but not
Ctrl+Alt+Del. Fourth, scroll lock only locking to the client (which
only happened when using a synergy server on windows) has been fixed;
unfortunately the solution causes a lot of screen redraws for some
reason. Finally, there's been a fix to clipboard handling that may
or may not fix a problem where the clipboard would stop transferring
between systems after a little while. I can't be sure if it fixes
the problem because I can't reproduce the problem.
2003-04-13 14:59:53 +00:00
|
|
|
bool isModifier(UINT vkCode) const;
|
2003-07-08 18:40:46 +00:00
|
|
|
KeyButton mapKeyToScanCode(UINT vk1, UINT vk2) const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-07-15 15:01:36 +00:00
|
|
|
IPrimaryScreenReceiver* m_receiver;
|
|
|
|
CMSWindowsScreen* m_screen;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
2002-06-01 19:26:11 +00:00
|
|
|
bool m_is95Family;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// the main loop's thread id
|
|
|
|
DWORD m_threadID;
|
|
|
|
|
2003-05-17 20:58:27 +00:00
|
|
|
// my window
|
|
|
|
HWND m_window;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// used to discard queued messages that are no longer needed
|
|
|
|
UInt32 m_mark;
|
|
|
|
UInt32 m_markReceived;
|
|
|
|
|
|
|
|
// map of key state
|
|
|
|
BYTE m_keys[256];
|
|
|
|
|
2003-05-04 21:40:42 +00:00
|
|
|
// map of button state
|
|
|
|
BYTE m_buttons[1 + kButtonExtra0 + 1];
|
|
|
|
|
2002-06-19 20:24:35 +00:00
|
|
|
// last mouse position
|
|
|
|
SInt32 m_x, m_y;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// position of center pixel of screen
|
|
|
|
SInt32 m_xCenter, m_yCenter;
|
|
|
|
|
|
|
|
// hook library stuff
|
|
|
|
HINSTANCE m_hookLibrary;
|
2002-06-23 21:53:31 +00:00
|
|
|
InitFunc m_init;
|
|
|
|
CleanupFunc m_cleanup;
|
2002-06-08 21:48:00 +00:00
|
|
|
InstallFunc m_install;
|
|
|
|
UninstallFunc m_uninstall;
|
2002-07-11 13:13:37 +00:00
|
|
|
SetSidesFunc m_setSides;
|
2002-06-08 21:48:00 +00:00
|
|
|
SetZoneFunc m_setZone;
|
|
|
|
SetRelayFunc m_setRelay;
|
2003-05-03 12:54:22 +00:00
|
|
|
bool m_lowLevel;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
2003-05-17 20:58:27 +00:00
|
|
|
// stuff for hiding the cursor
|
|
|
|
DWORD m_cursorThread;
|
2001-11-19 00:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|