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