Skip to content

Commit fdb07f8

Browse files
committed
Initial backend plugin infrastructure
1 parent 62ed09f commit fdb07f8

26 files changed

+470
-309
lines changed

panel/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ set(PRIV_HEADERS
2121
config/configstyling.h
2222
config/configpluginswidget.h
2323
config/addplugindialog.h
24-
25-
backends/ilxqttaskbarabstractbackend.h
26-
backends/lxqttaskbartypes.h
27-
28-
backends/lxqttaskbardummybackend.h
29-
backends/xcb/lxqttaskbarbackend_x11.h
3024
)
3125

3226
# using LXQt namespace in the public headers.
@@ -35,9 +29,6 @@ set(PUB_HEADERS
3529
pluginsettings.h
3630
ilxqtpanelplugin.h
3731
ilxqtpanel.h
38-
39-
backends/ilxqttaskbarabstractbackend.h
40-
backends/lxqttaskbartypes.h
4132
)
4233

4334
set(SOURCES
@@ -57,11 +48,6 @@ set(SOURCES
5748
config/configstyling.cpp
5849
config/configpluginswidget.cpp
5950
config/addplugindialog.cpp
60-
61-
backends/ilxqttaskbarabstractbackend.cpp
62-
63-
backends/lxqttaskbardummybackend.cpp
64-
backends/xcb/lxqttaskbarbackend_x11.cpp
6551
)
6652

6753
set(UI
@@ -122,6 +108,7 @@ target_link_libraries(${PROJECT}
122108
KF6::WindowSystem
123109
LayerShellQt::Interface
124110
${STATIC_PLUGINS}
111+
lxqt-panel-backend-common
125112
)
126113

127114
set_property(TARGET ${PROJECT} PROPERTY ENABLE_EXPORTS TRUE)

panel/backends/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1+
# Common interface for Window Manager abstraction backend
2+
# This also contains dummy backend
3+
4+
add_library(lxqt-panel-backend-common STATIC
5+
6+
lxqttaskbartypes.h
7+
ilxqtabstractwmiface.h
8+
ilxqtabstractwmiface.cpp
9+
10+
lxqtdummywmbackend.h
11+
lxqtdummywmbackend.cpp
12+
)
13+
14+
target_link_libraries(lxqt-panel-backend-common
15+
Qt6::Gui
16+
)
17+
118
add_subdirectory(xcb)

panel/backends/ilxqttaskbarabstractbackend.cpp renamed to panel/backends/ilxqtabstractwmiface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include "../panel/backends/ilxqttaskbarabstractbackend.h"
1+
#include "ilxqtabstractwmiface.h"
22

33

4-
ILXQtTaskbarAbstractBackend::ILXQtTaskbarAbstractBackend(QObject *parent)
4+
ILXQtAbstractWMInterface::ILXQtAbstractWMInterface(QObject *parent)
55
: QObject(parent)
66
{
77

88
}
99

10-
void ILXQtTaskbarAbstractBackend::moveApplicationToPrevNextDesktop(WId windowId, bool next)
10+
void ILXQtAbstractWMInterface::moveApplicationToPrevNextDesktop(WId windowId, bool next)
1111
{
1212
int count = getWorkspacesCount();
1313
if (count <= 1)

panel/backends/ilxqttaskbarabstractbackend.h renamed to panel/backends/ilxqtabstractwmiface.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#ifndef ILXQTTASKBARABSTRACTBACKEND_H
2-
#define ILXQTTASKBARABSTRACTBACKEND_H
1+
#ifndef ILXQT_ABSTRACT_WM_INTERFACE_H
2+
#define ILXQT_ABSTRACT_WM_INTERFACE_H
33

44
#include <QObject>
55

6+
#include "../lxqtpanelglobals.h"
67
#include "lxqttaskbartypes.h"
78

89
class QIcon;
910
class QScreen;
1011

11-
class ILXQtTaskbarAbstractBackend : public QObject
12+
class LXQT_PANEL_API ILXQtAbstractWMInterface : public QObject
1213
{
1314
Q_OBJECT
1415

1516
public:
16-
explicit ILXQtTaskbarAbstractBackend(QObject *parent = nullptr);
17+
explicit ILXQtAbstractWMInterface(QObject *parent = nullptr);
1718

1819
// Backend
1920
virtual bool supportsAction(WId windowId, LXQtTaskBarBackendAction action) const = 0;
@@ -96,4 +97,28 @@ class ILXQtTaskbarAbstractBackend : public QObject
9697
void activeWindowChanged(WId windowId);
9798
};
9899

99-
#endif // ILXQTTASKBARABSTRACTBACKEND_H
100+
class LXQT_PANEL_API ILXQtWMBackendLibrary
101+
{
102+
public:
103+
/**
104+
Destroys the ILXQtWMBackendLibrary object.
105+
**/
106+
virtual ~ILXQtWMBackendLibrary() {}
107+
108+
/**
109+
Returns the score of this backend for current detected environment.
110+
This is used to select correct backend at runtime
111+
**/
112+
virtual int getBackendScore() const = 0;
113+
114+
/**
115+
Returns the root component object of the backend. When the library is finally unloaded, the root component will automatically be deleted.
116+
**/
117+
virtual ILXQtAbstractWMInterface* instance() const = 0;
118+
};
119+
120+
121+
Q_DECLARE_INTERFACE(ILXQtWMBackendLibrary,
122+
"lxqt.org/Panel/WMInterface/1.0")
123+
124+
#endif // ILXQT_ABSTRACT_WM_INTERFACE_H

panel/backends/lxqtdummywmbackend.cpp

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#include "lxqtdummywmbackend.h"
2+
3+
#include <QIcon>
4+
5+
LXQtDummyWMBackend::LXQtDummyWMBackend(QObject *parent)
6+
: ILXQtAbstractWMInterface(parent)
7+
{
8+
9+
}
10+
11+
/************************************************
12+
* Windows function
13+
************************************************/
14+
bool LXQtDummyWMBackend::supportsAction(WId, LXQtTaskBarBackendAction) const
15+
{
16+
return false;
17+
}
18+
19+
bool LXQtDummyWMBackend::reloadWindows()
20+
{
21+
return false;
22+
}
23+
24+
QVector<WId> LXQtDummyWMBackend::getCurrentWindows() const
25+
{
26+
return {};
27+
}
28+
29+
QString LXQtDummyWMBackend::getWindowTitle(WId) const
30+
{
31+
return QString();
32+
}
33+
34+
bool LXQtDummyWMBackend::applicationDemandsAttention(WId) const
35+
{
36+
return false;
37+
}
38+
39+
QIcon LXQtDummyWMBackend::getApplicationIcon(WId, int) const
40+
{
41+
return QIcon();
42+
}
43+
44+
QString LXQtDummyWMBackend::getWindowClass(WId) const
45+
{
46+
return QString();
47+
}
48+
49+
LXQtTaskBarWindowLayer LXQtDummyWMBackend::getWindowLayer(WId) const
50+
{
51+
return LXQtTaskBarWindowLayer::Normal;
52+
}
53+
54+
bool LXQtDummyWMBackend::setWindowLayer(WId, LXQtTaskBarWindowLayer)
55+
{
56+
return false;
57+
}
58+
59+
LXQtTaskBarWindowState LXQtDummyWMBackend::getWindowState(WId) const
60+
{
61+
return LXQtTaskBarWindowState::Normal;
62+
}
63+
64+
bool LXQtDummyWMBackend::setWindowState(WId, LXQtTaskBarWindowState, bool)
65+
{
66+
return false;
67+
}
68+
69+
bool LXQtDummyWMBackend::isWindowActive(WId) const
70+
{
71+
return false;
72+
}
73+
74+
bool LXQtDummyWMBackend::raiseWindow(WId, bool)
75+
{
76+
return false;
77+
}
78+
79+
bool LXQtDummyWMBackend::closeWindow(WId)
80+
{
81+
return false;
82+
}
83+
84+
WId LXQtDummyWMBackend::getActiveWindow() const
85+
{
86+
return 0;
87+
}
88+
89+
90+
/************************************************
91+
* Workspaces
92+
************************************************/
93+
int LXQtDummyWMBackend::getWorkspacesCount() const
94+
{
95+
return 1; // Fake 1 workspace
96+
}
97+
98+
QString LXQtDummyWMBackend::getWorkspaceName(int) const
99+
{
100+
return QString();
101+
}
102+
103+
int LXQtDummyWMBackend::getCurrentWorkspace() const
104+
{
105+
return 0;
106+
}
107+
108+
bool LXQtDummyWMBackend::setCurrentWorkspace(int)
109+
{
110+
return false;
111+
}
112+
113+
int LXQtDummyWMBackend::getWindowWorkspace(WId) const
114+
{
115+
return 0;
116+
}
117+
118+
bool LXQtDummyWMBackend::setWindowOnWorkspace(WId, int)
119+
{
120+
return false;
121+
}
122+
123+
void LXQtDummyWMBackend::moveApplicationToPrevNextMonitor(WId, bool, bool)
124+
{
125+
//No-op
126+
}
127+
128+
bool LXQtDummyWMBackend::isWindowOnScreen(QScreen *, WId) const
129+
{
130+
return false;
131+
}
132+
133+
bool LXQtDummyWMBackend::setDesktopLayout(Qt::Orientation, int, int, bool)
134+
{
135+
return false;
136+
}
137+
138+
/************************************************
139+
* X11 Specific
140+
************************************************/
141+
void LXQtDummyWMBackend::moveApplication(WId)
142+
{
143+
//No-op
144+
}
145+
146+
void LXQtDummyWMBackend::resizeApplication(WId)
147+
{
148+
//No-op
149+
}
150+
151+
void LXQtDummyWMBackend::refreshIconGeometry(WId, QRect const &)
152+
{
153+
//No-op
154+
}
155+
156+
bool LXQtDummyWMBackend::isAreaOverlapped(const QRect &) const
157+
{
158+
return false;
159+
}
160+
161+
bool LXQtDummyWMBackend::isShowingDesktop() const
162+
{
163+
return false;
164+
}
165+
166+
bool LXQtDummyWMBackend::showDesktop(bool)
167+
{
168+
return false;
169+
}
170+

panel/backends/lxqttaskbardummybackend.h renamed to panel/backends/lxqtdummywmbackend.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#ifndef LXQTTASKBARDUMMYBACKEND_H
2-
#define LXQTTASKBARDUMMYBACKEND_H
1+
#ifndef LXQT_DUMMY_WM_BACKEND_H
2+
#define LXQT_DUMMY_WM_BACKEND_H
33

4-
#include "ilxqttaskbarabstractbackend.h"
4+
#include "ilxqtabstractwmiface.h"
55

6-
class LXQtTaskBarDummyBackend : public ILXQtTaskbarAbstractBackend
6+
class LXQtDummyWMBackend : public ILXQtAbstractWMInterface
77
{
88
Q_OBJECT
99

1010
public:
11-
explicit LXQtTaskBarDummyBackend(QObject *parent = nullptr);
11+
explicit LXQtDummyWMBackend(QObject *parent = nullptr);
1212

1313
// Backend
1414
bool supportsAction(WId windowId, LXQtTaskBarBackendAction action) const override;
@@ -85,4 +85,4 @@ class LXQtTaskBarDummyBackend : public ILXQtTaskbarAbstractBackend
8585
void activeWindowChanged(WId windowId);
8686
};
8787

88-
#endif // LXQTTASKBARDUMMYBACKEND_H
88+
#endif // LXQT_DUMMY_WM_BACKEND_H

0 commit comments

Comments
 (0)