Wayland++
1.0.1
C++ Bindings for Wayland
Toggle main menu visibility
Loading...
Searching...
No Matches
dump.cpp
1
/*
2
* Copyright (c) 2017-2019, Philipp Kerling
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* 1. Redistributions of source code must retain the above copyright notice, this
9
* list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
*
14
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
*/
25
30
31
#include <iostream>
32
#include <cstdint>
33
34
#include <
wayland-client.hpp
>
35
36
using namespace
wayland;
37
38
// Wayland protocol info dumper
39
class
dumper
40
{
41
private
:
42
// global objects
43
display_t display;
44
registry_t registry;
45
46
public
:
47
dumper() =
default
;
48
dumper(
const
dumper&) =
delete
;
49
dumper(dumper&&) noexcept = delete;
50
~dumper() noexcept = default;
51
dumper& operator=(const dumper&) = delete;
52
dumper& operator=(dumper&&) noexcept = delete;
53
54
void
run()
55
{
56
std::vector<output_t> outputs;
57
// retrieve global objects
58
registry = display.get_registry();
59
registry.on_global() = [&] (uint32_t name,
const
std::string& interface, uint32_t version)
60
{
61
std::cout <<
"* Global interface "
<<
interface
<< " (name
" << name << "
version
" << version << "
)
" << std::endl;
62
if(interface == output_t::interface_name)
63
{
64
outputs.emplace_back();
65
auto& output = outputs.back();
66
registry.bind(name, output, version);
67
}
68
};
69
// Print global information
70
display.roundtrip();
71
std::cout << "
------
" << std::endl;
72
73
for(auto& output : outputs)
74
{
75
output.on_geometry() = [&](int32_t x, int32_t y, int32_t physw, int32_t physh, output_subpixel subp, const std::string& make, const std::string& model, const output_transform& transform)
76
{
77
std::cout << "
* Output geometry
for
" << output.get_id() << "
:
" << std::endl
78
<< "
Maker:
" << make << std::endl
79
<< "
Model:
" << model << std::endl
80
<< "
X:
" << x << std::endl
81
<< "
Y:
" << y << std::endl
82
<< "
PhysW:
" << physw << "
mm
" << std::endl
83
<< "
PhysH:
" << physh << "
mm
" << std::endl
84
<< "
Subpix:
" << static_cast<unsigned int>(subp) << std::endl
85
<< "
Transf:
" << static_cast<unsigned int>(transform) << std::endl;
86
};
87
output.on_scale() = [&](int32_t scale)
88
{
89
std::cout << "
* Output scale
for
" << output.get_id() << "
:
" << scale << std::endl;
90
};
91
output.on_mode() = [&](uint32_t flags, int32_t width, int32_t height, int32_t refresh)
92
{
93
std::cout << "
* Output mode
for
" << output.get_id() << "
:
" << std::endl
94
<< "
Width:
" << width << std::endl
95
<< "
Height:
" << height << std::endl
96
<< "
Refresh:
" << refresh << "
mHz
" << std::endl
97
<< "
Flags:
" << flags << std::endl;
98
};
99
}
100
101
// Print output information
102
display.roundtrip();
103
104
// Release outputs
105
for(auto &output : outputs)
106
output.release();
107
display.roundtrip();
108
}
109
};
110
111
int main()
112
{
113
dumper d;
114
d.run();
115
return 0;
116
}
wayland-client.hpp
example
dump.cpp
Generated on
for Wayland++ by
1.17.0