2 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
22 #if defined (HAVE_WAYLAND)
27 #include <boost/noncopyable.hpp>
28 #include <boost/scope_exit.hpp>
29 #include <boost/scoped_ptr.hpp>
33 #include <wayland-client.h>
34 #include <xkbcommon/xkbcommon.h>
36 #include "Application.h"
37 #include "WindowingFactory.h"
38 #include "WinEvents.h"
39 #include "WinEventsWayland.h"
41 #include "DllWaylandClient.h"
42 #include "DllXKBCommon.h"
43 #include "WaylandProtocol.h"
47 IDllWaylandClient *g_clientLibrary = NULL;
48 struct wl_display *g_display = NULL;
51 CWinEventsWayland::CWinEventsWayland()
55 void CWinEventsWayland::RefreshDevices()
59 bool CWinEventsWayland::IsRemoteLowBattery()
64 /* This function reads the display connection and dispatches
65 * any events through the specified object listeners */
66 bool CWinEventsWayland::MessagePump()
71 /* It is very important that these functions occurr in this order.
72 * Deadlocks might occurr otherwise.
74 * The first function dispatches any pending events that have been
75 * determined from prior reads of the event queue without *also*
76 * reading the event queue.
78 * The second function flushes the output buffer of any requests
79 * to be made to the server, including requests that should have
80 * been made in response to just-dispatched events earlier.
82 * The third function reads the input buffer and dispatches any events
85 * If the functions are not called in this order, you might run into
86 * a situation where pending-dispatch events might have generated a
87 * write to the event queue in order to keep us awake (frame events
88 * are a particular culprit here), or where events that we need to
89 * dispatch in order to keep going are never read.
91 g_clientLibrary->wl_display_dispatch_pending(g_display);
92 g_clientLibrary->wl_display_flush(g_display);
93 g_clientLibrary->wl_display_dispatch(g_display);
98 size_t CWinEventsWayland::GetQueueSize()
100 /* We can't query the size of the queue */
104 void CWinEventsWayland::SetWaylandDisplay(IDllWaylandClient *clientLibrary,
105 struct wl_display *d)
107 g_clientLibrary = clientLibrary;
111 void CWinEventsWayland::DestroyWaylandDisplay()
113 /* We should make sure that everything else is gone first before
114 * destroying the display */