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.
|
|
|
|
*/
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
#ifndef CSECONDARYSCREEN_H
|
|
|
|
#define CSECONDARYSCREEN_H
|
|
|
|
|
|
|
|
#include "ClipboardTypes.h"
|
|
|
|
#include "KeyTypes.h"
|
|
|
|
#include "MouseTypes.h"
|
2002-12-23 13:55:21 +00:00
|
|
|
#include "OptionTypes.h"
|
2002-07-13 22:00:38 +00:00
|
|
|
#include "CMutex.h"
|
|
|
|
|
|
|
|
class IClipboard;
|
|
|
|
class IScreen;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
class CSecondaryScreen {
|
|
|
|
public:
|
|
|
|
CSecondaryScreen();
|
|
|
|
virtual ~CSecondaryScreen();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! Open screen
|
|
|
|
/*!
|
2003-03-12 22:34:07 +00:00
|
|
|
Opens the screen. 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.
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
|
|
|
void open();
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Run event loop
|
|
|
|
/*!
|
|
|
|
Run the screen's event loop. This returns when it detects
|
2002-07-30 15:17:44 +00:00
|
|
|
the application should terminate or when exitMainLoop() is called.
|
|
|
|
mainLoop() may only be called between open() and close().
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
2002-07-30 15:17:44 +00:00
|
|
|
void mainLoop();
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Exit event loop
|
|
|
|
/*!
|
2002-07-30 15:17:44 +00:00
|
|
|
Force mainLoop() to return. This call can return before
|
|
|
|
mainLoop() does (i.e. asynchronously).
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
2002-07-30 15:17:44 +00:00
|
|
|
void exitMainLoop();
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-03-12 22:34:07 +00:00
|
|
|
//! Prepare for remote control
|
|
|
|
/*!
|
|
|
|
Prepares the screen for remote control by the server. In
|
|
|
|
particular, it disables the screen saver.
|
|
|
|
*/
|
|
|
|
void remoteControl();
|
|
|
|
|
|
|
|
//! Release from remote control
|
|
|
|
/*!
|
|
|
|
Cleans up the screen from remote control by the server. In
|
|
|
|
particular, it enables the screen saver. 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 localControl();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Close screen
|
|
|
|
/*!
|
2003-03-12 22:34:07 +00:00
|
|
|
Closes the screen.
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void close();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void enter(SInt32 x, SInt32 y, KeyModifierMask mask);
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Leave screen
|
|
|
|
/*!
|
|
|
|
Called when the user navigates off the secondary screen. Cleans
|
|
|
|
up input event synthesis and hides the cursor.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void leave();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Set clipboard
|
|
|
|
/*!
|
|
|
|
Sets the system's clipboard contents. This is usually called
|
|
|
|
soon after an enter().
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void setClipboard(ClipboardID, const IClipboard*);
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Grab clipboard
|
|
|
|
/*!
|
|
|
|
Grabs (i.e. take ownership of) the system clipboard.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void grabClipboard(ClipboardID);
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Activate/deactivate screen saver
|
|
|
|
/*!
|
|
|
|
Forcibly activates the screen saver if \c activate is true otherwise
|
|
|
|
forcibly deactivates it.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
void screensaver(bool activate);
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Notify of key press
|
|
|
|
/*!
|
|
|
|
Synthesize key events to generate a press of key \c id. If possible
|
2003-04-27 17:01:14 +00:00
|
|
|
match the given modifier mask. The KeyButton identifies the physical
|
|
|
|
key on the server that generated this key down. The client must
|
|
|
|
ensure that a key up or key repeat that uses the same KeyButton will
|
|
|
|
synthesize an up or repeat for the same client key synthesized by
|
|
|
|
keyDown().
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
2003-04-27 17:01:14 +00:00
|
|
|
virtual void keyDown(KeyID id, KeyModifierMask, KeyButton) = 0;
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! 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.
|
|
|
|
*/
|
2003-04-27 17:01:14 +00:00
|
|
|
virtual void keyRepeat(KeyID id, KeyModifierMask,
|
|
|
|
SInt32 count, KeyButton) = 0;
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Notify of key release
|
|
|
|
/*!
|
|
|
|
Synthesize key events to generate a release of key \c id. If possible
|
|
|
|
match the given modifier mask.
|
|
|
|
*/
|
2003-04-27 17:01:14 +00:00
|
|
|
virtual void keyUp(KeyID id, KeyModifierMask, KeyButton) = 0;
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void mouseWheel(SInt32 delta) = 0;
|
|
|
|
|
2002-12-23 13:55:21 +00:00
|
|
|
//! Notify of options changes
|
|
|
|
/*!
|
2003-05-03 14:38:36 +00:00
|
|
|
Reset all options to their default values. Overrides should call
|
|
|
|
the superclass's method.
|
2002-12-23 13:55:21 +00:00
|
|
|
*/
|
2003-05-03 14:38:36 +00:00
|
|
|
virtual void resetOptions();
|
2002-12-23 13:55:21 +00:00
|
|
|
|
|
|
|
//! Notify of options changes
|
|
|
|
/*!
|
|
|
|
Set options to given values. Ignore unknown options and don't
|
2003-05-03 14:38:36 +00:00
|
|
|
modify our options that aren't given in \c options. Overrides
|
|
|
|
should call the superclass's method.
|
2002-12-23 13:55:21 +00:00
|
|
|
*/
|
2003-05-03 14:38:36 +00:00
|
|
|
virtual void setOptions(const COptionsList& options);
|
2002-12-23 13:55:21 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
bool isActive() const;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual SInt32 getJumpZoneSize() const = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void getShape(SInt32& x, SInt32& y,
|
|
|
|
SInt32& width, SInt32& height) const;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Get cursor position
|
|
|
|
/*!
|
|
|
|
Return the current position of the cursor in \c x,y.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Get screen
|
|
|
|
/*!
|
|
|
|
Return the platform dependent screen.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual IScreen* getScreen() const = 0;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//@}
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
protected:
|
2002-07-30 15:17:44 +00:00
|
|
|
//! Pre-mainLoop() hook
|
2002-07-30 14:59:36 +00:00
|
|
|
/*!
|
2002-07-30 15:17:44 +00:00
|
|
|
Called on entry to mainLoop(). Override to perform platform specific
|
2002-07-30 14:59:36 +00:00
|
|
|
operations. Default does nothing. May throw.
|
|
|
|
*/
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
2002-07-30 15:17:44 +00:00
|
|
|
//! Post-mainLoop() hook
|
2002-07-30 14:59:36 +00:00
|
|
|
/*!
|
2002-07-30 15:17:44 +00:00
|
|
|
Called on exit from mainLoop(). Override to perform platform specific
|
2002-07-30 14:59:36 +00:00
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPostMainLoop();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Pre-open() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to open(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreOpen();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Post-open() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from open() iff the open was successful. Default
|
|
|
|
does nothing. May throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPostOpen();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Pre-close() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to close(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreClose();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Post-close() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from close(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPostClose();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Pre-enter() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to enter() after desktop synchronization. Override
|
|
|
|
to perform platform specific operations. Default does nothing. May
|
|
|
|
\b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreEnter();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Post-enter() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from enter(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPostEnter();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Pre-leave() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to leave() after desktop synchronization. Override
|
|
|
|
to perform platform specific operations. Default does nothing. May
|
|
|
|
\b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPreLeave();
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Post-leave() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from leave(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void onPostLeave();
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Create window
|
|
|
|
/*!
|
|
|
|
Called to create the window. This window is generally used to
|
|
|
|
receive events and hide the cursor.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void createWindow() = 0;
|
2002-07-30 14:59:36 +00:00
|
|
|
|
|
|
|
//! Destroy window
|
|
|
|
/*!
|
|
|
|
Called to destroy the window created by createWindow().
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void destroyWindow() = 0;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Show window
|
|
|
|
/*!
|
|
|
|
Called when the user navigates off this secondary screen. It needn't
|
2003-05-03 13:50:06 +00:00
|
|
|
actually show the window created by createWindow() but it must move
|
|
|
|
the cursor to x,y, hide it, and clean up event synthesis.
|
2002-07-30 14:59:36 +00:00
|
|
|
*/
|
2003-05-03 13:50:06 +00:00
|
|
|
virtual void showWindow(SInt32 x, SInt32 y) = 0;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void hideWindow() = 0;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Warp cursor
|
|
|
|
/*!
|
|
|
|
Warp the cursor to the absolute coordinates \c x,y.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! 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.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void updateKeys() = 0;
|
|
|
|
|
2003-03-12 22:34:07 +00:00
|
|
|
//! Release keys
|
|
|
|
/*!
|
|
|
|
Synthesizes key release event for any key that our key state
|
|
|
|
says is down.
|
|
|
|
*/
|
|
|
|
virtual void releaseKeys() = 0;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Synchronize toggle key state
|
|
|
|
/*!
|
|
|
|
Toggle modifiers that don't match the given state so that they do.
|
|
|
|
*/
|
2002-07-13 22:00:38 +00:00
|
|
|
virtual void setToggleState(KeyModifierMask) = 0;
|
|
|
|
|
2002-12-15 22:14:49 +00:00
|
|
|
//! Get the toggle key state
|
|
|
|
/*!
|
|
|
|
Returns the current state of the toggle keys.
|
|
|
|
*/
|
|
|
|
virtual KeyModifierMask getToggleState() const = 0;
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
private:
|
|
|
|
CMutex m_mutex;
|
|
|
|
|
2003-05-03 14:38:36 +00:00
|
|
|
// true if ready for remote control
|
|
|
|
bool m_remoteReady;
|
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
// m_active is true if this screen has been entered
|
|
|
|
bool m_active;
|
2002-12-15 22:14:49 +00:00
|
|
|
|
|
|
|
// the toggle key state when this screen was last entered
|
|
|
|
KeyModifierMask m_toggleKeys;
|
2003-05-03 14:38:36 +00:00
|
|
|
|
|
|
|
// true if screen saver should be synchronized to server
|
|
|
|
bool m_screenSaverSync;
|
2002-07-13 22:00:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|