mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-25 05:12:16 +08:00
checkpoint. still refactoring. merged common code from primary
screens into CPrimaryScreen and merged common code from secondary screens into CSecondaryScreen. changed is-a relationship to a has-a between the primary and secondary screen classes and the generic platform dependent screen class to avoid multiple inheritance of implementation. also standardized the interface for those generic screen classes. adding a platform now involves implementing simpler interfaces: IScreen for the generic screen, IScreenEventHandler and some methods of CPrimaryScreen for the primary screen, and IScreenEventHandler and some methods of CSecondaryScreen for the secondary screen. did X11 platform but not win32 platform.
This commit is contained in:
@@ -32,7 +32,7 @@ public:
|
||||
virtual void close() = 0;
|
||||
virtual void enter(SInt32 xAbs, SInt32 yAbs,
|
||||
UInt32 seqNum, KeyModifierMask mask,
|
||||
bool screenSaver) = 0;
|
||||
bool forScreensaver) = 0;
|
||||
virtual bool leave() = 0;
|
||||
virtual void setClipboard(ClipboardID, const CString&) = 0;
|
||||
virtual void grabClipboard(ClipboardID) = 0;
|
||||
@@ -44,13 +44,13 @@ public:
|
||||
virtual void mouseUp(ButtonID) = 0;
|
||||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;
|
||||
virtual void mouseWheel(SInt32 delta) = 0;
|
||||
virtual void screenSaver(bool activate) = 0;
|
||||
virtual void screensaver(bool activate) = 0;
|
||||
virtual CString getName() const;
|
||||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const = 0;
|
||||
virtual void getCenter(SInt32& x, SInt32& y) const = 0;
|
||||
virtual void getMousePos(SInt32& x, SInt32& y) const = 0;
|
||||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
virtual void getCursorPos(SInt32& x, SInt32& y) const = 0;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0;
|
||||
|
||||
private:
|
||||
IServer* m_server;
|
||||
|
||||
@@ -236,12 +236,19 @@ CClientProxy1_0::mouseWheel(SInt32 delta)
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::screenSaver(bool on)
|
||||
CClientProxy1_0::screensaver(bool on)
|
||||
{
|
||||
log((CLOG_DEBUG1 "send screen saver to \"%s\" on=%d", getName().c_str(), on ? 1 : 0));
|
||||
CProtocolUtil::writef(getOutputStream(), kMsgCScreenSaver, on ? 1 : 0);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CClientProxy1_0::getJumpZoneSize() const
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
return m_info.m_zoneSize;
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
@@ -253,24 +260,17 @@ CClientProxy1_0::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::getCenter(SInt32& x, SInt32& y) const
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
x = m_info.m_mx;
|
||||
y = m_info.m_my;
|
||||
}
|
||||
|
||||
void
|
||||
CClientProxy1_0::getMousePos(SInt32&, SInt32&) const
|
||||
CClientProxy1_0::getCursorPos(SInt32&, SInt32&) const
|
||||
{
|
||||
assert(0 && "shouldn't be called");
|
||||
}
|
||||
|
||||
SInt32
|
||||
CClientProxy1_0::getJumpZoneSize() const
|
||||
void
|
||||
CClientProxy1_0::getCursorCenter(SInt32& x, SInt32& y) const
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
return m_info.m_zoneSize;
|
||||
x = m_info.m_mx;
|
||||
y = m_info.m_my;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
virtual void close();
|
||||
virtual void enter(SInt32 xAbs, SInt32 yAbs,
|
||||
UInt32 seqNum, KeyModifierMask mask,
|
||||
bool screenSaver);
|
||||
bool forScreensaver);
|
||||
virtual bool leave();
|
||||
virtual void setClipboard(ClipboardID, const CString&);
|
||||
virtual void grabClipboard(ClipboardID);
|
||||
@@ -30,12 +30,12 @@ public:
|
||||
virtual void mouseUp(ButtonID);
|
||||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
|
||||
virtual void mouseWheel(SInt32 delta);
|
||||
virtual void screenSaver(bool activate);
|
||||
virtual void screensaver(bool activate);
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const;
|
||||
virtual void getCenter(SInt32& x, SInt32& y) const;
|
||||
virtual void getMousePos(SInt32& x, SInt32& y) const;
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
||||
|
||||
private:
|
||||
void recvInfo(bool notify);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "CPrimaryClient.h"
|
||||
#include "IServer.h"
|
||||
#include "IPrimaryScreen.h"
|
||||
#include "CPrimaryScreen.h"
|
||||
#include "CClipboard.h"
|
||||
#include "CLog.h"
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
// CPrimaryClient
|
||||
//
|
||||
|
||||
CPrimaryClient::CPrimaryClient(IServer* server, const CString& name) :
|
||||
CPrimaryClient::CPrimaryClient(IServer* server,
|
||||
IPrimaryScreenReceiver* receiver, const CString& name) :
|
||||
m_server(server),
|
||||
m_name(name),
|
||||
m_seqNum(0)
|
||||
@@ -25,9 +26,9 @@ CPrimaryClient::CPrimaryClient(IServer* server, const CString& name) :
|
||||
// create screen
|
||||
log((CLOG_DEBUG1 "creating primary screen"));
|
||||
#if WINDOWS_LIKE
|
||||
m_screen = new CMSWindowsPrimaryScreen(this, m_server);
|
||||
m_screen = new CMSWindowsPrimaryScreen(this, receiver);
|
||||
#elif UNIX_LIKE
|
||||
m_screen = new CXWindowsPrimaryScreen(this, m_server);
|
||||
m_screen = new CXWindowsPrimaryScreen(this, receiver);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@ CPrimaryClient::mouseWheel(SInt32)
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::screenSaver(bool)
|
||||
CPrimaryClient::screensaver(bool)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
@@ -222,6 +223,12 @@ CPrimaryClient::getName() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
SInt32
|
||||
CPrimaryClient::getJumpZoneSize() const
|
||||
{
|
||||
return m_info.m_zoneSize;
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
@@ -232,20 +239,14 @@ CPrimaryClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::getCenter(SInt32& x, SInt32& y) const
|
||||
{
|
||||
x = m_info.m_mx;
|
||||
y = m_info.m_my;
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryClient::getMousePos(SInt32&, SInt32&) const
|
||||
CPrimaryClient::getCursorPos(SInt32&, SInt32&) const
|
||||
{
|
||||
assert(0 && "shouldn't be called");
|
||||
}
|
||||
|
||||
SInt32
|
||||
CPrimaryClient::getJumpZoneSize() const
|
||||
void
|
||||
CPrimaryClient::getCursorCenter(SInt32& x, SInt32& y) const
|
||||
{
|
||||
return m_info.m_zoneSize;
|
||||
x = m_info.m_mx;
|
||||
y = m_info.m_my;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
#include "ProtocolTypes.h"
|
||||
|
||||
class IClipboard;
|
||||
class IPrimaryScreen;
|
||||
class CPrimaryScreen;
|
||||
class IPrimaryScreenReceiver;
|
||||
class IServer;
|
||||
|
||||
class CPrimaryClient : public IScreenReceiver, public IClient {
|
||||
public:
|
||||
CPrimaryClient(IServer*, const CString& name);
|
||||
CPrimaryClient(IServer*, IPrimaryScreenReceiver*, const CString& name);
|
||||
~CPrimaryClient();
|
||||
|
||||
// manipulators
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
virtual void close();
|
||||
virtual void enter(SInt32 xAbs, SInt32 yAbs,
|
||||
UInt32 seqNum, KeyModifierMask mask,
|
||||
bool screenSaver);
|
||||
bool forScreensaver);
|
||||
virtual bool leave();
|
||||
virtual void setClipboard(ClipboardID, const CString&);
|
||||
virtual void grabClipboard(ClipboardID);
|
||||
@@ -56,17 +57,17 @@ public:
|
||||
virtual void mouseUp(ButtonID);
|
||||
virtual void mouseMove(SInt32 xAbs, SInt32 yAbs);
|
||||
virtual void mouseWheel(SInt32 delta);
|
||||
virtual void screenSaver(bool activate);
|
||||
virtual void screensaver(bool activate);
|
||||
virtual CString getName() const;
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const;
|
||||
virtual void getCenter(SInt32& x, SInt32& y) const;
|
||||
virtual void getMousePos(SInt32& x, SInt32& y) const;
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
||||
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
||||
|
||||
private:
|
||||
IServer* m_server;
|
||||
IPrimaryScreen* m_screen;
|
||||
CPrimaryScreen* m_screen;
|
||||
CString m_name;
|
||||
UInt32 m_seqNum;
|
||||
CClientInfo m_info;
|
||||
|
||||
270
server/CPrimaryScreen.cpp
Normal file
270
server/CPrimaryScreen.cpp
Normal file
@@ -0,0 +1,270 @@
|
||||
#include "CPrimaryScreen.h"
|
||||
#include "IScreen.h"
|
||||
#include "IScreenReceiver.h"
|
||||
#include "ProtocolTypes.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
|
||||
// FIXME -- should be locking
|
||||
|
||||
//
|
||||
// CPrimaryScreen
|
||||
//
|
||||
|
||||
CPrimaryScreen::CPrimaryScreen(IScreenReceiver* receiver) :
|
||||
m_receiver(receiver),
|
||||
m_active(false)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CPrimaryScreen::~CPrimaryScreen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::run()
|
||||
{
|
||||
// change our priority
|
||||
CThread::getCurrentThread().setPriority(-3);
|
||||
|
||||
// run event loop
|
||||
try {
|
||||
log((CLOG_DEBUG "entering event loop"));
|
||||
onPreRun();
|
||||
getScreen()->mainLoop();
|
||||
onPostRun();
|
||||
log((CLOG_DEBUG "exiting event loop"));
|
||||
}
|
||||
catch (...) {
|
||||
onPostRun();
|
||||
log((CLOG_DEBUG "exiting event loop"));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::stop()
|
||||
{
|
||||
getScreen()->exitMainLoop();
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::open()
|
||||
{
|
||||
CClientInfo info;
|
||||
try {
|
||||
// subclass hook
|
||||
onPreOpen();
|
||||
|
||||
// open the screen
|
||||
getScreen()->open();
|
||||
|
||||
// create and prepare our window
|
||||
createWindow();
|
||||
|
||||
// collect screen info
|
||||
getScreen()->getShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
||||
getScreen()->getCursorPos(info.m_mx, info.m_my);
|
||||
info.m_zoneSize = getJumpZoneSize();
|
||||
|
||||
// update keyboard state
|
||||
updateKeys();
|
||||
|
||||
// get notified of screen saver activation/deactivation
|
||||
getScreen()->openScreenSaver(true);
|
||||
|
||||
// subclass hook
|
||||
onPostOpen();
|
||||
}
|
||||
catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
|
||||
// enter the screen
|
||||
enterNoWarp();
|
||||
|
||||
// send screen info
|
||||
m_receiver->onInfoChanged(info);
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::close()
|
||||
{
|
||||
onPreClose();
|
||||
getScreen()->closeScreenSaver();
|
||||
destroyWindow();
|
||||
getScreen()->close();
|
||||
onPostClose();
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::enter(SInt32 x, SInt32 y, bool forScreensaver)
|
||||
{
|
||||
log((CLOG_INFO "entering primary at %d,%d%s", x, y, forScreensaver ? " for screen saver" : ""));
|
||||
assert(m_active == true);
|
||||
|
||||
enterNoWarp();
|
||||
if (!forScreensaver) {
|
||||
warpCursor(x, y);
|
||||
}
|
||||
else {
|
||||
onEnterScreensaver();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::enterNoWarp()
|
||||
{
|
||||
// not active anymore
|
||||
m_active = false;
|
||||
|
||||
// subclass hook
|
||||
onPreEnter();
|
||||
|
||||
// restore active window and hide our window
|
||||
hideWindow();
|
||||
|
||||
// subclass hook
|
||||
onPostEnter();
|
||||
}
|
||||
|
||||
bool
|
||||
CPrimaryScreen::leave()
|
||||
{
|
||||
log((CLOG_INFO "leaving primary"));
|
||||
assert(m_active == false);
|
||||
|
||||
// subclass hook
|
||||
onPreLeave();
|
||||
|
||||
// show our window
|
||||
if (!showWindow()) {
|
||||
onPostLeave(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// get keyboard state as we leave
|
||||
updateKeys();
|
||||
|
||||
// warp mouse to center
|
||||
warpCursorToCenter();
|
||||
// FIXME -- this doesn't match the win32 version. that just does
|
||||
// the warp while we flush the input queue until we find the warp
|
||||
// and we discard that too. would prefer to at least match our
|
||||
// own warping when we receive MotionNotify; that just does the
|
||||
// warp. however, the win32 version sometimes stutters when
|
||||
// leaving and perhaps this is why. hmm, win32 does ignore the
|
||||
// events until after the warp (via the mark).
|
||||
|
||||
// subclass hook
|
||||
onPostLeave(true);
|
||||
|
||||
// local client now active
|
||||
m_active = true;
|
||||
|
||||
// make sure our idea of clipboard ownership is correct
|
||||
getScreen()->checkClipboards();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::setClipboard(ClipboardID id,
|
||||
const IClipboard* clipboard)
|
||||
{
|
||||
getScreen()->setClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::grabClipboard(ClipboardID id)
|
||||
{
|
||||
getScreen()->setClipboard(id, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
CPrimaryScreen::isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::getClipboard(ClipboardID id,
|
||||
IClipboard* clipboard) const
|
||||
{
|
||||
getScreen()->getClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CPrimaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPreRun()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPostRun()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPreOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPostOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPreClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPostClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPreEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPostEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onEnterScreensaver()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPreLeave()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CPrimaryScreen::onPostLeave(bool)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
157
server/CPrimaryScreen.h
Normal file
157
server/CPrimaryScreen.h
Normal file
@@ -0,0 +1,157 @@
|
||||
#ifndef CPRIMARYSCREEN_H
|
||||
#define CPRIMARYSCREEN_H
|
||||
|
||||
#include "ClipboardTypes.h"
|
||||
#include "KeyTypes.h"
|
||||
|
||||
class IClipboard;
|
||||
class IScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
// platform independent base class for primary screen implementations.
|
||||
// each platform will derive a class from CPrimaryScreen to handle
|
||||
// platform dependent operations.
|
||||
class CPrimaryScreen {
|
||||
public:
|
||||
CPrimaryScreen(IScreenReceiver*);
|
||||
virtual ~CPrimaryScreen();
|
||||
|
||||
// manipulators
|
||||
|
||||
// enter the screen's message loop. this returns when it detects
|
||||
// the application should terminate or when stop() is called.
|
||||
// run() may only be called between open() and close().
|
||||
void run();
|
||||
|
||||
// cause run() to return
|
||||
void stop();
|
||||
|
||||
// initializes the screen and starts reporting events
|
||||
void open();
|
||||
|
||||
// close the screen
|
||||
void close();
|
||||
|
||||
// called when the user navigates to the primary screen.
|
||||
// forScreensaver == true means that we're entering the primary
|
||||
// screen because the screensaver has activated.
|
||||
void enter(SInt32 x, SInt32 y, bool forScreensaver);
|
||||
|
||||
// called when the user navigates off the primary screen. returns
|
||||
// true iff successful.
|
||||
bool leave();
|
||||
|
||||
// called when the configuration has changed. activeSides is a
|
||||
// bitmask of CConfig::EDirectionMask indicating which sides of
|
||||
// the primary screen are linked to clients.
|
||||
virtual void reconfigure(UInt32 activeSides) = 0;
|
||||
|
||||
// warp the cursor to the given absolute coordinates
|
||||
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
||||
|
||||
// set the screen's clipboard contents. this is usually called
|
||||
// soon after an enter().
|
||||
void setClipboard(ClipboardID, const IClipboard*);
|
||||
|
||||
// synergy should own the clipboard
|
||||
void grabClipboard(ClipboardID);
|
||||
|
||||
// accessors
|
||||
|
||||
// returns true iff the screen is active (i.e. the user has left
|
||||
// the screen)
|
||||
bool isActive() const;
|
||||
|
||||
// return the contents of the given clipboard
|
||||
void getClipboard(ClipboardID, IClipboard*) const;
|
||||
|
||||
// returns the size of the zone on the edges of the screen that
|
||||
// causes the cursor to jump to another screen. default returns 1.
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
|
||||
// get 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.
|
||||
virtual KeyModifierMask getToggleMask() const = 0;
|
||||
|
||||
// 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.
|
||||
virtual bool isLockedToScreen() const = 0;
|
||||
|
||||
// get the platform dependent screen object
|
||||
virtual IScreen* getScreen() const = 0;
|
||||
|
||||
protected:
|
||||
// template method hooks. these are called on entry/exit to the
|
||||
// named method. onEnterScreensaver() is called by enter() iff
|
||||
// forScreensaver is true. onPostLeave() is passed the result of
|
||||
// showWindow(). override to do platform specific operations.
|
||||
// defaults do nothing.
|
||||
virtual void onPreRun();
|
||||
virtual void onPostRun();
|
||||
virtual void onPreOpen();
|
||||
virtual void onPostOpen();
|
||||
virtual void onPreClose();
|
||||
virtual void onPostClose();
|
||||
virtual void onPreEnter();
|
||||
virtual void onPostEnter();
|
||||
virtual void onEnterScreensaver();
|
||||
virtual void onPreLeave();
|
||||
virtual void onPostLeave(bool success);
|
||||
|
||||
// create/destroy the window. this window is generally used to
|
||||
// receive events and, when the user navigates to another screen,
|
||||
// to capture keyboard and mouse input.
|
||||
virtual void createWindow() = 0;
|
||||
virtual void destroyWindow() = 0;
|
||||
|
||||
// called when the user navigates off the primary screen. hide the
|
||||
// cursor and grab exclusive access to the input devices. returns
|
||||
// true iff successful. 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 until hideWindow() is called. report
|
||||
// mouse motion to IPrimaryScreenReceiver::onMouseMoveSecondary().
|
||||
// user input should not be delivered to any application except
|
||||
// synergy.
|
||||
virtual bool showWindow() = 0;
|
||||
|
||||
// called when the user navigates back to the primary screen. show
|
||||
// the cursor and ungab the input devices.
|
||||
//
|
||||
// after hideWindow(), user input events should be delivered normally.
|
||||
// mouse motion over (at least) the jump zones must be reported to
|
||||
// an IPrimaryScreenReceiver::onMouseMovePrimary().
|
||||
virtual void hideWindow() = 0;
|
||||
|
||||
// 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().
|
||||
virtual void warpCursorToCenter() = 0;
|
||||
|
||||
// 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().
|
||||
virtual void updateKeys() = 0;
|
||||
|
||||
private:
|
||||
void enterNoWarp();
|
||||
|
||||
private:
|
||||
// FIXME -- should have a mutex
|
||||
|
||||
IScreenReceiver* m_receiver;
|
||||
|
||||
// m_active is true if this screen has been left
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -92,7 +92,6 @@ CServer::run()
|
||||
}
|
||||
|
||||
// handle events
|
||||
log((CLOG_DEBUG "starting event handling"));
|
||||
m_primaryClient->run();
|
||||
|
||||
// clean up
|
||||
@@ -108,9 +107,6 @@ CServer::run()
|
||||
stopThreads(); \
|
||||
delete m_httpServer; \
|
||||
m_httpServer = NULL; \
|
||||
if (m_primaryClient != NULL) { \
|
||||
closePrimaryScreen(); \
|
||||
} \
|
||||
} while (false)
|
||||
FINALLY;
|
||||
}
|
||||
@@ -144,6 +140,15 @@ CServer::quit()
|
||||
m_primaryClient->stop();
|
||||
}
|
||||
|
||||
void
|
||||
CServer::close()
|
||||
{
|
||||
if (m_primaryClient != NULL) {
|
||||
closePrimaryScreen();
|
||||
}
|
||||
log((CLOG_INFO "closed screen"));
|
||||
}
|
||||
|
||||
bool
|
||||
CServer::setConfig(const CConfig& config)
|
||||
{
|
||||
@@ -211,20 +216,6 @@ CServer::getActivePrimarySides() const
|
||||
return sides;
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onError()
|
||||
{
|
||||
// stop all running threads but don't wait too long since some
|
||||
// threads may be unable to proceed until this thread returns.
|
||||
stopThreads(3.0);
|
||||
|
||||
// done with the HTTP server
|
||||
delete m_httpServer;
|
||||
m_httpServer = NULL;
|
||||
|
||||
// note -- we do not attempt to close down the primary screen
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onInfoChanged(const CString& name, const CClientInfo& info)
|
||||
{
|
||||
@@ -347,10 +338,74 @@ CServer::onClipboardChangedNoLock(ClipboardID id,
|
||||
m_active->setClipboard(id, m_clipboards[id].m_clipboardData);
|
||||
}
|
||||
|
||||
bool
|
||||
CServer::onCommandKey(KeyID /*id*/, KeyModifierMask /*mask*/, bool /*down*/)
|
||||
void
|
||||
CServer::onError()
|
||||
{
|
||||
return false;
|
||||
// stop all running threads but don't wait too long since some
|
||||
// threads may be unable to proceed until this thread returns.
|
||||
stopThreads(3.0);
|
||||
|
||||
// done with the HTTP server
|
||||
delete m_httpServer;
|
||||
m_httpServer = NULL;
|
||||
|
||||
// note -- we do not attempt to close down the primary screen
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onScreensaver(bool activated)
|
||||
{
|
||||
log((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
||||
CLock lock(&m_mutex);
|
||||
|
||||
if (activated) {
|
||||
// save current screen and position
|
||||
m_activeSaver = m_active;
|
||||
m_xSaver = m_x;
|
||||
m_ySaver = m_y;
|
||||
|
||||
// jump to primary screen
|
||||
if (m_active != m_primaryClient) {
|
||||
switchScreen(m_primaryClient, 0, 0, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// jump back to previous screen and position. we must check
|
||||
// that the position is still valid since the screen may have
|
||||
// changed resolutions while the screen saver was running.
|
||||
if (m_activeSaver != NULL && m_activeSaver != m_primaryClient) {
|
||||
// check position
|
||||
IClient* screen = m_activeSaver;
|
||||
SInt32 x, y, w, h;
|
||||
screen->getShape(x, y, w, h);
|
||||
SInt32 zoneSize = screen->getJumpZoneSize();
|
||||
if (m_xSaver < x + zoneSize) {
|
||||
m_xSaver = x + zoneSize;
|
||||
}
|
||||
else if (m_xSaver >= x + w - zoneSize) {
|
||||
m_xSaver = x + w - zoneSize - 1;
|
||||
}
|
||||
if (m_ySaver < y + zoneSize) {
|
||||
m_ySaver = y + zoneSize;
|
||||
}
|
||||
else if (m_ySaver >= y + h - zoneSize) {
|
||||
m_ySaver = y + h - zoneSize - 1;
|
||||
}
|
||||
|
||||
// jump
|
||||
switchScreen(screen, m_xSaver, m_ySaver, false);
|
||||
}
|
||||
|
||||
// reset state
|
||||
m_activeSaver = NULL;
|
||||
}
|
||||
|
||||
// send message to all clients
|
||||
for (CClientList::const_iterator index = m_clients.begin();
|
||||
index != m_clients.end(); ++index) {
|
||||
IClient* client = index->second;
|
||||
client->screensaver(activated);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -615,60 +670,10 @@ CServer::onMouseWheel(SInt32 delta)
|
||||
m_active->mouseWheel(delta);
|
||||
}
|
||||
|
||||
void
|
||||
CServer::onScreenSaver(bool activated)
|
||||
bool
|
||||
CServer::onCommandKey(KeyID /*id*/, KeyModifierMask /*mask*/, bool /*down*/)
|
||||
{
|
||||
log((CLOG_DEBUG "onScreenSaver %s", activated ? "activated" : "deactivated"));
|
||||
CLock lock(&m_mutex);
|
||||
|
||||
if (activated) {
|
||||
// save current screen and position
|
||||
m_activeSaver = m_active;
|
||||
m_xSaver = m_x;
|
||||
m_ySaver = m_y;
|
||||
|
||||
// jump to primary screen
|
||||
if (m_active != m_primaryClient) {
|
||||
switchScreen(m_primaryClient, 0, 0, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// jump back to previous screen and position. we must check
|
||||
// that the position is still valid since the screen may have
|
||||
// changed resolutions while the screen saver was running.
|
||||
if (m_activeSaver != NULL && m_activeSaver != m_primaryClient) {
|
||||
// check position
|
||||
IClient* screen = m_activeSaver;
|
||||
SInt32 x, y, w, h;
|
||||
screen->getShape(x, y, w, h);
|
||||
SInt32 zoneSize = screen->getJumpZoneSize();
|
||||
if (m_xSaver < x + zoneSize) {
|
||||
m_xSaver = x + zoneSize;
|
||||
}
|
||||
else if (m_xSaver >= x + w - zoneSize) {
|
||||
m_xSaver = x + w - zoneSize - 1;
|
||||
}
|
||||
if (m_ySaver < y + zoneSize) {
|
||||
m_ySaver = y + zoneSize;
|
||||
}
|
||||
else if (m_ySaver >= y + h - zoneSize) {
|
||||
m_ySaver = y + h - zoneSize - 1;
|
||||
}
|
||||
|
||||
// jump
|
||||
switchScreen(screen, m_xSaver, m_ySaver, false);
|
||||
}
|
||||
|
||||
// reset state
|
||||
m_activeSaver = NULL;
|
||||
}
|
||||
|
||||
// send message to all clients
|
||||
for (CClientList::const_iterator index = m_clients.begin();
|
||||
index != m_clients.end(); ++index) {
|
||||
IClient* client = index->second;
|
||||
client->screenSaver(activated);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -689,7 +694,7 @@ CServer::isLockedToScreenNoLock() const
|
||||
}
|
||||
|
||||
void
|
||||
CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool screenSaver)
|
||||
CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool forScreensaver)
|
||||
{
|
||||
assert(dst != NULL);
|
||||
#ifndef NDEBUG
|
||||
@@ -741,7 +746,8 @@ CServer::switchScreen(IClient* dst, SInt32 x, SInt32 y, bool screenSaver)
|
||||
|
||||
// enter new screen
|
||||
m_active->enter(x, y, m_seqNum,
|
||||
m_primaryClient->getToggleMask(), screenSaver);
|
||||
m_primaryClient->getToggleMask(),
|
||||
forScreensaver);
|
||||
|
||||
// send the clipboard data to new active screen
|
||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||
@@ -1209,7 +1215,7 @@ CServer::runClient(void* vsocket)
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
if (m_activeSaver != NULL) {
|
||||
proxy->screenSaver(true);
|
||||
proxy->screensaver(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1510,7 +1516,7 @@ CServer::openPrimaryScreen()
|
||||
|
||||
// create the primary client and open it
|
||||
try {
|
||||
m_primaryClient = new CPrimaryClient(this, primary);
|
||||
m_primaryClient = new CPrimaryClient(this, this, primary);
|
||||
|
||||
// add connection
|
||||
addConnection(m_primaryClient);
|
||||
@@ -1593,7 +1599,7 @@ CServer::removeConnection(const CString& name)
|
||||
IClient* active = (m_activeSaver != NULL) ? m_activeSaver : m_active;
|
||||
if (active == index->second && active != m_primaryClient) {
|
||||
// record new position (center of primary screen)
|
||||
m_primaryClient->getCenter(m_x, m_y);
|
||||
m_primaryClient->getCursorCenter(m_x, m_y);
|
||||
|
||||
// don't notify active screen since it probably already disconnected
|
||||
log((CLOG_INFO "jump from \"%s\" to \"%s\" at %d,%d", active->getName().c_str(), m_primaryClient->getName().c_str(), m_x, m_y));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CSERVER_H
|
||||
|
||||
#include "IServer.h"
|
||||
#include "IPrimaryScreenReceiver.h"
|
||||
#include "CConfig.h"
|
||||
#include "CClipboard.h"
|
||||
#include "CCondVar.h"
|
||||
@@ -20,7 +21,7 @@ class IServerProtocol;
|
||||
class ISocketFactory;
|
||||
class ISecurityFactory;
|
||||
|
||||
class CServer : public IServer {
|
||||
class CServer : public IServer, public IPrimaryScreenReceiver {
|
||||
public:
|
||||
CServer(const CString& serverName);
|
||||
~CServer();
|
||||
@@ -38,6 +39,9 @@ public:
|
||||
// after a successful open().
|
||||
void quit();
|
||||
|
||||
// close the server's screen
|
||||
void close();
|
||||
|
||||
// update screen map. returns true iff the new configuration was
|
||||
// accepted.
|
||||
bool setConfig(const CConfig&);
|
||||
@@ -50,8 +54,14 @@ public:
|
||||
// get the primary screen's name
|
||||
CString getPrimaryScreenName() const;
|
||||
|
||||
// IServer overrides
|
||||
virtual void onInfoChanged(const CString&, const CClientInfo&);
|
||||
virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
|
||||
virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
|
||||
|
||||
// IPrimaryScreenReceiver overrides
|
||||
virtual void onError();
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual void onKeyDown(KeyID, KeyModifierMask);
|
||||
virtual void onKeyUp(KeyID, KeyModifierMask);
|
||||
virtual void onKeyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
||||
@@ -60,12 +70,6 @@ public:
|
||||
virtual bool onMouseMovePrimary(SInt32 x, SInt32 y);
|
||||
virtual void onMouseMoveSecondary(SInt32 dx, SInt32 dy);
|
||||
virtual void onMouseWheel(SInt32 delta);
|
||||
virtual void onScreenSaver(bool activated);
|
||||
|
||||
// IServer overrides
|
||||
virtual void onInfoChanged(const CString&, const CClientInfo&);
|
||||
virtual bool onGrabClipboard(const CString&, ClipboardID, UInt32);
|
||||
virtual void onClipboardChanged(ClipboardID, UInt32, const CString&);
|
||||
|
||||
protected:
|
||||
bool onCommandKey(KeyID, KeyModifierMask, bool down);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
#include "CXWindowsPrimaryScreen.h"
|
||||
#include "IScreenReceiver.h"
|
||||
#include "IPrimaryScreenReceiver.h"
|
||||
#include "CXWindowsClipboard.h"
|
||||
#include "CXWindowsScreenSaver.h"
|
||||
#include "CXWindowsScreen.h"
|
||||
#include "CXWindowsUtil.h"
|
||||
#include "CClipboard.h"
|
||||
#include "ProtocolTypes.h"
|
||||
#include "IPrimaryScreenReceiver.h"
|
||||
#include "XScreen.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
@@ -26,162 +22,17 @@
|
||||
CXWindowsPrimaryScreen::CXWindowsPrimaryScreen(
|
||||
IScreenReceiver* receiver,
|
||||
IPrimaryScreenReceiver* primaryReceiver) :
|
||||
m_receiver(receiver),
|
||||
m_primaryReceiver(primaryReceiver),
|
||||
m_active(false),
|
||||
CPrimaryScreen(receiver),
|
||||
m_receiver(primaryReceiver),
|
||||
m_window(None)
|
||||
{
|
||||
// do nothing
|
||||
m_screen = new CXWindowsScreen(receiver, this);
|
||||
}
|
||||
|
||||
CXWindowsPrimaryScreen::~CXWindowsPrimaryScreen()
|
||||
{
|
||||
assert(m_window == None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::run()
|
||||
{
|
||||
// change our priority
|
||||
CThread::getCurrentThread().setPriority(-3);
|
||||
|
||||
// run event loop
|
||||
try {
|
||||
log((CLOG_INFO "entering event loop"));
|
||||
mainLoop();
|
||||
log((CLOG_INFO "exiting event loop"));
|
||||
}
|
||||
catch (...) {
|
||||
log((CLOG_INFO "exiting event loop"));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::stop()
|
||||
{
|
||||
exitMainLoop();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::open()
|
||||
{
|
||||
assert(m_window == None);
|
||||
|
||||
CClientInfo info;
|
||||
try {
|
||||
// open the display
|
||||
openDisplay();
|
||||
|
||||
// create and prepare our window
|
||||
createWindow();
|
||||
|
||||
// get the display
|
||||
CDisplayLock display(this);
|
||||
|
||||
// initialize the clipboards
|
||||
initClipboards(m_window);
|
||||
|
||||
// miscellaneous initialization
|
||||
m_atomScreenSaver = XInternAtom(display, "SCREENSAVER", False);
|
||||
|
||||
// check for peculiarities
|
||||
// FIXME -- may have to get these from some database
|
||||
m_numLockHalfDuplex = false;
|
||||
m_capsLockHalfDuplex = false;
|
||||
// m_numLockHalfDuplex = true;
|
||||
// m_capsLockHalfDuplex = true;
|
||||
|
||||
// collect screen info
|
||||
getScreenShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
||||
getCursorPos(info.m_mx, info.m_my);
|
||||
info.m_zoneSize = getJumpZoneSize();
|
||||
|
||||
// save mouse position
|
||||
m_x = info.m_mx;
|
||||
m_y = info.m_my;
|
||||
|
||||
// compute center pixel of primary screen
|
||||
getCursorCenter(m_xCenter, m_yCenter);
|
||||
|
||||
// update key state
|
||||
updateModifierMap(display);
|
||||
|
||||
// get notified of screen saver activation/deactivation
|
||||
installScreenSaver();
|
||||
}
|
||||
catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
|
||||
// enter the screen
|
||||
enterNoWarp();
|
||||
|
||||
// send screen info
|
||||
m_receiver->onInfoChanged(info);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::close()
|
||||
{
|
||||
uninstallScreenSaver();
|
||||
destroyWindow();
|
||||
closeDisplay();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::enter(SInt32 x, SInt32 y, bool forScreenSaver)
|
||||
{
|
||||
log((CLOG_INFO "entering primary at %d,%d%s", x, y, forScreenSaver ? " for screen saver" : ""));
|
||||
assert(m_active == true);
|
||||
assert(m_window != None);
|
||||
|
||||
// enter the screen
|
||||
enterNoWarp();
|
||||
|
||||
// warp to requested location
|
||||
if (!forScreenSaver) {
|
||||
warpCursor(x, y);
|
||||
}
|
||||
|
||||
// redirect input to root window. do not warp the mouse because
|
||||
// that will deactivate the screen saver.
|
||||
else {
|
||||
CDisplayLock display(this);
|
||||
XSetInputFocus(display, PointerRoot, PointerRoot, CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsPrimaryScreen::leave()
|
||||
{
|
||||
log((CLOG_INFO "leaving primary"));
|
||||
assert(m_active == false);
|
||||
assert(m_window != None);
|
||||
|
||||
// show our window
|
||||
if (!showWindow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// warp mouse to center
|
||||
warpCursorToCenter();
|
||||
// FIXME -- this doesn't match the win32 version. that just does
|
||||
// the warp while we flush the input queue until we find the warp
|
||||
// and we discard that too. would prefer to at least match our
|
||||
// own warping when we receive MotionNotify; that just does the
|
||||
// warp. however, the win32 version sometimes stutters when
|
||||
// leaving and perhaps this is why. hmm, win32 does ignore the
|
||||
// events until after the warp (via the mark).
|
||||
|
||||
// local client now active
|
||||
m_active = true;
|
||||
|
||||
// make sure our idea of clipboard ownership is correct
|
||||
checkClipboard();
|
||||
|
||||
return true;
|
||||
delete m_screen;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -193,7 +44,7 @@ CXWindowsPrimaryScreen::reconfigure(UInt32)
|
||||
void
|
||||
CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// warp mouse
|
||||
warpCursorNoFlush(display, x, y);
|
||||
@@ -213,30 +64,10 @@ CXWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
|
||||
m_y = y;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::setClipboard(ClipboardID id,
|
||||
const IClipboard* clipboard)
|
||||
{
|
||||
setDisplayClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::grabClipboard(ClipboardID id)
|
||||
{
|
||||
setDisplayClipboard(id, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::getClipboard(ClipboardID id,
|
||||
IClipboard* clipboard) const
|
||||
{
|
||||
getDisplayClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
KeyModifierMask
|
||||
CXWindowsPrimaryScreen::getToggleMask() const
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// query the pointer to get the keyboard state
|
||||
Window root, window;
|
||||
@@ -265,7 +96,7 @@ CXWindowsPrimaryScreen::getToggleMask() const
|
||||
bool
|
||||
CXWindowsPrimaryScreen::isLockedToScreen() const
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// query the pointer to get the button state
|
||||
Window root, window;
|
||||
@@ -295,11 +126,29 @@ CXWindowsPrimaryScreen::isLockedToScreen() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsPrimaryScreen::onPreDispatch(const CEvent* event)
|
||||
IScreen*
|
||||
CXWindowsPrimaryScreen::getScreen() const
|
||||
{
|
||||
// forward to superclass
|
||||
return CXWindowsScreen::onPreDispatch(event);
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onError()
|
||||
{
|
||||
// tell server to shutdown
|
||||
m_receiver->onError();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onScreensaver(bool activated)
|
||||
{
|
||||
m_receiver->onScreensaver(activated);
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsPrimaryScreen::onPreDispatch(const CEvent*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -313,41 +162,28 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
case CreateNotify:
|
||||
{
|
||||
// select events on new window
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
selectEvents(display, xevent.xcreatewindow.window);
|
||||
}
|
||||
return true;
|
||||
|
||||
case MappingNotify:
|
||||
{
|
||||
// keyboard mapping changed
|
||||
CDisplayLock display(this);
|
||||
XRefreshKeyboardMapping(&xevent.xmapping);
|
||||
updateModifierMap(display);
|
||||
}
|
||||
// keyboard mapping changed
|
||||
updateKeys();
|
||||
return true;
|
||||
|
||||
case ClientMessage:
|
||||
if (xevent.xclient.message_type == m_atomScreenSaver ||
|
||||
xevent.xclient.format == 32) {
|
||||
// screen saver activation/deactivation event
|
||||
m_primaryReceiver->onScreenSaver(xevent.xclient.data.l[0] != 0);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
{
|
||||
log((CLOG_DEBUG1 "event: KeyPress code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||
const KeyModifierMask mask = mapModifier(xevent.xkey.state);
|
||||
const KeyID key = mapKey(&xevent.xkey);
|
||||
if (key != kKeyNone) {
|
||||
m_primaryReceiver->onKeyDown(key, mask);
|
||||
m_receiver->onKeyDown(key, mask);
|
||||
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
|
||||
m_primaryReceiver->onKeyUp(key, mask | KeyModifierCapsLock);
|
||||
m_receiver->onKeyUp(key, mask | KeyModifierCapsLock);
|
||||
}
|
||||
else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
|
||||
m_primaryReceiver->onKeyUp(key, mask | KeyModifierNumLock);
|
||||
m_receiver->onKeyUp(key, mask | KeyModifierNumLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,20 +205,24 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
filter.m_keycode = xevent.xkey.keycode;
|
||||
|
||||
// now check for event
|
||||
XEvent xevent2;
|
||||
CDisplayLock display(this);
|
||||
if (XCheckIfEvent(display, &xevent2,
|
||||
&CXWindowsPrimaryScreen::findKeyEvent,
|
||||
(XPointer)&filter) != True) {
|
||||
bool hasPress;
|
||||
{
|
||||
XEvent xevent2;
|
||||
CDisplayLock display(m_screen);
|
||||
hasPress = (XCheckIfEvent(display, &xevent2,
|
||||
&CXWindowsPrimaryScreen::findKeyEvent,
|
||||
(XPointer)&filter) == True);
|
||||
}
|
||||
if (!hasPress) {
|
||||
// no press event follows so it's a plain release
|
||||
log((CLOG_DEBUG1 "event: KeyRelease code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||
if (key == XK_Caps_Lock && m_capsLockHalfDuplex) {
|
||||
m_primaryReceiver->onKeyDown(key, mask);
|
||||
m_receiver->onKeyDown(key, mask);
|
||||
}
|
||||
else if (key == XK_Num_Lock && m_numLockHalfDuplex) {
|
||||
m_primaryReceiver->onKeyDown(key, mask);
|
||||
m_receiver->onKeyDown(key, mask);
|
||||
}
|
||||
m_primaryReceiver->onKeyUp(key, mask);
|
||||
m_receiver->onKeyUp(key, mask);
|
||||
}
|
||||
else {
|
||||
// found a press event following so it's a repeat.
|
||||
@@ -390,7 +230,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
// repeats but we'll just send a repeat of 1.
|
||||
// note that we discard the press event.
|
||||
log((CLOG_DEBUG1 "event: repeat code=%d, state=0x%04x", xevent.xkey.keycode, xevent.xkey.state));
|
||||
m_primaryReceiver->onKeyRepeat(key, mask, 1);
|
||||
m_receiver->onKeyRepeat(key, mask, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +241,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
log((CLOG_DEBUG1 "event: ButtonPress button=%d", xevent.xbutton.button));
|
||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||
if (button != kButtonNone) {
|
||||
m_primaryReceiver->onMouseDown(button);
|
||||
m_receiver->onMouseDown(button);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -411,15 +251,15 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
log((CLOG_DEBUG1 "event: ButtonRelease button=%d", xevent.xbutton.button));
|
||||
const ButtonID button = mapButton(xevent.xbutton.button);
|
||||
if (button != kButtonNone) {
|
||||
m_primaryReceiver->onMouseUp(button);
|
||||
m_receiver->onMouseUp(button);
|
||||
}
|
||||
else if (xevent.xbutton.button == 4) {
|
||||
// wheel forward (away from user)
|
||||
m_primaryReceiver->onMouseWheel(120);
|
||||
m_receiver->onMouseWheel(120);
|
||||
}
|
||||
else if (xevent.xbutton.button == 5) {
|
||||
// wheel backward (toward user)
|
||||
m_primaryReceiver->onMouseWheel(-120);
|
||||
m_receiver->onMouseWheel(-120);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -443,14 +283,14 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
// warpCursorNoFlush() for where the events are
|
||||
// sent. we discard the matching sent event and
|
||||
// can be sure we've skipped the warp event.
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
do {
|
||||
XMaskEvent(display, PointerMotionMask, &xevent);
|
||||
} while (!xevent.xmotion.send_event);
|
||||
}
|
||||
else if (!m_active) {
|
||||
else if (!isActive()) {
|
||||
// motion on primary screen
|
||||
m_primaryReceiver->onMouseMovePrimary(m_x, m_y);
|
||||
m_receiver->onMouseMovePrimary(m_x, m_y);
|
||||
}
|
||||
else {
|
||||
// motion on secondary screen. warp mouse back to
|
||||
@@ -470,7 +310,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
xevent.xmotion.x_root - m_xCenter > s_size ||
|
||||
xevent.xmotion.y_root - m_yCenter < -s_size ||
|
||||
xevent.xmotion.y_root - m_yCenter > s_size) {
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
warpCursorNoFlush(display, m_xCenter, m_yCenter);
|
||||
}
|
||||
|
||||
@@ -481,7 +321,7 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
// warping to the primary screen's enter position,
|
||||
// effectively overriding it.
|
||||
if (x != 0 || y != 0) {
|
||||
m_primaryReceiver->onMouseMoveSecondary(x, y);
|
||||
m_receiver->onMouseMoveSecondary(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -492,77 +332,117 @@ CXWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onUnexpectedClose()
|
||||
CXWindowsPrimaryScreen::onPreRun()
|
||||
{
|
||||
// tell server to shutdown
|
||||
m_primaryReceiver->onError();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onLostClipboard(ClipboardID id)
|
||||
{
|
||||
// tell server that the clipboard was grabbed locally
|
||||
m_receiver->onGrabClipboard(id);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CXWindowsPrimaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::warpCursorToCenter()
|
||||
{
|
||||
warpCursor(m_xCenter, m_yCenter);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::warpCursorNoFlush(
|
||||
Display* display, SInt32 x, SInt32 y)
|
||||
{
|
||||
assert(display != NULL);
|
||||
assert(m_window != None);
|
||||
|
||||
// send an event that we can recognize before the mouse warp
|
||||
XEvent eventBefore;
|
||||
eventBefore.type = MotionNotify;
|
||||
eventBefore.xmotion.display = display;
|
||||
eventBefore.xmotion.window = m_window;
|
||||
eventBefore.xmotion.root = getRoot();
|
||||
eventBefore.xmotion.subwindow = m_window;
|
||||
eventBefore.xmotion.time = CurrentTime;
|
||||
eventBefore.xmotion.x = x;
|
||||
eventBefore.xmotion.y = y;
|
||||
eventBefore.xmotion.x_root = x;
|
||||
eventBefore.xmotion.y_root = y;
|
||||
eventBefore.xmotion.state = 0;
|
||||
eventBefore.xmotion.is_hint = False;
|
||||
eventBefore.xmotion.same_screen = True;
|
||||
XEvent eventAfter = eventBefore;
|
||||
XSendEvent(display, m_window, False, 0, &eventBefore);
|
||||
|
||||
// warp mouse
|
||||
XWarpPointer(display, None, getRoot(), 0, 0, 0, 0, x, y);
|
||||
|
||||
// send an event that we can recognize after the mouse warp
|
||||
XSendEvent(display, m_window, False, 0, &eventAfter);
|
||||
XSync(display, False);
|
||||
|
||||
log((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::enterNoWarp()
|
||||
CXWindowsPrimaryScreen::onPreOpen()
|
||||
{
|
||||
m_active = false;
|
||||
hideWindow();
|
||||
assert(m_window == None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onPostOpen()
|
||||
{
|
||||
// get cursor info
|
||||
m_screen->getCursorPos(m_x, m_y);
|
||||
m_screen->getCursorCenter(m_xCenter, m_yCenter);
|
||||
|
||||
// check for peculiarities
|
||||
// FIXME -- may have to get these from some database
|
||||
m_numLockHalfDuplex = false;
|
||||
m_capsLockHalfDuplex = false;
|
||||
// m_numLockHalfDuplex = true;
|
||||
// m_capsLockHalfDuplex = true;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onPreEnter()
|
||||
{
|
||||
assert(m_window != None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onPreLeave()
|
||||
{
|
||||
assert(m_window != None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::onEnterScreenSaver()
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// set keyboard focus to root window. the screensaver should then
|
||||
// pick up key events for when the user enters a password to unlock.
|
||||
XSetInputFocus(display, PointerRoot, PointerRoot, CurrentTime);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::createWindow()
|
||||
{
|
||||
assert(m_window == None);
|
||||
|
||||
// get size of screen
|
||||
SInt32 x, y, w, h;
|
||||
m_screen->getShape(x, y, w, h);
|
||||
|
||||
// grab window attributes. this window is used to capture user
|
||||
// input when the user is focused on another client. don't let
|
||||
// the window manager mess with it.
|
||||
XSetWindowAttributes attr;
|
||||
attr.event_mask = PointerMotionMask |
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
KeyPressMask | KeyReleaseMask |
|
||||
KeymapStateMask | PropertyChangeMask;
|
||||
attr.do_not_propagate_mask = 0;
|
||||
attr.override_redirect = True;
|
||||
attr.cursor = m_screen->getBlankCursor();
|
||||
|
||||
{
|
||||
// create the grab window
|
||||
CDisplayLock display(m_screen);
|
||||
m_window = XCreateWindow(display, m_screen->getRoot(),
|
||||
x, y, w, h, 0, 0,
|
||||
InputOnly, CopyFromParent,
|
||||
CWDontPropagate | CWEventMask |
|
||||
CWOverrideRedirect | CWCursor,
|
||||
&attr);
|
||||
if (m_window == None) {
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||
|
||||
// start watching for events on other windows
|
||||
selectEvents(display, m_screen->getRoot());
|
||||
}
|
||||
|
||||
// tell our superclass about the window
|
||||
m_screen->setWindow(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::destroyWindow()
|
||||
{
|
||||
// display can be NULL if the server unexpectedly disconnected
|
||||
if (m_window != None) {
|
||||
m_screen->setWindow(None);
|
||||
CDisplayLock display(m_screen);
|
||||
if (display != NULL) {
|
||||
XDestroyWindow(display, m_window);
|
||||
}
|
||||
m_window = None;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsPrimaryScreen::showWindow()
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
assert(m_window != None);
|
||||
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// raise and show the input window
|
||||
XMapRaised(display, m_window);
|
||||
@@ -616,83 +496,51 @@ CXWindowsPrimaryScreen::showWindow()
|
||||
void
|
||||
CXWindowsPrimaryScreen::hideWindow()
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// unmap the grab window. this also ungrabs the mouse and keyboard.
|
||||
XUnmapWindow(display, m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::checkClipboard()
|
||||
CXWindowsPrimaryScreen::warpCursorToCenter()
|
||||
{
|
||||
// do nothing, we're always up to date
|
||||
warpCursor(m_xCenter, m_yCenter);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::createWindow()
|
||||
CXWindowsPrimaryScreen::warpCursorNoFlush(
|
||||
Display* display, SInt32 x, SInt32 y)
|
||||
{
|
||||
assert(m_window == None);
|
||||
assert(display != NULL);
|
||||
assert(m_window != None);
|
||||
|
||||
// get size of screen
|
||||
SInt32 x, y, w, h;
|
||||
getScreenShape(x, y, w, h);
|
||||
// send an event that we can recognize before the mouse warp
|
||||
XEvent eventBefore;
|
||||
eventBefore.type = MotionNotify;
|
||||
eventBefore.xmotion.display = display;
|
||||
eventBefore.xmotion.window = m_window;
|
||||
eventBefore.xmotion.root = m_screen->getRoot();
|
||||
eventBefore.xmotion.subwindow = m_window;
|
||||
eventBefore.xmotion.time = CurrentTime;
|
||||
eventBefore.xmotion.x = x;
|
||||
eventBefore.xmotion.y = y;
|
||||
eventBefore.xmotion.x_root = x;
|
||||
eventBefore.xmotion.y_root = y;
|
||||
eventBefore.xmotion.state = 0;
|
||||
eventBefore.xmotion.is_hint = False;
|
||||
eventBefore.xmotion.same_screen = True;
|
||||
XEvent eventAfter = eventBefore;
|
||||
XSendEvent(display, m_window, False, 0, &eventBefore);
|
||||
|
||||
// grab window attributes. this window is used to capture user
|
||||
// input when the user is focused on another client. don't let
|
||||
// the window manager mess with it.
|
||||
XSetWindowAttributes attr;
|
||||
attr.event_mask = PointerMotionMask |
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
KeyPressMask | KeyReleaseMask |
|
||||
KeymapStateMask | PropertyChangeMask;
|
||||
attr.do_not_propagate_mask = 0;
|
||||
attr.override_redirect = True;
|
||||
attr.cursor = getBlankCursor();
|
||||
// warp mouse
|
||||
XWarpPointer(display, None, m_screen->getRoot(), 0, 0, 0, 0, x, y);
|
||||
|
||||
// create the grab window
|
||||
CDisplayLock display(this);
|
||||
m_window = XCreateWindow(display, getRoot(),
|
||||
x, y, w, h, 0, 0,
|
||||
InputOnly, CopyFromParent,
|
||||
CWDontPropagate | CWEventMask |
|
||||
CWOverrideRedirect | CWCursor,
|
||||
&attr);
|
||||
if (m_window == None) {
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||
// send an event that we can recognize after the mouse warp
|
||||
XSendEvent(display, m_window, False, 0, &eventAfter);
|
||||
XSync(display, False);
|
||||
|
||||
// start watching for events on other windows
|
||||
selectEvents(display, getRoot());
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::destroyWindow()
|
||||
{
|
||||
// display can be NULL if the server unexpectedly disconnected
|
||||
CDisplayLock display(this);
|
||||
if (display != NULL && m_window != None) {
|
||||
XDestroyWindow(display, m_window);
|
||||
}
|
||||
m_window = None;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::installScreenSaver()
|
||||
{
|
||||
assert(getScreenSaver() != NULL);
|
||||
|
||||
getScreenSaver()->setNotify(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::uninstallScreenSaver()
|
||||
{
|
||||
// stop being notified of screen saver activation/deactivation
|
||||
if (getScreenSaver() != NULL) {
|
||||
getScreenSaver()->setNotify(None);
|
||||
}
|
||||
m_atomScreenSaver = None;
|
||||
log((CLOG_DEBUG2 "warped to %d,%d", x, y));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -777,7 +625,7 @@ CXWindowsPrimaryScreen::mapKey(XKeyEvent* event) const
|
||||
KeySym keysym;
|
||||
char dummy[1];
|
||||
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
XLookupString(event, dummy, 0, &keysym, NULL);
|
||||
return static_cast<KeyID>(keysym);
|
||||
}
|
||||
@@ -795,8 +643,10 @@ CXWindowsPrimaryScreen::mapButton(unsigned int button) const
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsPrimaryScreen::updateModifierMap(Display* display)
|
||||
CXWindowsPrimaryScreen::updateKeys()
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// get modifier map from server
|
||||
XModifierKeymap* keymap = XGetModifierMapping(display);
|
||||
|
||||
|
||||
@@ -1,63 +1,59 @@
|
||||
#ifndef CXWINDOWSPRIMARYSCREEN_H
|
||||
#define CXWINDOWSPRIMARYSCREEN_H
|
||||
|
||||
#include "CXWindowsScreen.h"
|
||||
#include "IPrimaryScreen.h"
|
||||
#include "CPrimaryScreen.h"
|
||||
#include "IScreenEventHandler.h"
|
||||
#include "MouseTypes.h"
|
||||
#if defined(X_DISPLAY_MISSING)
|
||||
# error X11 is required to build synergy
|
||||
#else
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
class CXWindowsScreen;
|
||||
class IScreenReceiver;
|
||||
class IPrimaryScreenReceiver;
|
||||
|
||||
class CXWindowsPrimaryScreen : public CXWindowsScreen, public IPrimaryScreen {
|
||||
class CXWindowsPrimaryScreen :
|
||||
public CPrimaryScreen, public IScreenEventHandler {
|
||||
public:
|
||||
CXWindowsPrimaryScreen(IScreenReceiver*, IPrimaryScreenReceiver*);
|
||||
virtual ~CXWindowsPrimaryScreen();
|
||||
|
||||
// IPrimaryScreen overrides
|
||||
virtual void run();
|
||||
virtual void stop();
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute, bool);
|
||||
virtual bool leave();
|
||||
// CPrimaryScreen overrides
|
||||
virtual void reconfigure(UInt32 activeSides);
|
||||
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute);
|
||||
virtual void setClipboard(ClipboardID, const IClipboard*);
|
||||
virtual void grabClipboard(ClipboardID);
|
||||
virtual void getClipboard(ClipboardID, IClipboard*) const;
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual KeyModifierMask getToggleMask() const;
|
||||
virtual bool isLockedToScreen() const;
|
||||
virtual IScreen* getScreen() const;
|
||||
|
||||
protected:
|
||||
// CXWindowsScreen overrides
|
||||
// IScreenEventHandler overrides
|
||||
virtual void onError();
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual bool onPreDispatch(const CEvent* event);
|
||||
virtual bool onEvent(CEvent* event);
|
||||
virtual void onUnexpectedClose();
|
||||
virtual void onLostClipboard(ClipboardID);
|
||||
|
||||
protected:
|
||||
// CPrimaryScreen overrides
|
||||
virtual void onPreRun();
|
||||
virtual void onPreOpen();
|
||||
virtual void onPostOpen();
|
||||
virtual void onPreEnter();
|
||||
virtual void onPreLeave();
|
||||
virtual void onEnterScreenSaver();
|
||||
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual bool showWindow();
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursorToCenter();
|
||||
|
||||
virtual void updateKeys();
|
||||
|
||||
private:
|
||||
SInt32 getJumpZoneSize() const;
|
||||
|
||||
void warpCursorToCenter();
|
||||
void warpCursorNoFlush(Display*,
|
||||
SInt32 xAbsolute, SInt32 yAbsolute);
|
||||
|
||||
void enterNoWarp();
|
||||
bool showWindow();
|
||||
void hideWindow();
|
||||
|
||||
// check clipboard ownership and, if necessary, tell the receiver
|
||||
// of a grab.
|
||||
void checkClipboard();
|
||||
|
||||
// create/destroy window
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
|
||||
// start/stop watch for screen saver changes
|
||||
void installScreenSaver();
|
||||
void uninstallScreenSaver();
|
||||
|
||||
void selectEvents(Display*, Window) const;
|
||||
void doSelectEvents(Display*, Window) const;
|
||||
|
||||
@@ -65,8 +61,6 @@ private:
|
||||
KeyID mapKey(XKeyEvent*) const;
|
||||
ButtonID mapButton(unsigned int button) const;
|
||||
|
||||
void updateModifierMap(Display* display);
|
||||
|
||||
class CKeyEventInfo {
|
||||
public:
|
||||
int m_event;
|
||||
@@ -77,15 +71,12 @@ private:
|
||||
static Bool findKeyEvent(Display*, XEvent* xevent, XPointer arg);
|
||||
|
||||
private:
|
||||
IScreenReceiver* m_receiver;
|
||||
IPrimaryScreenReceiver* m_primaryReceiver;
|
||||
CXWindowsScreen* m_screen;
|
||||
IPrimaryScreenReceiver* m_receiver;
|
||||
|
||||
bool m_active;
|
||||
// our window
|
||||
Window m_window;
|
||||
|
||||
// atom for screen saver messages
|
||||
Atom m_atomScreenSaver;
|
||||
|
||||
// note toggle keys that toggle on up/down (false) or on
|
||||
// transition (true)
|
||||
bool m_numLockHalfDuplex;
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#ifndef IPRIMARYSCREEN_H
|
||||
#define IPRIMARYSCREEN_H
|
||||
|
||||
#include "IInterface.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "ClipboardTypes.h"
|
||||
|
||||
class IClipboard;
|
||||
|
||||
class IPrimaryScreen : public IInterface {
|
||||
public:
|
||||
// manipulators
|
||||
|
||||
// enter the screen's message loop. this returns when it detects
|
||||
// the application should terminate or when stop() is called.
|
||||
// the screen must be open()'d before run() and must not be
|
||||
// close()'d until run() returns.
|
||||
virtual void run() = 0;
|
||||
|
||||
// cause run() to return
|
||||
virtual void stop() = 0;
|
||||
|
||||
// initialize the screen and start reporting events to the receiver
|
||||
// (which is set through some interface of the derived class).
|
||||
// events should be reported no matter where on the screen they
|
||||
// occur but do not interfere with normal event dispatch. the
|
||||
// screen saver engaging should be reported as an event. if that
|
||||
// can't be detected then this object should disable the system's
|
||||
// screen saver timer and should start the screen saver after
|
||||
// idling for an appropriate time.
|
||||
//
|
||||
// open() must call receiver->onInfoChanged() to notify of the
|
||||
// primary screen's initial resolution and jump zone size. it
|
||||
// must also call receiver->onClipboardChanged() for each
|
||||
// clipboard that the primary screen has.
|
||||
virtual void open() = 0;
|
||||
|
||||
// close the screen. should restore the screen saver timer if it
|
||||
// was disabled.
|
||||
virtual void close() = 0;
|
||||
|
||||
// called when the user navigates back to the primary screen.
|
||||
// warp the cursor to the given coordinates, unhide it, and
|
||||
// ungrab the input devices. every call to enter has a matching
|
||||
// call to leave() which preceeds it, however the screen should
|
||||
// assume an implicit call to enter() in the call to open().
|
||||
// if warpCursor is false then do not warp the mouse.
|
||||
//
|
||||
// enter() must not call any receiver methods except onError().
|
||||
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute,
|
||||
bool forScreenSaver) = 0;
|
||||
|
||||
// called when the user navigates off the primary screen. hide the
|
||||
// cursor and grab exclusive access to the input devices. return
|
||||
// true iff successful.
|
||||
//
|
||||
// leave() must not call any receiver methods except onError().
|
||||
virtual bool leave() = 0;
|
||||
|
||||
// called when the configuration has changed. activeSides is a
|
||||
// bitmask of CConfig::EDirectionMask indicating which sides of
|
||||
// the primary screen are linked to clients.
|
||||
virtual void reconfigure(UInt32 activeSides) = 0;
|
||||
|
||||
// warp the cursor to the given position
|
||||
virtual void warpCursor(SInt32 xAbsolute, SInt32 yAbsolute) = 0;
|
||||
|
||||
// set the screen's clipboard contents. this is usually called
|
||||
// soon after an enter().
|
||||
//
|
||||
// setClipboard() must not call any receiver methods except onError().
|
||||
virtual void setClipboard(ClipboardID, const IClipboard*) = 0;
|
||||
|
||||
// synergy should own the clipboard
|
||||
virtual void grabClipboard(ClipboardID) = 0;
|
||||
|
||||
// accessors
|
||||
|
||||
// return the contents of the given clipboard.
|
||||
//
|
||||
// getClipboard() must not call any receiver methods except onError().
|
||||
virtual void getClipboard(ClipboardID, IClipboard*) const = 0;
|
||||
|
||||
// get 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.
|
||||
virtual KeyModifierMask getToggleMask() const = 0;
|
||||
|
||||
// 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.
|
||||
virtual bool isLockedToScreen() const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@ synergyd_SOURCES = \
|
||||
CConfig.cpp \
|
||||
CHTTPServer.cpp \
|
||||
CPrimaryClient.cpp \
|
||||
CPrimaryScreen.cpp \
|
||||
CServer.cpp \
|
||||
CXWindowsPrimaryScreen.cpp \
|
||||
server.cpp \
|
||||
@@ -17,9 +18,9 @@ synergyd_SOURCES = \
|
||||
CConfig.h \
|
||||
CHTTPServer.h \
|
||||
CPrimaryClient.h \
|
||||
CPrimaryScreen.h \
|
||||
CServer.h \
|
||||
CXWindowsPrimaryScreen.h \
|
||||
IPrimaryScreen.h \
|
||||
$(NULL)
|
||||
synergyd_LDADD = \
|
||||
$(DEPTH)/platform/libplatform.a \
|
||||
|
||||
@@ -132,6 +132,7 @@ realMain(CMutex* mutex)
|
||||
}
|
||||
|
||||
// clean up
|
||||
s_server->close();
|
||||
delete s_server;
|
||||
s_server = NULL;
|
||||
CLog::setLock(NULL);
|
||||
@@ -142,8 +143,11 @@ realMain(CMutex* mutex)
|
||||
if (!locked && mutex != NULL) {
|
||||
mutex->lock();
|
||||
}
|
||||
delete s_server;
|
||||
s_server = NULL;
|
||||
if (s_server != NULL) {
|
||||
s_server->close();
|
||||
delete s_server;
|
||||
s_server = NULL;
|
||||
}
|
||||
CLog::setLock(NULL);
|
||||
s_logMutex = NULL;
|
||||
throw;
|
||||
|
||||
Reference in New Issue
Block a user