Added initial support for displaying on Wayland compositors.
[vuplus_xbmc] / xbmc / windowing / WinEvents.cpp
1 /*
2  *      Copyright (C) 2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "WinEvents.h"
22 #include "peripherals/Peripherals.h"
23 #include "threads/SingleLock.h"
24
25 #if   defined(TARGET_WINDOWS)
26 #include "windows/WinEventsWin32.h"
27 #define WinEventsType CWinEventsWin32
28
29 #elif defined(TARGET_DARWIN_OSX)
30 #include "osx/WinEventsOSX.h"
31 #define WinEventsType CWinEventsOSX
32
33 #elif defined(TARGET_DARWIN_IOS)
34 #include "osx/WinEventsIOS.h"
35 #define WinEventsType CWinEventsIOS
36
37 #elif defined(TARGET_ANDROID)
38 #include "android/WinEventsAndroid.h"
39 #define WinEventsType CWinEventsAndroid
40
41 #elif (defined(TARGET_FREEBSD) || defined(TARGET_LINUX)) && defined(HAS_SDL_WIN_EVENTS)
42 #include "WinEventsSDL.h"
43 #define WinEventsType CWinEventsSDL
44
45 #elif defined(HAVE_WAYLAND)
46 #include "WinEventsWayland.h"
47 #define WinEventsType CWinEventsWayland
48
49 #elif defined(TARGET_LINUX) && defined(HAS_LINUX_EVENTS)
50 #include "WinEventsLinux.h"
51 #define WinEventsType CWinEventsLinux
52 #endif
53
54 static WinEventsType    g_imp;
55 static CCriticalSection g_lock;
56 static bool             g_init  = false;
57
58 void Init()
59 {
60   CSingleLock lock(g_lock);
61   if (!g_init)
62   {
63     PERIPHERALS::CPeripherals::Get().RegisterObserver(&g_imp);
64     g_init = true;
65   }
66 }
67
68 void CWinEvents::MessagePush(XBMC_Event* ev)
69 {
70   if (!g_init)
71     Init();
72   g_imp.MessagePush(ev);
73 }
74
75 bool CWinEvents::MessagePump()
76 {
77   if (!g_init)
78     Init();
79   return g_imp.MessagePump();
80 }
81
82 size_t CWinEvents::GetQueueSize()
83 {
84   if (!g_init)
85     Init();
86   return g_imp.GetQueueSize();
87 }
88