4692.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. From f3e6d3ca196aaef28478c27fd6a3caaed3cdbdff Mon Sep 17 00:00:00 2001
  2. From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
  3. Date: Wed, 22 Nov 2023 15:05:52 +0200
  4. Subject: [PATCH 1/4] Ignore decoration changes of closed windows
  5. Ideally the decoration of a closed window should not change. However,
  6. it seems like it can happen when resuming the session.
  7. When switching to another VT, the touchpad input device is removed, but
  8. the touch input device is still kept on my machine. This results in
  9. the tablet mode changing temporarily and triggering recalculation of new
  10. borders in breeze decoration. It's a no-no thing to do if the window is
  11. closed. We need to guard against this case. But in long term, we need to
  12. reroute all decoration state updates through kwin so it can block state
  13. updates when the window is closed. It's also needed for double buffered
  14. state.
  15. How to improve handling of tablet mode detection when switching between
  16. VTs needs a separate investigation.
  17. CCBUG: 477166
  18. ---
  19. src/window.cpp | 30 +++++++++++++++++++++++-------
  20. src/x11window.cpp | 18 +++++++++++++++---
  21. 2 files changed, 38 insertions(+), 10 deletions(-)
  22. diff --git a/src/window.cpp b/src/window.cpp
  23. index d60ff3db325..be9ca43b2f1 100644
  24. --- a/src/window.cpp
  25. +++ b/src/window.cpp
  26. @@ -2625,20 +2625,32 @@ void Window::setDecoration(std::shared_ptr<KDecoration2::Decoration> decoration)
  27. }
  28. if (decoration) {
  29. QMetaObject::invokeMethod(decoration.get(), QOverload<>::of(&KDecoration2::Decoration::update), Qt::QueuedConnection);
  30. - connect(decoration.get(), &KDecoration2::Decoration::shadowChanged, this, &Window::updateShadow);
  31. - connect(decoration.get(), &KDecoration2::Decoration::bordersChanged,
  32. - this, &Window::updateDecorationInputShape);
  33. - connect(decoration.get(), &KDecoration2::Decoration::resizeOnlyBordersChanged,
  34. - this, &Window::updateDecorationInputShape);
  35. + connect(decoration.get(), &KDecoration2::Decoration::shadowChanged, this, [this]() {
  36. + if (!isDeleted()) {
  37. + updateShadow();
  38. + }
  39. + });
  40. connect(decoration.get(), &KDecoration2::Decoration::bordersChanged, this, [this]() {
  41. + if (isDeleted()) {
  42. + return;
  43. + }
  44. GeometryUpdatesBlocker blocker(this);
  45. const QRectF oldGeometry = moveResizeGeometry();
  46. if (!isShade()) {
  47. checkWorkspacePosition(oldGeometry);
  48. }
  49. + updateDecorationInputShape();
  50. + });
  51. + connect(decoration.get(), &KDecoration2::Decoration::resizeOnlyBordersChanged, this, [this]() {
  52. + if (!isDeleted()) {
  53. + updateDecorationInputShape();
  54. + }
  55. + });
  56. + connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::sizeChanged, this, [this]() {
  57. + if (!isDeleted()) {
  58. + updateDecorationInputShape();
  59. + }
  60. });
  61. - connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::sizeChanged,
  62. - this, &Window::updateDecorationInputShape);
  63. }
  64. m_decoration.decoration = decoration;
  65. updateDecorationInputShape();
  66. @@ -3658,6 +3670,10 @@ void Window::sendToOutput(Output *newOutput)
  67. void Window::checkWorkspacePosition(QRectF oldGeometry, const VirtualDesktop *oldDesktop)
  68. {
  69. + if (isDeleted()) {
  70. + qCWarning(KWIN_CORE) << "Window::checkWorkspacePosition: called for a closed window. Consider this a bug";
  71. + return;
  72. + }
  73. if (isDock() || isDesktop() || !isPlaceable()) {
  74. return;
  75. }
  76. diff --git a/src/x11window.cpp b/src/x11window.cpp
  77. index 724f49e0964..8b2fce35f43 100644
  78. --- a/src/x11window.cpp
  79. +++ b/src/x11window.cpp
  80. @@ -1340,9 +1340,21 @@ void X11Window::createDecoration()
  81. {
  82. std::shared_ptr<KDecoration2::Decoration> decoration(Workspace::self()->decorationBridge()->createDecoration(this));
  83. if (decoration) {
  84. - connect(decoration.get(), &KDecoration2::Decoration::resizeOnlyBordersChanged, this, &X11Window::updateInputWindow);
  85. - connect(decoration.get(), &KDecoration2::Decoration::bordersChanged, this, &X11Window::updateFrameExtents);
  86. - connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::sizeChanged, this, &X11Window::updateInputWindow);
  87. + connect(decoration.get(), &KDecoration2::Decoration::resizeOnlyBordersChanged, this, [this]() {
  88. + if (!isDeleted()) {
  89. + updateInputWindow();
  90. + }
  91. + });
  92. + connect(decoration.get(), &KDecoration2::Decoration::bordersChanged, this, [this]() {
  93. + if (!isDeleted()) {
  94. + updateFrameExtents();
  95. + }
  96. + });
  97. + connect(decoratedClient()->decoratedClient(), &KDecoration2::DecoratedClient::sizeChanged, this, [this]() {
  98. + if (!isDeleted()) {
  99. + updateInputWindow();
  100. + }
  101. + });
  102. }
  103. setDecoration(decoration);
  104. --
  105. GitLab
  106. From 4d0d153a579ed3b0bd74b7f4d95539d9e926a271 Mon Sep 17 00:00:00 2001
  107. From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
  108. Date: Wed, 22 Nov 2023 16:23:53 +0200
  109. Subject: [PATCH 2/4] Always reset tabbox ClientModel if a window is added or
  110. removed
  111. Otherwise dangling pointers can end up in TabBox::ClientModel. Tabbox is
  112. written with hard model resets in mind. In order to fix it, the client
  113. model has to be rewritten.
  114. BUG: 477166
  115. ---
  116. src/workspace.cpp | 6 +++---
  117. 1 file changed, 3 insertions(+), 3 deletions(-)
  118. diff --git a/src/workspace.cpp b/src/workspace.cpp
  119. index db37ade6eea..664fc76d975 100644
  120. --- a/src/workspace.cpp
  121. +++ b/src/workspace.cpp
  122. @@ -2002,9 +2002,9 @@ void Workspace::setWasUserInteraction()
  123. void Workspace::updateTabbox()
  124. {
  125. #if KWIN_BUILD_TABBOX
  126. - if (m_tabbox->isDisplayed()) {
  127. - m_tabbox->reset(true);
  128. - }
  129. + // Need to reset the client model even if the task switcher is hidden otherwise there
  130. + // might be dangling pointers. Consider rewriting client model logic!
  131. + m_tabbox->reset(true);
  132. #endif
  133. }
  134. --
  135. GitLab
  136. From b40b13b661c44199633d58b43ba571ca92cf30f1 Mon Sep 17 00:00:00 2001
  137. From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
  138. Date: Wed, 22 Nov 2023 18:03:02 +0200
  139. Subject: [PATCH 3/4] tabbox: Fix ClientModel::createClientList() reinserting
  140. closed windows
  141. ---
  142. src/tabbox/clientmodel.cpp | 2 +-
  143. 1 file changed, 1 insertion(+), 1 deletion(-)
  144. diff --git a/src/tabbox/clientmodel.cpp b/src/tabbox/clientmodel.cpp
  145. index af3fe4273bf..29f968d5be4 100644
  146. --- a/src/tabbox/clientmodel.cpp
  147. +++ b/src/tabbox/clientmodel.cpp
  148. @@ -198,7 +198,7 @@ void ClientModel::createClientList(bool partialReset)
  149. // TODO: new clients are not added at correct position
  150. if (partialReset && !m_mutableClientList.isEmpty()) {
  151. Window *firstClient = m_mutableClientList.constFirst();
  152. - if (firstClient) {
  153. + if (!firstClient->isDeleted()) {
  154. start = firstClient;
  155. }
  156. }
  157. --
  158. GitLab
  159. From 3ffa3ed0d8ab5da79a0d4e2546c157ed317d6aa8 Mon Sep 17 00:00:00 2001
  160. From: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
  161. Date: Wed, 22 Nov 2023 18:41:49 +0200
  162. Subject: [PATCH 4/4] tabbox: Guard against including closed windows when using
  163. stacking order
  164. Closed windows are present in the stack. If user has selected
  165. "Stacking order" sort order in task switcher KCM, we need to guard
  166. against closed windows in the stack.
  167. ---
  168. src/tabbox/tabbox.cpp | 2 +-
  169. 1 file changed, 1 insertion(+), 1 deletion(-)
  170. diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp
  171. index 809c60e682d..2c16009ac42 100644
  172. --- a/src/tabbox/tabbox.cpp
  173. +++ b/src/tabbox/tabbox.cpp
  174. @@ -171,7 +171,7 @@ bool TabBoxHandlerImpl::checkMultiScreen(Window *client) const
  175. Window *TabBoxHandlerImpl::clientToAddToList(Window *client) const
  176. {
  177. - if (!client) {
  178. + if (!client || client->isDeleted()) {
  179. return nullptr;
  180. }
  181. Window *ret = nullptr;
  182. --
  183. GitLab