···
1
+
From 84f020835e3624342a928aae68e62e636bf2cc8c Mon Sep 17 00:00:00 2001
2
+
From: Yuriy Taraday <yorik.sar@gmail.com>
3
+
Date: Wed, 12 Oct 2022 12:07:23 +0400
4
+
Subject: [PATCH] Revert "[x11] Refactor output updates"
6
+
This reverts commit 9a34ebbffc791cbeadc9abafda793ebee654b270.
8
+
This should fix compilation with older GCC.
10
+
CMakeLists.txt | 2 +-
11
+
.../standalone/x11_standalone_platform.cpp | 63 +++++++++++--------
12
+
2 files changed, 38 insertions(+), 27 deletions(-)
14
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
15
+
index 3e7bf700e..6ff24aa5c 100644
16
+
--- a/CMakeLists.txt
17
+
+++ b/CMakeLists.txt
18
+
@@ -70,7 +70,7 @@ add_definitions(-DMESA_EGL_NO_X11_HEADERS)
19
+
add_definitions(-DEGL_NO_X11)
20
+
add_definitions(-DEGL_NO_PLATFORM_SPECIFIC_TYPES)
22
+
-set(CMAKE_CXX_STANDARD 20)
23
+
+set(CMAKE_CXX_STANDARD 17)
24
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
26
+
# required frameworks by Core
27
+
diff --git a/src/backends/x11/standalone/x11_standalone_platform.cpp b/src/backends/x11/standalone/x11_standalone_platform.cpp
28
+
index 498d5cbe3..ac0f732b2 100644
29
+
--- a/src/backends/x11/standalone/x11_standalone_platform.cpp
30
+
+++ b/src/backends/x11/standalone/x11_standalone_platform.cpp
40
+
@@ -407,7 +405,8 @@ void X11StandalonePlatform::invertScreen()
41
+
ScreenResources res((active_client && active_client->window() != XCB_WINDOW_NONE) ? active_client->window() : rootWindow());
43
+
if (!res.isNull()) {
44
+
- for (auto crtc : std::span(res.crtcs(), res->num_crtcs)) {
45
+
+ for (int j = 0; j < res->num_crtcs; ++j) {
46
+
+ auto crtc = res.crtcs()[j];
47
+
CrtcGamma gamma(crtc);
48
+
if (gamma.isNull()) {
50
+
@@ -480,39 +479,54 @@ void X11StandalonePlatform::doUpdateOutputs()
51
+
if (Xcb::Extensions::self()->isRandrAvailable()) {
52
+
T resources(rootWindow());
53
+
if (!resources.isNull()) {
54
+
+ xcb_randr_crtc_t *crtcs = resources.crtcs();
55
+
+ const xcb_randr_mode_info_t *modes = resources.modes();
57
+
+ QVector<Xcb::RandR::CrtcInfo> infos(resources->num_crtcs);
58
+
+ for (int i = 0; i < resources->num_crtcs; ++i) {
59
+
+ infos[i] = Xcb::RandR::CrtcInfo(crtcs[i], resources->config_timestamp);
62
+
- std::span crtcs(resources.crtcs(), resources->num_crtcs);
63
+
- for (auto crtc : crtcs) {
64
+
- Xcb::RandR::CrtcInfo info(crtc, resources->config_timestamp);
65
+
+ for (int i = 0; i < resources->num_crtcs; ++i) {
66
+
+ Xcb::RandR::CrtcInfo info(infos.at(i));
68
+
const QRect geometry = info.rect();
69
+
if (!geometry.isValid()) {
73
+
- float refreshRate = -1.0f;
74
+
+ xcb_randr_output_t *outputs = info.outputs();
75
+
+ QVector<Xcb::RandR::OutputInfo> outputInfos(outputs ? resources->num_outputs : 0);
76
+
+ QVector<Xcb::RandR::OutputProperty> edids(outputs ? resources->num_outputs : 0);
78
+
+ for (int i = 0; i < resources->num_outputs; ++i) {
79
+
+ outputInfos[i] = Xcb::RandR::OutputInfo(outputs[i], resources->config_timestamp);
80
+
+ edids[i] = Xcb::RandR::OutputProperty(outputs[i], atoms->edid, XCB_ATOM_INTEGER, 0, 100, false, false);
84
+
- for (auto mode : std::span(resources.modes(), resources->num_modes)) {
85
+
- if (info->mode == mode.id) {
86
+
- if (mode.htotal != 0 && mode.vtotal != 0) { // BUG 313996
87
+
+ float refreshRate = -1.0f;
88
+
+ for (int j = 0; j < resources->num_modes; ++j) {
89
+
+ if (info->mode == modes[j].id) {
90
+
+ if (modes[j].htotal != 0 && modes[j].vtotal != 0) { // BUG 313996
91
+
// refresh rate calculation - WTF was wikipedia 1998 when I needed it?
92
+
- int dotclock = mode.dot_clock,
93
+
- vtotal = mode.vtotal;
94
+
- if (mode.mode_flags & XCB_RANDR_MODE_FLAG_INTERLACE) {
95
+
+ int dotclock = modes[j].dot_clock,
96
+
+ vtotal = modes[j].vtotal;
97
+
+ if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_INTERLACE) {
100
+
- if (mode.mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN) {
101
+
+ if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN) {
104
+
- refreshRate = dotclock / float(mode.htotal * vtotal);
105
+
+ refreshRate = dotclock / float(modes[j].htotal * vtotal);
107
+
break; // found mode
111
+
- for (auto xcbOutput : std::span(info.outputs(), info->num_outputs)) {
112
+
- Xcb::RandR::OutputInfo outputInfo(xcbOutput, resources->config_timestamp);
113
+
- if (outputInfo->crtc != crtc) {
114
+
+ for (int j = 0; j < info->num_outputs; ++j) {
115
+
+ Xcb::RandR::OutputInfo outputInfo(outputInfos.at(j));
116
+
+ if (outputInfo->crtc != crtcs[i]) {
120
+
@@ -528,14 +542,12 @@ void X11StandalonePlatform::doUpdateOutputs()
121
+
// TODO: Perhaps the output has to save the inherited gamma ramp and
122
+
// restore it during tear down. Currently neither standalone x11 nor
123
+
// drm platform do this.
124
+
- Xcb::RandR::CrtcGamma gamma(crtc);
125
+
+ Xcb::RandR::CrtcGamma gamma(crtcs[i]);
127
+
output->setRenderLoop(m_renderLoop.get());
128
+
- output->setCrtc(crtc);
129
+
+ output->setCrtc(crtcs[i]);
130
+
output->setGammaRampSize(gamma.isNull() ? 0 : gamma->size);
131
+
- auto it = std::find(crtcs.begin(), crtcs.end(), crtc);
132
+
- int crtcIndex = std::distance(crtcs.begin(), it);
133
+
- output->setXineramaNumber(crtcIndex);
134
+
+ output->setXineramaNumber(i);
136
+
QSize physicalSize(outputInfo->mm_width, outputInfo->mm_height);
137
+
switch (info->rotation) {
138
+
@@ -556,10 +568,9 @@ void X11StandalonePlatform::doUpdateOutputs()
139
+
.physicalSize = physicalSize,
142
+
- auto edidProperty = Xcb::RandR::OutputProperty(xcbOutput, atoms->edid, XCB_ATOM_INTEGER, 0, 100, false, false);
144
+
- if (auto data = edidProperty.toByteArray(&ok); ok && !data.isEmpty()) {
145
+
- if (auto edid = Edid(data, edidProperty.data()->num_items); edid.isValid()) {
146
+
+ if (auto data = edids[j].toByteArray(&ok); ok && !data.isEmpty()) {
147
+
+ if (auto edid = Edid(data, edids[j].data()->num_items); edid.isValid()) {
148
+
information.manufacturer = edid.manufacturerString();
149
+
information.model = edid.monitorName();
150
+
information.serialNumber = edid.serialNumber();