2002-07-14 02:00:38 +04:00
|
|
|
#ifndef CPRIMARYSCREEN_H
|
|
|
|
#define CPRIMARYSCREEN_H
|
|
|
|
|
|
|
|
#include "ClipboardTypes.h"
|
|
|
|
#include "KeyTypes.h"
|
2002-07-16 20:52:26 +04:00
|
|
|
#include "CMutex.h"
|
2002-07-14 02:00:38 +04:00
|
|
|
|
|
|
|
class IClipboard;
|
|
|
|
class IScreen;
|
|
|
|
class IScreenReceiver;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Generic server-side screen
|
|
|
|
/*!
|
|
|
|
This is a platform independent base class for primary screen
|
|
|
|
implementations. A primary screen is a server-side screen.
|
|
|
|
Each platform will derive a class from CPrimaryScreen to handle
|
|
|
|
platform dependent operations.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
class CPrimaryScreen {
|
|
|
|
public:
|
|
|
|
CPrimaryScreen(IScreenReceiver*);
|
|
|
|
virtual ~CPrimaryScreen();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
|
|
|
|
|
|
|
//! Open screen
|
|
|
|
/*!
|
|
|
|
Opens the screen. This includes initializing the screen, opening
|
|
|
|
the screen saver, synchronizing keyboard state, and causing events
|
|
|
|
to be reported to an IPrimaryScreenReceiver (set through another
|
|
|
|
interface). Calls close() before returning (rethrowing) if it
|
|
|
|
fails for any reason.
|
|
|
|
*/
|
|
|
|
void open();
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Run event loop
|
|
|
|
/*!
|
|
|
|
Run the screen's event loop. This returns when it detects
|
|
|
|
the application should terminate or when stop() is called.
|
|
|
|
run() may only be called between open() and close().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void run();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Exit event loop
|
|
|
|
/*!
|
|
|
|
Force run() to return. This call can return before
|
|
|
|
run() does (i.e. asynchronously).
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void stop();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Close screen
|
|
|
|
/*!
|
|
|
|
Closes the screen. This close the screen saver and the screen.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void close();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Enter screen
|
|
|
|
/*!
|
|
|
|
Called when the user navigates to the primary screen. Warps
|
|
|
|
the cursor to the absolute coordinates \c x,y and unhides
|
|
|
|
it. If \c forScreensaver is true then we're entering because
|
|
|
|
the screen saver started and the cursor is not warped.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void enter(SInt32 x, SInt32 y, bool forScreensaver);
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Leave screen
|
|
|
|
/*!
|
|
|
|
Called when the user navigates off the primary screen. Returns
|
|
|
|
true iff successful.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
bool leave();
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Update configuration
|
|
|
|
/*!
|
|
|
|
This is called when the configuration has changed. \c activeSides
|
|
|
|
is a bitmask of EDirectionMask indicating which sides of the
|
|
|
|
primary screen are linked to clients. Override to handle the
|
|
|
|
possible change in jump zones.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void reconfigure(UInt32 activeSides) = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Warp cursor
|
|
|
|
/*!
|
|
|
|
Warp the cursor to the absolute coordinates \c x,y. Also
|
|
|
|
discard input events up to and including the warp before
|
|
|
|
returning.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Set clipboard
|
|
|
|
/*!
|
|
|
|
Sets the system's clipboard contents. This is usually called
|
|
|
|
soon after an enter().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void setClipboard(ClipboardID, const IClipboard*);
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Grab clipboard
|
|
|
|
/*!
|
|
|
|
Grabs (i.e. take ownership of) the system clipboard.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void grabClipboard(ClipboardID);
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Test if active
|
|
|
|
/*!
|
|
|
|
Returns true iff the screen is active (i.e. the user has left
|
|
|
|
the screen). Note this is the reverse of a secdonary screen.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
bool isActive() const;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Get clipboard
|
|
|
|
/*!
|
|
|
|
Saves the contents of the system clipboard indicated by \c id.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
void getClipboard(ClipboardID, IClipboard*) const;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! 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 19:01:36 +04:00
|
|
|
virtual SInt32 getJumpZoneSize() const = 0;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Get toggle key state
|
|
|
|
/*!
|
|
|
|
Return the primary screen's current toggle modifier key state.
|
|
|
|
The returned mask should have the corresponding bit set for
|
|
|
|
each toggle key that is active. For example, if caps lock is
|
|
|
|
on then the returned mask should have \c KeyModifierCapsLock set.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual KeyModifierMask getToggleMask() const = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Get screen lock state
|
|
|
|
/*!
|
|
|
|
Return true if any key or button is being pressed or if there's
|
|
|
|
any other reason that the user should not be allowed to switch
|
|
|
|
screens. Active toggle keys (including the scroll lock key)
|
|
|
|
should not be counted as reasons to lock to the screen.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual bool isLockedToScreen() const = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Get screen
|
|
|
|
/*!
|
|
|
|
Return the platform dependent screen.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual IScreen* getScreen() const = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//@}
|
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
protected:
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Pre-run() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to run(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPreRun();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Post-run() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from run(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPostRun();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Pre-open() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to open(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPreOpen();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Post-open() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from open() iff the open was successful. Default
|
|
|
|
does nothing. May throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPostOpen();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Pre-close() hook
|
|
|
|
/*!
|
|
|
|
Called on entry to close(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPreClose();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Post-close() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from close(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPostClose();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Pre-enter() hook
|
|
|
|
/*!
|
|
|
|
Called from enter() after the cursor has been warped or, if
|
|
|
|
\c forScreensaver is true, onEnterScreensaver() was called. Override
|
|
|
|
to perform platform specific operations. Default does nothing. May
|
|
|
|
\b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPreEnter();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Post-enter() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from enter(). Override to perform platform specific
|
|
|
|
operations. Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPostEnter();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Pre-enter() for screen saver hook
|
|
|
|
/*!
|
|
|
|
Called on entry to enter() if the \c forScreensaver passed to it was
|
|
|
|
true. Override to perform platform specific operations. Default
|
|
|
|
does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onEnterScreensaver();
|
2002-07-30 18:59:36 +04: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-14 02:00:38 +04:00
|
|
|
virtual void onPreLeave();
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Post-leave() hook
|
|
|
|
/*!
|
|
|
|
Called on exit from leave(). \c success is the value returned by
|
|
|
|
showWindow(). Override to perform platform specific operations.
|
|
|
|
Default does nothing. May \b not throw.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void onPostLeave(bool success);
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Create window
|
|
|
|
/*!
|
|
|
|
Called to create the window. This window is generally used to
|
|
|
|
receive events, hide the cursor, and to capture keyboard and mouse
|
|
|
|
input.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void createWindow() = 0;
|
2002-07-30 18:59:36 +04:00
|
|
|
|
|
|
|
//! Destroy window
|
|
|
|
/*!
|
|
|
|
Called to destroy the window created by createWindow().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void destroyWindow() = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Show window
|
|
|
|
/*!
|
|
|
|
Called when the user navigates off the primary screen. Hide the
|
|
|
|
cursor and grab exclusive access to the input devices. Every call
|
|
|
|
to showWindow() has a matching call to hideWindow() which preceeds
|
|
|
|
it. Return true iff successful (in particular, iff the input
|
|
|
|
devices were grabbed).
|
|
|
|
|
|
|
|
After a successful showWindow(), user input events and
|
|
|
|
screensaver activation/deactivation should be reported to an
|
|
|
|
IPrimaryScreenReceiver (set through another interface) until
|
|
|
|
hideWindow() is called. Report mouse motion to its
|
|
|
|
onMouseMoveSecondary(). User input should not be delivered to
|
|
|
|
any application except this one.
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual bool showWindow() = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Hide window
|
|
|
|
/*!
|
|
|
|
Called when the user navigates back to the primary screen. Show
|
|
|
|
the cursor and ungrab the input devices.
|
|
|
|
|
|
|
|
After hideWindow(), user input events should be delivered normally
|
|
|
|
to other applications. Mouse motion over (at least) the jump zones
|
|
|
|
must be reported to an IPrimaryScreenReceiver's onMouseMovePrimary().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void hideWindow() = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04:00
|
|
|
//! Warp cursor for relative motion
|
|
|
|
/*!
|
|
|
|
Prepare the cursor to report relative motion. When the user has
|
|
|
|
navigated to another screen, synergy requires the cursor motion
|
|
|
|
deltas, not the absolute coordinates. Typically this is done by
|
|
|
|
warping the cursor to the center of the primary screen and then
|
|
|
|
every time it moves compute the motion and warp back to the
|
|
|
|
center (but without reporting that warp as motion). This is
|
|
|
|
only called after a successful showWindow().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void warpCursorToCenter() = 0;
|
|
|
|
|
2002-07-30 18:59:36 +04: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 handling user input and in methods like isLockedToScreen().
|
|
|
|
*/
|
2002-07-14 02:00:38 +04:00
|
|
|
virtual void updateKeys() = 0;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void enterNoWarp();
|
|
|
|
|
|
|
|
private:
|
2002-07-16 20:52:26 +04:00
|
|
|
CMutex m_mutex;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2002-07-16 20:52:26 +04:00
|
|
|
// object to notify of changes
|
2002-07-14 02:00:38 +04:00
|
|
|
IScreenReceiver* m_receiver;
|
|
|
|
|
|
|
|
// m_active is true if this screen has been left
|
|
|
|
bool m_active;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|