From 18a3db68430244907658f71823d7947396b4c793 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Sat, 29 Jun 2013 22:02:04 +0000 Subject: [PATCH] patch by jerry: fixed new event queue on Mac and Linu --- .../synergyc/COSXClientTaskBarReceiver.cpp | 8 +++-- src/cmd/synergyc/COSXClientTaskBarReceiver.h | 3 +- .../CXWindowsClientTaskBarReceiver.cpp | 8 +++-- .../synergyc/CXWindowsClientTaskBarReceiver.h | 4 ++- .../synergys/COSXServerTaskBarReceiver.cpp | 7 ++-- src/cmd/synergys/COSXServerTaskBarReceiver.h | 2 +- .../CXWindowsServerTaskBarReceiver.cpp | 7 ++-- .../synergys/CXWindowsServerTaskBarReceiver.h | 4 ++- src/lib/base/CEventQueue.h | 2 +- src/lib/base/CEventTypes.cpp | 2 +- src/lib/base/CEventTypes.h | 4 +-- src/lib/platform/COSXEventQueueBuffer.cpp | 6 ++-- src/lib/platform/COSXEventQueueBuffer.h | 5 ++- src/lib/platform/COSXKeyState.cpp | 1 + src/lib/platform/COSXScreen.cpp | 21 +++++++----- src/lib/platform/COSXScreen.h | 7 +++- src/lib/platform/COSXScreenSaver.cpp | 3 +- src/lib/platform/COSXScreenSaver.h | 5 ++- .../platform/CXWindowsEventQueueBuffer.cpp | 3 +- src/lib/platform/CXWindowsEventQueueBuffer.h | 7 ++-- src/lib/platform/CXWindowsKeyState.cpp | 5 ++- src/lib/platform/CXWindowsKeyState.h | 4 ++- src/lib/platform/CXWindowsScreen.cpp | 14 +++++--- src/lib/platform/CXWindowsScreen.h | 4 ++- src/lib/platform/CXWindowsScreenSaver.cpp | 4 +-- src/lib/synergy/CApp.h | 2 +- src/lib/synergy/CAppUtilUnix.cpp | 2 +- src/lib/synergy/CAppUtilUnix.h | 4 ++- src/lib/synergy/CAppUtilWindows.cpp | 2 +- src/lib/synergy/CClientApp.cpp | 4 +-- src/lib/synergy/CServerApp.cpp | 6 ++-- src/lib/synergy/IApp.h | 2 +- .../integtests/platform/COSXKeyStateTests.cpp | 6 ++-- .../platform/CXWindowsKeyStateTests.cpp | 33 ++++++++++++------- .../platform/CXWindowsScreenSaverTests.cpp | 7 ++-- .../platform/CXWindowsScreenTests.cpp | 3 +- 36 files changed, 135 insertions(+), 76 deletions(-) diff --git a/src/cmd/synergyc/COSXClientTaskBarReceiver.cpp b/src/cmd/synergyc/COSXClientTaskBarReceiver.cpp index 1ed759e3..388f2654 100644 --- a/src/cmd/synergyc/COSXClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/COSXClientTaskBarReceiver.cpp @@ -24,7 +24,9 @@ // COSXClientTaskBarReceiver::COSXClientTaskBarReceiver( - const CBufferedLogOutputter*) + const CBufferedLogOutputter*, + IEventQueue* events) : + CClientTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -60,8 +62,8 @@ COSXClientTaskBarReceiver::getIcon() const } IArchTaskBarReceiver* -createTaskBarReceiver(const CBufferedLogOutputter* logBuffer) +createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events) { - return new COSXClientTaskBarReceiver(logBuffer); + return new COSXClientTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergyc/COSXClientTaskBarReceiver.h b/src/cmd/synergyc/COSXClientTaskBarReceiver.h index 27784c75..6d309a5b 100644 --- a/src/cmd/synergyc/COSXClientTaskBarReceiver.h +++ b/src/cmd/synergyc/COSXClientTaskBarReceiver.h @@ -22,11 +22,12 @@ #include "CClientTaskBarReceiver.h" class CBufferedLogOutputter; +class IEventQueue; //! Implementation of CClientTaskBarReceiver for OS X class COSXClientTaskBarReceiver : public CClientTaskBarReceiver { public: - COSXClientTaskBarReceiver(const CBufferedLogOutputter*); + COSXClientTaskBarReceiver(const CBufferedLogOutputter*, IEventQueue* events); virtual ~COSXClientTaskBarReceiver(); // IArchTaskBarReceiver overrides diff --git a/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.cpp b/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.cpp index 91c0f7a3..31c80b89 100644 --- a/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.cpp +++ b/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.cpp @@ -24,7 +24,9 @@ // CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver( - const CBufferedLogOutputter*) + const CBufferedLogOutputter*, + IEventQueue* events) : + CClientTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -60,7 +62,7 @@ CXWindowsClientTaskBarReceiver::getIcon() const } IArchTaskBarReceiver* -createTaskBarReceiver(const CBufferedLogOutputter* logBuffer) +createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events) { - return new CXWindowsClientTaskBarReceiver(logBuffer); + return new CXWindowsClientTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.h b/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.h index 54ab5997..83576414 100644 --- a/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.h +++ b/src/cmd/synergyc/CXWindowsClientTaskBarReceiver.h @@ -22,11 +22,13 @@ #include "CClientTaskBarReceiver.h" class CBufferedLogOutputter; +class IEventQueue; //! Implementation of CClientTaskBarReceiver for X Windows class CXWindowsClientTaskBarReceiver : public CClientTaskBarReceiver { public: - CXWindowsClientTaskBarReceiver(const CBufferedLogOutputter*); + CXWindowsClientTaskBarReceiver( + const CBufferedLogOutputter*, IEventQueue* events); virtual ~CXWindowsClientTaskBarReceiver(); // IArchTaskBarReceiver overrides diff --git a/src/cmd/synergys/COSXServerTaskBarReceiver.cpp b/src/cmd/synergys/COSXServerTaskBarReceiver.cpp index aae65393..264e69a7 100644 --- a/src/cmd/synergys/COSXServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/COSXServerTaskBarReceiver.cpp @@ -24,7 +24,8 @@ // COSXServerTaskBarReceiver::COSXServerTaskBarReceiver( - const CBufferedLogOutputter*) + const CBufferedLogOutputter*, IEventQueue* events) : + CServerTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -60,7 +61,7 @@ COSXServerTaskBarReceiver::getIcon() const } IArchTaskBarReceiver* -createTaskBarReceiver(const CBufferedLogOutputter* logBuffer) +createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events) { - return new COSXServerTaskBarReceiver(logBuffer); + return new COSXServerTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergys/COSXServerTaskBarReceiver.h b/src/cmd/synergys/COSXServerTaskBarReceiver.h index d190f1af..cde33f05 100644 --- a/src/cmd/synergys/COSXServerTaskBarReceiver.h +++ b/src/cmd/synergys/COSXServerTaskBarReceiver.h @@ -26,7 +26,7 @@ class CBufferedLogOutputter; //! Implementation of CServerTaskBarReceiver for OS X class COSXServerTaskBarReceiver : public CServerTaskBarReceiver { public: - COSXServerTaskBarReceiver(const CBufferedLogOutputter*); + COSXServerTaskBarReceiver(const CBufferedLogOutputter*, IEventQueue* events); virtual ~COSXServerTaskBarReceiver(); // IArchTaskBarReceiver overrides diff --git a/src/cmd/synergys/CXWindowsServerTaskBarReceiver.cpp b/src/cmd/synergys/CXWindowsServerTaskBarReceiver.cpp index 598555b9..032fe7b8 100644 --- a/src/cmd/synergys/CXWindowsServerTaskBarReceiver.cpp +++ b/src/cmd/synergys/CXWindowsServerTaskBarReceiver.cpp @@ -24,7 +24,8 @@ // CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver( - const CBufferedLogOutputter*) + const CBufferedLogOutputter*, IEventQueue* events) : + CServerTaskBarReceiver(events) { // add ourself to the task bar ARCH->addReceiver(this); @@ -60,7 +61,7 @@ CXWindowsServerTaskBarReceiver::getIcon() const } IArchTaskBarReceiver* -createTaskBarReceiver(const CBufferedLogOutputter* logBuffer) +createTaskBarReceiver(const CBufferedLogOutputter* logBuffer, IEventQueue* events) { - return new CXWindowsServerTaskBarReceiver(logBuffer); + return new CXWindowsServerTaskBarReceiver(logBuffer, events); } diff --git a/src/cmd/synergys/CXWindowsServerTaskBarReceiver.h b/src/cmd/synergys/CXWindowsServerTaskBarReceiver.h index 0adc8124..181e633a 100644 --- a/src/cmd/synergys/CXWindowsServerTaskBarReceiver.h +++ b/src/cmd/synergys/CXWindowsServerTaskBarReceiver.h @@ -22,11 +22,13 @@ #include "CServerTaskBarReceiver.h" class CBufferedLogOutputter; +class IEventQueue; //! Implementation of CServerTaskBarReceiver for X Windows class CXWindowsServerTaskBarReceiver : public CServerTaskBarReceiver { public: - CXWindowsServerTaskBarReceiver(const CBufferedLogOutputter*); + CXWindowsServerTaskBarReceiver( + const CBufferedLogOutputter*, IEventQueue* events); virtual ~CXWindowsServerTaskBarReceiver(); // IArchTaskBarReceiver overrides diff --git a/src/lib/base/CEventQueue.h b/src/lib/base/CEventQueue.h index 77514751..70e2feed 100644 --- a/src/lib/base/CEventQueue.h +++ b/src/lib/base/CEventQueue.h @@ -177,7 +177,7 @@ private: #define EVENT_TYPE_ACCESSOR(type_) \ type_##Events& \ -CEventQueue::for##type_##() { \ +CEventQueue::for##type_() { \ if (m_typesFor##type_ == NULL) { \ m_typesFor##type_ = new type_##Events(); \ m_typesFor##type_->setEvents(dynamic_cast(this)); \ diff --git a/src/lib/base/CEventTypes.cpp b/src/lib/base/CEventTypes.cpp index 5541b4bb..68d70b73 100644 --- a/src/lib/base/CEventTypes.cpp +++ b/src/lib/base/CEventTypes.cpp @@ -26,7 +26,7 @@ CEventTypes::CEventTypes() : } IEventQueue* -CEventTypes::events() const +CEventTypes::getEvents() const { assert(m_events != NULL); return m_events; diff --git a/src/lib/base/CEventTypes.h b/src/lib/base/CEventTypes.h index 80e31979..74679f1e 100644 --- a/src/lib/base/CEventTypes.h +++ b/src/lib/base/CEventTypes.h @@ -27,7 +27,7 @@ public: void setEvents(IEventQueue* events); protected: - IEventQueue* events() const; + IEventQueue* getEvents() const; private: IEventQueue* m_events; @@ -37,7 +37,7 @@ private: CEvent::Type \ type_##Events::name_() \ { \ - return events()->registerTypeOnce(m_##name_, __FUNCTION__); \ + return getEvents()->registerTypeOnce(m_##name_, __FUNCTION__); \ } class CClientEvents : public CEventTypes { diff --git a/src/lib/platform/COSXEventQueueBuffer.cpp b/src/lib/platform/COSXEventQueueBuffer.cpp index b2dd3134..b79db653 100644 --- a/src/lib/platform/COSXEventQueueBuffer.cpp +++ b/src/lib/platform/COSXEventQueueBuffer.cpp @@ -30,8 +30,8 @@ class CEventQueueTimer { }; // COSXEventQueueBuffer // -COSXEventQueueBuffer::COSXEventQueueBuffer() : - m_event(NULL) +COSXEventQueueBuffer::COSXEventQueueBuffer(IEventQueue* events) : + m_eventQueue(events), m_event(NULL) { // do nothing } @@ -80,7 +80,7 @@ COSXEventQueueBuffer::getEvent(CEvent& event, UInt32& dataID) default: event = CEvent(CEvent::kSystem, - m_events->getSystemTarget(), &m_event); + m_eventQueue->getSystemTarget(), &m_event); return kSystem; } } diff --git a/src/lib/platform/COSXEventQueueBuffer.h b/src/lib/platform/COSXEventQueueBuffer.h index 055e7a59..b47b5806 100644 --- a/src/lib/platform/COSXEventQueueBuffer.h +++ b/src/lib/platform/COSXEventQueueBuffer.h @@ -22,10 +22,12 @@ #include #include "IEventQueueBuffer.h" +class IEventQueue; + //! Event queue buffer for OS X class COSXEventQueueBuffer : public IEventQueueBuffer { public: - COSXEventQueueBuffer(); + COSXEventQueueBuffer(IEventQueue* eventQueue); virtual ~COSXEventQueueBuffer(); // IEventQueueBuffer overrides @@ -39,6 +41,7 @@ public: private: EventRef m_event; + IEventQueue* m_eventQueue; }; #endif diff --git a/src/lib/platform/COSXKeyState.cpp b/src/lib/platform/COSXKeyState.cpp index b85c6b38..e265cf0d 100644 --- a/src/lib/platform/COSXKeyState.cpp +++ b/src/lib/platform/COSXKeyState.cpp @@ -181,6 +181,7 @@ static const CKeyEntry s_controlKeys[] = { // COSXKeyState::COSXKeyState(IEventQueue* events) : + CKeyState(events), m_deadKeyState(0) { init(); diff --git a/src/lib/platform/COSXScreen.cpp b/src/lib/platform/COSXScreen.cpp index 338adb66..69332e10 100644 --- a/src/lib/platform/COSXScreen.cpp +++ b/src/lib/platform/COSXScreen.cpp @@ -64,7 +64,9 @@ enum { bool COSXScreen::s_testedForGHOM = false; bool COSXScreen::s_hasGHOM = false; -COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) : +COSXScreen::COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCursor) : + CPlatformScreen(events), + m_events(events), MouseButtonEventMap(NumButtonIDs), m_isPrimary(isPrimary), m_isOnScreen(m_isPrimary), @@ -98,8 +100,8 @@ COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) : try { m_displayID = CGMainDisplayID(); updateScreenShape(m_displayID, 0); - m_screensaver = new COSXScreenSaver(getEventTarget()); - m_keyState = new COSXKeyState(); + m_screensaver = new COSXScreenSaver(m_events, getEventTarget()); + m_keyState = new COSXKeyState(m_events); // TODO: http://stackoverflow.com/questions/2950124/enable-access-for-assistive-device-programmatically if (m_isPrimary && !AXAPIEnabled()) @@ -178,7 +180,7 @@ COSXScreen::COSXScreen(bool isPrimary, bool autoShowHideCursor) : &COSXScreen::handleSystemEvent)); // install the platform event queue - m_events->adoptBuffer(new COSXEventQueueBuffer); + m_events->adoptBuffer(new COSXEventQueueBuffer(m_events)); } COSXScreen::~COSXScreen() @@ -1036,7 +1038,7 @@ COSXScreen::onMouseMove(SInt32 mx, SInt32 my) if (m_isOnScreen) { // motion on primary screen - sendEvent(m_events->forIScreen().motionOnPrimary(), + sendEvent(m_events->forIPrimaryScreen().motionOnPrimary(), CMotionInfo::alloc(m_xCursor, m_yCursor)); } else { @@ -1058,7 +1060,7 @@ COSXScreen::onMouseMove(SInt32 mx, SInt32 my) } else { // send motion - sendEvent(m_events->forIScreen().motionOnSecondary(), CMotionInfo::alloc(x, y)); + sendEvent(m_events->forIPrimaryScreen().motionOnSecondary(), CMotionInfo::alloc(x, y)); } } @@ -1494,7 +1496,7 @@ COSXScreen::updateScreenShape() delete[] displays; // We want to notify the peer screen whether we are primary screen or not - sendEvent(m_events->forIPrimaryScreen().shapeChanged()); + sendEvent(m_events->forIScreen().shapeChanged()); LOG((CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, @@ -1518,15 +1520,16 @@ COSXScreen::userSwitchCallback(EventHandlerCallRef nextHandler, { COSXScreen* screen = (COSXScreen*)inUserData; UInt32 kind = GetEventKind(theEvent); + IEventQueue* events = screen->getEvents(); if (kind == kEventSystemUserSessionDeactivated) { LOG((CLOG_DEBUG "user session deactivated")); - m_events->addEvent(CEvent(m_events->forIScreen().suspend(), + events->addEvent(CEvent(events->forIScreen().suspend(), screen->getEventTarget())); } else if (kind == kEventSystemUserSessionActivated) { LOG((CLOG_DEBUG "user session activated")); - m_events->addEvent(CEvent(m_events->forIScreen().resume(), + events->addEvent(CEvent(events->forIScreen().resume(), screen->getEventTarget())); } return (CallNextEventHandler(nextHandler, theEvent)); diff --git a/src/lib/platform/COSXScreen.h b/src/lib/platform/COSXScreen.h index a995aaa9..eae23804 100644 --- a/src/lib/platform/COSXScreen.h +++ b/src/lib/platform/COSXScreen.h @@ -49,13 +49,16 @@ class CMutex; class CThread; class COSXKeyState; class COSXScreenSaver; +class IEventQueue; //! Implementation of IPlatformScreen for OS X class COSXScreen : public CPlatformScreen { public: - COSXScreen(bool isPrimary, bool autoShowHideCursor=true); + COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCursor=true); virtual ~COSXScreen(); + IEventQueue* getEvents() const { return m_events; } + // IScreen overrides virtual void* getEventTarget() const; virtual bool getClipboard(ClipboardID id, IClipboard*) const; @@ -335,6 +338,8 @@ private: // cursor will hide and show on enable and disable if true. bool m_autoShowHideCursor; + + IEventQueue* m_events; }; #endif diff --git a/src/lib/platform/COSXScreenSaver.cpp b/src/lib/platform/COSXScreenSaver.cpp index 631726d8..ac09ddbd 100644 --- a/src/lib/platform/COSXScreenSaver.cpp +++ b/src/lib/platform/COSXScreenSaver.cpp @@ -27,7 +27,8 @@ // COSXScreenSaver // -COSXScreenSaver::COSXScreenSaver(void* eventTarget) : +COSXScreenSaver::COSXScreenSaver(IEventQueue* events, void* eventTarget) : + m_events(events), m_eventTarget(eventTarget), m_enabled(true) { diff --git a/src/lib/platform/COSXScreenSaver.h b/src/lib/platform/COSXScreenSaver.h index 04081fb6..f381483f 100644 --- a/src/lib/platform/COSXScreenSaver.h +++ b/src/lib/platform/COSXScreenSaver.h @@ -22,10 +22,12 @@ #include "IScreenSaver.h" #include +class IEventQueue; + //! OSX screen saver implementation class COSXScreenSaver : public IScreenSaver { public: - COSXScreenSaver(void* eventTarget); + COSXScreenSaver(IEventQueue* events, void* eventTarget); virtual ~COSXScreenSaver(); // IScreenSaver overrides @@ -53,6 +55,7 @@ private: void* m_autoReleasePool; EventHandlerRef m_launchTerminationEventHandlerRef; ProcessSerialNumber m_screenSaverPSN; + IEventQueue* m_events; }; #endif diff --git a/src/lib/platform/CXWindowsEventQueueBuffer.cpp b/src/lib/platform/CXWindowsEventQueueBuffer.cpp index 55c56796..b71420d5 100644 --- a/src/lib/platform/CXWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/CXWindowsEventQueueBuffer.cpp @@ -51,7 +51,8 @@ class CEventQueueTimer { }; // CXWindowsEventQueueBuffer::CXWindowsEventQueueBuffer( - Display* display, Window window) : + Display* display, Window window, IEventQueue* events) : + m_events(events), m_display(display), m_window(window), m_waiting(false) diff --git a/src/lib/platform/CXWindowsEventQueueBuffer.h b/src/lib/platform/CXWindowsEventQueueBuffer.h index 116eca5e..61e67c1d 100644 --- a/src/lib/platform/CXWindowsEventQueueBuffer.h +++ b/src/lib/platform/CXWindowsEventQueueBuffer.h @@ -28,10 +28,12 @@ # include #endif +class IEventQueue; + //! Event queue buffer for X11 class CXWindowsEventQueueBuffer : public IEventQueueBuffer { public: - CXWindowsEventQueueBuffer(Display*, Window); + CXWindowsEventQueueBuffer(Display*, Window, IEventQueue* events); virtual ~CXWindowsEventQueueBuffer(); // IEventQueueBuffer overrides @@ -56,7 +58,8 @@ private: XEvent m_event; CEventList m_postedEvents; bool m_waiting; - int m_pipefd[2]; + int m_pipefd[2]; + IEventQueue* m_events; }; #endif diff --git a/src/lib/platform/CXWindowsKeyState.cpp b/src/lib/platform/CXWindowsKeyState.cpp index 0bc644e9..c66cb280 100644 --- a/src/lib/platform/CXWindowsKeyState.cpp +++ b/src/lib/platform/CXWindowsKeyState.cpp @@ -38,7 +38,10 @@ static const size_t ModifiersFromXDefaultSize = 32; -CXWindowsKeyState::CXWindowsKeyState(Display* display, bool useXKB) : +CXWindowsKeyState::CXWindowsKeyState( + Display* display, bool useXKB, + IEventQueue* events) : + CKeyState(events), m_display(display), m_modifierFromX(ModifiersFromXDefaultSize) { diff --git a/src/lib/platform/CXWindowsKeyState.h b/src/lib/platform/CXWindowsKeyState.h index ca1d1e35..d2aa7c2b 100644 --- a/src/lib/platform/CXWindowsKeyState.h +++ b/src/lib/platform/CXWindowsKeyState.h @@ -36,6 +36,8 @@ # endif #endif +class IEventQueue; + //! X Windows key state /*! A key state for X Windows. @@ -48,7 +50,7 @@ public: kGroupPollAndSet = -2 }; - CXWindowsKeyState(Display*, bool useXKB); + CXWindowsKeyState(Display*, bool useXKB, IEventQueue* events); CXWindowsKeyState(Display*, bool useXKB, IEventQueue* events, CKeyMap& keyMap); ~CXWindowsKeyState(); diff --git a/src/lib/platform/CXWindowsScreen.cpp b/src/lib/platform/CXWindowsScreen.cpp index 796cc852..99ca61e0 100644 --- a/src/lib/platform/CXWindowsScreen.cpp +++ b/src/lib/platform/CXWindowsScreen.cpp @@ -88,7 +88,12 @@ static int xi_opcode; CXWindowsScreen* CXWindowsScreen::s_screen = NULL; -CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue* events) : +CXWindowsScreen::CXWindowsScreen( + const char* displayName, + bool isPrimary, + bool disableXInitThreads, + int mouseScrollDelta, + IEventQueue* events) : m_isPrimary(isPrimary), m_mouseScrollDelta(mouseScrollDelta), m_display(NULL), @@ -185,7 +190,8 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d &CXWindowsScreen::handleSystemEvent)); // install the platform event queue - m_events->adoptBuffer(new CXWindowsEventQueueBuffer(m_display, m_window)); + m_events->adoptBuffer(new CXWindowsEventQueueBuffer( + m_display, m_window, m_events)); } CXWindowsScreen::~CXWindowsScreen() @@ -1317,7 +1323,7 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*) if (id != kClipboardEnd) { LOG((CLOG_DEBUG "lost clipboard %d ownership at time %d", id, xevent->xselectionclear.time)); m_clipboard[id]->lost(xevent->xselectionclear.time); - sendClipboardEvent(m_events->forIPrimaryScreen().clipboardGrabbed(), id); + sendClipboardEvent(m_events->forIScreen().clipboardGrabbed(), id); return; } } @@ -1731,7 +1737,7 @@ CXWindowsScreen::onError() m_display = NULL; // notify of failure - sendEvent(m_events->forIPrimaryScreen().error(), NULL); + sendEvent(m_events->forIScreen().error(), NULL); // FIXME -- should ensure that we ignore operations that involve // m_display from now on. however, Xlib will simply exit the diff --git a/src/lib/platform/CXWindowsScreen.h b/src/lib/platform/CXWindowsScreen.h index 14b3cfd1..c45eb18a 100644 --- a/src/lib/platform/CXWindowsScreen.h +++ b/src/lib/platform/CXWindowsScreen.h @@ -36,7 +36,9 @@ class CXWindowsScreenSaver; //! Implementation of IPlatformScreen for X11 class CXWindowsScreen : public CPlatformScreen { public: - CXWindowsScreen(const char* displayName, bool isPrimary, bool disableXInitThreads, int mouseScrollDelta, IEventQueue* events); + CXWindowsScreen(const char* displayName, bool isPrimary, + bool disableXInitThreads, int mouseScrollDelta, + IEventQueue* events); virtual ~CXWindowsScreen(); //! @name manipulators diff --git a/src/lib/platform/CXWindowsScreenSaver.cpp b/src/lib/platform/CXWindowsScreenSaver.cpp index d82f8ed5..6f74dcdf 100644 --- a/src/lib/platform/CXWindowsScreenSaver.cpp +++ b/src/lib/platform/CXWindowsScreenSaver.cpp @@ -398,12 +398,12 @@ CXWindowsScreenSaver::setXScreenSaverActive(bool activated) if (activated) { m_events->addEvent(CEvent( - m_events->forIPlatformScreen().screensaverActivated(), + m_events->forIPrimaryScreen().screensaverActivated(), m_eventTarget)); } else { m_events->addEvent(CEvent( - m_events->forIPlatformScreen().screensaverDeactivated(), + m_events->forIPrimaryScreen().screensaverDeactivated(), m_eventTarget)); } } diff --git a/src/lib/synergy/CApp.h b/src/lib/synergy/CApp.h index d388730e..31bd0a46 100644 --- a/src/lib/synergy/CApp.h +++ b/src/lib/synergy/CApp.h @@ -95,7 +95,7 @@ public: virtual void setByeFunc(void(*bye)(int)) { m_bye = bye; } virtual void bye(int error) { m_bye(error); } - virtual IEventQueue* events() const { return m_events; } + virtual IEventQueue* getEvents() const { return m_events; } private: void handleIpcMessage(const CEvent&, void*); diff --git a/src/lib/synergy/CAppUtilUnix.cpp b/src/lib/synergy/CAppUtilUnix.cpp index c287b1c7..af2fa569 100644 --- a/src/lib/synergy/CAppUtilUnix.cpp +++ b/src/lib/synergy/CAppUtilUnix.cpp @@ -19,7 +19,7 @@ #include "CAppUtilUnix.h" #include "CArgsBase.h" -CAppUtilUnix::CAppUtilUnix() +CAppUtilUnix::CAppUtilUnix(IEventQueue* events) { } diff --git a/src/lib/synergy/CAppUtilUnix.h b/src/lib/synergy/CAppUtilUnix.h index c69d8d11..34d70787 100644 --- a/src/lib/synergy/CAppUtilUnix.h +++ b/src/lib/synergy/CAppUtilUnix.h @@ -22,9 +22,11 @@ #define ARCH_APP_UTIL CAppUtilUnix +class IEventQueue; + class CAppUtilUnix : public CAppUtil { public: - CAppUtilUnix(); + CAppUtilUnix(IEventQueue* events); virtual ~CAppUtilUnix(); bool parseArg(const int& argc, const char* const* argv, int& i); diff --git a/src/lib/synergy/CAppUtilWindows.cpp b/src/lib/synergy/CAppUtilWindows.cpp index fb289acc..e352dbfd 100644 --- a/src/lib/synergy/CAppUtilWindows.cpp +++ b/src/lib/synergy/CAppUtilWindows.cpp @@ -53,7 +53,7 @@ CAppUtilWindows::~CAppUtilWindows() BOOL WINAPI CAppUtilWindows::consoleHandler(DWORD) { LOG((CLOG_INFO "got shutdown signal")); - IEventQueue* events = CAppUtil::instance().app().events(); + IEventQueue* events = CAppUtil::instance().app().getEvents(); events->addEvent(CEvent(CEvent::kQuit)); return TRUE; } diff --git a/src/lib/synergy/CClientApp.cpp b/src/lib/synergy/CClientApp.cpp index 93e91813..1e3976ce 100644 --- a/src/lib/synergy/CClientApp.cpp +++ b/src/lib/synergy/CClientApp.cpp @@ -234,9 +234,9 @@ CClientApp::createScreen() #elif WINAPI_XWINDOWS return new CScreen(new CXWindowsScreen( args().m_display, false, args().m_disableXInitThreads, - args().m_yscroll, m_events)); + args().m_yscroll, m_events), m_events); #elif WINAPI_CARBON - return new CScreen(new COSXScreen(false)); + return new CScreen(new COSXScreen(m_events, false), m_events); #endif } diff --git a/src/lib/synergy/CServerApp.cpp b/src/lib/synergy/CServerApp.cpp index 0e29e947..7df21b5e 100644 --- a/src/lib/synergy/CServerApp.cpp +++ b/src/lib/synergy/CServerApp.cpp @@ -203,7 +203,7 @@ CServerApp::help() void CServerApp::reloadSignalHandler(CArch::ESignal, void*) { - IEventQueue* events = CApp::instance().events(); + IEventQueue* events = CApp::instance().getEvents(); events->addEvent(CEvent(events->forCServerApp().reloadConfig(), events->getSystemTarget())); } @@ -625,9 +625,9 @@ CServerApp::createScreen() true, args().m_noHooks, args().m_gameDevice, args().m_stopOnDeskSwitch, m_events), m_events); #elif WINAPI_XWINDOWS return new CScreen(new CXWindowsScreen( - args().m_display, true, args().m_disableXInitThreads, 0, m_events)); + args().m_display, true, args().m_disableXInitThreads, 0, m_events), m_events); #elif WINAPI_CARBON - return new CScreen(new COSXScreen(true)); + return new CScreen(new COSXScreen(m_events, true), m_events); #endif } diff --git a/src/lib/synergy/IApp.h b/src/lib/synergy/IApp.h index 0879760d..f438e4a2 100644 --- a/src/lib/synergy/IApp.h +++ b/src/lib/synergy/IApp.h @@ -46,5 +46,5 @@ public: virtual const char* daemonName() const = 0; virtual int foregroundStartup(int argc, char** argv) = 0; virtual CScreen* createScreen() = 0; - virtual IEventQueue* events() const = 0; + virtual IEventQueue* getEvents() const = 0; }; diff --git a/src/test/integtests/platform/COSXKeyStateTests.cpp b/src/test/integtests/platform/COSXKeyStateTests.cpp index f965142c..372e549f 100644 --- a/src/test/integtests/platform/COSXKeyStateTests.cpp +++ b/src/test/integtests/platform/COSXKeyStateTests.cpp @@ -40,7 +40,7 @@ TEST_F(COSXKeyStateTests, fakeAndPoll_shift) { CKeyMap keyMap; CMockEventQueue eventQueue; - COSXKeyState keyState((IEventQueue*)eventQueue, keyMap); + COSXKeyState keyState(&eventQueue, keyMap); keyState.updateKeyMap(); keyState.fakeKeyDown(SHIFT_ID_L, 0, 1); @@ -60,7 +60,7 @@ TEST_F(COSXKeyStateTests, fakeAndPoll_charKey) { CKeyMap keyMap; CMockEventQueue eventQueue; - COSXKeyState keyState((IEventQueue*)eventQueue, keyMap); + COSXKeyState keyState(&eventQueue, keyMap); keyState.updateKeyMap(); keyState.fakeKeyDown(A_CHAR_ID, 0, 1); @@ -79,7 +79,7 @@ TEST_F(COSXKeyStateTests, fakeAndPoll_charKeyAndModifier) { CKeyMap keyMap; CMockEventQueue eventQueue; - COSXKeyState keyState((IEventQueue*)eventQueue, keyMap); + COSXKeyState keyState(&eventQueue, keyMap); keyState.updateKeyMap(); keyState.fakeKeyDown(A_CHAR_ID, KeyModifierShift, 1); diff --git a/src/test/integtests/platform/CXWindowsKeyStateTests.cpp b/src/test/integtests/platform/CXWindowsKeyStateTests.cpp index 780862c5..45d45a04 100644 --- a/src/test/integtests/platform/CXWindowsKeyStateTests.cpp +++ b/src/test/integtests/platform/CXWindowsKeyStateTests.cpp @@ -77,7 +77,8 @@ TEST_F(CXWindowsKeyStateTests, setActiveGroup_pollAndSet_groupIsZero) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(CXWindowsKeyState::kGroupPollAndSet); @@ -88,7 +89,8 @@ TEST_F(CXWindowsKeyStateTests, setActiveGroup_poll_groupIsNotSet) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(CXWindowsKeyState::kGroupPoll); @@ -99,7 +101,8 @@ TEST_F(CXWindowsKeyStateTests, setActiveGroup_customGroup_groupWasSet) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); keyState.setActiveGroup(1); @@ -110,7 +113,8 @@ TEST_F(CXWindowsKeyStateTests, mapModifiersFromX_zeroState_zeroMask) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); int mask = keyState.mapModifiersFromX(0); @@ -121,7 +125,8 @@ TEST_F(CXWindowsKeyStateTests, mapModifiersToX_zeroMask_resultIsTrue) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); unsigned int modifiers = 0; bool result = keyState.mapModifiersToX(0, modifiers); @@ -133,7 +138,8 @@ TEST_F(CXWindowsKeyStateTests, fakeCtrlAltDel_default_returnsFalse) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); bool result = keyState.fakeCtrlAltDel(); @@ -144,7 +150,8 @@ TEST_F(CXWindowsKeyStateTests, pollActiveModifiers_defaultState_returnsZero) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); KeyModifierMask actual = keyState.pollActiveModifiers(); @@ -155,7 +162,8 @@ TEST_F(CXWindowsKeyStateTests, pollActiveModifiers_shiftKeyDownThenUp_masksAreCo { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); // set mock modifier mapping std::fill( @@ -187,7 +195,8 @@ TEST_F(CXWindowsKeyStateTests, pollActiveGroup_defaultState_returnsZero) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); SInt32 actual = keyState.pollActiveGroup(); @@ -198,7 +207,8 @@ TEST_F(CXWindowsKeyStateTests, pollActiveGroup_positiveGroup_returnsGroup) { CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); keyState.m_group = 3; @@ -212,7 +222,8 @@ TEST_F(CXWindowsKeyStateTests, pollActiveGroup_xkb_areEqual) #if HAVE_XKB_EXTENSION CMockKeyMap keyMap; CMockEventQueue eventQueue; - CXWindowsKeyState keyState(m_display, true, eventQueue, keyMap); + CXWindowsKeyState keyState( + m_display, true, &eventQueue, keyMap); // reset the group keyState.m_group = -1; diff --git a/src/test/integtests/platform/CXWindowsScreenSaverTests.cpp b/src/test/integtests/platform/CXWindowsScreenSaverTests.cpp index c7a2bca5..8094bd3f 100644 --- a/src/test/integtests/platform/CXWindowsScreenSaverTests.cpp +++ b/src/test/integtests/platform/CXWindowsScreenSaverTests.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#if 0 #include #include "CXWindowsScreenSaver.h" #include "CMockEventQueue.h" @@ -24,14 +25,14 @@ using ::testing::_; // TODO: not working on build machine for some reason -#if 0 TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo) { Display* display = XOpenDisplay(":0.0"); Window window = DefaultRootWindow(display); CMockEventQueue eventQueue; EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(1); - CXWindowsScreenSaver screenSaver(display, window, NULL, eventQueue); + CXWindowsScreenSaver screenSaver( + display, window, NULL, &eventQueue); screenSaver.activate(); @@ -41,4 +42,4 @@ TEST(CXWindowsScreenSaverTests, activate_defaultScreen_todo) ASSERT_EQ(true, isActive); } -#endif \ No newline at end of file +#endif diff --git a/src/test/integtests/platform/CXWindowsScreenTests.cpp b/src/test/integtests/platform/CXWindowsScreenTests.cpp index 9e5835e2..846e35b0 100644 --- a/src/test/integtests/platform/CXWindowsScreenTests.cpp +++ b/src/test/integtests/platform/CXWindowsScreenTests.cpp @@ -28,7 +28,8 @@ TEST(CXWindowsScreenTests, fakeMouseMove_nonPrimary_getCursorPosValuesCorrect) EXPECT_CALL(eventQueue, adoptHandler(_, _, _)).Times(2); EXPECT_CALL(eventQueue, adoptBuffer(_)).Times(2); EXPECT_CALL(eventQueue, removeHandler(_, _)).Times(2); - CXWindowsScreen screen(":0.0", false, false, 0, eventQueue); + CXWindowsScreen screen( + ":0.0", false, false, 0, &eventQueue); screen.fakeMouseMove(10, 20);