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 CMSWINDOWSSCREEN_H
|
|
|
|
#define CMSWINDOWSSCREEN_H
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
#include "IScreen.h"
|
|
|
|
#include "CSynergyHook.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include "CMutex.h"
|
2002-06-11 20:09:59 +00:00
|
|
|
#include "CString.h"
|
2002-06-10 16:49:46 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2001-11-19 00:33:36 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2002-06-23 21:53:31 +00:00
|
|
|
class CMSWindowsScreenSaver;
|
2001-11-19 00:33:36 +00:00
|
|
|
class CThread;
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
// Microsoft windows event
|
2002-07-12 20:41:23 +00:00
|
|
|
class CEvent {
|
|
|
|
public:
|
|
|
|
MSG m_msg;
|
|
|
|
LRESULT m_result;
|
|
|
|
};
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
class IScreenReceiver;
|
|
|
|
class IMSWindowsScreenEventHandler;
|
|
|
|
|
2003-01-05 21:48:54 +00:00
|
|
|
//! Implementation of IScreen for Microsoft Windows
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsScreen : public IScreen {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-07-15 15:01:36 +00:00
|
|
|
CMSWindowsScreen(IScreenReceiver*, IMSWindowsScreenEventHandler*);
|
2001-11-19 00:33:36 +00:00
|
|
|
virtual ~CMSWindowsScreen();
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! Initialize
|
|
|
|
/*!
|
|
|
|
Saves the application's HINSTANCE. This \b must be called by
|
|
|
|
WinMain with the HINSTANCE it was passed.
|
|
|
|
*/
|
2001-11-19 00:33:36 +00:00
|
|
|
static void init(HINSTANCE);
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! Open desktop
|
|
|
|
/*!
|
|
|
|
Open the desktop and create and return the window. Returns NULL
|
|
|
|
on failure.
|
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
HWND openDesktop();
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! Close desktop
|
|
|
|
/*!
|
|
|
|
Close the window and desktop.
|
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
void closeDesktop();
|
|
|
|
|
2003-03-12 22:34:07 +00:00
|
|
|
//! Install a one-shot timer
|
|
|
|
/*!
|
|
|
|
Installs a one-shot timer for \c timeout seconds and returns the
|
|
|
|
id of the timer (which will be passed to the receiver's
|
|
|
|
\c onTimerExpired()).
|
|
|
|
*/
|
|
|
|
UInt32 addOneShotTimer(double timeout);
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2002-06-08 21:48:00 +00:00
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! Test for multiple monitors
|
|
|
|
/*!
|
|
|
|
Returns true iff the system appears to have multiple monitors.
|
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
bool isMultimon() const;
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! Get instance
|
|
|
|
/*!
|
|
|
|
Returns the application instance handle passed to init().
|
|
|
|
*/
|
2002-06-08 21:48:00 +00:00
|
|
|
static HINSTANCE getInstance();
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//@}
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// IScreen overrides
|
|
|
|
// note -- this class expects the hook DLL to have been loaded
|
|
|
|
// and initialized before open() is called.
|
|
|
|
void open();
|
2002-07-12 20:41:23 +00:00
|
|
|
void mainLoop();
|
|
|
|
void exitMainLoop();
|
2002-07-15 15:01:36 +00:00
|
|
|
void close();
|
|
|
|
bool setClipboard(ClipboardID, const IClipboard*);
|
|
|
|
void checkClipboards();
|
|
|
|
void openScreensaver(bool notify);
|
|
|
|
void closeScreensaver();
|
|
|
|
void screensaver(bool activate);
|
|
|
|
void syncDesktop();
|
|
|
|
bool getClipboard(ClipboardID, IClipboard*) const;
|
|
|
|
void getShape(SInt32&, SInt32&, SInt32&, SInt32&) const;
|
|
|
|
void getCursorPos(SInt32&, SInt32&) const;
|
|
|
|
void getCursorCenter(SInt32&, SInt32&) const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
private:
|
2002-05-24 17:54:28 +00:00
|
|
|
// update screen size cache
|
2002-06-19 17:03:29 +00:00
|
|
|
void updateScreenShape();
|
2002-05-24 17:54:28 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// internal pre-dispatch event processing
|
|
|
|
bool onPreDispatch(const CEvent* event);
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// internal (post-dispatch) event processing
|
|
|
|
bool onEvent(CEvent* event);
|
2002-07-11 18:58:49 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// create the transparent cursor
|
|
|
|
void createBlankCursor();
|
|
|
|
|
|
|
|
// switch to the given desktop. this destroys the window and unhooks
|
|
|
|
// all hooks, switches the desktop, then creates the window and rehooks
|
|
|
|
// all hooks (because you can't switch the thread's desktop if it has
|
|
|
|
// any windows or hooks).
|
|
|
|
bool switchDesktop(HDESK desk);
|
2002-07-11 18:58:49 +00:00
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// get the input desktop. caller must CloseDesktop() the result.
|
|
|
|
// do not call under windows 95/98/me.
|
|
|
|
HDESK openInputDesktop() const;
|
|
|
|
|
|
|
|
// get the desktop's name. do not call under windows 95/98/me.
|
|
|
|
CString getDesktopName(HDESK) const;
|
|
|
|
|
|
|
|
// returns true iff desk is the current desk. do not call under
|
|
|
|
// windows 95/98/me.
|
|
|
|
bool isCurrentDesktop(HDESK desk) const;
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// our window proc
|
2001-11-19 00:33:36 +00:00
|
|
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2001-11-19 00:33:36 +00:00
|
|
|
static HINSTANCE s_instance;
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
IScreenReceiver* m_receiver;
|
|
|
|
IMSWindowsScreenEventHandler* m_eventHandler;
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
ATOM m_class;
|
|
|
|
HICON m_icon;
|
|
|
|
HCURSOR m_cursor;
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
|
|
|
bool m_is95Family;
|
|
|
|
|
|
|
|
// our window
|
|
|
|
HWND m_window;
|
|
|
|
|
|
|
|
// screen shape
|
2002-06-19 17:03:29 +00:00
|
|
|
SInt32 m_x, m_y;
|
2001-11-19 00:33:36 +00:00
|
|
|
SInt32 m_w, m_h;
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
// true if system appears to have multiple monitors
|
|
|
|
bool m_multimon;
|
|
|
|
|
|
|
|
// the main loop's thread id
|
|
|
|
DWORD m_threadID;
|
|
|
|
|
|
|
|
// the thread id of the last attached thread
|
|
|
|
DWORD m_lastThreadID;
|
|
|
|
|
|
|
|
// clipboard stuff
|
|
|
|
HWND m_nextClipboardWindow;
|
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 m_ownClipboard;
|
2002-07-15 15:01:36 +00:00
|
|
|
|
|
|
|
// the timer used to check for desktop switching
|
|
|
|
UINT m_timer;
|
|
|
|
|
2003-03-12 22:34:07 +00:00
|
|
|
// the one shot timer
|
|
|
|
UINT m_oneShotTimer;
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// the current desk and it's name
|
|
|
|
HDESK m_desk;
|
|
|
|
CString m_deskName;
|
|
|
|
|
|
|
|
// screen saver stuff
|
|
|
|
HINSTANCE m_hookLibrary;
|
|
|
|
InstallScreenSaverFunc m_installScreensaver;
|
|
|
|
UninstallScreenSaverFunc m_uninstallScreensaver;
|
|
|
|
CMSWindowsScreenSaver* m_screensaver;
|
|
|
|
bool m_screensaverNotify;
|
|
|
|
|
2003-05-17 20:58:27 +00:00
|
|
|
// true when the current desktop is inaccessible. while
|
|
|
|
// the desktop is inaccessible we won't receive user input
|
|
|
|
// and we'll lose track of the keyboard state. when the
|
|
|
|
// desktop becomes accessible again we'll notify the event
|
|
|
|
// handler of that.
|
|
|
|
bool m_inaccessibleDesktop;
|
|
|
|
|
2001-11-25 18:32:41 +00:00
|
|
|
static CMSWindowsScreen* s_screen;
|
2001-11-19 00:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|