1 #ifndef _TCUX11_HPP
2 #define _TCUX11_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief X11 utilities.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 #include "gluRenderConfig.hpp"
28 #include "gluPlatform.hpp"
29 #include "deMutex.hpp"
30 
31 #include <X11/Xlib.h>
32 #include <X11/Xutil.h>
33 #include <X11/keysym.h>
34 #include <X11/Xatom.h>
35 
36 namespace tcu
37 {
38 namespace x11
39 {
40 
41 class EventState
42 {
43 public:
44 							EventState				(void);
45 	virtual					~EventState				(void);
46 
47 	void					setQuitFlag				(bool quit);
48 	bool					getQuitFlag				(void);
49 
50 protected:
51 	de::Mutex				m_mutex;
52 	bool					m_quit;
53 
54 private:
55 							EventState				(const EventState&);
56 	EventState&				operator=				(const EventState&);
57 };
58 
59 class Display
60 {
61 public:
62 							Display					(EventState& platform, const char* name);
63 	virtual					~Display				(void);
64 
getXDisplay(void)65 	::Display*				getXDisplay				(void) { return m_display;		}
getDeleteAtom(void)66 	Atom					getDeleteAtom			(void) { return m_deleteAtom;	}
67 
68 	::Visual*				getVisual				(VisualID visualID);
69 	bool					getVisualInfo			(VisualID visualID, XVisualInfo& dst);
70 	void					processEvents			(void);
71 
72 protected:
73 	EventState&				m_eventState;
74 	::Display*				m_display;
75 	Atom					m_deleteAtom;
76 
77 private:
78 							Display					(const Display&);
79 	Display&				operator=				(const Display&);
80 };
81 
82 class Window
83 {
84 public:
85 							Window					(Display& display, int width, int height,
86 													 ::Visual* visual);
87 							~Window					(void);
88 
89 	void					setVisibility			(bool visible);
90 
91 	void					processEvents			(void);
getDisplay(void)92 	Display&				getDisplay				(void) { return m_display; }
getXID(void)93 	::Window&				getXID					(void) { return m_window; }
94 
95 	void					getDimensions			(int* width, int* height) const;
96 	void					setDimensions			(int width, int height);
97 
98 protected:
99 
100 	Display&				m_display;
101 	::Colormap				m_colormap;
102 	::Window				m_window;
103 	bool					m_visible;
104 
105 private:
106 							Window					(const Window&);
107 	Window&					operator=				(const Window&);
108 };
109 
110 } // x11
111 } // tcu
112 
113 #endif // _TCUX11_HPP
114