Skip to content

Commit

Permalink
Initial backend plugin infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgit committed Jul 9, 2024
1 parent 62ed09f commit fdb07f8
Show file tree
Hide file tree
Showing 26 changed files with 470 additions and 309 deletions.
15 changes: 1 addition & 14 deletions panel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ set(PRIV_HEADERS
config/configstyling.h
config/configpluginswidget.h
config/addplugindialog.h

backends/ilxqttaskbarabstractbackend.h
backends/lxqttaskbartypes.h

backends/lxqttaskbardummybackend.h
backends/xcb/lxqttaskbarbackend_x11.h
)

# using LXQt namespace in the public headers.
Expand All @@ -35,9 +29,6 @@ set(PUB_HEADERS
pluginsettings.h
ilxqtpanelplugin.h
ilxqtpanel.h

backends/ilxqttaskbarabstractbackend.h
backends/lxqttaskbartypes.h
)

set(SOURCES
Expand All @@ -57,11 +48,6 @@ set(SOURCES
config/configstyling.cpp
config/configpluginswidget.cpp
config/addplugindialog.cpp

backends/ilxqttaskbarabstractbackend.cpp

backends/lxqttaskbardummybackend.cpp
backends/xcb/lxqttaskbarbackend_x11.cpp
)

set(UI
Expand Down Expand Up @@ -122,6 +108,7 @@ target_link_libraries(${PROJECT}
KF6::WindowSystem
LayerShellQt::Interface
${STATIC_PLUGINS}
lxqt-panel-backend-common
)

set_property(TARGET ${PROJECT} PROPERTY ENABLE_EXPORTS TRUE)
Expand Down
17 changes: 17 additions & 0 deletions panel/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# Common interface for Window Manager abstraction backend
# This also contains dummy backend

add_library(lxqt-panel-backend-common STATIC

lxqttaskbartypes.h
ilxqtabstractwmiface.h
ilxqtabstractwmiface.cpp

lxqtdummywmbackend.h
lxqtdummywmbackend.cpp
)

target_link_libraries(lxqt-panel-backend-common
Qt6::Gui
)

add_subdirectory(xcb)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "../panel/backends/ilxqttaskbarabstractbackend.h"
#include "ilxqtabstractwmiface.h"


ILXQtTaskbarAbstractBackend::ILXQtTaskbarAbstractBackend(QObject *parent)
ILXQtAbstractWMInterface::ILXQtAbstractWMInterface(QObject *parent)
: QObject(parent)
{

}

void ILXQtTaskbarAbstractBackend::moveApplicationToPrevNextDesktop(WId windowId, bool next)
void ILXQtAbstractWMInterface::moveApplicationToPrevNextDesktop(WId windowId, bool next)
{
int count = getWorkspacesCount();
if (count <= 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#ifndef ILXQTTASKBARABSTRACTBACKEND_H
#define ILXQTTASKBARABSTRACTBACKEND_H
#ifndef ILXQT_ABSTRACT_WM_INTERFACE_H
#define ILXQT_ABSTRACT_WM_INTERFACE_H

#include <QObject>

#include "../lxqtpanelglobals.h"
#include "lxqttaskbartypes.h"

class QIcon;
class QScreen;

class ILXQtTaskbarAbstractBackend : public QObject
class LXQT_PANEL_API ILXQtAbstractWMInterface : public QObject
{
Q_OBJECT

public:
explicit ILXQtTaskbarAbstractBackend(QObject *parent = nullptr);
explicit ILXQtAbstractWMInterface(QObject *parent = nullptr);

// Backend
virtual bool supportsAction(WId windowId, LXQtTaskBarBackendAction action) const = 0;
Expand Down Expand Up @@ -96,4 +97,28 @@ class ILXQtTaskbarAbstractBackend : public QObject
void activeWindowChanged(WId windowId);
};

#endif // ILXQTTASKBARABSTRACTBACKEND_H
class LXQT_PANEL_API ILXQtWMBackendLibrary
{
public:
/**
Destroys the ILXQtWMBackendLibrary object.
**/
virtual ~ILXQtWMBackendLibrary() {}

/**
Returns the score of this backend for current detected environment.
This is used to select correct backend at runtime
**/
virtual int getBackendScore() const = 0;

/**
Returns the root component object of the backend. When the library is finally unloaded, the root component will automatically be deleted.
**/
virtual ILXQtAbstractWMInterface* instance() const = 0;
};


Q_DECLARE_INTERFACE(ILXQtWMBackendLibrary,
"lxqt.org/Panel/WMInterface/1.0")

#endif // ILXQT_ABSTRACT_WM_INTERFACE_H
170 changes: 170 additions & 0 deletions panel/backends/lxqtdummywmbackend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#include "lxqtdummywmbackend.h"

#include <QIcon>

LXQtDummyWMBackend::LXQtDummyWMBackend(QObject *parent)
: ILXQtAbstractWMInterface(parent)
{

}

/************************************************
* Windows function
************************************************/
bool LXQtDummyWMBackend::supportsAction(WId, LXQtTaskBarBackendAction) const
{
return false;
}

bool LXQtDummyWMBackend::reloadWindows()
{
return false;
}

QVector<WId> LXQtDummyWMBackend::getCurrentWindows() const
{
return {};
}

QString LXQtDummyWMBackend::getWindowTitle(WId) const
{
return QString();
}

bool LXQtDummyWMBackend::applicationDemandsAttention(WId) const
{
return false;
}

QIcon LXQtDummyWMBackend::getApplicationIcon(WId, int) const
{
return QIcon();
}

QString LXQtDummyWMBackend::getWindowClass(WId) const
{
return QString();
}

LXQtTaskBarWindowLayer LXQtDummyWMBackend::getWindowLayer(WId) const
{
return LXQtTaskBarWindowLayer::Normal;
}

bool LXQtDummyWMBackend::setWindowLayer(WId, LXQtTaskBarWindowLayer)
{
return false;
}

LXQtTaskBarWindowState LXQtDummyWMBackend::getWindowState(WId) const
{
return LXQtTaskBarWindowState::Normal;
}

bool LXQtDummyWMBackend::setWindowState(WId, LXQtTaskBarWindowState, bool)
{
return false;
}

bool LXQtDummyWMBackend::isWindowActive(WId) const
{
return false;
}

bool LXQtDummyWMBackend::raiseWindow(WId, bool)
{
return false;
}

bool LXQtDummyWMBackend::closeWindow(WId)
{
return false;
}

WId LXQtDummyWMBackend::getActiveWindow() const
{
return 0;
}


/************************************************
* Workspaces
************************************************/
int LXQtDummyWMBackend::getWorkspacesCount() const
{
return 1; // Fake 1 workspace
}

QString LXQtDummyWMBackend::getWorkspaceName(int) const
{
return QString();
}

int LXQtDummyWMBackend::getCurrentWorkspace() const
{
return 0;
}

bool LXQtDummyWMBackend::setCurrentWorkspace(int)
{
return false;
}

int LXQtDummyWMBackend::getWindowWorkspace(WId) const
{
return 0;
}

bool LXQtDummyWMBackend::setWindowOnWorkspace(WId, int)
{
return false;
}

void LXQtDummyWMBackend::moveApplicationToPrevNextMonitor(WId, bool, bool)
{
//No-op
}

bool LXQtDummyWMBackend::isWindowOnScreen(QScreen *, WId) const
{
return false;
}

bool LXQtDummyWMBackend::setDesktopLayout(Qt::Orientation, int, int, bool)
{
return false;
}

/************************************************
* X11 Specific
************************************************/
void LXQtDummyWMBackend::moveApplication(WId)
{
//No-op
}

void LXQtDummyWMBackend::resizeApplication(WId)
{
//No-op
}

void LXQtDummyWMBackend::refreshIconGeometry(WId, QRect const &)
{
//No-op
}

bool LXQtDummyWMBackend::isAreaOverlapped(const QRect &) const
{
return false;
}

bool LXQtDummyWMBackend::isShowingDesktop() const
{
return false;
}

bool LXQtDummyWMBackend::showDesktop(bool)
{
return false;
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef LXQTTASKBARDUMMYBACKEND_H
#define LXQTTASKBARDUMMYBACKEND_H
#ifndef LXQT_DUMMY_WM_BACKEND_H
#define LXQT_DUMMY_WM_BACKEND_H

#include "ilxqttaskbarabstractbackend.h"
#include "ilxqtabstractwmiface.h"

class LXQtTaskBarDummyBackend : public ILXQtTaskbarAbstractBackend
class LXQtDummyWMBackend : public ILXQtAbstractWMInterface
{
Q_OBJECT

public:
explicit LXQtTaskBarDummyBackend(QObject *parent = nullptr);
explicit LXQtDummyWMBackend(QObject *parent = nullptr);

// Backend
bool supportsAction(WId windowId, LXQtTaskBarBackendAction action) const override;
Expand Down Expand Up @@ -85,4 +85,4 @@ class LXQtTaskBarDummyBackend : public ILXQtTaskbarAbstractBackend
void activeWindowChanged(WId windowId);
};

#endif // LXQTTASKBARDUMMYBACKEND_H
#endif // LXQT_DUMMY_WM_BACKEND_H
Loading

0 comments on commit fdb07f8

Please sign in to comment.