1#ifndef _TCULNXWAYLAND_HPP 2#define _TCULNXWAYLAND_HPP 3/*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 5 * ---------------------------------------- 6 * 7 * Copyright (c) 2014 The Android Open Source Project 8 * Copyright (c) 2016 The Khronos Group Inc. 9 * Copyright (c) 2016 Mun Gwan-gyeong <elongbug@gmail.com> 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); 12 * you may not use this file except in compliance with the License. 13 * You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 * 23 *//*! 24 * \file 25 * \brief wayland utilities. 26 *//*--------------------------------------------------------------------*/ 27 28#include "tcuDefs.hpp" 29#include "gluRenderConfig.hpp" 30#include "gluPlatform.hpp" 31#include "tcuLnx.hpp" 32 33#include <wayland-client.h> 34#include <wayland-egl.h> 35#include "xdg-shell.h" 36 37namespace tcu 38{ 39namespace lnx 40{ 41namespace wayland 42{ 43 44class Display 45{ 46public: 47 Display (EventState& platform, const char* name); 48 virtual ~Display (void); 49 50 struct wl_display* getDisplay (void) { return m_display; } 51 struct wl_compositor* getCompositor (void) { return m_compositor; } 52 struct xdg_wm_base* getShell (void) { return m_shell; } 53 54 void processEvents (void); 55 static bool hasDisplay (const char* name); 56 57 enum DisplayState 58 { 59 DISPLAY_STATE_UNKNOWN = -1, 60 DISPLAY_STATE_UNAVAILABLE, 61 DISPLAY_STATE_AVAILABLE 62 }; 63 static DisplayState s_displayState; 64 65protected: 66 EventState& m_eventState; 67 struct wl_display* m_display; 68 struct wl_registry* m_registry; 69 struct wl_compositor* m_compositor; 70 struct xdg_wm_base* m_shell; 71 72private: 73 Display (const Display&); 74 Display& operator= (const Display&); 75 76 static const struct wl_registry_listener s_registryListener; 77 78 static void handleGlobal (void* data, struct wl_registry* registry, uint32_t id, const char* interface, uint32_t version); 79 static void handleGlobalRemove (void* data, struct wl_registry* registry, uint32_t name); 80}; 81 82class Window 83{ 84public: 85 Window (Display& display, int width, int height); 86 ~Window (void); 87 88 void setVisibility (bool visible); 89 90 void processEvents (void); 91 Display& getDisplay (void) { return m_display; } 92 void* getSurface (void) { return m_surface; } 93 void* getWindow (void) { return m_window; } 94 95 void getDimensions (int* width, int* height) const; 96 void setDimensions (int width, int height); 97 98protected: 99 100 Display& m_display; 101 struct wl_egl_window* m_window; 102 struct wl_surface* m_surface; 103 struct xdg_surface* m_xdgSurface; 104 struct xdg_toplevel* m_topLevel; 105 bool m_configured; 106 bool m_visible; 107 108private: 109 Window (const Window&); 110 Window& operator= (const Window&); 111 112 static const struct xdg_surface_listener s_xdgSurfaceListener; 113 static const struct xdg_wm_base_listener s_wmBaseListener; 114 115 static void handlePing (void* data, struct xdg_wm_base* shellSurface, uint32_t serial); 116 static void handleConfigure (void* data, struct xdg_surface* shellSurface, uint32_t serial); 117 118 static bool s_addWMBaseListener; 119}; 120 121} // wayland 122} // lnx 123} // tcu 124 125#endif // _TCULNXWAYLAND_HPP 126