Repository navigation
Expand file tree
/
Copy pathlinux_window.h
More file actions
107 lines (92 loc) · 2.47 KB
/
Copy pathlinux_window.h
File metadata and controls
107 lines (92 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <cstdint>
#include <optional>
#include <queue>
#include <GL/glx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "core/auto_release.h"
#include "events/event.h"
#include "graphics/material_manager.h"
#include "graphics/texture_manager.h"
#include "graphics/window.h"
#include "graphics/window_manager.h"
namespace iris
{
/**
* Abstract implementation of Window for linux.
*/
class LinuxWindow : public Window
{
public:
/**
* Construct a new LinuxWindow.
*
* @param width
* Width of window.
*
* @param height
* Height of window.
*
* @param window_manager
* Window manager object.
*
* @param texture_manager
* Texture manager object.
*
* @param material_manager
* Material manager object.
*/
LinuxWindow(
std::uint32_t width,
std::uint32_t height,
WindowManager &window_manager,
TextureManager &texture_manager,
MaterialManager &material_manager);
/**
* Get the natural scale for the screen. This value reflects the scale
* factor needed to convert from the default logical coordinate space into
* the device coordinate space of this screen.
*
* @returns
* Screen scale factor.
*/
std::uint32_t screen_scale() const override;
/**
* Pump the next user input event. Result will be empty if there are no
* new events.
*
* @returns
* Optional event.
*/
std::optional<Event> pump_event() override;
/**
* Get display handle.
*
* @returns
* Handle to X11 display.
*/
Display *display() const;
/**
* Get window handle.
*
* @returns
* Handle to X11 window.
*/
::Window window() const;
private:
/** X11 display handle. */
AutoRelease<Display *, nullptr> display_;
/** X11 window handle. */
AutoRelease<::Window, 0> window_;
/** OpenGL context object. */
AutoRelease<GLXContext, nullptr> context_;
/** Queue of input events. */
std::queue<Event> events_;
};
}