1 #ifndef _TCULNXX11XCB_HPP 2 #define _TCULNXX11XCB_HPP 3 /*------------------------------------------------------------------------- 4 * drawElements Quality Program Tester Core 5 * ---------------------------------------- 6 * 7 * Copyright (c) 2016 The Khronos Group Inc. 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 using XCB utilities. 24 *//*--------------------------------------------------------------------*/ 25 26 #include "tcuLnxX11.hpp" 27 #include <xcb/xcb.h> 28 29 namespace tcu 30 { 31 namespace lnx 32 { 33 namespace x11 34 { 35 36 class XcbDisplay : public DisplayBase 37 { 38 public: 39 XcbDisplay(EventState &platform, const char *name); 40 virtual ~XcbDisplay(void); 41 getScreen(void)42 xcb_screen_t *getScreen(void) 43 { 44 return m_screen; 45 } getConnection(void)46 xcb_connection_t *getConnection(void) 47 { 48 return m_connection; 49 } 50 51 void processEvents(void); 52 static bool hasDisplay(const char *name); 53 54 static DisplayState s_displayState; 55 56 protected: 57 xcb_screen_t *m_screen; 58 xcb_connection_t *m_connection; 59 60 private: 61 XcbDisplay(const XcbDisplay &); 62 XcbDisplay &operator=(const XcbDisplay &); 63 }; 64 65 class XcbWindow : public WindowBase 66 { 67 public: 68 XcbWindow(XcbDisplay &display, int width, int height, xcb_visualid_t *visual); 69 ~XcbWindow(void); 70 71 void setVisibility(bool visible); 72 73 void processEvents(void); getDisplay(void)74 DisplayBase &getDisplay(void) 75 { 76 return (DisplayBase &)m_display; 77 } getXID(void)78 xcb_window_t &getXID(void) 79 { 80 return m_window; 81 } 82 83 void getDimensions(int *width, int *height) const; 84 void setDimensions(int width, int height); 85 86 protected: 87 XcbDisplay &m_display; 88 xcb_colormap_t m_colormap; 89 xcb_window_t m_window; 90 91 private: 92 XcbWindow(const XcbWindow &); 93 XcbWindow &operator=(const XcbWindow &); 94 }; 95 96 } // namespace x11 97 } // namespace lnx 98 } // namespace tcu 99 100 #endif // _TCULNXX11XCB_HPP 101