Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Window Manager interaction #2041

Merged
merged 44 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d274b54
TaskBar: forward declare
gfgit Jan 28, 2024
43ddc7c
TaskBar: new ILXQtTaskbarAbstractBackend
gfgit Jan 27, 2024
223e8fc
ILXQtTaskbarAbstractBackend: add supportsAction() method
gfgit Jan 28, 2024
f1bf02a
TaskBar: add X11 backend
gfgit Jan 27, 2024
d0fe4b4
TaskBar: new LXQtTaskBarProxyModel
gfgit Jan 27, 2024
3a842e7
TaskBar: use backend in LXQtTaskBar
gfgit Jan 27, 2024
b81220d
TaskBar: initial use of backend in LXQtTaskButton
gfgit Feb 3, 2024
9cd7198
TaskBar: use backend for urgency hint
gfgit Feb 3, 2024
354e027
TaskBar: use backend to set window layer
gfgit Feb 3, 2024
290178e
TaskBar: use backend to close and raise window
gfgit Feb 3, 2024
78b5f7e
TaskBar: use backend to roll up (shade) windows
gfgit Feb 3, 2024
74bcae4
TaskBar: use backend to minimize window
gfgit Feb 3, 2024
a14a0fe
TaskBar: use backend to de-maximize window
gfgit Feb 3, 2024
d0d674e
TaskBar: use backend to get window state
gfgit Feb 3, 2024
b4af0df
TaskBar: use backend to set window state
gfgit Feb 3, 2024
6a28f7a
TaskBar: port workspace usage to backend
gfgit Jan 28, 2024
7fad2a1
TaskBar: remove X11 specific includes in lxqttaskbutton.cpp
gfgit Feb 3, 2024
d5a4751
TaskBar: remove X11 code from LXQtTaskBar and LXQtTaskGroup
gfgit Jan 28, 2024
649e85a
TaskBar: LXQtTaskButton remove X11 specific code
gfgit Jan 28, 2024
9974761
TaskBar: set context menu parent
gfgit Feb 17, 2024
b0e54b8
LXQtPanel: rework calculatePopupWindowPos()
gfgit Feb 17, 2024
8fd51ef
LXQtPanel: avoid QCursor::pos() usage
gfgit Feb 18, 2024
be23ae5
ILXQtTaskbarAbstractBackend: new Geometry window property
gfgit Feb 19, 2024
e334ec0
Move ILXQtTaskbarAbstractBackend to panel directory
gfgit Feb 17, 2024
9bbf4fa
ILXQtTaskbarAbstractBackend: new isAreaOverlapped() method
gfgit Feb 19, 2024
b9c8dfd
LXQtPanel: use less KX11Extras and more ILXQtTaskbarAbstractBackend
gfgit Feb 19, 2024
145d598
ILXQtTaskbarAbstractBackend: add dummy implementation
gfgit Feb 22, 2024
a3b7c02
LXQtMainMenu: indent header include
gfgit Feb 28, 2024
b199b77
ILXQtTaskbarAbstractBackend: new showDesktop() function
gfgit Feb 22, 2024
f59269c
ShowDesktop: use ILXQtTaskbarAbstractBackend
gfgit Feb 22, 2024
f1a26d4
DesktopSwitch: port to ILXQtTaskbarAbstractBackend
gfgit Feb 23, 2024
72a75e0
LXQtTaskbarConfiguration: port to ILXQtTaskBarAbstractBackend
gfgit Feb 23, 2024
05fc742
DesktopSwitchConfiguration: port to ILXQtTaskBarAbstractBackend TODO
gfgit Feb 23, 2024
8b78add
TaskBar: consider initial windows
gfgit Feb 22, 2024
0990829
DesktopSwitch: remove unused isWindowHighlightable()
gfgit May 10, 2024
1b7dadc
DesktopSwitch: show unsupported widget if backend does not have switch
gfgit May 10, 2024
79ace78
ILXQtTaskbarAbstractBackend: add setDesktopLayout() function
gfgit May 10, 2024
5e8966e
LXQtTaskbarX11Backend: fix re-add window after property changes
gfgit May 10, 2024
0e79998
LXQtTaskBarDummyBackend: fix compilation
gfgit May 10, 2024
09f006f
LXQtTaskBarPlugin: fix headers path
gfgit May 31, 2024
3fe36af
Revert "LXQtPanel: rework calculatePopupWindowPos()"
gfgit May 31, 2024
b5ffeee
Merge branch 'master' into work/gfgit/refactor_wm_interaction
gfgit Jun 5, 2024
76dad95
Removed `mDesktops` after rebasing
tsujan Jun 6, 2024
84ad2be
Reverted X11 codes of `DesktopSwitchConfiguration::loadDesktopsNames`
tsujan Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions panel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set(PROJECT lxqt-panel)

# TODO
add_subdirectory(backends)

set(PRIV_HEADERS
panelpluginsmodel.h
windownotifier.h
Expand All @@ -18,6 +21,12 @@ 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 @@ -26,6 +35,9 @@ set(PUB_HEADERS
pluginsettings.h
ilxqtpanelplugin.h
ilxqtpanel.h

backends/ilxqttaskbarabstractbackend.h
backends/lxqttaskbartypes.h
)

set(SOURCES
Expand All @@ -45,6 +57,11 @@ 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
1 change: 1 addition & 0 deletions panel/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(xcb)
25 changes: 25 additions & 0 deletions panel/backends/ilxqttaskbarabstractbackend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "../panel/backends/ilxqttaskbarabstractbackend.h"


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

}

void ILXQtTaskbarAbstractBackend::moveApplicationToPrevNextDesktop(WId windowId, bool next)
{
int count = getWorkspacesCount();
if (count <= 1)
return;

int targetWorkspace = getWindowWorkspace(windowId) + (next ? 1 : -1);

// Wrap around
if (targetWorkspace > count)
targetWorkspace = 1; //Ids are 1-based
else if (targetWorkspace < 1)
targetWorkspace = count;

setWindowOnWorkspace(windowId, targetWorkspace);
}
99 changes: 99 additions & 0 deletions panel/backends/ilxqttaskbarabstractbackend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#ifndef ILXQTTASKBARABSTRACTBACKEND_H
#define ILXQTTASKBARABSTRACTBACKEND_H

#include <QObject>

#include "lxqttaskbartypes.h"

class QIcon;
class QScreen;

class ILXQtTaskbarAbstractBackend : public QObject
{
Q_OBJECT

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

// Backend
virtual bool supportsAction(WId windowId, LXQtTaskBarBackendAction action) const = 0;

// Windows
virtual bool reloadWindows() = 0;

virtual QVector<WId> getCurrentWindows() const = 0;

virtual QString getWindowTitle(WId windowId) const = 0;

virtual bool applicationDemandsAttention(WId windowId) const = 0;

virtual QIcon getApplicationIcon(WId windowId, int fallbackDevicePixels) const = 0;

virtual QString getWindowClass(WId windowId) const = 0;

virtual LXQtTaskBarWindowLayer getWindowLayer(WId windowId) const = 0;
virtual bool setWindowLayer(WId windowId, LXQtTaskBarWindowLayer layer) = 0;

virtual LXQtTaskBarWindowState getWindowState(WId windowId) const = 0;
virtual bool setWindowState(WId windowId, LXQtTaskBarWindowState state, bool set = true) = 0;

virtual bool isWindowActive(WId windowId) const = 0;
virtual bool raiseWindow(WId windowId, bool onCurrentWorkSpace) = 0;

virtual bool closeWindow(WId windowId) = 0;

virtual WId getActiveWindow() const = 0;

// Workspaces
// NOTE: indexes are 1-based, 0 means "Show on All desktops"
virtual int getWorkspacesCount() const = 0;
virtual QString getWorkspaceName(int idx) const = 0;

virtual int getCurrentWorkspace() const = 0;
virtual bool setCurrentWorkspace(int idx) = 0;

virtual int getWindowWorkspace(WId windowId) const = 0;
virtual bool setWindowOnWorkspace(WId windowId, int idx) = 0;

virtual void moveApplicationToPrevNextDesktop(WId windowId, bool next); // Default implementation
virtual void moveApplicationToPrevNextMonitor(WId windowId, bool next, bool raiseOnCurrentDesktop) = 0;

virtual bool isWindowOnScreen(QScreen *screen, WId windowId) const = 0;

virtual bool setDesktopLayout(Qt::Orientation orientation, int rows, int columns, bool rightToLeft) = 0;

// X11 Specific
virtual void moveApplication(WId windowId) = 0;
virtual void resizeApplication(WId windowId) = 0;

virtual void refreshIconGeometry(WId windowId, const QRect &geom) = 0;

// Panel internal
virtual bool isAreaOverlapped(const QRect& area) const = 0;

// Show Destop TODO: split in multiple interfeces, this is becoming big
// NOTE: KWindowSystem already has these functions
// However on Wayland they are only compatible with KWin
// because internally it uses org_kde_plasma_window_management protocol
// We make this virtual so it can be implemented also for other compositors
virtual bool isShowingDesktop() const = 0;
virtual bool showDesktop(bool value) = 0;

signals:
void reloaded();

// Windows
void windowAdded(WId windowId);
void windowRemoved(WId windowId);
void windowPropertyChanged(WId windowId, int prop);

// Workspaces
void workspacesCountChanged();
void workspaceNameChanged(int idx);
void currentWorkspaceChanged(int idx);

// TODO: needed?
void activeWindowChanged(WId windowId);
};

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

#include <QIcon>

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

}


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading
Loading