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.
|
|
|
|
*/
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
#ifndef IPLATFORMSCREEN_H
|
|
|
|
#define IPLATFORMSCREEN_H
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2004-02-14 14:04:36 +00:00
|
|
|
#include "IScreen.h"
|
2003-09-02 22:05:47 +00:00
|
|
|
#include "IPrimaryScreen.h"
|
|
|
|
#include "ISecondaryScreen.h"
|
2004-03-21 20:01:41 +00:00
|
|
|
#include "IKeyState.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "ClipboardTypes.h"
|
2003-09-02 22:05:47 +00:00
|
|
|
#include "OptionTypes.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
|
|
|
|
class IClipboard;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Screen interface
|
|
|
|
/*!
|
|
|
|
This interface defines the methods common to all platform dependent
|
2003-09-02 22:05:47 +00:00
|
|
|
screen implementations that are used by both primary and secondary
|
2004-03-14 17:55:53 +00:00
|
|
|
screens.
|
2002-07-29 16:07:26 +00:00
|
|
|
*/
|
2004-02-14 14:04:36 +00:00
|
|
|
class IPlatformScreen : public IScreen,
|
2004-03-21 20:01:41 +00:00
|
|
|
public IPrimaryScreen, public ISecondaryScreen,
|
|
|
|
public IKeyState {
|
2002-07-13 22:00:38 +00:00
|
|
|
public:
|
2002-07-29 16:07:26 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
//! Enable screen
|
|
|
|
/*!
|
|
|
|
Enable the screen, preparing it to report system and user events.
|
|
|
|
For a secondary screen it also means preparing to synthesize events
|
|
|
|
and hiding the cursor.
|
|
|
|
*/
|
|
|
|
virtual void enable() = 0;
|
|
|
|
|
|
|
|
//! Disable screen
|
|
|
|
/*!
|
|
|
|
Undoes the operations in enable() and events should no longer
|
|
|
|
be reported.
|
|
|
|
*/
|
|
|
|
virtual void disable() = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
//! Enter screen
|
2002-07-29 16:07:26 +00:00
|
|
|
/*!
|
2003-09-02 22:05:47 +00:00
|
|
|
Called when the user navigates to this screen.
|
2002-07-29 16:07:26 +00:00
|
|
|
*/
|
2003-09-02 22:05:47 +00:00
|
|
|
virtual void enter() = 0;
|
|
|
|
|
|
|
|
//! Leave screen
|
|
|
|
/*!
|
|
|
|
Called when the user navigates off the screen. Returns true on
|
|
|
|
success, false on failure. A typical reason for failure is being
|
|
|
|
unable to install the keyboard and mouse snoopers on a primary
|
|
|
|
screen. Secondary screens should not fail.
|
|
|
|
*/
|
|
|
|
virtual bool leave() = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Set clipboard
|
|
|
|
/*!
|
|
|
|
Set the contents of the system clipboard indicated by \c id.
|
|
|
|
*/
|
|
|
|
virtual bool setClipboard(ClipboardID id, const IClipboard*) = 0;
|
|
|
|
|
|
|
|
//! Check clipboard owner
|
|
|
|
/*!
|
2004-02-14 14:04:36 +00:00
|
|
|
Check ownership of all clipboards and post grab events for any that
|
|
|
|
have changed. This is used as a backup in case the system doesn't
|
|
|
|
reliably report clipboard ownership changes.
|
2002-07-29 16:07:26 +00:00
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void checkClipboards() = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Open screen saver
|
|
|
|
/*!
|
|
|
|
Open the screen saver. If \c notify is true then this object must
|
2004-02-14 14:04:36 +00:00
|
|
|
send events when the screen saver activates or deactivates until
|
|
|
|
\c closeScreensaver() is called. If \c notify is false then the
|
|
|
|
screen saver is disabled and restored on \c closeScreensaver().
|
2002-07-29 16:07:26 +00:00
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void openScreensaver(bool notify) = 0;
|
2002-07-29 16:07:26 +00:00
|
|
|
|
|
|
|
//! Close screen saver
|
|
|
|
/*!
|
|
|
|
// Close the screen saver. Stop reporting screen saver activation
|
|
|
|
and deactivation and, if the screen saver was disabled by
|
|
|
|
openScreensaver(), enable the screen saver.
|
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void closeScreensaver() = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Activate/deactivate screen saver
|
|
|
|
/*!
|
|
|
|
Forcibly activate the screen saver if \c activate is true otherwise
|
|
|
|
forcibly deactivate it.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void screensaver(bool activate) = 0;
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
//! 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 options that aren't given in \c options.
|
|
|
|
*/
|
|
|
|
virtual void setOptions(const COptionsList& options) = 0;
|
|
|
|
|
2004-02-14 14:04:36 +00:00
|
|
|
//! Set clipboard sequence number
|
|
|
|
/*!
|
|
|
|
Sets the sequence number to use in subsequent clipboard events.
|
|
|
|
*/
|
|
|
|
virtual void setSequenceNumber(UInt32) = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
//! Test if is primary screen
|
|
|
|
/*!
|
|
|
|
Return true iff this screen is a primary screen.
|
|
|
|
*/
|
|
|
|
virtual bool isPrimary() const = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//@}
|
2003-09-02 22:05:47 +00:00
|
|
|
|
2004-02-14 14:04:36 +00:00
|
|
|
// IScreen overrides
|
|
|
|
virtual void* getEventTarget() const = 0;
|
|
|
|
virtual bool getClipboard(ClipboardID id, IClipboard*) const = 0;
|
|
|
|
virtual void getShape(SInt32& x, SInt32& y,
|
|
|
|
SInt32& width, SInt32& height) const = 0;
|
|
|
|
virtual void getCursorPos(SInt32& x, SInt32& y) const = 0;
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// IPrimaryScreen overrides
|
|
|
|
virtual void reconfigure(UInt32 activeSides) = 0;
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
|
|
|
virtual SInt32 getJumpZoneSize() const = 0;
|
|
|
|
virtual bool isAnyMouseButtonDown() const = 0;
|
2004-02-14 14:04:36 +00:00
|
|
|
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
2003-09-02 22:05:47 +00:00
|
|
|
|
|
|
|
// ISecondaryScreen overrides
|
|
|
|
virtual void fakeMouseButton(ButtonID id, bool press) const = 0;
|
|
|
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const = 0;
|
2004-05-01 15:18:59 +00:00
|
|
|
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const = 0;
|
2003-09-02 22:05:47 +00:00
|
|
|
virtual void fakeMouseWheel(SInt32 delta) const = 0;
|
2004-03-21 20:01:41 +00:00
|
|
|
|
|
|
|
// IKeyState overrides
|
|
|
|
virtual void updateKeys() = 0;
|
|
|
|
virtual void setHalfDuplexMask(KeyModifierMask) = 0;
|
|
|
|
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask,
|
|
|
|
KeyButton button) = 0;
|
|
|
|
virtual void fakeKeyRepeat(KeyID id, KeyModifierMask mask,
|
|
|
|
SInt32 count, KeyButton button) = 0;
|
|
|
|
virtual void fakeKeyUp(KeyButton button) = 0;
|
|
|
|
virtual void fakeToggle(KeyModifierMask modifier) = 0;
|
2004-03-26 20:59:26 +00:00
|
|
|
virtual bool fakeCtrlAltDel() = 0;
|
2004-03-21 20:01:41 +00:00
|
|
|
virtual bool isKeyDown(KeyButton) const = 0;
|
|
|
|
virtual KeyModifierMask
|
|
|
|
getActiveModifiers() const = 0;
|
|
|
|
virtual const char* getKeyName(KeyButton) const = 0;
|
2004-02-14 14:04:36 +00:00
|
|
|
|
2004-03-14 17:55:53 +00:00
|
|
|
protected:
|
|
|
|
//! Handle system event
|
|
|
|
/*!
|
|
|
|
A platform screen is expected to install a handler for system
|
|
|
|
events in its c'tor like so:
|
|
|
|
\code
|
|
|
|
EVENTQUEUE->adoptHandler(CEvent::kSystem,
|
|
|
|
IEventQueue::getSystemTarget(),
|
2004-09-27 21:54:49 +00:00
|
|
|
new TMethodEventJob<CXXXPlatformScreen>(this,
|
|
|
|
&CXXXPlatformScreen::handleSystemEvent));
|
2004-03-14 17:55:53 +00:00
|
|
|
\endcode
|
|
|
|
It should remove the handler in its d'tor. Override the
|
|
|
|
\c handleSystemEvent() method to process system events.
|
|
|
|
It should post the events \c IScreen as appropriate.
|
|
|
|
|
|
|
|
A primary screen has further responsibilities. It should post
|
|
|
|
the events in \c IPrimaryScreen as appropriate. It should also
|
2004-03-21 20:01:41 +00:00
|
|
|
call \c setKeyDown() on its \c CKeyState whenever a key is pressed
|
|
|
|
or released (but not for key repeats). And it should call
|
|
|
|
\c updateKeys() on its \c CKeyState if necessary when the keyboard
|
|
|
|
mapping changes.
|
2004-03-14 17:55:53 +00:00
|
|
|
|
|
|
|
The target of all events should be the value returned by
|
|
|
|
\c getEventTarget().
|
|
|
|
*/
|
|
|
|
virtual void handleSystemEvent(const CEvent& event, void*) = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|