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
33
#include <
wayland-client.hpp
>
34
35
using namespace
wayland;
36
37
// Wayland protocol info dumper
38
class
dumper
39
{
40
private
:
41
// global objects
42
display_t display;
43
registry_t registry;
44
45
public
:
46
dumper() =
default
;
47
dumper(
const
dumper&) =
delete
;
48
dumper(dumper&&) noexcept = delete;
49
~dumper() noexcept = default;
50
dumper& operator=(const dumper&) = delete;
51
dumper& operator=(dumper&&) noexcept = delete;
52
53
void
run()
54
{
55
std::vector<output_t> outputs;
56
// retrieve global objects
57
registry = display.get_registry();
58
registry.on_global() = [&] (uint32_t name,
const
std::string& interface, uint32_t version)
59
{
60
std::cout <<
"* Global interface "
<<
interface
<< " (name
" << name << "
version
" << version << "
)
" << std::endl;
61
if(interface == output_t::interface_name)
62
{
63
outputs.emplace_back();
64
auto& output = outputs.back();
65
registry.bind(name, output, version);
66
}
67
};
68
// Print global information
69
display.roundtrip();
70
std::cout << "
------
" << std::endl;
71
72
for(auto& output : outputs)
73
{
74
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)
75
{
76
std::cout << "
* Output geometry
for
" << output.get_id() << "
:
" << std::endl
77
<< "
Maker:
" << make << std::endl
78
<< "
Model:
" << model << std::endl
79
<< "
X:
" << x << std::endl
80
<< "
Y:
" << y << std::endl
81
<< "
PhysW:
" << physw << "
mm
" << std::endl
82
<< "
PhysH:
" << physh << "
mm
" << std::endl
83
<< "
Subpix:
" << static_cast<unsigned int>(subp) << std::endl
84
<< "
Transf:
" << static_cast<unsigned int>(transform) << std::endl;
85
};
86
output.on_scale() = [&](int32_t scale)
87
{
88
std::cout << "
* Output scale
for
" << output.get_id() << "
:
" << scale << std::endl;
89
};
90
output.on_mode() = [&](uint32_t flags, int32_t width, int32_t height, int32_t refresh)
91
{
92
std::cout << "
* Output mode
for
" << output.get_id() << "
:
" << std::endl
93
<< "
Width:
" << width << std::endl
94
<< "
Height:
" << height << std::endl
95
<< "
Refresh:
" << refresh << "
mHz
" << std::endl
96
<< "
Flags:
" << flags << std::endl;
97
};
98
}
99
100
// Print output information
101
display.roundtrip();
102
103
// Release outputs
104
for(auto &output : outputs)
105
output.release();
106
display.roundtrip();
107
}
108
};
109
110
int main()
111
{
112
dumper d;
113
d.run();
114
return 0;
115
}
wayland-client.hpp
example
dump.cpp
Generated on
for Wayland++ by
1.17.0