From 3598eb6a47468a446f5d6c0d5d9015cd62ce8efd Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 1 Jan 2026 09:26:09 -0500 Subject: [PATCH] refactor: RM IEventQueueBuffer::newTimer and IEventQueueBuffer::deleteTimer port: https://github.com/input-leap/input-leap/pull/1592 Original Message: base: Remove IEventQueueBuffor newTimer and deleteTimer APIs In the current implementation timers are not platform-specific. On all currently supported platforms timer constrution and destruction is simple new and delete, so it does not make sense having this customization point. Original Author: p12tic Ported By: sithlord48 --- src/lib/base/EventQueue.cpp | 9 +++++---- src/lib/base/IEventQueueBuffer.h | 20 ------------------- src/lib/base/SimpleEventQueueBuffer.cpp | 15 +------------- src/lib/base/SimpleEventQueueBuffer.h | 3 +-- src/lib/platform/EiEventQueueBuffer.cpp | 11 ---------- src/lib/platform/EiEventQueueBuffer.h | 2 -- .../platform/MSWindowsEventQueueBuffer.cpp | 12 +---------- src/lib/platform/MSWindowsEventQueueBuffer.h | 3 +-- src/lib/platform/OSXEventQueueBuffer.cpp | 12 +---------- src/lib/platform/OSXEventQueueBuffer.h | 3 +-- src/lib/platform/XWindowsEventQueueBuffer.cpp | 12 +---------- src/lib/platform/XWindowsEventQueueBuffer.h | 3 +-- 12 files changed, 13 insertions(+), 92 deletions(-) diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index f04eb9863..fc8f8d370 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -1,6 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers + * SPDX-FileCopyrightText: (C) 2025 - 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -9,6 +9,7 @@ #include "base/EventQueue.h" #include "arch/Arch.h" +#include "base/EventQueueTimer.h" #include "base/Log.h" #include "base/SimpleEventQueueBuffer.h" #include "mt/Lock.h" @@ -213,7 +214,7 @@ EventQueueTimer *EventQueue::newTimer(double duration, void *target) { assert(duration > 0.0); - EventQueueTimer *timer = m_buffer->newTimer(duration, false); + EventQueueTimer *timer = new EventQueueTimer; if (target == nullptr) { target = timer; } @@ -230,7 +231,7 @@ EventQueueTimer *EventQueue::newOneShotTimer(double duration, void *target) { assert(duration > 0.0); - EventQueueTimer *timer = m_buffer->newTimer(duration, true); + EventQueueTimer *timer = new EventQueueTimer; if (target == nullptr) { target = timer; } @@ -255,7 +256,7 @@ void EventQueue::deleteTimer(EventQueueTimer *timer) if (Timers::iterator index = m_timers.find(timer); index != m_timers.end()) { m_timers.erase(index); } - m_buffer->deleteTimer(timer); + delete timer; } void EventQueue::addHandler(EventTypes type, void *target, const EventHandler &handler) diff --git a/src/lib/base/IEventQueueBuffer.h b/src/lib/base/IEventQueueBuffer.h index ea79f6481..94c4dc973 100644 --- a/src/lib/base/IEventQueueBuffer.h +++ b/src/lib/base/IEventQueueBuffer.h @@ -65,29 +65,9 @@ public: */ virtual bool addEvent(uint32_t dataID) = 0; - //@} - //! @name accessors - //@{ - //! Check if event queue buffer is empty /*! Return true iff the event queue buffer is empty. */ virtual bool isEmpty() const = 0; - - //! Create a timer object - /*! - Create and return a timer object. The object is opaque and is - used only by the buffer but it must be a valid object (i.e. - not nullptr). - */ - virtual EventQueueTimer *newTimer(double duration, bool oneShot) const = 0; - - //! Destroy a timer object - /*! - Destroy a timer object previously returned by \c newTimer(). - */ - virtual void deleteTimer(EventQueueTimer *) const = 0; - - //@} }; diff --git a/src/lib/base/SimpleEventQueueBuffer.cpp b/src/lib/base/SimpleEventQueueBuffer.cpp index e0123f9cf..5583a6739 100644 --- a/src/lib/base/SimpleEventQueueBuffer.cpp +++ b/src/lib/base/SimpleEventQueueBuffer.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -9,10 +10,6 @@ #include "arch/Arch.h" #include "base/Stopwatch.h" -class EventQueueTimer -{ -}; - // // SimpleEventQueueBuffer // @@ -73,13 +70,3 @@ bool SimpleEventQueueBuffer::isEmpty() const ArchMutexLock lock(m_queueMutex); return !m_queueReady; } - -EventQueueTimer *SimpleEventQueueBuffer::newTimer(double, bool) const -{ - return new EventQueueTimer; -} - -void SimpleEventQueueBuffer::deleteTimer(EventQueueTimer *timer) const -{ - delete timer; -} diff --git a/src/lib/base/SimpleEventQueueBuffer.h b/src/lib/base/SimpleEventQueueBuffer.h index 878f9c06a..7aad33164 100644 --- a/src/lib/base/SimpleEventQueueBuffer.h +++ b/src/lib/base/SimpleEventQueueBuffer.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -35,8 +36,6 @@ public: Type getEvent(Event &event, uint32_t &dataID) override; bool addEvent(uint32_t dataID) override; bool isEmpty() const override; - EventQueueTimer *newTimer(double duration, bool oneShot) const override; - void deleteTimer(EventQueueTimer *) const override; private: using EventDeque = std::deque; diff --git a/src/lib/platform/EiEventQueueBuffer.cpp b/src/lib/platform/EiEventQueueBuffer.cpp index 520c21f29..db7e55ce4 100644 --- a/src/lib/platform/EiEventQueueBuffer.cpp +++ b/src/lib/platform/EiEventQueueBuffer.cpp @@ -8,7 +8,6 @@ #include "platform/EiEventQueueBuffer.h" #include "base/Event.h" -#include "base/EventQueueTimer.h" #include "base/EventTypes.h" #include "base/IEventQueue.h" #include "base/Log.h" @@ -133,14 +132,4 @@ bool EiEventQueueBuffer::isEmpty() const return m_queue.empty(); } -EventQueueTimer *EiEventQueueBuffer::newTimer(double, bool) const -{ - return new EventQueueTimer; -} - -void EiEventQueueBuffer::deleteTimer(EventQueueTimer *timer) const -{ - delete timer; -} - } // namespace deskflow diff --git a/src/lib/platform/EiEventQueueBuffer.h b/src/lib/platform/EiEventQueueBuffer.h index 7cce40ba1..8e7704dbe 100644 --- a/src/lib/platform/EiEventQueueBuffer.h +++ b/src/lib/platform/EiEventQueueBuffer.h @@ -32,8 +32,6 @@ public: Type getEvent(Event &event, uint32_t &dataID) override; bool addEvent(uint32_t dataID) override; bool isEmpty() const override; - EventQueueTimer *newTimer(double duration, bool oneShot) const override; - void deleteTimer(EventQueueTimer *) const override; private: ei *m_ei; diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.cpp b/src/lib/platform/MSWindowsEventQueueBuffer.cpp index 793c1fe58..9f2ebb29a 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/MSWindowsEventQueueBuffer.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -8,7 +9,6 @@ #include "platform/MSWindowsEventQueueBuffer.h" #include "arch/win32/ArchMiscWindows.h" -#include "base/EventQueueTimer.h" #include "base/IEventQueue.h" // @@ -97,13 +97,3 @@ bool MSWindowsEventQueueBuffer::isEmpty() const { return (HIWORD(GetQueueStatus(m_supportedMessages)) == 0); } - -EventQueueTimer *MSWindowsEventQueueBuffer::newTimer(double, bool) const -{ - return new EventQueueTimer; -} - -void MSWindowsEventQueueBuffer::deleteTimer(EventQueueTimer *timer) const -{ - delete timer; -} diff --git a/src/lib/platform/MSWindowsEventQueueBuffer.h b/src/lib/platform/MSWindowsEventQueueBuffer.h index 76fc5791d..14f6360b2 100644 --- a/src/lib/platform/MSWindowsEventQueueBuffer.h +++ b/src/lib/platform/MSWindowsEventQueueBuffer.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -29,8 +30,6 @@ public: Type getEvent(Event &event, uint32_t &dataID) override; bool addEvent(uint32_t dataID) override; bool isEmpty() const override; - EventQueueTimer *newTimer(double duration, bool oneShot) const override; - void deleteTimer(EventQueueTimer *) const override; private: DWORD m_thread; diff --git a/src/lib/platform/OSXEventQueueBuffer.cpp b/src/lib/platform/OSXEventQueueBuffer.cpp index 59db1d022..a4157373e 100644 --- a/src/lib/platform/OSXEventQueueBuffer.cpp +++ b/src/lib/platform/OSXEventQueueBuffer.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 Stephen Jensen * SPDX-FileCopyrightText: (C) 2012 - 2025 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman @@ -9,7 +10,6 @@ #include "platform/OSXEventQueueBuffer.h" #include "base/Event.h" -#include "base/EventQueueTimer.h" #include "base/IEventQueue.h" #include "base/Log.h" @@ -77,13 +77,3 @@ bool OSXEventQueueBuffer::isEmpty() const LOG_DEBUG2("queue is %s", empty ? "empty" : "not empty"); return empty; } - -EventQueueTimer *OSXEventQueueBuffer::newTimer(double, bool) const -{ - return new EventQueueTimer; -} - -void OSXEventQueueBuffer::deleteTimer(EventQueueTimer *timer) const -{ - delete timer; -} diff --git a/src/lib/platform/OSXEventQueueBuffer.h b/src/lib/platform/OSXEventQueueBuffer.h index cf9cce9c7..0057aa2eb 100644 --- a/src/lib/platform/OSXEventQueueBuffer.h +++ b/src/lib/platform/OSXEventQueueBuffer.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2025 Stephen Jensen * SPDX-FileCopyrightText: (C) 2012 - 2025 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman @@ -30,8 +31,6 @@ public: Type getEvent(Event &event, uint32_t &dataID) override; bool addEvent(uint32_t dataID) override; bool isEmpty() const override; - EventQueueTimer *newTimer(double duration, bool oneShot) const override; - void deleteTimer(EventQueueTimer *timer) const override; private: IEventQueue *m_eventQueue; diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 84f24fced..9ef51d922 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -8,7 +9,6 @@ #include "platform/XWindowsEventQueueBuffer.h" #include "base/Event.h" -#include "base/EventQueueTimer.h" #include "base/IEventQueue.h" #include "mt/Thread.h" @@ -183,16 +183,6 @@ bool XWindowsEventQueueBuffer::isEmpty() const return (XPending(m_display) == 0); } -EventQueueTimer *XWindowsEventQueueBuffer::newTimer(double, bool) const -{ - return new EventQueueTimer; -} - -void XWindowsEventQueueBuffer::deleteTimer(EventQueueTimer *timer) const -{ - delete timer; -} - void XWindowsEventQueueBuffer::flush() { // note -- m_mutex must be locked on entry diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index 77b370cf2..2ee807220 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception @@ -37,8 +38,6 @@ public: Type getEvent(Event &event, uint32_t &dataID) override; bool addEvent(uint32_t dataID) override; bool isEmpty() const override; - EventQueueTimer *newTimer(double duration, bool oneShot) const override; - void deleteTimer(EventQueueTimer *) const override; private: void flush();