mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-08 14:41:57 +08:00
Moved CPrimaryScreen and CSecondaryScreen to the lib/synergy
and the platform specific implementations to lib/platform. Added an lib/arch method to query the platform's native wide character encoding and changed CUnicode to use it. All platform dependent code is now in lib/arch, lib/platform, and the programs under cmd. Also added more documentation.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef CMSWINDOWSSECONDARYSCREEN_H
|
||||
#define CMSWINDOWSSECONDARYSCREEN_H
|
||||
|
||||
// ensure that we get SendInput()
|
||||
#if _WIN32_WINNT <= 0x400
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x401
|
||||
#endif
|
||||
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IMSWindowsScreenEventHandler.h"
|
||||
#include "CMutex.h"
|
||||
#include "CString.h"
|
||||
#include "stdvector.h"
|
||||
|
||||
class CMSWindowsScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
//! Microsoft windows secondary screen implementation
|
||||
class CMSWindowsSecondaryScreen :
|
||||
public CSecondaryScreen, public IMSWindowsScreenEventHandler {
|
||||
public:
|
||||
CMSWindowsSecondaryScreen(IScreenReceiver*);
|
||||
virtual ~CMSWindowsSecondaryScreen();
|
||||
|
||||
// CSecondaryScreen overrides
|
||||
virtual void keyDown(KeyID, KeyModifierMask);
|
||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
||||
virtual void keyUp(KeyID, KeyModifierMask);
|
||||
virtual void mouseDown(ButtonID);
|
||||
virtual void mouseUp(ButtonID);
|
||||
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute);
|
||||
virtual void mouseWheel(SInt32 delta);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual IScreen* getScreen() const;
|
||||
|
||||
// IMSWindowsScreenEventHandler overrides
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual bool onPreDispatch(const CEvent* event);
|
||||
virtual bool onEvent(CEvent* event);
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void postCreateWindow(HWND);
|
||||
virtual void preDestroyWindow(HWND);
|
||||
|
||||
protected:
|
||||
// CSecondaryScreen overrides
|
||||
virtual void onPreMainLoop();
|
||||
virtual void onPreOpen();
|
||||
virtual void onPreEnter();
|
||||
virtual void onPreLeave();
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual void showWindow();
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
virtual void setToggleState(KeyModifierMask);
|
||||
virtual KeyModifierMask getToggleState() const;
|
||||
|
||||
private:
|
||||
enum EKeyAction { kPress, kRelease, kRepeat };
|
||||
class Keystroke {
|
||||
public:
|
||||
UINT m_virtualKey;
|
||||
bool m_press;
|
||||
bool m_repeat;
|
||||
};
|
||||
typedef std::vector<Keystroke> Keystrokes;
|
||||
|
||||
// open/close desktop (for windows 95/98/me)
|
||||
bool openDesktop();
|
||||
void closeDesktop();
|
||||
|
||||
// make desk the thread desktop (for windows NT/2000/XP)
|
||||
bool switchDesktop(HDESK desk);
|
||||
|
||||
// returns true iff there appear to be multiple monitors
|
||||
bool isMultimon() const;
|
||||
|
||||
// key and button queries and operations
|
||||
DWORD mapButton(ButtonID button, bool press) const;
|
||||
KeyModifierMask mapKey(Keystrokes&, UINT& virtualKey, KeyID,
|
||||
KeyModifierMask, EKeyAction) const;
|
||||
void doKeystrokes(const Keystrokes&, SInt32 count);
|
||||
|
||||
void releaseKeys();
|
||||
void toggleKey(UINT virtualKey, KeyModifierMask mask);
|
||||
UINT virtualKeyToScanCode(UINT& virtualKey) const;
|
||||
bool isExtendedKey(UINT virtualKey) const;
|
||||
void sendKeyEvent(UINT virtualKey, bool press);
|
||||
|
||||
private:
|
||||
CMutex m_mutex;
|
||||
CMSWindowsScreen* m_screen;
|
||||
|
||||
// true if windows 95/98/me
|
||||
bool m_is95Family;
|
||||
|
||||
// our window
|
||||
HWND m_window;
|
||||
|
||||
// virtual key states
|
||||
BYTE m_keys[256];
|
||||
|
||||
// current active modifiers
|
||||
KeyModifierMask m_mask;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,285 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IScreen.h"
|
||||
#include "CLock.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
|
||||
//
|
||||
// CSecondaryScreen
|
||||
//
|
||||
|
||||
CSecondaryScreen::CSecondaryScreen() :
|
||||
m_active(false),
|
||||
m_toggleKeys(0)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CSecondaryScreen::~CSecondaryScreen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::mainLoop()
|
||||
{
|
||||
// change our priority
|
||||
CThread::getCurrentThread().setPriority(-7);
|
||||
|
||||
// run event loop
|
||||
try {
|
||||
LOG((CLOG_DEBUG "entering event loop"));
|
||||
onPreMainLoop();
|
||||
getScreen()->mainLoop();
|
||||
onPostMainLoop();
|
||||
LOG((CLOG_DEBUG "exiting event loop"));
|
||||
}
|
||||
catch (...) {
|
||||
onPostMainLoop();
|
||||
LOG((CLOG_DEBUG "exiting event loop"));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::exitMainLoop()
|
||||
{
|
||||
getScreen()->exitMainLoop();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::open()
|
||||
{
|
||||
try {
|
||||
// subclass hook
|
||||
onPreOpen();
|
||||
|
||||
// open the screen
|
||||
getScreen()->open();
|
||||
|
||||
// create and prepare our window
|
||||
createWindow();
|
||||
|
||||
// assume primary has all clipboards
|
||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||
grabClipboard(id);
|
||||
}
|
||||
|
||||
// update keyboard state
|
||||
updateKeys();
|
||||
|
||||
// disable the screen saver
|
||||
getScreen()->openScreensaver(false);
|
||||
|
||||
// subclass hook
|
||||
onPostOpen();
|
||||
|
||||
// reset options
|
||||
resetOptions();
|
||||
}
|
||||
catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
|
||||
// hide the cursor
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
m_active = true;
|
||||
}
|
||||
leave();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::close()
|
||||
{
|
||||
onPreClose();
|
||||
getScreen()->closeScreensaver();
|
||||
destroyWindow();
|
||||
getScreen()->close();
|
||||
onPostClose();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active == false);
|
||||
|
||||
LOG((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
||||
|
||||
getScreen()->syncDesktop();
|
||||
|
||||
// now active
|
||||
m_active = true;
|
||||
|
||||
// subclass hook
|
||||
onPreEnter();
|
||||
|
||||
// update our keyboard state to reflect the local state
|
||||
updateKeys();
|
||||
|
||||
// remember toggle key state
|
||||
m_toggleKeys = getToggleState();
|
||||
|
||||
// toggle modifiers that don't match the desired state
|
||||
setToggleState(mask);
|
||||
|
||||
// warp to requested location
|
||||
warpCursor(x, y);
|
||||
|
||||
// show mouse
|
||||
hideWindow();
|
||||
|
||||
// subclass hook
|
||||
onPostEnter();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::leave()
|
||||
{
|
||||
LOG((CLOG_INFO "leaving screen"));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active == true);
|
||||
|
||||
getScreen()->syncDesktop();
|
||||
|
||||
// subclass hook
|
||||
onPreLeave();
|
||||
|
||||
// restore toggle key state
|
||||
setToggleState(m_toggleKeys);
|
||||
|
||||
// hide mouse
|
||||
showWindow();
|
||||
|
||||
// subclass hook
|
||||
onPostLeave();
|
||||
|
||||
// not active anymore
|
||||
m_active = false;
|
||||
|
||||
// make sure our idea of clipboard ownership is correct
|
||||
getScreen()->checkClipboards();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::setClipboard(ClipboardID id,
|
||||
const IClipboard* clipboard)
|
||||
{
|
||||
getScreen()->setClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::grabClipboard(ClipboardID id)
|
||||
{
|
||||
getScreen()->setClipboard(id, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::screensaver(bool activate)
|
||||
{
|
||||
getScreen()->screensaver(activate);
|
||||
}
|
||||
|
||||
bool
|
||||
CSecondaryScreen::isActive() const
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getClipboard(ClipboardID id,
|
||||
IClipboard* clipboard) const
|
||||
{
|
||||
getScreen()->getClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
getScreen()->syncDesktop();
|
||||
getScreen()->getShape(x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getCursorPos(SInt32& x, SInt32& y) const
|
||||
{
|
||||
getScreen()->syncDesktop();
|
||||
getScreen()->getCursorPos(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreMainLoop()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostMainLoop()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreLeave()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostLeave()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -1,357 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef CSECONDARYSCREEN_H
|
||||
#define CSECONDARYSCREEN_H
|
||||
|
||||
#include "ClipboardTypes.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "OptionTypes.h"
|
||||
#include "CMutex.h"
|
||||
|
||||
class IClipboard;
|
||||
class IScreen;
|
||||
|
||||
//! Generic client-side screen
|
||||
/*!
|
||||
This is a platform independent base class for secondary screen
|
||||
implementations. A secondary screen is a client-side screen.
|
||||
Each platform will derive a class from CSecondaryScreen to handle
|
||||
platform dependent operations.
|
||||
*/
|
||||
class CSecondaryScreen {
|
||||
public:
|
||||
CSecondaryScreen();
|
||||
virtual ~CSecondaryScreen();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//! Open screen
|
||||
/*!
|
||||
Opens the screen. This includes initializing the screen,
|
||||
hiding the cursor, and disabling the screen saver. It also causes
|
||||
events to the reported to an IScreenReceiver (which is set through
|
||||
some other interface). Calls close() before returning (rethrowing)
|
||||
if it fails for any reason.
|
||||
*/
|
||||
void open();
|
||||
|
||||
//! Run event loop
|
||||
/*!
|
||||
Run the screen's event loop. This returns when it detects
|
||||
the application should terminate or when exitMainLoop() is called.
|
||||
mainLoop() may only be called between open() and close().
|
||||
*/
|
||||
void mainLoop();
|
||||
|
||||
//! Exit event loop
|
||||
/*!
|
||||
Force mainLoop() to return. This call can return before
|
||||
mainLoop() does (i.e. asynchronously).
|
||||
*/
|
||||
void exitMainLoop();
|
||||
|
||||
//! Close screen
|
||||
/*!
|
||||
Closes the screen. This restores the screen saver, shows the cursor
|
||||
and closes the screen. It also synthesizes key up events for any
|
||||
keys that are logically down; without this the client will leave
|
||||
its keyboard in the wrong logical state.
|
||||
*/
|
||||
void close();
|
||||
|
||||
//! Enter screen
|
||||
/*!
|
||||
Called when the user navigates to this secondary screen. Warps
|
||||
the cursor to the absolute coordinates \c x,y and unhides
|
||||
it. Also prepares to synthesize input events.
|
||||
*/
|
||||
void enter(SInt32 x, SInt32 y, KeyModifierMask mask);
|
||||
|
||||
//! Leave screen
|
||||
/*!
|
||||
Called when the user navigates off the secondary screen. Cleans
|
||||
up input event synthesis and hides the cursor.
|
||||
*/
|
||||
void leave();
|
||||
|
||||
//! Set clipboard
|
||||
/*!
|
||||
Sets the system's clipboard contents. This is usually called
|
||||
soon after an enter().
|
||||
*/
|
||||
void setClipboard(ClipboardID, const IClipboard*);
|
||||
|
||||
//! Grab clipboard
|
||||
/*!
|
||||
Grabs (i.e. take ownership of) the system clipboard.
|
||||
*/
|
||||
void grabClipboard(ClipboardID);
|
||||
|
||||
//! Activate/deactivate screen saver
|
||||
/*!
|
||||
Forcibly activates the screen saver if \c activate is true otherwise
|
||||
forcibly deactivates it.
|
||||
*/
|
||||
void screensaver(bool activate);
|
||||
|
||||
//! Notify of key press
|
||||
/*!
|
||||
Synthesize key events to generate a press of key \c id. If possible
|
||||
match the given modifier mask.
|
||||
*/
|
||||
virtual void keyDown(KeyID id, KeyModifierMask) = 0;
|
||||
|
||||
//! Notify of key repeat
|
||||
/*!
|
||||
Synthesize key events to generate a press and release of key \c id
|
||||
\c count times. If possible match the given modifier mask.
|
||||
*/
|
||||
virtual void keyRepeat(KeyID id, KeyModifierMask, SInt32 count) = 0;
|
||||
|
||||
//! Notify of key release
|
||||
/*!
|
||||
Synthesize key events to generate a release of key \c id. If possible
|
||||
match the given modifier mask.
|
||||
*/
|
||||
virtual void keyUp(KeyID id, KeyModifierMask) = 0;
|
||||
|
||||
//! Notify of mouse press
|
||||
/*!
|
||||
Synthesize mouse events to generate a press of mouse button \c id.
|
||||
*/
|
||||
virtual void mouseDown(ButtonID id) = 0;
|
||||
|
||||
//! Notify of mouse release
|
||||
/*!
|
||||
Synthesize mouse events to generate a release of mouse button \c id.
|
||||
*/
|
||||
virtual void mouseUp(ButtonID id) = 0;
|
||||
|
||||
//! Notify of mouse motion
|
||||
/*!
|
||||
Synthesize mouse events to generate mouse motion to the absolute
|
||||
screen position \c xAbs,yAbs.
|
||||
*/
|
||||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||
|
||||
//! Notify of mouse wheel motion
|
||||
/*!
|
||||
Synthesize mouse events to generate mouse wheel motion of \c delta.
|
||||
\c delta is positive for motion away from the user and negative for
|
||||
motion towards the user. Each wheel click should generate a delta
|
||||
of +/-120.
|
||||
*/
|
||||
virtual void mouseWheel(SInt32 delta) = 0;
|
||||
|
||||
//! Notify of options changes
|
||||
/*!
|
||||
Reset all options to their default values.
|
||||
*/
|
||||
virtual void resetOptions() = 0;
|
||||
|
||||
//! Notify of options changes
|
||||
/*!
|
||||
Set options to given values. Ignore unknown options and don't
|
||||
modify our options that aren't given in \c options.
|
||||
*/
|
||||
virtual void setOptions(const COptionsList& options) = 0;
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
//@{
|
||||
|
||||
//! Test if active
|
||||
/*!
|
||||
Returns true iff the screen is active (i.e. the user has entered
|
||||
the screen). Note this is the reverse of a primary screen.
|
||||
*/
|
||||
bool isActive() const;
|
||||
|
||||
//! Get clipboard
|
||||
/*!
|
||||
Saves the contents of the system clipboard indicated by \c id.
|
||||
*/
|
||||
void getClipboard(ClipboardID id, IClipboard*) const;
|
||||
|
||||
//! Get jump zone size
|
||||
/*!
|
||||
Return the jump zone size, the size of the regions on the edges of
|
||||
the screen that cause the cursor to jump to another screen.
|
||||
*/
|
||||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
|
||||
//! Get screen shape
|
||||
/*!
|
||||
Return the position of the upper-left corner of the screen in \c x and
|
||||
\c y and the size of the screen in \c width and \c height.
|
||||
*/
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const;
|
||||
|
||||
//! Get cursor position
|
||||
/*!
|
||||
Return the current position of the cursor in \c x,y.
|
||||
*/
|
||||
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
||||
|
||||
//! Get screen
|
||||
/*!
|
||||
Return the platform dependent screen.
|
||||
*/
|
||||
virtual IScreen* getScreen() const = 0;
|
||||
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! Pre-mainLoop() hook
|
||||
/*!
|
||||
Called on entry to mainLoop(). Override to perform platform specific
|
||||
operations. Default does nothing. May throw.
|
||||
*/
|
||||
virtual void onPreMainLoop();
|
||||
|
||||
//! Post-mainLoop() hook
|
||||
/*!
|
||||
Called on exit from mainLoop(). Override to perform platform specific
|
||||
operations. Default does nothing. May \b not throw.
|
||||
*/
|
||||
virtual void onPostMainLoop();
|
||||
|
||||
//! Pre-open() hook
|
||||
/*!
|
||||
Called on entry to open(). Override to perform platform specific
|
||||
operations. Default does nothing. May throw.
|
||||
*/
|
||||
virtual void onPreOpen();
|
||||
|
||||
//! Post-open() hook
|
||||
/*!
|
||||
Called on exit from open() iff the open was successful. Default
|
||||
does nothing. May throw.
|
||||
*/
|
||||
virtual void onPostOpen();
|
||||
|
||||
//! Pre-close() hook
|
||||
/*!
|
||||
Called on entry to close(). Override to perform platform specific
|
||||
operations. Default does nothing. May \b not throw.
|
||||
*/
|
||||
virtual void onPreClose();
|
||||
|
||||
//! Post-close() hook
|
||||
/*!
|
||||
Called on exit from close(). Override to perform platform specific
|
||||
operations. Default does nothing. May \b not throw.
|
||||
*/
|
||||
virtual void onPostClose();
|
||||
|
||||
//! Pre-enter() hook
|
||||
/*!
|
||||
Called on entry to enter() after desktop synchronization. Override
|
||||
to perform platform specific operations. Default does nothing. May
|
||||
\b not throw.
|
||||
*/
|
||||
virtual void onPreEnter();
|
||||
|
||||
//! Post-enter() hook
|
||||
/*!
|
||||
Called on exit from enter(). Override to perform platform specific
|
||||
operations. Default does nothing. May \b not throw.
|
||||
*/
|
||||
virtual void onPostEnter();
|
||||
|
||||
//! Pre-leave() hook
|
||||
/*!
|
||||
Called on entry to leave() after desktop synchronization. Override
|
||||
to perform platform specific operations. Default does nothing. May
|
||||
\b not throw.
|
||||
*/
|
||||
virtual void onPreLeave();
|
||||
|
||||
//! Post-leave() hook
|
||||
/*!
|
||||
Called on exit from leave(). Override to perform platform specific
|
||||
operations. Default does nothing. May \b not throw.
|
||||
*/
|
||||
virtual void onPostLeave();
|
||||
|
||||
//! Create window
|
||||
/*!
|
||||
Called to create the window. This window is generally used to
|
||||
receive events and hide the cursor.
|
||||
*/
|
||||
virtual void createWindow() = 0;
|
||||
|
||||
//! Destroy window
|
||||
/*!
|
||||
Called to destroy the window created by createWindow().
|
||||
*/
|
||||
virtual void destroyWindow() = 0;
|
||||
|
||||
//! Show window
|
||||
/*!
|
||||
Called when the user navigates off this secondary screen. It needn't
|
||||
actually show the window created by createWindow() but it must hide
|
||||
the cursor and clean up event synthesis.
|
||||
*/
|
||||
virtual void showWindow() = 0;
|
||||
|
||||
//! Hide window
|
||||
/*!
|
||||
Called when the user navigates to this secondary screen. It should
|
||||
hide the window (if shown), show the cursor, and prepare to synthesize
|
||||
input events.
|
||||
*/
|
||||
virtual void hideWindow() = 0;
|
||||
|
||||
//! Warp cursor
|
||||
/*!
|
||||
Warp the cursor to the absolute coordinates \c x,y.
|
||||
*/
|
||||
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
||||
|
||||
//! Synchronize key state
|
||||
/*!
|
||||
Check the current keyboard state. Normally a screen will save
|
||||
the keyboard state in this method and use this shadow state
|
||||
when synthesizing events.
|
||||
*/
|
||||
virtual void updateKeys() = 0;
|
||||
|
||||
//! Synchronize toggle key state
|
||||
/*!
|
||||
Toggle modifiers that don't match the given state so that they do.
|
||||
*/
|
||||
virtual void setToggleState(KeyModifierMask) = 0;
|
||||
|
||||
//! Get the toggle key state
|
||||
/*!
|
||||
Returns the current state of the toggle keys.
|
||||
*/
|
||||
virtual KeyModifierMask getToggleState() const = 0;
|
||||
|
||||
private:
|
||||
CMutex m_mutex;
|
||||
|
||||
// m_active is true if this screen has been entered
|
||||
bool m_active;
|
||||
|
||||
// the toggle key state when this screen was last entered
|
||||
KeyModifierMask m_toggleKeys;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef CXWINDOWSSECONDARYSCREEN_H
|
||||
#define CXWINDOWSSECONDARYSCREEN_H
|
||||
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IScreenEventHandler.h"
|
||||
#include "stdmap.h"
|
||||
#include "stdvector.h"
|
||||
#if defined(X_DISPLAY_MISSING)
|
||||
# error X11 is required to build synergy
|
||||
#else
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
class CXWindowsScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
//! X11 secondary screen implementation
|
||||
class CXWindowsSecondaryScreen :
|
||||
public CSecondaryScreen, public IScreenEventHandler {
|
||||
public:
|
||||
CXWindowsSecondaryScreen(IScreenReceiver*);
|
||||
virtual ~CXWindowsSecondaryScreen();
|
||||
|
||||
// CSecondaryScreen overrides
|
||||
virtual void keyDown(KeyID, KeyModifierMask);
|
||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
||||
virtual void keyUp(KeyID, KeyModifierMask);
|
||||
virtual void mouseDown(ButtonID);
|
||||
virtual void mouseUp(ButtonID);
|
||||
virtual void mouseMove(SInt32 x, SInt32 y);
|
||||
virtual void mouseWheel(SInt32 delta);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual IScreen* getScreen() const;
|
||||
|
||||
// IScreenEventHandler overrides
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual bool onPreDispatch(const CEvent* event);
|
||||
virtual bool onEvent(CEvent* event);
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
|
||||
protected:
|
||||
// CSecondaryScreen overrides
|
||||
virtual void onPreMainLoop();
|
||||
virtual void onPreOpen();
|
||||
virtual void onPostOpen();
|
||||
virtual void onPreEnter();
|
||||
virtual void onPreLeave();
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual void showWindow();
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
virtual void setToggleState(KeyModifierMask);
|
||||
virtual KeyModifierMask getToggleState() const;
|
||||
|
||||
private:
|
||||
enum EKeyAction { kPress, kRelease, kRepeat };
|
||||
class KeyCodeMask {
|
||||
public:
|
||||
KeyCodeMask();
|
||||
public:
|
||||
KeyCode m_keycode[4];
|
||||
// FIXME -- don't need masks
|
||||
unsigned int m_keyMask[4];
|
||||
unsigned int m_keyMaskMask[4];
|
||||
};
|
||||
class Keystroke {
|
||||
public:
|
||||
KeyCode m_keycode;
|
||||
Bool m_press;
|
||||
bool m_repeat;
|
||||
};
|
||||
typedef std::vector<Keystroke> Keystrokes;
|
||||
typedef std::vector<KeyCode> KeyCodes;
|
||||
typedef std::map<KeySym, KeyCodeMask> KeyCodeMap;
|
||||
typedef KeyCodeMap::const_iterator KeyCodeIndex;
|
||||
typedef std::map<KeyCode, unsigned int> ModifierMap;
|
||||
|
||||
unsigned int mapButton(ButtonID button) const;
|
||||
|
||||
unsigned int mapKey(Keystrokes&, KeyCode&, KeyID,
|
||||
KeyModifierMask, EKeyAction) const;
|
||||
/*
|
||||
bool findKeyCode(KeyCode&, unsigned int&,
|
||||
KeyID id, unsigned int) const;
|
||||
*/
|
||||
void doKeystrokes(const Keystrokes&, SInt32 count);
|
||||
unsigned int maskToX(KeyModifierMask) const;
|
||||
|
||||
void releaseKeys(Display*);
|
||||
void updateKeycodeMap(Display* display);
|
||||
void updateModifiers(Display* display);
|
||||
void updateModifierMap(Display* display);
|
||||
unsigned int indexToModifierMask(int index) const;
|
||||
void toggleKey(Display*, KeySym, unsigned int mask);
|
||||
static bool isToggleKeysym(KeySym);
|
||||
|
||||
KeyCodeIndex findKey(KeyID keysym, KeyModifierMask& mask) const;
|
||||
KeyCodeIndex noKey() const;
|
||||
bool adjustForNumLock(KeySym) const;
|
||||
bool adjustForCapsLock(KeySym) const;
|
||||
|
||||
private:
|
||||
enum { kNONE, kSHIFT, kALTGR, kSHIFT_ALTGR };
|
||||
|
||||
CXWindowsScreen* m_screen;
|
||||
Window m_window;
|
||||
|
||||
// note toggle keys that toggles on up/down (false) or on
|
||||
// transition (true)
|
||||
bool m_numLockHalfDuplex;
|
||||
bool m_capsLockHalfDuplex;
|
||||
|
||||
// set entries indicate keys that are pressed. indexed by keycode.
|
||||
bool m_keys[256];
|
||||
|
||||
// logical to physical button mapping. m_buttons[i] gives the
|
||||
// physical button for logical button i+1.
|
||||
std::vector<unsigned char> m_buttons;
|
||||
|
||||
// current active modifiers (X key masks)
|
||||
unsigned int m_mask;
|
||||
|
||||
// maps key IDs to X keycodes and the X modifier key mask needed
|
||||
// to generate the right keysym
|
||||
KeyCodeMap m_keycodeMap;
|
||||
|
||||
// the modifiers that have keys bound to them
|
||||
unsigned int m_modifierMask;
|
||||
|
||||
// set bits indicate modifiers that toggle (e.g. caps-lock)
|
||||
unsigned int m_toggleModifierMask;
|
||||
|
||||
// modifier masks
|
||||
unsigned int m_altMask;
|
||||
unsigned int m_metaMask;
|
||||
unsigned int m_superMask;
|
||||
unsigned int m_modeSwitchMask;
|
||||
unsigned int m_numLockMask;
|
||||
unsigned int m_capsLockMask;
|
||||
unsigned int m_scrollLockMask;
|
||||
|
||||
// map X modifier key indices to the key codes bound to them
|
||||
unsigned int m_keysPerModifier;
|
||||
KeyCodes m_modifierToKeycode;
|
||||
KeyCodes m_modifierToKeycodes;
|
||||
|
||||
// maps keycodes to modifier indices
|
||||
ModifierMap m_keycodeToModifier;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ISECONDARYSCREENFACTORY_H
|
||||
#define ISECONDARYSCREENFACTORY_H
|
||||
|
||||
#include "IInterface.h"
|
||||
|
||||
class CSecondaryScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
//! Secondary screen factory interface
|
||||
/*!
|
||||
This interface provides factory methods to create secondary screens.
|
||||
*/
|
||||
class ISecondaryScreenFactory : public IInterface {
|
||||
public:
|
||||
//! Create screen
|
||||
/*!
|
||||
Create and return a secondary screen. The caller must delete the
|
||||
returned object.
|
||||
*/
|
||||
virtual CSecondaryScreen*
|
||||
create(IScreenReceiver*) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -17,8 +17,6 @@ VDEPTH = ./$(VPATH)/$(DEPTH)
|
||||
|
||||
EXTRA_DIST = \
|
||||
client.dsp \
|
||||
CMSWindowsSecondaryScreen.cpp \
|
||||
CMSWindowsSecondaryScreen.h \
|
||||
$(NULL)
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
@@ -28,14 +26,9 @@ MAINTAINERCLEANFILES = \
|
||||
noinst_LIBRARIES = libclient.a
|
||||
libclient_a_SOURCES = \
|
||||
CClient.cpp \
|
||||
CSecondaryScreen.cpp \
|
||||
CServerProxy.cpp \
|
||||
CXWindowsSecondaryScreen.cpp \
|
||||
CClient.h \
|
||||
CSecondaryScreen.h \
|
||||
CServerProxy.h \
|
||||
CXWindowsSecondaryScreen.h \
|
||||
ISecondaryScreenFactory.h \
|
||||
$(NULL)
|
||||
INCLUDES = \
|
||||
-I$(VDEPTH)/lib/common \
|
||||
|
||||
@@ -91,14 +91,6 @@ SOURCE=.\CClient.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CMSWindowsSecondaryScreen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CSecondaryScreen.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CServerProxy.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
@@ -111,20 +103,8 @@ SOURCE=.\CClient.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CMSWindowsSecondaryScreen.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CSecondaryScreen.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CServerProxy.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ISecondaryScreenFactory.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user