vsg: include/vsg/platform/xcb/Xcb_Window.h Source File

vsg 1.1.10 VulkanSceneGraph library |

Loading...
Searching...
No Matches
Xcb_Window.h
1/* <editor-fold desc="MIT License">
2
3Copyright(c) 2018 Robert Osfield
4
5Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
7The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
9THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
11</editor-fold> */
12
13#pragma once
14
15#include <vsg/app/Window.h>
16#include <vsg/ui/KeyEvent.h>
17
18#include <xcb/xcb.h>
19
20#include <vulkan/vulkan_xcb.h>
21
22namespace vsgXcb
23{
24
26 class KeyboardMap : public vsg::Object
27 {
28 public:
29 KeyboardMap();
30
31 using KeycodeModifier = std::pair<uint16_t, uint16_t>;
32 using KeycodeMap = std::map<KeycodeModifier, vsg::KeySymbol>;
33
34 void add(uint16_t keycode, uint16_t modifier, vsg::KeySymbol key);
35
36 void add(uint16_t keycode, std::initializer_list<std::pair<uint16_t, vsg::KeySymbol>> combinations);
37
38 vsg::KeySymbol getKeySymbol(uint16_t keycode, uint16_t modifier);
39 vsg::KeyModifier getKeyModifier(vsg::KeySymbol keySym, uint16_t modifier, bool pressed);
40
41 protected:
42 KeycodeMap _keycodeMap;
43 uint16_t _modifierMask;
44 };
45
47 class Xcb_Surface : public vsg::Surface
48 {
49 public:
50 Xcb_Surface(vsg::Instance* instance, xcb_connection_t* connection, xcb_window_t window);
51 };
52
54 class Xcb_Window : public vsg::Inherit<vsg::Window, Xcb_Window>
55 {
56 public:
57 Xcb_Window(vsg::ref_ptr<vsg::WindowTraits> traits);
58 Xcb_Window() = delete;
59 Xcb_Window(const Xcb_Window&) = delete;
60 Xcb_Window& operator=(const Xcb_Window&) = delete;
61
62 const char* instanceExtensionSurfaceName() const override { return VK_KHR_XCB_SURFACE_EXTENSION_NAME; }
63
64 bool valid() const override;
65
66 bool visible() const override;
67
68 void releaseWindow() override;
69 void releaseConnection() override;
70
71 bool pollEvents(vsg::UIEvents& events) override;
72
73 void resize() override;
74
75 protected:
76 ~Xcb_Window();
77
78 void _initSurface() override;
79
80 xcb_connection_t* _connection = nullptr;
81 xcb_screen_t* _screen = nullptr;
82 xcb_window_t _window{};
83 xcb_atom_t _wmProtocols{};
84 xcb_atom_t _wmDeleteWindow{};
85
86 bool _windowMapped = false;
87
88 xcb_timestamp_t _first_xcb_timestamp = 0;
89 vsg::clock::time_point _first_xcb_time_point;
90
91 vsg::ref_ptr<KeyboardMap> _keyboard;
92 };
93
94} // namespace vsgXcb
95
96EVSG_type_name(vsgXcb::Xcb_Window);
vsg::Inherit
Definition Inherit.h:28
vsg::Instance
Instance encapsulates the VkInstance.
Definition Instance.h:46
vsg::Object
Definition Object.h:60
vsg::Surface
Surface encapsulates VkSurfaceKHR.
Definition Surface.h:22
vsg::ref_ptr
Definition ref_ptr.h:22
vsgXcb::Xcb_Window
Xcb_Window implements Xcb specific window creation, event handling and vulkan Surface setup.
Definition Xcb_Window.h:55
vsgXcb::Xcb_Window::pollEvents
bool pollEvents(vsg::UIEvents &events) override
get the list of events since the last pollEvents() call by splicing bufferEvents with polled windowin...
vsgXcb::Xcb_Window::releaseWindow
void releaseWindow() override
vsgXcb::Xcb_Window::releaseConnection
void releaseConnection() override