• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _TCULNXX11_HPP
2 #define _TCULNXX11_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 "tcuLnx.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 lnx
39 {
40 namespace x11
41 {
42 
43 class DisplayBase
44 {
45 public:
46 					DisplayBase		(EventState& platform);
47 	virtual			~DisplayBase	(void);
48 	virtual void	processEvents	(void) = 0;
49 
50 protected:
51 	EventState&		m_eventState;
52 
53 private:
54 					DisplayBase		(const DisplayBase&);
55 	DisplayBase&	operator=		(const DisplayBase&);
56 };
57 
58 class WindowBase
59 {
60 public:
61 							WindowBase		(void);
62 	virtual					~WindowBase		(void);
63 
64 	virtual void			setVisibility	(bool visible) = 0;
65 
66 	virtual void			processEvents	(void) = 0;
67 	virtual DisplayBase&	getDisplay		(void) = 0;
68 
69 	virtual void			getDimensions	(int* width, int* height) const = 0;
70 	virtual void			setDimensions	(int width, int height) = 0;
71 
72 protected:
73 	bool					m_visible;
74 
75 private:
76 							WindowBase		(const WindowBase&);
77 	WindowBase&				operator=		(const WindowBase&);
78 };
79 
80 class XlibDisplay : public DisplayBase
81 {
82 public:
83 					XlibDisplay		(EventState& platform, const char* name);
84 	virtual			~XlibDisplay	(void);
85 
getXDisplay(void)86 	::Display*		getXDisplay		(void) { return m_display;		}
getDeleteAtom(void)87 	Atom			getDeleteAtom	(void) { return m_deleteAtom;	}
88 
89 	::Visual*		getVisual		(VisualID visualID);
90 	bool			getVisualInfo	(VisualID visualID, XVisualInfo& dst);
91 	void			processEvents	(void);
92 	void			processEvent	(XEvent& event);
93 
94 protected:
95 	::Display*		m_display;
96 	Atom			m_deleteAtom;
97 
98 private:
99 					XlibDisplay		(const XlibDisplay&);
100 	XlibDisplay&	operator=		(const XlibDisplay&);
101 };
102 
103 class XlibWindow : public WindowBase
104 {
105 public:
106 					XlibWindow			(XlibDisplay& display, int width, int height,
107 										::Visual* visual);
108 					~XlibWindow			(void);
109 
110 	void			setVisibility	(bool visible);
111 
112 	void			processEvents	(void);
getDisplay(void)113 	DisplayBase&	getDisplay		(void) { return (DisplayBase&)m_display; }
getXID(void)114 	::Window&		getXID			(void) { return m_window; }
115 
116 	void			getDimensions	(int* width, int* height) const;
117 	void			setDimensions	(int width, int height);
118 
119 protected:
120 	XlibDisplay&	m_display;
121 	::Colormap		m_colormap;
122 	::Window		m_window;
123 
124 private:
125 					XlibWindow		(const XlibWindow&);
126 	XlibWindow&		operator=		(const XlibWindow&);
127 };
128 
129 } // x11
130 } // lnx
131 } // tcu
132 
133 #endif // _TCULNXX11_HPP
134