From f321b9772bec5f7925e58435e1027ecec5a4e9a8 Mon Sep 17 00:00:00 2001
From: Chupligin Sergey <neochapay@gmail.com>
Date: Wed, 24 Mar 2021 19:39:56 +0300
Subject: [PATCH] [compositor] Drop Qt extended surface

---
 src/compositor/lipstickcompositor.cpp       | 11 ---------
 src/compositor/lipstickcompositor.h         |  7 ------
 src/compositor/lipstickcompositorwindow.cpp | 25 +++++----------------
 src/compositor/lipstickcompositorwindow.h   |  6 -----
 src/compositor/windowmodel.cpp              | 22 ------------------
 5 files changed, 5 insertions(+), 66 deletions(-)

diff --git a/src/compositor/lipstickcompositor.cpp b/src/compositor/lipstickcompositor.cpp
index 4dce9d7b..00bb548e 100644
--- a/src/compositor/lipstickcompositor.cpp
+++ b/src/compositor/lipstickcompositor.cpp
@@ -35,7 +35,6 @@
 #include <private/qguiapplication_p.h>
 #include <QtGui/qpa/qplatformintegration.h>
 #include <QWaylandQuickShellSurfaceItem>
-#include <QtWaylandCompositor/private/qwlextendedsurface_p.h>
 
 #include <mce/dbus-names.h>
 #include <mce/mode-names.h>
@@ -77,9 +76,6 @@ LipstickCompositor::LipstickCompositor()
     m_xdgShell = new QWaylandXdgShell(this);
     connect(m_xdgShell, &QWaylandXdgShell::toplevelCreated, this, &LipstickCompositor::onToplevelCreated);
 
-    m_surfExtGlob = new QtWayland::SurfaceExtensionGlobal(this);
-    connect(m_surfExtGlob, &QtWayland::SurfaceExtensionGlobal::extendedSurfaceReady, this, &LipstickCompositor::onExtendedSurfaceReady);
-
     m_wm = new QWaylandQtWindowManager(this);
     connect(m_wm, &QWaylandQtWindowManager::openUrl, this, &LipstickCompositor::openUrl);
 
@@ -194,13 +190,6 @@ void LipstickCompositor::onSurfaceCreated(QWaylandSurface *surface)
     connect(surface, SIGNAL(redraw()), this, SLOT(windowSwapped()));
 }
 
-void LipstickCompositor::onExtendedSurfaceReady(QtWayland::ExtendedSurface *extSurface, QWaylandSurface *surface)
-{
-    LipstickCompositorWindow *window = surfaceWindow(surface);
-    if(window)
-        window->setExtendedSurface(extSurface);
-}
-
 bool LipstickCompositor::openUrl(QWaylandClient *client, const QUrl &url)
 {
     Q_UNUSED(client)
diff --git a/src/compositor/lipstickcompositor.h b/src/compositor/lipstickcompositor.h
index a22b474f..b570f669 100644
--- a/src/compositor/lipstickcompositor.h
+++ b/src/compositor/lipstickcompositor.h
@@ -33,11 +33,6 @@
 #include <timed-qt5/exception>
 #include <timed-qt5/event-declarations.h>
 
-namespace QtWayland {
-    class SurfaceExtensionGlobal;
-    class ExtendedSurface;
-}
-
 class WindowModel;
 class LipstickCompositorWindow;
 class LipstickCompositorProcWindow;
@@ -191,7 +186,6 @@ private slots:
     void initialize();
 
     void onToplevelCreated(QWaylandXdgToplevel * topLevel, QWaylandXdgSurface * shellSurface);
-    void onExtendedSurfaceReady(QtWayland::ExtendedSurface *extSurface, QWaylandSurface *surface);
 
 private:
     friend class LipstickCompositorWindow;
@@ -245,7 +239,6 @@ private slots:
     QQuickWindow *m_window;
     QWaylandOutput *m_output;
     QWaylandXdgShell *m_xdgShell;
-    QtWayland::SurfaceExtensionGlobal *m_surfExtGlob;
     QWaylandQtWindowManager *m_wm;
 
     Maemo::Timed::Interface *m_timedDbus;
diff --git a/src/compositor/lipstickcompositorwindow.cpp b/src/compositor/lipstickcompositorwindow.cpp
index 5bfc79ea..db15f501 100644
--- a/src/compositor/lipstickcompositorwindow.cpp
+++ b/src/compositor/lipstickcompositorwindow.cpp
@@ -17,6 +17,7 @@
 #include <QWaylandCompositor>
 #include <QWaylandSeat>
 #include <QTimer>
+#include <QEvent>
 #include <sys/types.h>
 #include <signal.h>
 #include "lipstickcompositor.h"
@@ -28,14 +29,13 @@
 #include <EGL/egl.h>
 #include <private/qwaylandsurface_p.h>
 #include <private/qquickwindow_p.h>
-#include <QtWaylandCompositor/private/qwlextendedsurface_p.h>
 
 LipstickCompositorWindow::LipstickCompositorWindow(int windowId, const QString &category,
                                                    QWaylandSurface *surface, QQuickItem *parent)
 : QWaylandQuickItem(), m_windowId(windowId), m_category(category),
   m_delayRemove(false), m_windowClosed(false), m_removePosted(false),
   m_interceptingTouch(false), m_mapped(false), m_noHardwareComposition(false),
-  m_focusOnTouch(false), m_hasVisibleReferences(false), m_extSurface(nullptr)
+  m_focusOnTouch(false), m_hasVisibleReferences(false)
 {
     setFlags(QQuickItem::ItemIsFocusScope | flags());
 
@@ -111,29 +111,14 @@ QString LipstickCompositorWindow::category() const
     return m_category;
 }
 
-QtWayland::ExtendedSurface *LipstickCompositorWindow::extendedSurface()
-{
-    return m_extSurface;
-}
-
-void LipstickCompositorWindow::setExtendedSurface(QtWayland::ExtendedSurface *extSurface)
-{
-    m_extSurface = extSurface;
-    connect(m_extSurface, SIGNAL(windowFlagsChanged()), this, SIGNAL(windowFlagsChanged()));
-}
 
 qint16 LipstickCompositorWindow::windowFlags()
 {
-    if (m_extSurface) {
-        return m_extSurface->windowFlags();
-    }
     return 0;
 }
 
 QVariantMap LipstickCompositorWindow::windowProperties()
 {
-    if (m_extSurface)
-        return m_extSurface->windowProperties();
     return QVariantMap();
 }
 
@@ -198,15 +183,15 @@ bool LipstickCompositorWindow::eventFilter(QObject *obj, QEvent *event)
         }
         return false;
     }
-    if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
+    if (event->type() == 6 || event->type() == 7) {
         QKeyEvent *ke = static_cast<QKeyEvent *>(event);
         QWaylandSurface *m_surface = surface();
         if (m_surface) {
             QWaylandSeat *inputDevice = m_surface->compositor()->seatFor(ke);
-            if (event->type() == QEvent::KeyPress)
+            if (event->type() == 6) //KeyPress
                 inputDevice->setKeyboardFocus(m_surface);
             inputDevice->sendFullKeyEvent(ke);
-            if (event->type() == QEvent::KeyRelease)
+            if (event->type() == 7) //KeyRelease
                 qApp->removeEventFilter(this);
             return true;
         }
diff --git a/src/compositor/lipstickcompositorwindow.h b/src/compositor/lipstickcompositorwindow.h
index c85e46ad..4af3693c 100644
--- a/src/compositor/lipstickcompositorwindow.h
+++ b/src/compositor/lipstickcompositorwindow.h
@@ -20,9 +20,6 @@
 #include <QWaylandBufferRef>
 #include "lipstickglobal.h"
 
-namespace QtWayland {
-    class ExtendedSurface;
-}
 class LipstickCompositorWindowHwcNode;
 
 class LIPSTICK_EXPORT LipstickCompositorWindow : public QWaylandQuickItem
@@ -106,8 +103,6 @@ private slots:
     void tryRemove();
     void handleTouchEvent(QTouchEvent *e);
 
-    void setExtendedSurface(QtWayland::ExtendedSurface *extSurface);
-    QtWayland::ExtendedSurface *extendedSurface();
     void setTitle(QString title);
     QString m_title;
 
@@ -124,7 +119,6 @@ private slots:
     QVariant m_data;
     QList<QMetaObject::Connection> m_surfaceConnections;
     QVector<QQuickItem *> m_refs;
-    QtWayland::ExtendedSurface *m_extSurface;
 };
 
 #endif // LIPSTICKCOMPOSITORWINDOW_H
diff --git a/src/compositor/windowmodel.cpp b/src/compositor/windowmodel.cpp
index 245e23a2..c942d493 100644
--- a/src/compositor/windowmodel.cpp
+++ b/src/compositor/windowmodel.cpp
@@ -14,7 +14,6 @@
 ****************************************************************************/
 
 #include <QDBusConnection>
-#include <QtWaylandCompositor/private/qwlextendedsurface_p.h>
 #include "lipstickcompositorwindow.h"
 #include "lipstickcompositor.h"
 #include "windowmodel.h"
@@ -202,27 +201,6 @@ void WindowModel::launchProcess(const QString &binaryName)
                 proc << part;
             }
         }
-
-        // Cannot match, as the cmdline has less arguments than then binary part
-        if (binaryParts.size() > proc.size()) {
-            continue;
-        }
-
-        bool match = true;
-
-        // All parts of binaryName must be contained in this order in the
-        // process command line to match the given process
-        for (int i=0; i<binaryParts.count(); i++) {
-            if (proc[i] != binaryParts[i]) {
-                match = false;
-                break;
-            }
-        }
-
-        if (match) {
-            emit win->extendedSurface()->raiseRequested();
-            break;
-        }
     }
 }
 
