2 * Copyright (C) 2011-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/>.
26 #include <wayland-client.h>
28 #include "windowing/DllWaylandClient.h"
29 #include "windowing/WaylandProtocol.h"
32 namespace xw = xbmc::wayland;
34 xw::Display::Display(IDllWaylandClient &clientLibrary) :
35 m_clientLibrary(clientLibrary),
36 m_display(m_clientLibrary.wl_display_connect(NULL))
38 /* wl_display_connect won't throw when it fails, but it does
39 * return NULL on failure. If this object would be incomplete
40 * then that is a fatal error for the backend and we should
41 * throw a runtime_error for the main connection manager to handle
46 ss << "Failed to connect to "
47 << getenv("WAYLAND_DISPLAY");
48 throw std::runtime_error(ss.str());
52 xw::Display::~Display()
54 m_clientLibrary.wl_display_flush(m_display);
55 m_clientLibrary.wl_display_disconnect(m_display);
59 xw::Display::GetWlDisplay()
64 EGLNativeDisplayType *
65 xw::Display::GetEGLNativeDisplay()
70 /* Create a sync callback object. This can be wrapped in an
71 * xbmc::wayland::Callback object to call an arbitrary function
72 * as soon as the display has finished processing all commands.
74 * This does not block until a synchronization is complete -
75 * consider using a function like WaitForSynchronize to do that */
79 struct wl_callback *callback =
80 protocol::CreateWaylandObject<struct wl_callback *,
81 struct wl_display *> (m_clientLibrary,
83 m_clientLibrary.Get_wl_callback_interface());
84 protocol::CallMethodOnWaylandObject(m_clientLibrary,