2002-08-02 23:57:46 +04: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.
|
|
|
|
*/
|
|
|
|
|
2002-07-10 01:22:31 +04:00
|
|
|
#ifndef ICLIENT_H
|
|
|
|
#define ICLIENT_H
|
|
|
|
|
|
|
|
#include "IInterface.h"
|
|
|
|
#include "ClipboardTypes.h"
|
|
|
|
#include "KeyTypes.h"
|
|
|
|
#include "MouseTypes.h"
|
|
|
|
#include "CString.h"
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Client interface
|
|
|
|
/*!
|
|
|
|
This interface defines the methods necessary for the server to
|
|
|
|
communicate with a client.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
class IClient : public IInterface {
|
|
|
|
public:
|
2002-07-29 20:07:26 +04:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Open client
|
|
|
|
/*!
|
2002-07-31 16:39:34 +04:00
|
|
|
Open the client. Throw if the client cannot be opened. If the
|
|
|
|
screen cannot be opened but retrying later may succeed then throw
|
|
|
|
XScreenUnavailable.
|
2002-07-29 20:07:26 +04:00
|
|
|
*/
|
2002-07-31 16:39:34 +04:00
|
|
|
virtual void open() = 0;
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Client main loop
|
2002-07-29 20:07:26 +04:00
|
|
|
/*!
|
2002-07-30 18:59:36 +04:00
|
|
|
Run client's event loop. This method is typically called in a
|
|
|
|
separate thread and is exited by cancelling the thread. This
|
|
|
|
must be called between a successful open() and close().
|
2002-07-29 20:07:26 +04:00
|
|
|
|
|
|
|
(cancellation point)
|
|
|
|
*/
|
2002-07-30 19:17:44 +04:00
|
|
|
virtual void mainLoop() = 0;
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Close client
|
|
|
|
/*!
|
|
|
|
Close the client.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void close() = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Enter screen
|
|
|
|
/*!
|
|
|
|
Enter the screen. The cursor should be warped to \c xAbs,yAbs.
|
|
|
|
The client should record seqNum for future reporting of
|
|
|
|
clipboard changes. \c mask is the expected toggle button state
|
|
|
|
and the client should update its state to match. \c forScreensaver
|
|
|
|
is true iff the screen is being entered because the screen saver is
|
|
|
|
starting.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void enter(SInt32 xAbs, SInt32 yAbs,
|
|
|
|
UInt32 seqNum, KeyModifierMask mask,
|
2002-07-14 02:00:38 +04:00
|
|
|
bool forScreensaver) = 0;
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Leave screen
|
|
|
|
/*!
|
|
|
|
Leave the screen. Return false iff the user may not leave the
|
|
|
|
client's screen (because, for example, a button is down).
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual bool leave() = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Set clipboard
|
|
|
|
/*!
|
|
|
|
Update the client's clipboard. This implies that the client's
|
|
|
|
clipboard is now up to date. If the client's clipboard was
|
2002-07-30 18:59:36 +04:00
|
|
|
already known to be up to date then this may do nothing. \c data
|
|
|
|
has marshalled clipboard data.
|
2002-07-29 20:07:26 +04:00
|
|
|
*/
|
2002-07-30 18:59:36 +04:00
|
|
|
virtual void setClipboard(ClipboardID, const CString& data) = 0;
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Grab clipboard
|
|
|
|
/*!
|
|
|
|
Grab (i.e. take ownership of) the client's clipboard. Since this
|
|
|
|
is called when another client takes ownership of the clipboard it
|
|
|
|
implies that the client's clipboard is out of date.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void grabClipboard(ClipboardID) = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Mark clipboard dirty
|
|
|
|
/*!
|
|
|
|
Mark the client's clipboard as dirty (out of date) or clean (up to
|
|
|
|
date).
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void setClipboardDirty(ClipboardID, bool dirty) = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
2002-07-29 20:07:26 +04:00
|
|
|
|
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void mouseWheel(SInt32 delta) = 0;
|
2002-07-29 20:07:26 +04:00
|
|
|
|
|
|
|
//! Notify of screen saver change
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void screensaver(bool activate) = 0;
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2002-07-10 01:22:31 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Get client name
|
|
|
|
/*!
|
|
|
|
Return the client's name.
|
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual CString getName() const = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Get jump zone size
|
|
|
|
/*!
|
|
|
|
Called to get the jump zone size.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual SInt32 getJumpZoneSize() const = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Get screen shape
|
|
|
|
/*!
|
|
|
|
Return the position of the upper-left corner of the screen in \c x and
|
2002-07-30 18:59:36 +04:00
|
|
|
\c y and the size of the screen in \c width and \c height.
|
2002-07-29 20:07:26 +04:00
|
|
|
*/
|
2002-07-10 01:22:31 +04:00
|
|
|
virtual void getShape(SInt32& x, SInt32& y,
|
|
|
|
SInt32& width, SInt32& height) const = 0;
|
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Get cursor position
|
|
|
|
/*!
|
|
|
|
Return the current position of the cursor in \c x and \c y.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void getCursorPos(SInt32& x, SInt32& y) const = 0;
|
2002-07-11 00:18:32 +04:00
|
|
|
|
2002-07-29 20:07:26 +04:00
|
|
|
//! Get cursor center position
|
|
|
|
/*!
|
|
|
|
Return the cursor center position which is where we park the
|
|
|
|
cursor to compute cursor motion deltas and should be far from
|
|
|
|
the edges of the screen, typically the center.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
2002-07-29 20:07:26 +04:00
|
|
|
|
|
|
|
//@}
|
2002-07-10 01:22:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|