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
This commit is contained in:
parent
38722f7308
commit
3598eb6a47
12 changed files with 13 additions and 92 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
//@}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<uint32_t>;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2025 Stephen Jensen <sjensen313@proton.me>
|
||||
* 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
|
||||
* SPDX-FileCopyrightText: (C) 2025 Stephen Jensen <sjensen313@proton.me>
|
||||
* 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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue