diff options
author | Philipp Kerling <pkerling@casix.org> | 2017-06-09 09:12:07 +0200 |
---|---|---|
committer | Philipp Kerling <pkerling@casix.org> | 2017-06-09 09:56:36 +0200 |
commit | 59b935153d7f8950b7e70675b7da00fc517f543c (patch) | |
tree | c381959f6354cfa188d033f282ae6d290d9e6063 | |
parent | 304a1873833f3fd4b5ab8966d8efe4fcd59a3a7f (diff) |
Get rid of IWinEvents inheriting Observer
Only used by CWinEventsLinux which should inherit Observer directly
instead. It is completely unclear from looking at IWinEvents
what the Notify function is actually meant to receive notifications for.
-rw-r--r-- | xbmc/windowing/WinEvents.cpp | 21 | ||||
-rw-r--r-- | xbmc/windowing/WinEvents.h | 4 | ||||
-rw-r--r-- | xbmc/windowing/WinEventsLinux.cpp | 5 | ||||
-rw-r--r-- | xbmc/windowing/WinEventsLinux.h | 3 |
4 files changed, 9 insertions, 24 deletions
diff --git a/xbmc/windowing/WinEvents.cpp b/xbmc/windowing/WinEvents.cpp index 7dd44d05e6..068e688e20 100644 --- a/xbmc/windowing/WinEvents.cpp +++ b/xbmc/windowing/WinEvents.cpp @@ -19,9 +19,8 @@ */ #include "WinEvents.h" -#include "peripherals/Peripherals.h" -#include "threads/SingleLock.h" -#include "ServiceBroker.h" + +#include "system.h" #if defined(TARGET_WINDOWS) #include "windows/WinEventsWin32.h" @@ -57,30 +56,14 @@ #endif static WinEventsType g_imp; -static CCriticalSection g_lock; -static bool g_init = false; - -void Init() -{ - CSingleLock lock(g_lock); - if (!g_init) - { - CServiceBroker::GetPeripherals().RegisterObserver(&g_imp); - g_init = true; - } -} void CWinEvents::MessagePush(XBMC_Event* ev) { - if (!g_init) - Init(); g_imp.MessagePush(ev); } bool CWinEvents::MessagePump() { - if (!g_init) - Init(); return g_imp.MessagePump(); } diff --git a/xbmc/windowing/WinEvents.h b/xbmc/windowing/WinEvents.h index de08b00d3d..5c895a4da9 100644 --- a/xbmc/windowing/WinEvents.h +++ b/xbmc/windowing/WinEvents.h @@ -23,16 +23,14 @@ #pragma once -#include "utils/Observer.h" #include "XBMC_events.h" -class IWinEvents : public Observer +class IWinEvents { public: virtual ~IWinEvents() {}; virtual bool MessagePump() = 0; virtual void MessagePush(XBMC_Event* ev) {}; - virtual void Notify(const Observable &obs, const ObservableMessage msg) {}; }; class CWinEvents { diff --git a/xbmc/windowing/WinEventsLinux.cpp b/xbmc/windowing/WinEventsLinux.cpp index 5d48d904ef..cc6f2c5b38 100644 --- a/xbmc/windowing/WinEventsLinux.cpp +++ b/xbmc/windowing/WinEventsLinux.cpp @@ -29,6 +29,9 @@ #include "input/MouseStat.h" #include "utils/log.h" #include "powermanagement/PowerManager.h" +#include "peripherals/Peripherals.h" +#include "ServiceBroker.h" + bool CWinEventsLinux::m_initialized = false; CLinuxInputDevices CWinEventsLinux::m_devices; @@ -45,13 +48,13 @@ void CWinEventsLinux::RefreshDevices() bool CWinEventsLinux::IsRemoteLowBattery() { return m_devices.IsRemoteLowBattery(); - return false; } bool CWinEventsLinux::MessagePump() { if (!m_initialized) { + CServiceBroker::GetPeripherals().RegisterObserver(this); m_devices.InitAvailable(); m_checkHotplug = std::unique_ptr<CLinuxInputDevicesCheckHotplugged>(new CLinuxInputDevicesCheckHotplugged(m_devices)); m_initialized = true; diff --git a/xbmc/windowing/WinEventsLinux.h b/xbmc/windowing/WinEventsLinux.h index f806ba5ae3..169b36b205 100644 --- a/xbmc/windowing/WinEventsLinux.h +++ b/xbmc/windowing/WinEventsLinux.h @@ -23,10 +23,11 @@ #pragma once #include <memory> +#include "utils/Observer.h" #include "windowing/WinEvents.h" #include "input/linux/LinuxInputDevices.h" -class CWinEventsLinux : public IWinEvents +class CWinEventsLinux : public IWinEvents, public Observer { public: CWinEventsLinux(); |