summaryrefslogtreecommitdiff
path: root/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-crash-on-screen-setup-change.patch
blob: 4ddd9737e75913143b10f5c6f4aaa741a77f4807 (plain)
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
108
109
From 40364d2ee670a5a74318ef96c643762293ca95f0 Mon Sep 17 00:00:00 2001
From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Date: Fri, 8 Apr 2022 12:44:33 +0300
Subject: [PATCH] Simplify code that announces available modes and current mode

If no mode has the current flag set, the first mode object will be
announced twice.

There's also no benefit from sending the current mode as last. If the
current mode changes, the compositor will send the current_mode event,
not the mode event.

BUG: 452318


(cherry picked from commit b40c4e3f4108b9a0be9b4f5d437e72f7c2aa3fea)
---
 src/server/outputdevice_v2_interface.cpp | 35 ++++++++----------------
 1 file changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/server/outputdevice_v2_interface.cpp b/src/server/outputdevice_v2_interface.cpp
index 31ab16ca..9093bd2f 100644
--- a/src/server/outputdevice_v2_interface.cpp
+++ b/src/server/outputdevice_v2_interface.cpp
@@ -31,7 +31,7 @@ public:
 
     void sendGeometry(Resource *resource);
     wl_resource *sendNewMode(Resource *resource, OutputDeviceModeV2Interface *mode);
-    void sendCurrentMode(Resource *resource, OutputDeviceModeV2Interface *mode);
+    void sendCurrentMode(Resource *resource);
     void sendDone(Resource *resource);
     void sendUuid(Resource *resource);
     void sendEdid(Resource *resource);
@@ -180,7 +180,7 @@ void OutputDeviceV2Interface::setCurrentMode(OutputDeviceModeV2Interface *mode)
     const auto clientResources = d->resourceMap();
     for (auto it = clientResources.begin(); it != clientResources.end(); ++it) {
         auto resource = *it;
-        d->sendCurrentMode(resource, d->currentMode);
+        d->sendCurrentMode(resource);
         d->sendDone(resource);
     }
     d->updateGeometry();
@@ -257,22 +257,10 @@ void OutputDeviceV2InterfacePrivate::kde_output_device_v2_bind_resource(Resource
     sendName(resource);
     sendSerialNumber(resource);
 
-    auto currentModeIt = modes.end();
-    for (auto it = modes.begin(); it != modes.end(); ++it) {
-        auto &mode = *it;
-        if (mode->flags().testFlag(OutputDeviceModeV2Interface::ModeFlag::Current)) {
-            // needs to be sent as last mode
-            currentModeIt = it;
-            continue;
-        }
+    for (OutputDeviceModeV2Interface *mode : std::as_const(modes)) {
         sendNewMode(resource, mode);
     }
-
-    if (currentModeIt != modes.end()) {
-        auto modeResource = sendNewMode(resource, *currentModeIt);
-        send_current_mode(resource->handle, modeResource);
-    }
-
+    sendCurrentMode(resource);
     sendUuid(resource);
     sendEdid(resource);
     sendEnabled(resource);
@@ -296,9 +284,9 @@ wl_resource *OutputDeviceV2InterfacePrivate::sendNewMode(Resource *resource, Out
     return modeResource->handle;
 }
 
-void OutputDeviceV2InterfacePrivate::sendCurrentMode(Resource *outputResource, OutputDeviceModeV2Interface *mode)
+void OutputDeviceV2InterfacePrivate::sendCurrentMode(Resource *outputResource)
 {
-    const auto modeResource = OutputDeviceModeV2InterfacePrivate::get(mode)->findResource(outputResource);
+    const auto modeResource = OutputDeviceModeV2InterfacePrivate::get(currentMode)->findResource(outputResource);
     send_current_mode(outputResource->handle, modeResource->handle);
 }
 
@@ -506,12 +494,12 @@ void OutputDeviceV2Interface::setModes(const QList<OutputDeviceModeV2Interface *
         d->modes << outputDeviceMode;
         outputDeviceMode->setParent(this);
 
+        for (auto resource : clientResources) {
+            d->sendNewMode(resource, outputDeviceMode);
+        }
+
         if (outputDeviceMode->flags().testFlag(OutputDeviceModeV2Interface::ModeFlag::Current)) {
             d->currentMode = outputDeviceMode;
-        } else {
-            for (auto resource : clientResources) {
-                d->sendNewMode(resource, outputDeviceMode);
-            }
         }
     }
 
@@ -520,8 +508,7 @@ void OutputDeviceV2Interface::setModes(const QList<OutputDeviceModeV2Interface *
     }
 
     for (auto resource : clientResources) {
-        d->sendNewMode(resource, d->currentMode);
-        d->sendCurrentMode(resource, d->currentMode);
+        d->sendCurrentMode(resource);
     }
 
     qDeleteAll(oldModes.crbegin(), oldModes.crend());
-- 
GitLab