mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-26 13:53:14 +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:
@@ -4,7 +4,7 @@
|
||||
#include "CInputPacketStream.h"
|
||||
#include "COutputPacketStream.h"
|
||||
#include "CProtocolUtil.h"
|
||||
#include "ISecondaryScreen.h"
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IServer.h"
|
||||
#include "ProtocolTypes.h"
|
||||
#include "XScreen.h"
|
||||
@@ -148,9 +148,7 @@ CClient::run()
|
||||
this, &CClient::runSession));
|
||||
|
||||
// handle events
|
||||
log((CLOG_DEBUG "starting event handling"));
|
||||
m_screen->run();
|
||||
log((CLOG_DEBUG "stopped event handling"));
|
||||
|
||||
// clean up
|
||||
deleteSession(thread);
|
||||
@@ -160,7 +158,6 @@ CClient::run()
|
||||
log((CLOG_ERR "client error: %s", e.what()));
|
||||
|
||||
// clean up
|
||||
log((CLOG_DEBUG "stopped event handling"));
|
||||
deleteSession(thread);
|
||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||
CLock lock(&m_mutex);
|
||||
@@ -168,7 +165,6 @@ CClient::run()
|
||||
}
|
||||
catch (XThread&) {
|
||||
// clean up
|
||||
log((CLOG_DEBUG "stopped event handling"));
|
||||
deleteSession(thread);
|
||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||
throw;
|
||||
@@ -177,7 +173,6 @@ CClient::run()
|
||||
log((CLOG_DEBUG "unknown client error"));
|
||||
|
||||
// clean up
|
||||
log((CLOG_DEBUG "stopped event handling"));
|
||||
deleteSession(thread);
|
||||
log((CLOG_NOTE "stopping client \"%s\"", m_name.c_str()));
|
||||
throw;
|
||||
@@ -188,6 +183,7 @@ void
|
||||
CClient::close()
|
||||
{
|
||||
closeSecondaryScreen();
|
||||
log((CLOG_INFO "closed screen"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -291,9 +287,9 @@ CClient::mouseWheel(SInt32 delta)
|
||||
}
|
||||
|
||||
void
|
||||
CClient::screenSaver(bool activate)
|
||||
CClient::screensaver(bool activate)
|
||||
{
|
||||
m_screen->screenSaver(activate);
|
||||
m_screen->screensaver(activate);
|
||||
}
|
||||
|
||||
CString
|
||||
@@ -302,6 +298,12 @@ CClient::getName() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
SInt32
|
||||
CClient::getJumpZoneSize() const
|
||||
{
|
||||
return m_screen->getJumpZoneSize();
|
||||
}
|
||||
|
||||
void
|
||||
CClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
@@ -309,21 +311,15 @@ CClient::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
}
|
||||
|
||||
void
|
||||
CClient::getCenter(SInt32&, SInt32&) const
|
||||
CClient::getCursorPos(SInt32& x, SInt32& y) const
|
||||
{
|
||||
assert(0 && "shouldn't be called");
|
||||
m_screen->getCursorPos(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CClient::getMousePos(SInt32& x, SInt32& y) const
|
||||
CClient::getCursorCenter(SInt32&, SInt32&) const
|
||||
{
|
||||
m_screen->getMousePos(x, y);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CClient::getJumpZoneSize() const
|
||||
{
|
||||
return m_screen->getJumpZoneSize();
|
||||
assert(0 && "shouldn't be called");
|
||||
}
|
||||
|
||||
// FIXME -- use factory to create screen
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include "CNetworkAddress.h"
|
||||
#include "CMutex.h"
|
||||
|
||||
class CSecondaryScreen;
|
||||
class CServerProxy;
|
||||
class CThread;
|
||||
class IDataSocket;
|
||||
class ISecondaryScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
class CClient : public IScreenReceiver, public IClient {
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
// FIXME -- can we avoid passing everything here?
|
||||
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);
|
||||
@@ -62,13 +62,13 @@ 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:
|
||||
// open/close the secondary screen
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
private:
|
||||
CMutex m_mutex;
|
||||
CString m_name;
|
||||
ISecondaryScreen* m_screen;
|
||||
CSecondaryScreen* m_screen;
|
||||
IScreenReceiver* m_server;
|
||||
CNetworkAddress m_serverAddress;
|
||||
bool m_camp;
|
||||
|
||||
263
client/CSecondaryScreen.cpp
Normal file
263
client/CSecondaryScreen.cpp
Normal file
@@ -0,0 +1,263 @@
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IScreen.h"
|
||||
#include "CLock.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
|
||||
//
|
||||
// CSecondaryScreen
|
||||
//
|
||||
|
||||
CSecondaryScreen::CSecondaryScreen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
CSecondaryScreen::~CSecondaryScreen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
bool
|
||||
CSecondaryScreen::isActive() const
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::run()
|
||||
{
|
||||
// change our priority
|
||||
CThread::getCurrentThread().setPriority(-7);
|
||||
|
||||
// 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
|
||||
CSecondaryScreen::stop()
|
||||
{
|
||||
getScreen()->exitMainLoop();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::open()
|
||||
{
|
||||
try {
|
||||
// subclass hook
|
||||
onPreOpen();
|
||||
|
||||
// open the screen
|
||||
getScreen()->open();
|
||||
|
||||
// create and prepare our window
|
||||
createWindow();
|
||||
|
||||
// assume primary has all clipboards
|
||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||
grabClipboard(id);
|
||||
}
|
||||
|
||||
// update keyboard state
|
||||
updateKeys();
|
||||
|
||||
// disable the screen saver
|
||||
getScreen()->openScreenSaver(false);
|
||||
|
||||
// subclass hook
|
||||
onPostOpen();
|
||||
}
|
||||
catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
|
||||
// hide the cursor
|
||||
m_active = true;
|
||||
leave();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::close()
|
||||
{
|
||||
onPreClose();
|
||||
getScreen()->closeScreenSaver();
|
||||
destroyWindow();
|
||||
getScreen()->close();
|
||||
onPostClose();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
||||
{
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active == false);
|
||||
|
||||
log((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
||||
|
||||
getScreen()->syncDesktop();
|
||||
|
||||
// now active
|
||||
m_active = true;
|
||||
|
||||
// subclass hook
|
||||
onPreEnter();
|
||||
|
||||
// update our keyboard state to reflect the local state
|
||||
updateKeys();
|
||||
|
||||
// toggle modifiers that don't match the desired state
|
||||
setToggleState(mask);
|
||||
|
||||
// warp to requested location
|
||||
warpCursor(x, y);
|
||||
|
||||
// show mouse
|
||||
hideWindow();
|
||||
|
||||
// subclass hook
|
||||
onPostEnter();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::leave()
|
||||
{
|
||||
log((CLOG_INFO "leaving screen"));
|
||||
CLock lock(&m_mutex);
|
||||
assert(m_active == true);
|
||||
|
||||
getScreen()->syncDesktop();
|
||||
|
||||
// subclass hook
|
||||
onPreLeave();
|
||||
|
||||
// hide mouse
|
||||
showWindow();
|
||||
|
||||
// subclass hook
|
||||
onPostLeave();
|
||||
|
||||
// not active anymore
|
||||
m_active = false;
|
||||
|
||||
// make sure our idea of clipboard ownership is correct
|
||||
getScreen()->checkClipboards();
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::setClipboard(ClipboardID id,
|
||||
const IClipboard* clipboard)
|
||||
{
|
||||
getScreen()->setClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::grabClipboard(ClipboardID id)
|
||||
{
|
||||
getScreen()->setClipboard(id, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::screensaver(bool activate)
|
||||
{
|
||||
getScreen()->screensaver(activate);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getClipboard(ClipboardID id,
|
||||
IClipboard* clipboard) const
|
||||
{
|
||||
getScreen()->getClipboard(id, clipboard);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CSecondaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getShape(SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
getScreen()->syncDesktop();
|
||||
getScreen()->getShape(x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::getCursorPos(SInt32& x, SInt32& y) const
|
||||
{
|
||||
getScreen()->syncDesktop();
|
||||
getScreen()->getCursorPos(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreRun()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostRun()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostOpen()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostClose()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostEnter()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPreLeave()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CSecondaryScreen::onPostLeave()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
141
client/CSecondaryScreen.h
Normal file
141
client/CSecondaryScreen.h
Normal file
@@ -0,0 +1,141 @@
|
||||
#ifndef CSECONDARYSCREEN_H
|
||||
#define CSECONDARYSCREEN_H
|
||||
|
||||
#include "ClipboardTypes.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
#include "CMutex.h"
|
||||
|
||||
class IClipboard;
|
||||
class IScreen;
|
||||
|
||||
// platform independent base class for secondary screen implementations.
|
||||
// each platform will derive a class from CSecondaryScreen to handle
|
||||
// platform dependent operations.
|
||||
class CSecondaryScreen {
|
||||
public:
|
||||
CSecondaryScreen();
|
||||
virtual ~CSecondaryScreen();
|
||||
|
||||
// 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();
|
||||
|
||||
// initialize the screen, hide the cursor, and disable the screen
|
||||
// saver. start reporting events to the IScreenReceiver (which is
|
||||
// set through some other interface).
|
||||
void open();
|
||||
|
||||
// close the screen. should restore the screen saver. it should
|
||||
// also simulate key up events for any keys that have simulate key
|
||||
// down events without a matching key up. without this the client
|
||||
// will leave its keyboard in the wrong logical state.
|
||||
void close();
|
||||
|
||||
// called when the user navigates to this secondary screen. warps
|
||||
// the cursor to the given absoltue coordinates and unhide it. prepare to
|
||||
// simulate input events.
|
||||
void enter(SInt32 x, SInt32 y, KeyModifierMask mask);
|
||||
|
||||
// called when the user navigates off the secondary screen. clean
|
||||
// up input event simulation and hide the cursor.
|
||||
void leave();
|
||||
|
||||
// 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);
|
||||
|
||||
// activate or deactivate the screen saver
|
||||
void screensaver(bool activate);
|
||||
|
||||
// keyboard input event synthesis
|
||||
virtual void keyDown(KeyID, KeyModifierMask) = 0;
|
||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count) = 0;
|
||||
virtual void keyUp(KeyID, KeyModifierMask) = 0;
|
||||
|
||||
// mouse input event synthesis
|
||||
virtual void mouseDown(ButtonID) = 0;
|
||||
virtual void mouseUp(ButtonID) = 0;
|
||||
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute) = 0;
|
||||
virtual void mouseWheel(SInt32 delta) = 0;
|
||||
|
||||
// accessors
|
||||
|
||||
// returns true iff the screen is active (i.e. the user has entered
|
||||
// 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 0.
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
|
||||
// get the shape (position of upper-left corner and size) of the
|
||||
// screen
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const;
|
||||
|
||||
// get the position of the mouse on the screen
|
||||
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
||||
|
||||
// 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. 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 onPreLeave();
|
||||
virtual void onPostLeave();
|
||||
|
||||
// create/destroy the window. this window is generally used to
|
||||
// receive events and hide the cursor.
|
||||
virtual void createWindow() = 0;
|
||||
virtual void destroyWindow() = 0;
|
||||
|
||||
// called when the user navigates off the secondary screen. hide
|
||||
// the cursor.
|
||||
virtual void showWindow() = 0;
|
||||
|
||||
// called when the user navigates to this secondary screen. show
|
||||
// the cursor and prepare to synthesize input events.
|
||||
virtual void hideWindow() = 0;
|
||||
|
||||
// warp the cursor to the given absolute coordinates
|
||||
virtual void warpCursor(SInt32 x, SInt32 y) = 0;
|
||||
|
||||
// check the current keyboard state. normally a screen will save
|
||||
// the keyboard state in this method and use this shadow state
|
||||
// when synthesizing events.
|
||||
virtual void updateKeys() = 0;
|
||||
|
||||
// toggle modifiers that don't match the given state
|
||||
virtual void setToggleState(KeyModifierMask) = 0;
|
||||
|
||||
private:
|
||||
CMutex m_mutex;
|
||||
|
||||
// m_active is true if this screen has been entered
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -131,7 +131,7 @@ CServerProxy::run()
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
|
||||
screenSaver();
|
||||
screensaver();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgQInfo, 4) == 0) {
|
||||
@@ -484,7 +484,7 @@ CServerProxy::mouseWheel()
|
||||
}
|
||||
|
||||
void
|
||||
CServerProxy::screenSaver()
|
||||
CServerProxy::screensaver()
|
||||
{
|
||||
// parse
|
||||
SInt8 on;
|
||||
@@ -492,7 +492,7 @@ CServerProxy::screenSaver()
|
||||
log((CLOG_DEBUG1 "recv screen saver on=%d", on));
|
||||
|
||||
// forward
|
||||
getClient()->screenSaver(on != 0);
|
||||
getClient()->screensaver(on != 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -501,7 +501,7 @@ CServerProxy::queryInfo()
|
||||
// get current info
|
||||
CClientInfo info;
|
||||
getClient()->getShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
||||
getClient()->getMousePos(info.m_mx, info.m_my);
|
||||
getClient()->getCursorPos(info.m_mx, info.m_my);
|
||||
info.m_zoneSize = getClient()->getJumpZoneSize();
|
||||
|
||||
// send it
|
||||
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
void mouseUp();
|
||||
void mouseMove();
|
||||
void mouseWheel();
|
||||
void screenSaver();
|
||||
void screensaver();
|
||||
void queryInfo();
|
||||
void infoAcknowledgment();
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "CXWindowsSecondaryScreen.h"
|
||||
#include "IScreenReceiver.h"
|
||||
#include "CXWindowsClipboard.h"
|
||||
#include "CXWindowsScreen.h"
|
||||
#include "CXWindowsScreenSaver.h"
|
||||
#include "CXWindowsUtil.h"
|
||||
#include "IScreenReceiver.h"
|
||||
#include "XScreen.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
@@ -26,153 +27,16 @@
|
||||
//
|
||||
|
||||
CXWindowsSecondaryScreen::CXWindowsSecondaryScreen(IScreenReceiver* receiver) :
|
||||
m_receiver(receiver),
|
||||
m_window(None),
|
||||
m_active(false)
|
||||
CSecondaryScreen(),
|
||||
m_window(None)
|
||||
{
|
||||
assert(m_receiver != NULL);
|
||||
m_screen = new CXWindowsScreen(receiver, this);
|
||||
}
|
||||
|
||||
CXWindowsSecondaryScreen::~CXWindowsSecondaryScreen()
|
||||
{
|
||||
assert(m_window == None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::run()
|
||||
{
|
||||
assert(m_window != None);
|
||||
|
||||
// change our priority
|
||||
CThread::getCurrentThread().setPriority(-7);
|
||||
|
||||
// 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
|
||||
CXWindowsSecondaryScreen::stop()
|
||||
{
|
||||
exitMainLoop();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::open()
|
||||
{
|
||||
assert(m_window == None);
|
||||
|
||||
try {
|
||||
// open the display
|
||||
openDisplay();
|
||||
|
||||
// create and prepare our window
|
||||
createWindow();
|
||||
|
||||
// initialize the clipboards; assume primary has all clipboards
|
||||
initClipboards(m_window);
|
||||
for (ClipboardID id = 0; id < kClipboardEnd; ++id) {
|
||||
grabClipboard(id);
|
||||
}
|
||||
|
||||
// check for peculiarities
|
||||
// FIXME -- may have to get these from some database
|
||||
m_numLockHalfDuplex = false;
|
||||
m_capsLockHalfDuplex = false;
|
||||
// m_numLockHalfDuplex = true;
|
||||
// m_capsLockHalfDuplex = true;
|
||||
|
||||
// get the display
|
||||
CDisplayLock display(this);
|
||||
|
||||
// update key state
|
||||
updateKeys(display);
|
||||
updateKeycodeMap(display);
|
||||
updateModifierMap(display);
|
||||
updateModifiers(display);
|
||||
|
||||
// disable the screen saver
|
||||
installScreenSaver();
|
||||
}
|
||||
catch (...) {
|
||||
close();
|
||||
throw;
|
||||
}
|
||||
|
||||
// hide the cursor
|
||||
m_active = true;
|
||||
leave();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::close()
|
||||
{
|
||||
uninstallScreenSaver();
|
||||
destroyWindow();
|
||||
closeDisplay();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::enter(SInt32 x, SInt32 y, KeyModifierMask mask)
|
||||
{
|
||||
assert(m_window != None);
|
||||
assert(m_active == false);
|
||||
|
||||
log((CLOG_INFO "entering screen at %d,%d mask=%04x", x, y, mask));
|
||||
|
||||
CDisplayLock display(this);
|
||||
|
||||
// now active
|
||||
m_active = true;
|
||||
|
||||
// update our keyboard state to reflect the local state
|
||||
updateKeys(display);
|
||||
updateModifiers(display);
|
||||
|
||||
// toggle modifiers that don't match the desired state
|
||||
unsigned int xMask = maskToX(mask);
|
||||
if ((xMask & m_capsLockMask) != (m_mask & m_capsLockMask)) {
|
||||
toggleKey(display, XK_Caps_Lock, m_capsLockMask);
|
||||
}
|
||||
if ((xMask & m_numLockMask) != (m_mask & m_numLockMask)) {
|
||||
toggleKey(display, XK_Num_Lock, m_numLockMask);
|
||||
}
|
||||
if ((xMask & m_scrollLockMask) != (m_mask & m_scrollLockMask)) {
|
||||
toggleKey(display, XK_Scroll_Lock, m_scrollLockMask);
|
||||
}
|
||||
|
||||
// warp to requested location
|
||||
warpCursor(x, y);
|
||||
|
||||
// show mouse
|
||||
hideWindow();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::leave()
|
||||
{
|
||||
assert(m_window != None);
|
||||
assert(m_active == true);
|
||||
|
||||
log((CLOG_INFO "leaving screen"));
|
||||
|
||||
CDisplayLock display(this);
|
||||
|
||||
// hide mouse
|
||||
showWindow();
|
||||
|
||||
// not active anymore
|
||||
m_active = false;
|
||||
|
||||
// make sure our idea of clipboard ownership is correct
|
||||
checkClipboard();
|
||||
delete m_screen;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -236,7 +100,7 @@ CXWindowsSecondaryScreen::keyUp(KeyID key, KeyModifierMask mask)
|
||||
void
|
||||
CXWindowsSecondaryScreen::mouseDown(ButtonID button)
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
XTestFakeButtonEvent(display, mapButton(button), True, CurrentTime);
|
||||
XSync(display, False);
|
||||
}
|
||||
@@ -244,7 +108,7 @@ CXWindowsSecondaryScreen::mouseDown(ButtonID button)
|
||||
void
|
||||
CXWindowsSecondaryScreen::mouseUp(ButtonID button)
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
XTestFakeButtonEvent(display, mapButton(button), False, CurrentTime);
|
||||
XSync(display, False);
|
||||
}
|
||||
@@ -252,7 +116,6 @@ CXWindowsSecondaryScreen::mouseUp(ButtonID button)
|
||||
void
|
||||
CXWindowsSecondaryScreen::mouseMove(SInt32 x, SInt32 y)
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
warpCursor(x, y);
|
||||
}
|
||||
|
||||
@@ -268,7 +131,7 @@ CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
||||
}
|
||||
|
||||
// send as many clicks as necessary
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
for (; delta >= 120; delta -= 120) {
|
||||
XTestFakeButtonEvent(display, button, True, CurrentTime);
|
||||
XTestFakeButtonEvent(display, button, False, CurrentTime);
|
||||
@@ -276,63 +139,29 @@ CXWindowsSecondaryScreen::mouseWheel(SInt32 delta)
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::setClipboard(ClipboardID id,
|
||||
const IClipboard* clipboard)
|
||||
IScreen*
|
||||
CXWindowsSecondaryScreen::getScreen() const
|
||||
{
|
||||
setDisplayClipboard(id, clipboard);
|
||||
return m_screen;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::grabClipboard(ClipboardID id)
|
||||
CXWindowsSecondaryScreen::onScreensaver(bool)
|
||||
{
|
||||
setDisplayClipboard(id, NULL);
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::screenSaver(bool activate)
|
||||
CXWindowsSecondaryScreen::onError()
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
if (activate) {
|
||||
getScreenSaver()->activate();
|
||||
}
|
||||
else {
|
||||
getScreenSaver()->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::getMousePos(SInt32& x, SInt32& y) const
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
getCursorPos(x, y);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::getShape(
|
||||
SInt32& x, SInt32& y, SInt32& w, SInt32& h) const
|
||||
{
|
||||
getScreenShape(x, y, w, h);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CXWindowsSecondaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::getClipboard(ClipboardID id,
|
||||
IClipboard* clipboard) const
|
||||
{
|
||||
getDisplayClipboard(id, clipboard);
|
||||
// ignore
|
||||
// FIXME -- forward this? to whom?
|
||||
}
|
||||
|
||||
bool
|
||||
CXWindowsSecondaryScreen::onPreDispatch(const CEvent* event)
|
||||
CXWindowsSecondaryScreen::onPreDispatch(const CEvent*)
|
||||
{
|
||||
// forward to superclass
|
||||
return CXWindowsScreen::onPreDispatch(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -344,33 +173,117 @@ CXWindowsSecondaryScreen::onEvent(CEvent* event)
|
||||
// handle event
|
||||
switch (xevent.type) {
|
||||
case MappingNotify:
|
||||
{
|
||||
// keyboard mapping changed
|
||||
CDisplayLock display(this);
|
||||
XRefreshKeyboardMapping(&xevent.xmapping);
|
||||
updateKeys(display);
|
||||
updateKeycodeMap(display);
|
||||
updateModifierMap(display);
|
||||
updateModifiers(display);
|
||||
}
|
||||
// keyboard mapping changed
|
||||
updateKeys();
|
||||
return true;
|
||||
|
||||
case LeaveNotify:
|
||||
{
|
||||
// mouse moved out of hider window somehow. hide the window.
|
||||
assert(m_window != None);
|
||||
CDisplayLock display(this);
|
||||
hideWindow();
|
||||
}
|
||||
// mouse moved out of hider window somehow. hide the window.
|
||||
hideWindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::onLostClipboard(ClipboardID id)
|
||||
CXWindowsSecondaryScreen::onPreRun()
|
||||
{
|
||||
// tell client that the clipboard was grabbed locally
|
||||
m_receiver->onGrabClipboard(id);
|
||||
assert(m_window != None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::onPreOpen()
|
||||
{
|
||||
assert(m_window == None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::onPostOpen()
|
||||
{
|
||||
// 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
|
||||
CXWindowsSecondaryScreen::onPreEnter()
|
||||
{
|
||||
assert(m_window != None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::onPreLeave()
|
||||
{
|
||||
assert(m_window != None);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::createWindow()
|
||||
{
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// verify the availability of the XTest extension
|
||||
int majorOpcode, firstEvent, firstError;
|
||||
if (!XQueryExtension(display, XTestExtensionName,
|
||||
&majorOpcode, &firstEvent, &firstError)) {
|
||||
// FIXME -- subclass exception for more info?
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
|
||||
// cursor hider window attributes. this window is used to hide the
|
||||
// cursor when it's not on the screen. the window is hidden as soon
|
||||
// as the cursor enters the screen or the display's real cursor is
|
||||
// moved.
|
||||
XSetWindowAttributes attr;
|
||||
attr.event_mask = LeaveWindowMask;
|
||||
attr.do_not_propagate_mask = 0;
|
||||
attr.override_redirect = True;
|
||||
attr.cursor = m_screen->getBlankCursor();
|
||||
|
||||
// create the cursor hider window
|
||||
m_window = XCreateWindow(display, m_screen->getRoot(),
|
||||
0, 0, 1, 1, 0, 0,
|
||||
InputOnly, CopyFromParent,
|
||||
CWDontPropagate | CWEventMask |
|
||||
CWOverrideRedirect | CWCursor,
|
||||
&attr);
|
||||
if (m_window == None) {
|
||||
throw XScreenOpenFailure();
|
||||
}
|
||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||
|
||||
// become impervious to server grabs
|
||||
XTestGrabControl(display, True);
|
||||
}
|
||||
|
||||
// tell our superclass about the window
|
||||
m_screen->setWindow(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::destroyWindow()
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
if (display != NULL) {
|
||||
// release keys that are still pressed
|
||||
releaseKeys(display);
|
||||
|
||||
// no longer impervious to server grabs
|
||||
XTestGrabControl(display, False);
|
||||
|
||||
// destroy window
|
||||
if (m_window != None) {
|
||||
XDestroyWindow(display, m_window);
|
||||
m_window = None;
|
||||
}
|
||||
|
||||
// update
|
||||
XSync(display, False);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -380,106 +293,55 @@ CXWindowsSecondaryScreen::showWindow()
|
||||
// somewhere else on the screen)
|
||||
SInt32 x, y;
|
||||
getCursorPos(x, y);
|
||||
XMoveWindow(getDisplay(), m_window, x, y);
|
||||
CDisplayLock display(m_screen);
|
||||
XMoveWindow(display, m_window, x, y);
|
||||
|
||||
// raise and show the hider window. take activation.
|
||||
// FIXME -- take focus?
|
||||
XMapRaised(getDisplay(), m_window);
|
||||
XMapRaised(display, m_window);
|
||||
|
||||
/* XXX -- this should have no effect
|
||||
// hide cursor by moving it into the hider window
|
||||
XWarpPointer(getDisplay(), None, m_window, 0, 0, 0, 0, 0, 0);
|
||||
XWarpPointer(display, None, m_window, 0, 0, 0, 0, 0, 0);
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::hideWindow()
|
||||
{
|
||||
XUnmapWindow(getDisplay(), m_window);
|
||||
assert(m_window != None);
|
||||
|
||||
CDisplayLock display(m_screen);
|
||||
XUnmapWindow(display, m_window);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::warpCursor(SInt32 x, SInt32 y)
|
||||
{
|
||||
XTestFakeMotionEvent(getDisplay(), getScreen(), x, y, CurrentTime);
|
||||
XSync(getDisplay(), False);
|
||||
CDisplayLock display(m_screen);
|
||||
Display* pDisplay = display;
|
||||
XTestFakeMotionEvent(display, DefaultScreen(pDisplay), x, y, CurrentTime);
|
||||
XSync(display, False);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::checkClipboard()
|
||||
CXWindowsSecondaryScreen::setToggleState(KeyModifierMask mask)
|
||||
{
|
||||
// do nothing, we're always up to date
|
||||
}
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::createWindow()
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
|
||||
// verify the availability of the XTest extension
|
||||
int majorOpcode, firstEvent, firstError;
|
||||
if (!XQueryExtension(display, XTestExtensionName,
|
||||
&majorOpcode, &firstEvent, &firstError)) {
|
||||
// FIXME -- subclass exception for more info?
|
||||
throw XScreenOpenFailure();
|
||||
// toggle modifiers that don't match the desired state
|
||||
unsigned int xMask = maskToX(mask);
|
||||
if ((xMask & m_capsLockMask) != (m_mask & m_capsLockMask)) {
|
||||
toggleKey(display, XK_Caps_Lock, m_capsLockMask);
|
||||
}
|
||||
|
||||
// cursor hider window attributes. this window is used to hide the
|
||||
// cursor when it's not on the screen. the window is hidden as soon
|
||||
// as the cursor enters the screen or the display's real cursor is
|
||||
// moved.
|
||||
XSetWindowAttributes attr;
|
||||
attr.event_mask = LeaveWindowMask;
|
||||
attr.do_not_propagate_mask = 0;
|
||||
attr.override_redirect = True;
|
||||
attr.cursor = getBlankCursor();
|
||||
|
||||
// create the cursor hider window
|
||||
m_window = XCreateWindow(display, getRoot(),
|
||||
0, 0, 1, 1, 0, 0,
|
||||
InputOnly, CopyFromParent,
|
||||
CWDontPropagate | CWEventMask |
|
||||
CWOverrideRedirect | CWCursor,
|
||||
&attr);
|
||||
if (m_window == None) {
|
||||
throw XScreenOpenFailure();
|
||||
if ((xMask & m_numLockMask) != (m_mask & m_numLockMask)) {
|
||||
toggleKey(display, XK_Num_Lock, m_numLockMask);
|
||||
}
|
||||
log((CLOG_DEBUG "window is 0x%08x", m_window));
|
||||
|
||||
// become impervious to server grabs
|
||||
XTestGrabControl(display, True);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::destroyWindow()
|
||||
{
|
||||
releaseKeys();
|
||||
|
||||
CDisplayLock display(this);
|
||||
if (display != NULL) {
|
||||
// no longer impervious to server grabs
|
||||
XTestGrabControl(display, False);
|
||||
|
||||
// destroy window
|
||||
if (m_window != None) {
|
||||
XDestroyWindow(display, m_window);
|
||||
m_window = None;
|
||||
}
|
||||
if ((xMask & m_scrollLockMask) != (m_mask & m_scrollLockMask)) {
|
||||
toggleKey(display, XK_Scroll_Lock, m_scrollLockMask);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::installScreenSaver()
|
||||
{
|
||||
getScreenSaver()->disable();
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::uninstallScreenSaver()
|
||||
{
|
||||
getScreenSaver()->enable();
|
||||
}
|
||||
|
||||
unsigned int
|
||||
CXWindowsSecondaryScreen::mapButton(ButtonID id) const
|
||||
{
|
||||
@@ -848,7 +710,7 @@ CXWindowsSecondaryScreen::doKeystrokes(const Keystrokes& keys, SInt32 count)
|
||||
}
|
||||
|
||||
// lock display
|
||||
CDisplayLock display(this);
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// generate key events
|
||||
for (Keystrokes::const_iterator k = keys.begin(); k != keys.end(); ) {
|
||||
@@ -910,27 +772,24 @@ CXWindowsSecondaryScreen::maskToX(KeyModifierMask inMask) const
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::releaseKeys()
|
||||
CXWindowsSecondaryScreen::releaseKeys(Display* display)
|
||||
{
|
||||
CDisplayLock display(this);
|
||||
assert(display != NULL);
|
||||
|
||||
if (display != NULL) {
|
||||
// key up for each key that's down
|
||||
for (UInt32 i = 0; i < 256; ++i) {
|
||||
if (m_keys[i]) {
|
||||
XTestFakeKeyEvent(display, i, False, CurrentTime);
|
||||
m_keys[i] = false;
|
||||
}
|
||||
// key up for each key that's down
|
||||
for (UInt32 i = 0; i < 256; ++i) {
|
||||
if (m_keys[i]) {
|
||||
XTestFakeKeyEvent(display, i, False, CurrentTime);
|
||||
m_keys[i] = false;
|
||||
}
|
||||
|
||||
// update
|
||||
XSync(display, False);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::updateKeys(Display* display)
|
||||
CXWindowsSecondaryScreen::updateKeys()
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
|
||||
// ask server which keys are pressed
|
||||
char keys[32];
|
||||
XQueryKeymap(display, keys);
|
||||
@@ -946,6 +805,11 @@ CXWindowsSecondaryScreen::updateKeys(Display* display)
|
||||
m_keys[j + 6] = ((keys[i] & 0x40) != 0);
|
||||
m_keys[j + 7] = ((keys[i] & 0x80) != 0);
|
||||
}
|
||||
|
||||
// update mappings and current modifiers
|
||||
updateKeycodeMap(display);
|
||||
updateModifierMap(display);
|
||||
updateModifiers(display);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,47 +1,55 @@
|
||||
#ifndef CXWINDOWSSECONDARYSCREEN_H
|
||||
#define CXWINDOWSSECONDARYSCREEN_H
|
||||
|
||||
#include "CXWindowsScreen.h"
|
||||
#include "ISecondaryScreen.h"
|
||||
#include "CSecondaryScreen.h"
|
||||
#include "IScreenEventHandler.h"
|
||||
#include "stdmap.h"
|
||||
#include "stdvector.h"
|
||||
#if defined(X_DISPLAY_MISSING)
|
||||
# error X11 is required to build synergy
|
||||
#else
|
||||
# include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
class CXWindowsScreen;
|
||||
class IScreenReceiver;
|
||||
|
||||
class CXWindowsSecondaryScreen : public CXWindowsScreen,
|
||||
public ISecondaryScreen {
|
||||
class CXWindowsSecondaryScreen :
|
||||
public CSecondaryScreen, public IScreenEventHandler {
|
||||
public:
|
||||
CXWindowsSecondaryScreen(IScreenReceiver*);
|
||||
virtual ~CXWindowsSecondaryScreen();
|
||||
|
||||
// ISecondaryScreen overrides
|
||||
virtual void run();
|
||||
virtual void stop();
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute,
|
||||
KeyModifierMask mask);
|
||||
virtual void leave();
|
||||
// CSecondaryScreen overrides
|
||||
virtual void keyDown(KeyID, KeyModifierMask);
|
||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
||||
virtual void keyUp(KeyID, KeyModifierMask);
|
||||
virtual void mouseDown(ButtonID);
|
||||
virtual void mouseUp(ButtonID);
|
||||
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute);
|
||||
virtual void mouseMove(SInt32 x, SInt32 y);
|
||||
virtual void mouseWheel(SInt32 delta);
|
||||
virtual void setClipboard(ClipboardID, const IClipboard*);
|
||||
virtual void grabClipboard(ClipboardID);
|
||||
virtual void screenSaver(bool activate);
|
||||
virtual void getMousePos(SInt32& x, SInt32& y) const;
|
||||
virtual void getShape(SInt32&, SInt32&, SInt32&, SInt32&) const;
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void getClipboard(ClipboardID, IClipboard*) 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 onLostClipboard(ClipboardID);
|
||||
|
||||
protected:
|
||||
// CSecondaryScreen overrides
|
||||
virtual void onPreRun();
|
||||
virtual void onPreOpen();
|
||||
virtual void onPostOpen();
|
||||
virtual void onPreEnter();
|
||||
virtual void onPreLeave();
|
||||
virtual void createWindow();
|
||||
virtual void destroyWindow();
|
||||
virtual void showWindow();
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
virtual void setToggleState(KeyModifierMask);
|
||||
|
||||
private:
|
||||
enum EKeyAction { kPress, kRelease, kRepeat };
|
||||
@@ -62,26 +70,6 @@ private:
|
||||
typedef std::map<KeyID, KeyCodeMask> KeyCodeMap;
|
||||
typedef std::map<KeyCode, unsigned int> ModifierMap;
|
||||
|
||||
void showWindow();
|
||||
void hideWindow();
|
||||
|
||||
// warp the mouse to the specified position
|
||||
void warpCursor(SInt32 x, SInt32 y);
|
||||
|
||||
// check clipboard ownership and, if necessary, tell the receiver
|
||||
// of a grab.
|
||||
void checkClipboard();
|
||||
|
||||
// create/destroy window
|
||||
// also attach to desktop; this destroys and recreates the window
|
||||
// as necessary.
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
|
||||
// start/stop watch for screen saver changes
|
||||
void installScreenSaver();
|
||||
void uninstallScreenSaver();
|
||||
|
||||
unsigned int mapButton(ButtonID button) const;
|
||||
|
||||
unsigned int mapKey(Keystrokes&, KeyCode&, KeyID,
|
||||
@@ -91,8 +79,7 @@ private:
|
||||
void doKeystrokes(const Keystrokes&, SInt32 count);
|
||||
unsigned int maskToX(KeyModifierMask) const;
|
||||
|
||||
void releaseKeys();
|
||||
void updateKeys(Display* display);
|
||||
void releaseKeys(Display*);
|
||||
void updateKeycodeMap(Display* display);
|
||||
void updateModifiers(Display* display);
|
||||
void updateModifierMap(Display* display);
|
||||
@@ -100,12 +87,9 @@ private:
|
||||
static bool isToggleKeysym(KeySym);
|
||||
|
||||
private:
|
||||
IScreenReceiver* m_receiver;
|
||||
CXWindowsScreen* m_screen;
|
||||
Window m_window;
|
||||
|
||||
// m_active is true if this screen has been entered
|
||||
bool m_active;
|
||||
|
||||
// note toggle keys that toggles on up/down (false) or on
|
||||
// transition (true)
|
||||
bool m_numLockHalfDuplex;
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
#ifndef ISECONDARYSCREEN_H
|
||||
#define ISECONDARYSCREEN_H
|
||||
|
||||
#include "IInterface.h"
|
||||
#include "ClipboardTypes.h"
|
||||
#include "KeyTypes.h"
|
||||
#include "MouseTypes.h"
|
||||
|
||||
class IClipboard;
|
||||
|
||||
class ISecondaryScreen : 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, hide the cursor, and disable the screen
|
||||
// saver. start reporting events to the IScreenReceiver (which is
|
||||
// set through some other interface).
|
||||
virtual void open() = 0;
|
||||
|
||||
// close the screen. should restore the screen saver. it should
|
||||
// also simulate key up events for any keys that have simulate key
|
||||
// down events without a matching key up. without this the client
|
||||
// will leave its keyboard in the wrong logical state.
|
||||
virtual void close() = 0;
|
||||
|
||||
// called when the user navigates to the secondary screen. warp
|
||||
// the cursor to the given coordinates and unhide it. prepare to
|
||||
// simulate input events.
|
||||
virtual void enter(SInt32 xAbsolute, SInt32 yAbsolute,
|
||||
KeyModifierMask mask) = 0;
|
||||
|
||||
// called when the user navigates off the secondary screen. clean
|
||||
// up input event simulation and hide the cursor.
|
||||
virtual void leave() = 0;
|
||||
|
||||
// keyboard input simulation
|
||||
virtual void keyDown(KeyID, KeyModifierMask) = 0;
|
||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count) = 0;
|
||||
virtual void keyUp(KeyID, KeyModifierMask) = 0;
|
||||
|
||||
// mouse input simulation
|
||||
virtual void mouseDown(ButtonID) = 0;
|
||||
virtual void mouseUp(ButtonID) = 0;
|
||||
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute) = 0;
|
||||
virtual void mouseWheel(SInt32 delta) = 0;
|
||||
|
||||
// set the screen's clipboard contents. this is usually called
|
||||
// soon after an enter().
|
||||
virtual void setClipboard(ClipboardID, const IClipboard*) = 0;
|
||||
|
||||
// take ownership of clipboard
|
||||
virtual void grabClipboard(ClipboardID) = 0;
|
||||
|
||||
// activate or deactivate the screen saver
|
||||
virtual void screenSaver(bool activate) = 0;
|
||||
|
||||
// accessors
|
||||
|
||||
// get the position of the mouse on the screen
|
||||
virtual void getMousePos(SInt32& x, SInt32& y) const = 0;
|
||||
|
||||
// get the size of the screen
|
||||
virtual void getShape(SInt32& x, SInt32& y,
|
||||
SInt32& width, SInt32& height) const = 0;
|
||||
|
||||
// get the size of jump zone
|
||||
virtual SInt32 getJumpZoneSize() const = 0;
|
||||
|
||||
// get the screen's clipboard contents
|
||||
virtual void getClipboard(ClipboardID, IClipboard*) const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -5,13 +5,14 @@ DEPTH = ..
|
||||
bin_PROGRAMS = synergy
|
||||
synergy_SOURCES = \
|
||||
CClient.cpp \
|
||||
CSecondaryScreen.cpp \
|
||||
CServerProxy.cpp \
|
||||
CXWindowsSecondaryScreen.cpp \
|
||||
client.cpp \
|
||||
CClient.h \
|
||||
CSecondaryScreen.h \
|
||||
CServerProxy.h \
|
||||
CXWindowsSecondaryScreen.h \
|
||||
ISecondaryScreen.h \
|
||||
$(NULL)
|
||||
synergy_LDADD = \
|
||||
$(DEPTH)/platform/libplatform.a \
|
||||
|
||||
@@ -116,9 +116,11 @@ realMain(CMutex* mutex)
|
||||
if (!locked && mutex != NULL) {
|
||||
mutex->lock();
|
||||
}
|
||||
s_client->close();
|
||||
delete s_client;
|
||||
s_client = NULL;
|
||||
if (s_client != NULL) {
|
||||
s_client->close();
|
||||
delete s_client;
|
||||
s_client = NULL;
|
||||
}
|
||||
CLog::setLock(NULL);
|
||||
s_logMutex = NULL;
|
||||
throw;
|
||||
|
||||
Reference in New Issue
Block a user