From 705506f719d74af737f8bfcda6d3771aff4ad6e9 Mon Sep 17 00:00:00 2001
From: pei-jiankang <peijiankang@kylinos.cn>
Date: Fri, 11 Feb 2022 12:03:48 +0800
Subject: [PATCH] modify ukui-kwin compile error

---
 decorations/decoratedclient.cpp               |  5 +-
 decorations/decoratedclient.h                 |  2 +-
 decorations/decorationbridge.cpp              | 11 +---
 decorations/decorationbridge.h                |  2 +-
 effects.cpp                                   |  5 +-
 .../declarative-plugin/previewbridge.cpp      | 61 +++++++++++--------
 .../declarative-plugin/previewbridge.h        |  4 +-
 .../declarative-plugin/previewclient.cpp      |  3 +-
 .../declarative-plugin/previewclient.h        |  2 +-
 .../platforms/x11/common/eglonxbackend.cpp    |  1 +
 plugins/platforms/x11/common/eglonxbackend.h  |  3 +
 .../platforms/x11/standalone/x11_platform.h   |  1 +
 .../x11/windowed/x11windowed_backend.cpp      |  2 +-
 po/tr/{kwin.po => ukui-kwin.po}               |  0
 workspace.cpp                                 |  2 +-
 15 files changed, 55 insertions(+), 49 deletions(-)
 rename po/tr/{kwin.po => ukui-kwin.po} (100%)

diff --git a/decorations/decoratedclient.cpp b/decorations/decoratedclient.cpp
index 6e150d8..a708d3c 100644
--- a/decorations/decoratedclient.cpp
+++ b/decorations/decoratedclient.cpp
@@ -238,10 +238,9 @@ void DecoratedClientImpl::requestHideToolTip()
     m_toolTipShowing = false;
 }
 
-void DecoratedClientImpl::requestShowWindowMenu()
+void DecoratedClientImpl::requestShowWindowMenu(const QRect &rect)
 {
-    // TODO: add rect to requestShowWindowMenu
-    Workspace::self()->showWindowMenu(QRect(Cursor::pos(), Cursor::pos()), m_client);
+    Workspace::self()->showWindowMenu(QRect(m_client->pos() + rect.topLeft(), m_client->pos() + rect.bottomRight()), m_client);
 }
 
 void DecoratedClientImpl::requestShowApplicationMenu(const QRect &rect, int actionId)
diff --git a/decorations/decoratedclient.h b/decorations/decoratedclient.h
index 576b62c..1675751 100644
--- a/decorations/decoratedclient.h
+++ b/decorations/decoratedclient.h
@@ -81,7 +81,7 @@ public:
     void requestContextHelp() override;
     void requestToggleMaximization(Qt::MouseButtons buttons) override;
     void requestMinimize() override;
-    void requestShowWindowMenu() override;
+    void requestShowWindowMenu(const QRect &rect) override;
     void requestShowApplicationMenu(const QRect &rect, int actionId) override;
     void requestToggleKeepAbove() override;
     void requestToggleKeepBelow() override;
diff --git a/decorations/decorationbridge.cpp b/decorations/decorationbridge.cpp
index fc0265a..0abe08d 100644
--- a/decorations/decorationbridge.cpp
+++ b/decorations/decorationbridge.cpp
@@ -45,6 +45,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <KWayland/Server/server_decoration_interface.h>
 
 // Frameworks
+#include <KPluginFactory>
 #include <KPluginMetaData>
 #include <KPluginLoader>
 
@@ -339,16 +340,6 @@ std::unique_ptr<KDecoration2::DecorationSettingsPrivate> DecorationBridge::setti
     return std::unique_ptr<SettingsImpl>(new SettingsImpl(parent));
 }
 
-void DecorationBridge::update(KDecoration2::Decoration *decoration, const QRect &geometry)
-{
-    // TODO: remove check once all compositors implement it
-    if (AbstractClient *c = Workspace::self()->findAbstractClient([decoration] (const AbstractClient *client) { return client->decoration() == decoration; })) {
-        if (Renderer *renderer = c->decoratedClient()->renderer()) {
-            renderer->schedule(geometry);
-        }
-    }
-}
-
 KDecoration2::Decoration *DecorationBridge::createDecoration(AbstractClient *client)
 {
     if (m_noPlugin) {
diff --git a/decorations/decorationbridge.h b/decorations/decorationbridge.h
index 6f51a3f..6f2b1ed 100644
--- a/decorations/decorationbridge.h
+++ b/decorations/decorationbridge.h
@@ -56,12 +56,12 @@ class UKUI_KWIN_EXPORT DecorationBridge : public KDecoration2::DecorationBridge
 public:
     ~DecorationBridge() override;
 
+
     void init();
     KDecoration2::Decoration *createDecoration(AbstractClient *client);
 
     std::unique_ptr<KDecoration2::DecoratedClientPrivate> createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration) override;
     std::unique_ptr<KDecoration2::DecorationSettingsPrivate> settings(KDecoration2::DecorationSettings *parent) override;
-    void update(KDecoration2::Decoration *decoration, const QRect &geometry) override;
 
     bool needsBlur() const {
         return m_blur;
diff --git a/effects.cpp b/effects.cpp
index 9f765aa..86b1638 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -49,7 +49,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "kwineffectquickview.h"
 
 #include <QDebug>
-
+#include <QMouseEvent>
+#include <QWheelEvent>
 #include <Plasma/Theme>
 
 #include "composite.h"
@@ -86,7 +87,7 @@ static QByteArray readWindowProperty(xcb_window_t win, xcb_atom_t atom, xcb_atom
     }
 }
 
-static void deleteWindowProperty(Window win, long int atom)
+static void deleteWindowProperty(xcb_window_t win, long int atom)
 {
     if (win == XCB_WINDOW_NONE) {
         return;
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
index 41fe317..68962ef 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp
@@ -34,7 +34,7 @@
 #include <KCModule>
 #include <KPluginLoader>
 #include <KPluginFactory>
-#include <KPluginTrader>
+#include <KPluginMetaData>
 
 #include <QDebug>
 #include <QDBusConnection>
@@ -42,7 +42,11 @@
 #include <QDialog>
 #include <QDialogButtonBox>
 #include <QPushButton>
+#include <QQuickItem>
+#include <QQuickRenderControl>
+#include <QQuickWindow>
 #include <QVBoxLayout>
+#include <QWindow>
 
 namespace KDecoration2
 {
@@ -69,17 +73,6 @@ std::unique_ptr<DecoratedClientPrivate> PreviewBridge::createClient(DecoratedCli
     return ptr;
 }
 
-void PreviewBridge::update(Decoration *decoration, const QRect &geometry)
-{
-    Q_UNUSED(geometry)
-    auto it = std::find_if(m_previewItems.constBegin(), m_previewItems.constEnd(), [decoration](PreviewItem *item) {
-        return item->decoration() == decoration;
-    });
-    if (it != m_previewItems.constEnd()) {
-        (*it)->update();
-    }
-}
-
 std::unique_ptr<DecorationSettingsPrivate> PreviewBridge::settings(DecorationSettings *parent)
 {
     auto ptr = std::unique_ptr<PreviewSettings>(new PreviewSettings(parent));
@@ -135,11 +128,11 @@ void PreviewBridge::createFactory()
         return;
     }
 
-    const auto offers = KPluginTrader::self()->query(s_pluginName, s_pluginName);
-    auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginName() == m_plugin; });
+    const auto offers = KPluginLoader::findPlugins(s_pluginName);
+    auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginId() == m_plugin; });
     if (item != offers.constEnd()) {
-        KPluginLoader loader(item->libraryPath());
-        m_factory = loader.factory();
+	KPluginLoader loader(item->fileName());
+	m_factory = loader.factory();
     }
 
     setValid(!m_factory.isNull());
@@ -179,15 +172,16 @@ DecorationButton *PreviewBridge::createButton(KDecoration2::Decoration *decorati
     return m_factory->create<KDecoration2::DecorationButton>(QStringLiteral("button"), parent, QVariantList({QVariant::fromValue(type), QVariant::fromValue(decoration)}));
 }
 
-void PreviewBridge::configure()
+void PreviewBridge::configure(QQuickItem *ctx)
 {
     if (!m_valid) {
         return;
     }
     //setup the UI
-    QDialog dialog;
+    QDialog *dialog = new QDialog();
+    dialog->setAttribute(Qt::WA_DeleteOnClose);
     if (m_lastCreatedClient) {
-        dialog.setWindowTitle(m_lastCreatedClient->caption());
+        dialog->setWindowTitle(m_lastCreatedClient->caption());
     }
 
     // create the KCModule through the plugintrader
@@ -195,7 +189,15 @@ void PreviewBridge::configure()
     if (!m_theme.isNull()) {
         args.insert(QStringLiteral("theme"), m_theme);
     }
-    KCModule *kcm = m_factory->create<KCModule>(QStringLiteral("kcmodule"), &dialog, QVariantList({args}));
+
+    KCModule *kcm = nullptr;
+
+    kcm = m_factory->create<KCModule>(dialog, QVariantList({args}));
+
+    if (!kcm) {
+	kcm = m_factory->create<KCModule>(QStringLiteral("kcmodule"), dialog, QVariantList({args}));
+    }
+
     if (!kcm) {
         return;
     }
@@ -211,28 +213,35 @@ void PreviewBridge::configure()
                                                           QStringLiteral("reloadConfig"));
         QDBusConnection::sessionBus().send(message);
     };
-    connect(&dialog, &QDialog::accepted, this, save);
+    connect(dialog, &QDialog::accepted, this, save);
 
     QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok |
                                                      QDialogButtonBox::Cancel |
                                                      QDialogButtonBox::RestoreDefaults |
                                                      QDialogButtonBox::Reset,
-                                                     &dialog);
+                                                     dialog);
 
     QPushButton *reset = buttons->button(QDialogButtonBox::Reset);
     reset->setEnabled(false);
     // Here we connect our buttons with the dialog
-    connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
-    connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
+    connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
+    connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
     connect(reset, &QPushButton::clicked, kcm, &KCModule::load);
     auto changedSignal = static_cast<void(KCModule::*)(bool)>(&KCModule::changed);
     connect(kcm, changedSignal, reset, &QPushButton::setEnabled);
     connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults);
 
-    QVBoxLayout *layout = new QVBoxLayout(&dialog);
+    QVBoxLayout *layout = new QVBoxLayout(dialog);
     layout->addWidget(kcm);
     layout->addWidget(buttons);
-    dialog.exec();
+
+    if (ctx->window()) {
+	dialog->winId(); // so it creates windowHandle
+	dialog->windowHandle()->setTransientParent(QQuickRenderControl::renderWindowFor(ctx->window()));
+	dialog->setModal(true);
+    }
+
+    dialog->show();
 }
 
 BridgeItem::BridgeItem(QObject *parent)
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
index 7e1d8f3..079333b 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h
@@ -26,6 +26,7 @@
 #include <QList>
 #include <QPointer>
 
+class QQuickItem;
 class KPluginFactory;
 
 namespace KDecoration2
@@ -47,7 +48,6 @@ public:
     explicit PreviewBridge(QObject *parent = nullptr);
     ~PreviewBridge() override;
     std::unique_ptr<DecoratedClientPrivate> createClient(DecoratedClient *client, Decoration *decoration) override;
-    void update(Decoration* decoration, const QRect& geometry) override;
     std::unique_ptr<DecorationSettingsPrivate> settings(DecorationSettings *parent) override;
 
     PreviewClient *lastCreatedClient() {
@@ -70,7 +70,7 @@ public:
     KDecoration2::DecorationButton *createButton(KDecoration2::Decoration *decoration, KDecoration2::DecorationButtonType type, QObject *parent = nullptr);
 
 public Q_SLOTS:
-    void configure();
+    void configure(QQuickItem *ctx);
 
 Q_SIGNALS:
     void pluginChanged();
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp b/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp
index 8319ccb..d214b1b 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp
@@ -405,8 +405,9 @@ void PreviewClient::requestToggleKeepBelow()
     setKeepBelow(!isKeepBelow());
 }
 
-void PreviewClient::requestShowWindowMenu()
+void PreviewClient::requestShowWindowMenu(const QRect &rect)
 {
+    Q_UNUSED(rect)
     emit showWindowMenuRequested();
 }
 
diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewclient.h b/kcmkwin/kwindecoration/declarative-plugin/previewclient.h
index c37db74..fe043db 100644
--- a/kcmkwin/kwindecoration/declarative-plugin/previewclient.h
+++ b/kcmkwin/kwindecoration/declarative-plugin/previewclient.h
@@ -107,7 +107,7 @@ public:
     void requestToggleKeepAbove() override;
     void requestToggleKeepBelow() override;
     void requestToggleShade() override;
-    void requestShowWindowMenu() override;
+    void requestShowWindowMenu(const QRect &rect) override;
     void requestShowApplicationMenu(const QRect &rect, int actionId) override;
     void requestToggleOnAllDesktops() override;
 
diff --git a/plugins/platforms/x11/common/eglonxbackend.cpp b/plugins/platforms/x11/common/eglonxbackend.cpp
index 0bb109d..92cf5ed 100644
--- a/plugins/platforms/x11/common/eglonxbackend.cpp
+++ b/plugins/platforms/x11/common/eglonxbackend.cpp
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *********************************************************************/
 #include "eglonxbackend.h"
+#include <kwinglutils.h>
 // kwin
 #include "main.h"
 #include "options.h"
diff --git a/plugins/platforms/x11/common/eglonxbackend.h b/plugins/platforms/x11/common/eglonxbackend.h
index bd9c69b..f12ce5f 100644
--- a/plugins/platforms/x11/common/eglonxbackend.h
+++ b/plugins/platforms/x11/common/eglonxbackend.h
@@ -29,6 +29,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "swap_profiler.h"
 
 #include <xcb/xcb.h>
+#include <X11/Xlib-xcb.h>
+#include <fixx11h.h>
+#include "../windowed/x11windowed_backend.h"
 
 namespace KWin
 {
diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h
index 5b75af3..0de0bd8 100644
--- a/plugins/platforms/x11/standalone/x11_platform.h
+++ b/plugins/platforms/x11/standalone/x11_platform.h
@@ -33,6 +33,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <memory>
 
+#include "../windowed/x11windowed_backend.h"
 namespace KWin
 {
 class SyncFilter;
diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp
index be48ca2..2e0dbee 100644
--- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp
+++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp
@@ -237,7 +237,7 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
                     m_keySymbols = xcb_key_symbols_alloc(m_connection);
                 }
                 const xcb_keysym_t kc = xcb_key_symbols_get_keysym(m_keySymbols, event->detail, 0);
-                if (kc == XK_Control_R) {
+                if (kc == 0xffe4) {
                     grabKeyboard(event->time);
                 }
                 keyboardKeyPressed(event->detail - 8, event->time);
diff --git a/po/tr/kwin.po b/po/tr/ukui-kwin.po
similarity index 100%
rename from po/tr/kwin.po
rename to po/tr/ukui-kwin.po
diff --git a/workspace.cpp b/workspace.cpp
index 2c682af..7172771 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -455,7 +455,7 @@ void Workspace::initWithX11()
     }
 
     // TODO: better value
-    rootInfo->setActiveWindow(None);
+    rootInfo->setActiveWindow(XCB_WINDOW_NONE);
     focusToNull();
 
     if (!qApp->isSessionRestored())
-- 
2.33.0

