From 81f9da17fd9f367883b1fca02c7eb3a3ebaa1c34 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 4 Jan 2022 12:33:24 +0200 Subject: [PATCH] Drop resize effect After recent refactor changes to improve resizing of xdg-toplevel surfaces with an aspect ratio, the resize effect got really broken. The resize effect has always been a problem child on wayland. Unlike X11, geometry updates are performed asynchronously on Wayland. It's not possible to have a smooth transition after finishing interactive resize from the resized state to the normal state, geometry will jump from last moveResizeGeometry() to the current frameGeometry() and when the client repaints the window, the window size will jump back to the move resize geometry size. There are no ways to fix that without contradicting to how the effect is advertised to work, e.g. sending configure events behind the back. Keeping the frame geometry out of sync with the xdg_surface window geometry size is also not the option, geometry updates are already too complex (due to being async). Another wayland related issue with the resize effect is that the compositor doesn't know about aspect ratio or any other size constraints, except min and max size. The client can provide a smaller buffer to account for various geometry constraints. It will be confusing to have a mismatch between resize outline and the final real geometry. Aspect ratio or other geometry constraints won't be exposed to the compositor, it's a common decision of many wayland devs (including KDE). To some extent, the wayland issues can be addressed by performing content updates, with active feedback, the mismatch between outline and the final geometry would become less severe, but it won't be any different than resizing without the effect. Given the wayland issues and in part maintenance costs, this change drops the resize effect. Note that it can be still reimplemented without kwin core changes, but it would still suffer from the aforementioned issues. BUG: 443434 --- src/abstract_client.cpp | 13 +-- src/abstract_client.h | 10 -- src/effects/CMakeLists.txt | 1 - src/effects/resize/CMakeLists.txt | 28 ----- src/effects/resize/main.cpp | 17 --- src/effects/resize/metadata.json | 56 ---------- src/effects/resize/resize.cpp | 149 -------------------------- src/effects/resize/resize.h | 65 ----------- src/effects/resize/resize.kcfg | 15 --- src/effects/resize/resize_config.cpp | 57 ---------- src/effects/resize/resize_config.h | 43 -------- src/effects/resize/resize_config.ui | 45 -------- src/effects/resize/resizeconfig.kcfgc | 5 - src/libkwineffects/kwineffects.h | 2 +- src/x11client.cpp | 4 +- 15 files changed, 3 insertions(+), 507 deletions(-) delete mode 100644 src/effects/resize/CMakeLists.txt delete mode 100644 src/effects/resize/main.cpp delete mode 100644 src/effects/resize/metadata.json delete mode 100644 src/effects/resize/resize.cpp delete mode 100644 src/effects/resize/resize.h delete mode 100644 src/effects/resize/resize.kcfg delete mode 100644 src/effects/resize/resize_config.cpp delete mode 100644 src/effects/resize/resize_config.h delete mode 100644 src/effects/resize/resize_config.ui delete mode 100644 src/effects/resize/resizeconfig.kcfgc diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index 59273c6fab..99bc629ed6 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -18,7 +18,6 @@ #include "decorations/decoratedclient.h" #include "decorations/decorationpalette.h" #include "decorations/decorationbridge.h" -#include "effects.h" #include "focuschain.h" #include "outline.h" #include "platform.h" @@ -991,7 +990,6 @@ bool AbstractClient::startInteractiveMoveResize() } } - updateHaveResizeEffect(); updateInitialMoveResizeGeometry(); checkUnrestrictedInteractiveMoveResize(); Q_EMIT clientStartUserMovedResized(this); @@ -1452,9 +1450,7 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y if (isInteractiveMove()) { move(moveResizeGeometry().topLeft()); } else { - if (!haveResizeEffect()) { - doInteractiveResizeSync(); - } + doInteractiveResizeSync(); } Q_EMIT clientStepUserMovedResized(this, moveResizeGeometry()); @@ -2130,13 +2126,6 @@ void AbstractClient::leaveInteractiveMoveResize() } } -bool AbstractClient::s_haveResizeEffect = false; - -void AbstractClient::updateHaveResizeEffect() -{ - s_haveResizeEffect = effects && static_cast(effects)->provides(Effect::Resize); -} - bool AbstractClient::doStartInteractiveMoveResize() { return true; diff --git a/src/abstract_client.h b/src/abstract_client.h index 3906986959..7b2a46def7 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -1187,14 +1187,6 @@ protected: */ Position mousePosition() const; - static bool haveResizeEffect() { - return s_haveResizeEffect; - } - static void updateHaveResizeEffect(); - static void resetHaveResizeEffect() { - s_haveResizeEffect = false; - } - void setDecoration(QSharedPointer decoration); void startDecorationDoubleClickTimer(); void invalidateDecorationDoubleClickTimer(); @@ -1326,8 +1318,6 @@ private: QKeySequence _shortcut; WindowRules m_rules; - - static bool s_haveResizeEffect; }; /** diff --git a/src/effects/CMakeLists.txt b/src/effects/CMakeLists.txt index 8960cdf004..bc720d971d 100644 --- a/src/effects/CMakeLists.txt +++ b/src/effects/CMakeLists.txt @@ -136,7 +136,6 @@ add_subdirectory(screentransform) add_subdirectory(magiclamp) add_subdirectory(overview) add_subdirectory(presentwindows) -add_subdirectory(resize) add_subdirectory(screenedge) add_subdirectory(showfps) add_subdirectory(showpaint) diff --git a/src/effects/resize/CMakeLists.txt b/src/effects/resize/CMakeLists.txt deleted file mode 100644 index b64c0da2ad..0000000000 --- a/src/effects/resize/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -####################################### -# Effect - -set(resize_SOURCES - main.cpp - resize.cpp -) - -kconfig_add_kcfg_files(resize_SOURCES - resizeconfig.kcfgc -) - -kwin4_add_effect_module(kwin4_effect_resize ${resize_SOURCES}) - -####################################### -# Config -set(kwin_resize_config_SRCS resize_config.cpp) -ki18n_wrap_ui(kwin_resize_config_SRCS resize_config.ui) -kconfig_add_kcfg_files(kwin_resize_config_SRCS resizeconfig.kcfgc) - -kwin_add_effect_config(kwin_resize_config ${kwin_resize_config_SRCS}) - -target_link_libraries(kwin_resize_config - KF5::ConfigWidgets - KF5::I18n - Qt::DBus - KWinEffectsInterface -) diff --git a/src/effects/resize/main.cpp b/src/effects/resize/main.cpp deleted file mode 100644 index e5b6b7f8cc..0000000000 --- a/src/effects/resize/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - SPDX-FileCopyrightText: 2021 Vlad Zahorodnii - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#include "resize.h" - -namespace KWin -{ - -KWIN_EFFECT_FACTORY(ResizeEffect, - "metadata.json.stripped") - -} // namespace KWin - -#include "main.moc" diff --git a/src/effects/resize/metadata.json b/src/effects/resize/metadata.json deleted file mode 100644 index 18038e1f01..0000000000 --- a/src/effects/resize/metadata.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "KPlugin": { - "Category": "Window Management", - "Description": "Resizes windows with a fast texture scale instead of updating contents", - "Description[ar]": "يغيّر حجم النوافذ بتحجيم نقش سريع بدلًا من تحديث المحتويات", - "Description[az]": "Pəncərənin ölçüsünü tərkiblərini yeniləmək əvəzinə teksturasını miqyaslamaqla dəyişir", - "Description[ca@valencia]": "Redimensiona les finestres amb un escalat de textura ràpid en lloc d'actualitzar els continguts", - "Description[ca]": "Redimensiona les finestres amb un escalat de textura ràpid en lloc d'actualitzar els continguts", - "Description[cs]": "Změní velikost okna s využitím rychlého škálování textury místo aktualizace obsahu", - "Description[en_GB]": "Resizes windows with a fast texture scale instead of updating contents", - "Description[es]": "Cambia el tamaño de las ventanas con un escalado de textura rápido en lugar de actualizar su contenido", - "Description[fi]": "Muuttaa ikkunoiden kokoa nopealla pintakuvioskaalauksella sisällön päivittämisen sijaan", - "Description[fr]": "Redimensionne les fenêtres à l'aide d'une échelle texturée rapide au lieu de mettre à jour les contenus", - "Description[hu]": "Gyors textúraskálázással méretezi át az ablakokat a tartalom frissítése helyett", - "Description[ia]": "Redimensiona fenestras con un rapide scala de textura in vice de actualisar contentos", - "Description[it]": "Ridimensiona le finestra con una scalatura rapida della trama invece di aggiornarne i contenuti", - "Description[ko]": "내용을 갱신하는 대신 빠른 텍스처 스케일링으로 창 크기 조절하기", - "Description[nl]": "Wijzigt vensterafmetingen met een snelle textuurschaling in plaats van het bijwerken van de inhoud", - "Description[pl]": "Zmienia rozmiar okna metodą szybkiego skalowania tekstur zamiast uaktualniania zawartości", - "Description[pt_BR]": "Redimensiona as janelas com uma escala rápida com textura em vez de atualizar o conteúdo", - "Description[sl]": "Spremeni velikost oken s hitro teksturo, namesto da posodobil vsebine", - "Description[sv]": "Ändrar storlek på fönster med en snabb strukturskalning istället för att uppdatera innehållet.", - "Description[uk]": "Зміна розмірів вікон швидким масштабуванням текстур замість оновлення вмісту вікон", - "Description[vi]": "Đổi cỡ cửa sổ với một sự đổi cỡ nhanh ở bề mặt, thay vì cập nhật nội dung", - "Description[x-test]": "xxResizes windows with a fast texture scale instead of updating contentsxx", - "Description[zh_CN]": "调整窗口时显示简易材质,不实时更新窗口内容", - "EnabledByDefault": false, - "Id": "resize", - "License": "GPL", - "Name": "Resize Window", - "Name[ar]": "غير حجم النافذة", - "Name[az]": "Pəncərənin Ölçüsünü Dəyişmək", - "Name[ca@valencia]": "Redimensionament de les finestres", - "Name[ca]": "Redimensionament de les finestres", - "Name[cs]": "Změnit velikost okna", - "Name[en_GB]": "Resize Window", - "Name[es]": "Cambiar tamaño de la ventana", - "Name[fi]": "Ikkunan koon muuttaminen", - "Name[fr]": "Redimensionner une fenêtre", - "Name[hu]": "Ablakátméretezés", - "Name[ia]": "Redimensiona fenestra", - "Name[it]": "Ridimensiona la finestra", - "Name[ko]": "창 크기 조정", - "Name[nl]": "Afmeting venster aanpassen", - "Name[pl]": "Zmiana rozmiaru okien", - "Name[pt]": "Dimensionar a Janela", - "Name[pt_BR]": "Redimensionar janela", - "Name[sl]": "Spremeni velikost okna", - "Name[sv]": "Ändra fönsterstorlek", - "Name[uk]": "Зміна розмірів вікон", - "Name[vi]": "Đổi cỡ cửa sổ", - "Name[x-test]": "xxResize Windowxx", - "Name[zh_CN]": "窗口大小简易调整" - }, - "X-KDE-ConfigModule": "kwin_resize_config" -} diff --git a/src/effects/resize/resize.cpp b/src/effects/resize/resize.cpp deleted file mode 100644 index 9831b39349..0000000000 --- a/src/effects/resize/resize.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2009 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#include "resize.h" -// KConfigSkeleton -#include "resizeconfig.h" - -#include - -#include - -#include -#include - -namespace KWin -{ - -ResizeEffect::ResizeEffect() - : AnimationEffect() - , m_active(false) - , m_resizeWindow(nullptr) -{ - initConfig(); - reconfigure(ReconfigureAll); - connect(effects, &EffectsHandler::windowStartUserMovedResized, this, &ResizeEffect::slotWindowStartUserMovedResized); - connect(effects, &EffectsHandler::windowStepUserMovedResized, this, &ResizeEffect::slotWindowStepUserMovedResized); - connect(effects, &EffectsHandler::windowFinishUserMovedResized, this, &ResizeEffect::slotWindowFinishUserMovedResized); -} - -ResizeEffect::~ResizeEffect() -{ -} - -void ResizeEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) -{ - if (m_active) { - data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; - } - AnimationEffect::prePaintScreen(data, presentTime); -} - -void ResizeEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) -{ - if (m_active && w == m_resizeWindow) - data.mask |= PAINT_WINDOW_TRANSFORMED; - AnimationEffect::prePaintWindow(w, data, presentTime); -} - -void ResizeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) -{ - if (m_active && w == m_resizeWindow) { - if (m_features & TextureScale) { - data += (m_currentGeometry.topLeft() - m_originalGeometry.topLeft()); - data *= QVector2D(float(m_currentGeometry.width())/m_originalGeometry.width(), - float(m_currentGeometry.height())/m_originalGeometry.height()); - } - effects->paintWindow(w, mask, region, data); - - if (m_features & Outline) { - QRegion intersection = m_originalGeometry.intersected(m_currentGeometry); - QRegion paintRegion = QRegion(m_originalGeometry).united(m_currentGeometry).subtracted(intersection); - float alpha = 0.8f; - QColor color = KColorScheme(QPalette::Normal, KColorScheme::Selection).background().color(); - - if (effects->isOpenGLCompositing()) { - GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); - vbo->reset(); - vbo->setUseColor(true); - ShaderBinder binder(ShaderTrait::UniformColor); - binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, data.screenProjectionMatrix()); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - color.setAlphaF(alpha); - vbo->setColor(color); - QVector verts; - verts.reserve(paintRegion.rectCount() * 12); - for (const QRect &r : paintRegion) { - verts << r.x() + r.width() << r.y(); - verts << r.x() << r.y(); - verts << r.x() << r.y() + r.height(); - verts << r.x() << r.y() + r.height(); - verts << r.x() + r.width() << r.y() + r.height(); - verts << r.x() + r.width() << r.y(); - } - vbo->setData(verts.count() / 2, 2, verts.data(), nullptr); - vbo->render(GL_TRIANGLES); - glDisable(GL_BLEND); - } else if (effects->compositingType() == QPainterCompositing) { - QPainter *painter = effects->scenePainter(); - painter->save(); - color.setAlphaF(alpha); - for (const QRect &r : paintRegion) { - painter->fillRect(r, color); - } - painter->restore(); - } - } - } else { - AnimationEffect::paintWindow(w, mask, region, data); - } -} - -void ResizeEffect::reconfigure(ReconfigureFlags) -{ - m_features = 0; - ResizeConfig::self()->read(); - if (ResizeConfig::textureScale()) - m_features |= TextureScale; - if (ResizeConfig::outline()) - m_features |= Outline; -} - -void ResizeEffect::slotWindowStartUserMovedResized(EffectWindow *w) -{ - if (w->isUserResize() && !w->isUserMove()) { - m_active = true; - m_resizeWindow = w; - m_originalGeometry = w->frameGeometry(); - m_currentGeometry = w->frameGeometry(); - w->addRepaintFull(); - } -} - -void ResizeEffect::slotWindowFinishUserMovedResized(EffectWindow *w) -{ - if (m_active && w == m_resizeWindow) { - m_active = false; - m_resizeWindow = nullptr; - if (m_features & TextureScale) - animate(w, CrossFadePrevious, 0, 150, FPx2(1.0)); - effects->addRepaintFull(); - } -} - -void ResizeEffect::slotWindowStepUserMovedResized(EffectWindow *w, const QRect &geometry) -{ - if (m_active && w == m_resizeWindow) { - m_currentGeometry = geometry; - effects->addRepaintFull(); - } -} - -} // namespace diff --git a/src/effects/resize/resize.h b/src/effects/resize/resize.h deleted file mode 100644 index 58d58bedf6..0000000000 --- a/src/effects/resize/resize.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2009 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef KWIN_RESIZE_H -#define KWIN_RESIZE_H - -#include - -namespace KWin -{ - -class ResizeEffect - : public AnimationEffect -{ - Q_OBJECT - Q_PROPERTY(bool textureScale READ isTextureScale) - Q_PROPERTY(bool outline READ isOutline) -public: - ResizeEffect(); - ~ResizeEffect() override; - inline bool provides(Effect::Feature ef) override { - return ef == Effect::Resize; - } - inline bool isActive() const override { return m_active || AnimationEffect::isActive(); } - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; - void reconfigure(ReconfigureFlags) override; - - int requestedEffectChainPosition() const override { - return 60; - } - - bool isTextureScale() const { - return m_features & TextureScale; - } - bool isOutline() const { - return m_features & Outline; - } - -public Q_SLOTS: - void slotWindowStartUserMovedResized(KWin::EffectWindow *w); - void slotWindowStepUserMovedResized(KWin::EffectWindow *w, const QRect &geometry); - void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); - -private: - enum Feature { - TextureScale = 1 << 0, - Outline = 1 << 1, - }; - bool m_active; - int m_features; - EffectWindow* m_resizeWindow; - QRect m_currentGeometry, m_originalGeometry; -}; - -} - -#endif diff --git a/src/effects/resize/resize.kcfg b/src/effects/resize/resize.kcfg deleted file mode 100644 index a02a1660ad..0000000000 --- a/src/effects/resize/resize.kcfg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - true - - - false - - - diff --git a/src/effects/resize/resize_config.cpp b/src/effects/resize/resize_config.cpp deleted file mode 100644 index 80340375c6..0000000000 --- a/src/effects/resize/resize_config.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2010 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "resize_config.h" -// KConfigSkeleton -#include "resizeconfig.h" -#include -#include - -#include -#include -#include - -#include - -K_PLUGIN_CLASS(KWin::ResizeEffectConfig) - -namespace KWin -{ - -ResizeEffectConfigForm::ResizeEffectConfigForm(QWidget* parent) : QWidget(parent) -{ - setupUi(this); -} - -ResizeEffectConfig::ResizeEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) -{ - m_ui = new ResizeEffectConfigForm(this); - - QVBoxLayout* layout = new QVBoxLayout(this); - - layout->addWidget(m_ui); - - ResizeConfig::instance(KWIN_CONFIG); - addConfig(ResizeConfig::self(), m_ui); - - load(); -} - -void ResizeEffectConfig::save() -{ - KCModule::save(); - OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Effects"), - QDBusConnection::sessionBus()); - interface.reconfigureEffect(QStringLiteral("resize")); -} - -} // namespace - -#include "resize_config.moc" diff --git a/src/effects/resize/resize_config.h b/src/effects/resize/resize_config.h deleted file mode 100644 index c5286bccfe..0000000000 --- a/src/effects/resize/resize_config.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2010 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -#ifndef KWIN_RESIZE_CONFIG_H -#define KWIN_RESIZE_CONFIG_H - -#include - -#include "ui_resize_config.h" - - -namespace KWin -{ - -class ResizeEffectConfigForm : public QWidget, public Ui::ResizeEffectConfigForm -{ - Q_OBJECT -public: - explicit ResizeEffectConfigForm(QWidget* parent = nullptr); -}; - -class ResizeEffectConfig : public KCModule -{ - Q_OBJECT -public: - explicit ResizeEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); - -public Q_SLOTS: - void save() override; - -private: - ResizeEffectConfigForm* m_ui; -}; - -} // namespace - -#endif diff --git a/src/effects/resize/resize_config.ui b/src/effects/resize/resize_config.ui deleted file mode 100644 index 0dcc62bea8..0000000000 --- a/src/effects/resize/resize_config.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - KWin::ResizeEffectConfigForm - - - - 0 - 0 - 400 - 300 - - - - - - - Scale window - - - - - - - Show outline - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/effects/resize/resizeconfig.kcfgc b/src/effects/resize/resizeconfig.kcfgc deleted file mode 100644 index d6ade9d23a..0000000000 --- a/src/effects/resize/resizeconfig.kcfgc +++ /dev/null @@ -1,5 +0,0 @@ -File=resize.kcfg -ClassName=ResizeConfig -NameSpace=KWin -Singleton=true -Mutators=true diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index a39eb79715..3057baa6e8 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -329,7 +329,7 @@ public: enum Feature { Nothing = 0, - Resize, + Resize, /**< @deprecated */ GeometryTip, /**< @deprecated */ Outline, /**< @deprecated */ ScreenInversion, diff --git a/src/x11client.cpp b/src/x11client.cpp index 0efd2e0b08..cab3003e47 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -1404,8 +1404,6 @@ void X11Client::finishCompositing(ReleaseReason releaseReason) { Toplevel::finishCompositing(releaseReason); updateVisibility(); - // for safety in case KWin is just resizing the window - resetHaveResizeEffect(); // If compositing is off, render the decoration in the X11 frame window. maybeCreateX11DecorationRenderer(); } @@ -2780,7 +2778,7 @@ void X11Client::handleSync() void X11Client::performInteractiveResize() { - if (isInteractiveResize() && !haveResizeEffect()) { + if (isInteractiveResize()) { resize(moveResizeGeometry().size()); } }