From 75d2c5abf17e5a604030b2f387ac5e961967c663 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Mon, 17 Feb 2014 19:38:26 +0000 Subject: [PATCH] fixed: nothing happens on osx 10.6 --- src/lib/base/CEventQueue.cpp | 8 ++---- src/lib/base/CEventQueue.h | 2 -- src/lib/base/CSimpleEventQueueBuffer.h | 2 +- src/lib/base/IEventQueue.h | 2 -- src/lib/base/IEventQueueBuffer.h | 8 ++++-- src/lib/platform/CMSWindowsEventQueueBuffer.h | 3 +-- src/lib/platform/COSXEventQueueBuffer.cpp | 26 ++++++++++++------- src/lib/platform/COSXEventQueueBuffer.h | 4 +-- src/lib/platform/CXWindowsEventQueueBuffer.h | 3 +-- src/lib/synergy/CApp.cpp | 19 +++++++------- src/test/unittests/synergy/CMockEventQueue.h | 1 - 11 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/lib/base/CEventQueue.cpp b/src/lib/base/CEventQueue.cpp index f733d76b..cb2a50c0 100644 --- a/src/lib/base/CEventQueue.cpp +++ b/src/lib/base/CEventQueue.cpp @@ -96,6 +96,8 @@ CEventQueue::~CEventQueue() void CEventQueue::loop() { + m_buffer->init(); + CEvent event; getEvent(event); while (event.getType() != CEvent::kQuit) { @@ -594,9 +596,3 @@ CEventQueue::CTimer::operator<(const CTimer& t) const { return m_time < t.m_time; } - -void -CEventQueue::cacheCurrentEventQueueRef() -{ - m_buffer->cacheCurrentEventQueueRef(); -} diff --git a/src/lib/base/CEventQueue.h b/src/lib/base/CEventQueue.h index fa691d10..fbe5a74c 100644 --- a/src/lib/base/CEventQueue.h +++ b/src/lib/base/CEventQueue.h @@ -60,8 +60,6 @@ public: virtual CEvent::Type getRegisteredType(const CString& name) const; void* getSystemTarget(); - - void cacheCurrentEventQueueRef(); private: UInt32 saveEvent(const CEvent& event); diff --git a/src/lib/base/CSimpleEventQueueBuffer.h b/src/lib/base/CSimpleEventQueueBuffer.h index b901f7aa..a5aa9ff8 100644 --- a/src/lib/base/CSimpleEventQueueBuffer.h +++ b/src/lib/base/CSimpleEventQueueBuffer.h @@ -33,6 +33,7 @@ public: ~CSimpleEventQueueBuffer(); // IEventQueueBuffer overrides + void init() { } virtual void waitForEvent(double timeout); virtual Type getEvent(CEvent& event, UInt32& dataID); virtual bool addEvent(UInt32 dataID); @@ -40,7 +41,6 @@ public: virtual CEventQueueTimer* newTimer(double duration, bool oneShot) const; virtual void deleteTimer(CEventQueueTimer*) const; - void cacheCurrentEventQueueRef() { } private: typedef std::deque CEventDeque; diff --git a/src/lib/base/IEventQueue.h b/src/lib/base/IEventQueue.h index 6f855c30..dfdd7eb9 100644 --- a/src/lib/base/IEventQueue.h +++ b/src/lib/base/IEventQueue.h @@ -176,8 +176,6 @@ public: virtual CEvent::Type registerTypeOnce(CEvent::Type& type, const char* name) = 0; - - virtual void cacheCurrentEventQueueRef() = 0; //@} //! @name accessors diff --git a/src/lib/base/IEventQueueBuffer.h b/src/lib/base/IEventQueueBuffer.h index 08a3f238..8e3c5224 100644 --- a/src/lib/base/IEventQueueBuffer.h +++ b/src/lib/base/IEventQueueBuffer.h @@ -39,6 +39,12 @@ public: //! @name manipulators //@{ + + //! Initialize + /*! + Useful for platform-specific initialisation from a specific thread. + */ + virtual void init() = 0; //! Block waiting for an event /*! @@ -66,8 +72,6 @@ public: return at some future time if it's blocked waiting on an event. */ virtual bool addEvent(UInt32 dataID) = 0; - - virtual void cacheCurrentEventQueueRef() = 0; //@} //! @name accessors diff --git a/src/lib/platform/CMSWindowsEventQueueBuffer.h b/src/lib/platform/CMSWindowsEventQueueBuffer.h index cd6e0397..c63a62bf 100644 --- a/src/lib/platform/CMSWindowsEventQueueBuffer.h +++ b/src/lib/platform/CMSWindowsEventQueueBuffer.h @@ -32,6 +32,7 @@ public: virtual ~CMSWindowsEventQueueBuffer(); // IEventQueueBuffer overrides + virtual void init() { } virtual void waitForEvent(double timeout); virtual Type getEvent(CEvent& event, UInt32& dataID); virtual bool addEvent(UInt32 dataID); @@ -40,8 +41,6 @@ public: newTimer(double duration, bool oneShot) const; virtual void deleteTimer(CEventQueueTimer*) const; - virtual void cacheCurrentEventQueueRef() {} - private: DWORD m_thread; UINT m_userEvent; diff --git a/src/lib/platform/COSXEventQueueBuffer.cpp b/src/lib/platform/COSXEventQueueBuffer.cpp index ce79fded..5c572550 100644 --- a/src/lib/platform/COSXEventQueueBuffer.cpp +++ b/src/lib/platform/COSXEventQueueBuffer.cpp @@ -33,7 +33,7 @@ class CEventQueueTimer { }; COSXEventQueueBuffer::COSXEventQueueBuffer(IEventQueue* events) : m_eventQueue(events), m_event(NULL), - m_threadEventQueueRef(NULL) + m_carbonEventQueue(NULL) { // do nothing } @@ -46,6 +46,12 @@ COSXEventQueueBuffer::~COSXEventQueueBuffer() } } +void +COSXEventQueueBuffer::init() +{ + m_carbonEventQueue = GetCurrentEventQueue(); +} + void COSXEventQueueBuffer::waitForEvent(double timeout) { @@ -100,9 +106,15 @@ COSXEventQueueBuffer::addEvent(UInt32 dataID) kEventAttributeNone, &event); - if (error == noErr & m_threadEventQueueRef != NULL) { - error = PostEventToQueue(m_threadEventQueueRef, event, - kEventPriorityStandard); + if (error == noErr) { + + assert(m_carbonEventQueue != NULL); + + error = PostEventToQueue( + m_carbonEventQueue, + event, + kEventPriorityStandard); + ReleaseEvent(event); } @@ -128,9 +140,3 @@ COSXEventQueueBuffer::deleteTimer(CEventQueueTimer* timer) const { delete timer; } - -void -COSXEventQueueBuffer::cacheCurrentEventQueueRef() -{ - m_threadEventQueueRef = GetCurrentEventQueue(); -} diff --git a/src/lib/platform/COSXEventQueueBuffer.h b/src/lib/platform/COSXEventQueueBuffer.h index 6bebbf11..f571beef 100644 --- a/src/lib/platform/COSXEventQueueBuffer.h +++ b/src/lib/platform/COSXEventQueueBuffer.h @@ -31,6 +31,7 @@ public: virtual ~COSXEventQueueBuffer(); // IEventQueueBuffer overrides + virtual void init(); virtual void waitForEvent(double timeout); virtual Type getEvent(CEvent& event, UInt32& dataID); virtual bool addEvent(UInt32 dataID); @@ -38,12 +39,11 @@ public: virtual CEventQueueTimer* newTimer(double duration, bool oneShot) const; virtual void deleteTimer(CEventQueueTimer*) const; - virtual void cacheCurrentEventQueueRef(); private: EventRef m_event; IEventQueue* m_eventQueue; - EventQueueRef m_threadEventQueueRef; + EventQueueRef m_carbonEventQueue; }; #endif diff --git a/src/lib/platform/CXWindowsEventQueueBuffer.h b/src/lib/platform/CXWindowsEventQueueBuffer.h index 656e6415..b53ca23f 100644 --- a/src/lib/platform/CXWindowsEventQueueBuffer.h +++ b/src/lib/platform/CXWindowsEventQueueBuffer.h @@ -37,6 +37,7 @@ public: virtual ~CXWindowsEventQueueBuffer(); // IEventQueueBuffer overrides + virtual void init() { } virtual void waitForEvent(double timeout); virtual Type getEvent(CEvent& event, UInt32& dataID); virtual bool addEvent(UInt32 dataID); @@ -45,8 +46,6 @@ public: newTimer(double duration, bool oneShot) const; virtual void deleteTimer(CEventQueueTimer*) const; - virtual void cacheCurrentEventQueueRef() {} - private: void flush(); diff --git a/src/lib/synergy/CApp.cpp b/src/lib/synergy/CApp.cpp index 06908d8a..4ce07afc 100644 --- a/src/lib/synergy/CApp.cpp +++ b/src/lib/synergy/CApp.cpp @@ -182,18 +182,18 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i) #endif -#ifdef WINAPI_MSWINDOWS - - OSVERSIONINFO osvi; - ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&osvi); - +#ifdef WINAPI_MSWINDOWS + + OSVERSIONINFO osvi; + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + if (osvi.dwMajorVersion < 6) { useDragDrop = false; LOG((CLOG_INFO "ignoring --enable-drag-drop, not supported below vista.")); - } -#endif + } +#endif if (useDragDrop) { argsBase().m_enableDragDrop = true; @@ -415,7 +415,6 @@ CApp::handleIpcMessage(const CEvent& e, void*) void CApp::runEventsLoop(void*) { - m_events->cacheCurrentEventQueueRef(); m_events->loop(); #if defined(MAC_OS_X_VERSION_10_7) diff --git a/src/test/unittests/synergy/CMockEventQueue.h b/src/test/unittests/synergy/CMockEventQueue.h index bc8f28e2..e7e8e87a 100644 --- a/src/test/unittests/synergy/CMockEventQueue.h +++ b/src/test/unittests/synergy/CMockEventQueue.h @@ -61,7 +61,6 @@ public: MOCK_METHOD0(forIKeyState, IKeyStateEvents&()); MOCK_METHOD0(forIPrimaryScreen, IPrimaryScreenEvents&()); MOCK_METHOD0(forIScreen, IScreenEvents&()); - MOCK_METHOD0(cacheCurrentEventQueueRef, void()); }; #endif