wip ext-ws
This commit is contained in:
parent
767a8ef8ad
commit
24bbf34974
18 changed files with 765 additions and 0 deletions
|
@ -11,6 +11,7 @@ add_subdirectory(window)
|
||||||
add_subdirectory(io)
|
add_subdirectory(io)
|
||||||
add_subdirectory(widgets)
|
add_subdirectory(widgets)
|
||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
||||||
|
add_subdirectory(windowmanager)
|
||||||
|
|
||||||
if (CRASH_REPORTER)
|
if (CRASH_REPORTER)
|
||||||
add_subdirectory(crash)
|
add_subdirectory(crash)
|
||||||
|
|
|
@ -113,6 +113,8 @@ if (HYPRLAND)
|
||||||
add_subdirectory(hyprland)
|
add_subdirectory(hyprland)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(windowmanager)
|
||||||
|
|
||||||
# widgets for qmenu
|
# widgets for qmenu
|
||||||
target_link_libraries(quickshell-wayland PRIVATE
|
target_link_libraries(quickshell-wayland PRIVATE
|
||||||
Qt::Quick Qt::Widgets Qt::WaylandClient Qt::WaylandClientPrivate
|
Qt::Quick Qt::Widgets Qt::WaylandClient Qt::WaylandClientPrivate
|
||||||
|
|
20
src/wayland/windowmanager/CMakeLists.txt
Normal file
20
src/wayland/windowmanager/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
qt_add_library(quickshell-wayland-windowsystem STATIC
|
||||||
|
windowmanager.cpp
|
||||||
|
workspace.cpp
|
||||||
|
ext_workspace.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(quickshell-wayland-windowsystem-init OBJECT init.cpp)
|
||||||
|
target_link_libraries(quickshell-wayland-windowsystem-init PRIVATE Qt::Quick)
|
||||||
|
|
||||||
|
#wl_proto(wlp-ext-foreign-toplevel ext-foreign-toplevel-list-v1 "${WAYLAND_PROTOCOLS}/staging/ext-foreign-toplevel-list")
|
||||||
|
wl_proto(wlp-ext-workspace ext-workspace-v1 "${WAYLAND_PROTOCOLS}/staging/ext-workspace")
|
||||||
|
|
||||||
|
target_link_libraries(quickshell-wayland-windowsystem PRIVATE
|
||||||
|
Qt::WaylandClient Qt::WaylandClientPrivate wayland-client
|
||||||
|
Qt::Quick # for pch? potentially, check w/ gcc
|
||||||
|
|
||||||
|
wlp-ext-foreign-toplevel wlp-ext-workspace
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(quickshell PRIVATE quickshell-wayland-windowsystem quickshell-wayland-windowsystem-init)
|
116
src/wayland/windowmanager/ext_workspace.cpp
Normal file
116
src/wayland/windowmanager/ext_workspace.cpp
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
#include "ext_workspace.hpp"
|
||||||
|
|
||||||
|
#include <qloggingcategory.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
#include <qtypes.h>
|
||||||
|
|
||||||
|
#include "qwayland-ext-workspace-v1.h"
|
||||||
|
#include "wayland-ext-workspace-v1-client-protocol.h"
|
||||||
|
|
||||||
|
namespace qs::wayland::workspace {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
Q_LOGGING_CATEGORY(logWorkspace, "quickshell.wm.wayland.workspace");
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceManager::WorkspaceManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
|
||||||
|
|
||||||
|
WorkspaceManager* WorkspaceManager::instance() {
|
||||||
|
static auto* instance = new WorkspaceManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::ext_workspace_manager_v1_workspace_group(
|
||||||
|
::ext_workspace_group_handle_v1* workspaceGroup
|
||||||
|
) {
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::ext_workspace_manager_v1_workspace(::ext_workspace_handle_v1* workspace) {
|
||||||
|
auto* qws = new Workspace(workspace);
|
||||||
|
qCDebug(logWorkspace) << "Created workspace" << qws;
|
||||||
|
this->mWorkspaces.insert(workspace, qws);
|
||||||
|
emit this->workspaceCreated(qws);
|
||||||
|
};
|
||||||
|
|
||||||
|
void WorkspaceManager::destroyWorkspace(Workspace* workspace) {
|
||||||
|
this->destroyedWorkspaces.append(workspace);
|
||||||
|
emit this->workspaceDestroyed(workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::ext_workspace_manager_v1_done() {
|
||||||
|
qCDebug(logWorkspace) << "Workspace changes done";
|
||||||
|
emit this->serverCommit();
|
||||||
|
|
||||||
|
for (auto* workspace: this->destroyedWorkspaces) delete workspace;
|
||||||
|
this->destroyedWorkspaces.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::ext_workspace_manager_v1_finished() {
|
||||||
|
// todo
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceGroup::~WorkspaceGroup() { this->destroy(); }
|
||||||
|
void WorkspaceGroup::ext_workspace_group_handle_v1_removed() { delete this; }
|
||||||
|
|
||||||
|
Workspace::~Workspace() {
|
||||||
|
if (this->isInitialized()) this->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_id(const QString& id) {
|
||||||
|
qCDebug(logWorkspace) << "Updated id for" << this << "to" << id;
|
||||||
|
this->id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_name(const QString& name) {
|
||||||
|
qCDebug(logWorkspace) << "Updated name for" << this << "to" << name;
|
||||||
|
this->name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_coordinates(wl_array* coordinates) {
|
||||||
|
this->coordinates.clear();
|
||||||
|
|
||||||
|
auto* data = static_cast<qint32*>(coordinates->data);
|
||||||
|
auto size = static_cast<qsizetype>(coordinates->size / sizeof(qint32));
|
||||||
|
|
||||||
|
for (auto i = 0; i != size; ++i) {
|
||||||
|
this->coordinates.append(data[i]); // NOLINT
|
||||||
|
}
|
||||||
|
|
||||||
|
qCDebug(logWorkspace) << "Updated coordinates for" << this << "to" << this->coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_state(quint32 state) {
|
||||||
|
this->active = state & QtWayland::ext_workspace_handle_v1::state_active;
|
||||||
|
this->urgent = state & QtWayland::ext_workspace_handle_v1::state_urgent;
|
||||||
|
this->hidden = state & QtWayland::ext_workspace_handle_v1::state_hidden;
|
||||||
|
|
||||||
|
qCDebug(logWorkspace).nospace() << "Updated state for " << this << " to [active: " << this->active
|
||||||
|
<< ", urgent: " << this->urgent << ", hidden: " << this->hidden
|
||||||
|
<< ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_capabilities(quint32 capabilities) {
|
||||||
|
this->canActivate =
|
||||||
|
capabilities & QtWayland::ext_workspace_handle_v1::workspace_capabilities_activate;
|
||||||
|
this->canDeactivate =
|
||||||
|
capabilities & QtWayland::ext_workspace_handle_v1::workspace_capabilities_deactivate;
|
||||||
|
this->canRemove =
|
||||||
|
capabilities & QtWayland::ext_workspace_handle_v1::workspace_capabilities_remove;
|
||||||
|
this->canAssign =
|
||||||
|
capabilities & QtWayland::ext_workspace_handle_v1::workspace_capabilities_assign;
|
||||||
|
|
||||||
|
qCDebug(logWorkspace).nospace() << "Updated capabilities for " << this
|
||||||
|
<< " to [activate: " << this->canActivate
|
||||||
|
<< ", deactivate: " << this->canDeactivate
|
||||||
|
<< ", remove: " << this->canRemove
|
||||||
|
<< ", assign: " << this->canAssign << ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
void Workspace::ext_workspace_handle_v1_removed() {
|
||||||
|
qCDebug(logWorkspace) << "Destroyed workspace" << this;
|
||||||
|
this->destroy();
|
||||||
|
WorkspaceManager::instance()->destroyWorkspace(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qs::wayland::workspace
|
109
src/wayland/windowmanager/ext_workspace.hpp
Normal file
109
src/wayland/windowmanager/ext_workspace.hpp
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
|
#include <qlist.h>
|
||||||
|
#include <qloggingcategory.h>
|
||||||
|
#include <qscreen.h>
|
||||||
|
#include <qscreen_platform.h>
|
||||||
|
#include <qtclasshelpermacros.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
#include <qtypes.h>
|
||||||
|
#include <qwayland-ext-workspace-v1.h>
|
||||||
|
#include <qwaylandclientextension.h>
|
||||||
|
#include <wayland-ext-workspace-v1-client-protocol.h>
|
||||||
|
|
||||||
|
namespace qs::wayland::workspace {
|
||||||
|
|
||||||
|
class WorkspaceGroup;
|
||||||
|
class Workspace;
|
||||||
|
|
||||||
|
class WorkspaceManager
|
||||||
|
: public QWaylandClientExtensionTemplate<WorkspaceManager>
|
||||||
|
, public QtWayland::ext_workspace_manager_v1 {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static WorkspaceManager* instance();
|
||||||
|
|
||||||
|
[[nodiscard]] QList<Workspace*> workspaces() { return this->mWorkspaces.values(); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void serverCommit();
|
||||||
|
void workspaceCreated(Workspace* workspace);
|
||||||
|
void workspaceDestroyed(Workspace* workspace);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ext_workspace_manager_v1_workspace_group(::ext_workspace_group_handle_v1* workspaceGroup
|
||||||
|
) override;
|
||||||
|
void ext_workspace_manager_v1_workspace(::ext_workspace_handle_v1* workspace) override;
|
||||||
|
void ext_workspace_manager_v1_done() override;
|
||||||
|
void ext_workspace_manager_v1_finished() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
WorkspaceManager();
|
||||||
|
|
||||||
|
void destroyWorkspace(Workspace* workspace);
|
||||||
|
|
||||||
|
QHash<::ext_workspace_group_handle_v1*, WorkspaceGroup*> mGroups;
|
||||||
|
QHash<::ext_workspace_handle_v1*, Workspace*> mWorkspaces;
|
||||||
|
QList<Workspace*> destroyedWorkspaces;
|
||||||
|
|
||||||
|
friend class WorkspaceGroup;
|
||||||
|
friend class Workspace;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WorkspaceGroup: public QtWayland::ext_workspace_group_handle_v1 {
|
||||||
|
public:
|
||||||
|
WorkspaceGroup(::ext_workspace_group_handle_v1* handle)
|
||||||
|
: QtWayland::ext_workspace_group_handle_v1(handle) {}
|
||||||
|
~WorkspaceGroup() override;
|
||||||
|
Q_DISABLE_COPY_MOVE(WorkspaceGroup);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*void ext_workspace_group_handle_v1_capabilities(uint32_t capabilities) override;
|
||||||
|
void ext_workspace_group_handle_v1_output_enter(::wl_output* output) override;
|
||||||
|
void ext_workspace_group_handle_v1_output_leave(::wl_output* output) override;
|
||||||
|
void ext_workspace_group_handle_v1_workspace_enter(::ext_workspace_handle_v1* workspace) override;
|
||||||
|
void ext_workspace_group_handle_v1_workspace_leave(::ext_workspace_handle_v1* workspace) override;*/
|
||||||
|
void ext_workspace_group_handle_v1_removed() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QScreen*> screens;
|
||||||
|
QList<wl_output*> pendingScreens;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Workspace: public QtWayland::ext_workspace_handle_v1 {
|
||||||
|
public:
|
||||||
|
Workspace(::ext_workspace_handle_v1* handle): QtWayland::ext_workspace_handle_v1(handle) {}
|
||||||
|
~Workspace() override;
|
||||||
|
Q_DISABLE_COPY_MOVE(Workspace);
|
||||||
|
|
||||||
|
QString id;
|
||||||
|
QString name;
|
||||||
|
QList<qint32> coordinates;
|
||||||
|
|
||||||
|
bool active : 1 = false;
|
||||||
|
bool urgent : 1 = false;
|
||||||
|
bool hidden : 1 = false;
|
||||||
|
|
||||||
|
bool canActivate : 1 = false;
|
||||||
|
bool canDeactivate : 1 = false;
|
||||||
|
bool canRemove : 1 = false;
|
||||||
|
bool canAssign : 1 = false;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ext_workspace_handle_v1_id(const QString& id) override;
|
||||||
|
void ext_workspace_handle_v1_name(const QString& name) override;
|
||||||
|
void ext_workspace_handle_v1_coordinates(wl_array* coordinates) override;
|
||||||
|
void ext_workspace_handle_v1_state(uint32_t state) override;
|
||||||
|
void ext_workspace_handle_v1_capabilities(uint32_t capabilities) override;
|
||||||
|
void ext_workspace_handle_v1_removed() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//void enterGroup(WorkspaceGroup* group);
|
||||||
|
//void leaveGroup(WorkspaceGroup* group);
|
||||||
|
|
||||||
|
friend class WorkspaceGroup;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::wayland::workspace
|
21
src/wayland/windowmanager/init.cpp
Normal file
21
src/wayland/windowmanager/init.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include <qguiapplication.h>
|
||||||
|
|
||||||
|
#include "../../core/plugin.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm::wayland {
|
||||||
|
void installWmProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class WaylandWmPlugin: public QsEnginePlugin {
|
||||||
|
QList<QString> dependencies() override { return {"window"}; }
|
||||||
|
|
||||||
|
bool applies() override { return QGuiApplication::platformName() == "wayland"; }
|
||||||
|
|
||||||
|
void init() override { qs::wm::wayland::installWmProvider(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
QS_REGISTER_PLUGIN(WaylandWmPlugin);
|
||||||
|
|
||||||
|
} // namespace
|
14
src/wayland/windowmanager/windowmanager.cpp
Normal file
14
src/wayland/windowmanager/windowmanager.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "windowmanager.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm::wayland {
|
||||||
|
|
||||||
|
WaylandWindowManager* WaylandWindowManager::instance() {
|
||||||
|
static auto* instance = new WaylandWindowManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void installWmProvider() {
|
||||||
|
qs::wm::WindowManager::setProvider([]() { return WaylandWindowManager::instance(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qs::wm::wayland
|
21
src/wayland/windowmanager/windowmanager.hpp
Normal file
21
src/wayland/windowmanager/windowmanager.hpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
#include "../../windowmanager/windowmanager.hpp"
|
||||||
|
#include "workspace.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm::wayland {
|
||||||
|
|
||||||
|
class WaylandWindowManager: public WindowManager {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static WaylandWindowManager* instance();
|
||||||
|
|
||||||
|
[[nodiscard]] UntypedObjectModel* workspaces() const override {
|
||||||
|
return &WorkspaceManager::instance()->mWorkspaces;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::wm::wayland
|
116
src/wayland/windowmanager/workspace.cpp
Normal file
116
src/wayland/windowmanager/workspace.cpp
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
#include "workspace.hpp"
|
||||||
|
|
||||||
|
#include <qlist.h>
|
||||||
|
#include <qlogging.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qproperty.h>
|
||||||
|
|
||||||
|
#include "ext_workspace.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm::wayland {
|
||||||
|
|
||||||
|
WorkspaceManager::WorkspaceManager() {
|
||||||
|
auto* impl = impl::WorkspaceManager::instance();
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
impl,
|
||||||
|
&impl::WorkspaceManager::serverCommit,
|
||||||
|
this,
|
||||||
|
&WorkspaceManager::onServerCommit
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
impl,
|
||||||
|
&impl::WorkspaceManager::workspaceCreated,
|
||||||
|
this,
|
||||||
|
&WorkspaceManager::onWorkspaceCreated
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
impl,
|
||||||
|
&impl::WorkspaceManager::workspaceDestroyed,
|
||||||
|
this,
|
||||||
|
&WorkspaceManager::onWorkspaceDestroyed
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::onServerCommit() {
|
||||||
|
for (auto* ws: this->mWorkspaces.valueList()) ws->commitImpl();
|
||||||
|
|
||||||
|
for (auto* wsImpl: this->pendingWorkspaceCreations) {
|
||||||
|
auto* ws = new WlWorkspace(this, wsImpl);
|
||||||
|
this->workspaceByImpl.insert(wsImpl, ws);
|
||||||
|
this->mWorkspaces.insertObject(ws);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto* wsImpl: this->pendingWorkspaceDestructions) {
|
||||||
|
this->mWorkspaces.removeObject(this->workspaceByImpl.value(wsImpl));
|
||||||
|
this->workspaceByImpl.remove(wsImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->pendingWorkspaceCreations.clear();
|
||||||
|
this->pendingWorkspaceDestructions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::onWorkspaceCreated(impl::Workspace* workspace) {
|
||||||
|
this->pendingWorkspaceCreations.append(workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::onWorkspaceDestroyed(impl::Workspace* workspace) {
|
||||||
|
if (!this->pendingWorkspaceCreations.removeOne(workspace)) {
|
||||||
|
this->pendingWorkspaceDestructions.append(workspace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceManager* WorkspaceManager::instance() {
|
||||||
|
static auto* instance = new WorkspaceManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
WlWorkspace::WlWorkspace(WorkspaceManager* manager, impl::Workspace* impl)
|
||||||
|
: Workspace(manager)
|
||||||
|
, impl(impl) {
|
||||||
|
this->commitImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlWorkspace::commitImpl() {
|
||||||
|
Qt::beginPropertyUpdateGroup();
|
||||||
|
this->bId = this->impl->id;
|
||||||
|
this->bName = this->impl->name;
|
||||||
|
this->bActive = this->impl->active;
|
||||||
|
this->bShouldDisplay = !this->impl->hidden;
|
||||||
|
this->bUrgent = this->impl->urgent;
|
||||||
|
this->bCanActivate = this->impl->canActivate;
|
||||||
|
this->bCanDeactivate = this->impl->canDeactivate;
|
||||||
|
this->bCanSetGroup = this->impl->canAssign;
|
||||||
|
Qt::endPropertyUpdateGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlWorkspace::activate() {
|
||||||
|
if (!this->bCanActivate) {
|
||||||
|
qCritical(logWorkspace) << this << "cannot be activated";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->impl->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlWorkspace::deactivate() {
|
||||||
|
if (!this->bCanDeactivate) {
|
||||||
|
qCritical(logWorkspace) << this << "cannot be deactivated";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->impl->deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlWorkspace::remove() {
|
||||||
|
if (!this->bCanRemove) {
|
||||||
|
qCritical(logWorkspace) << this << "cannot be removed";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->impl->remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qs::wm::wayland
|
55
src/wayland/windowmanager/workspace.hpp
Normal file
55
src/wayland/windowmanager/workspace.hpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qhash.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qproperty.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
#include "../../core/model.hpp"
|
||||||
|
#include "../../windowmanager/workspace.hpp"
|
||||||
|
#include "ext_workspace.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm::wayland {
|
||||||
|
namespace impl = qs::wayland::workspace;
|
||||||
|
|
||||||
|
class WlWorkspace;
|
||||||
|
|
||||||
|
class WorkspaceManager: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static WorkspaceManager* instance();
|
||||||
|
|
||||||
|
ObjectModel<WorkspaceGroup> mWorkspaceGroups {this};
|
||||||
|
ObjectModel<WlWorkspace> mWorkspaces {this};
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onServerCommit();
|
||||||
|
void onWorkspaceCreated(impl::Workspace* workspace);
|
||||||
|
void onWorkspaceDestroyed(impl::Workspace* workspace);
|
||||||
|
|
||||||
|
private:
|
||||||
|
WorkspaceManager();
|
||||||
|
|
||||||
|
QList<impl::Workspace*> pendingWorkspaceCreations;
|
||||||
|
QList<impl::Workspace*> pendingWorkspaceDestructions;
|
||||||
|
QHash<impl::Workspace*, WlWorkspace*> workspaceByImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WlWorkspace: public Workspace {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
WlWorkspace(WorkspaceManager* manager, impl::Workspace* impl);
|
||||||
|
|
||||||
|
void commitImpl();
|
||||||
|
|
||||||
|
void activate() override;
|
||||||
|
void deactivate() override;
|
||||||
|
void remove() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
impl::Workspace* impl = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::wm::wayland
|
18
src/windowmanager/CMakeLists.txt
Normal file
18
src/windowmanager/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
qt_add_library(quickshell-windowmanager STATIC
|
||||||
|
windowmanager.cpp
|
||||||
|
workspace.cpp
|
||||||
|
workspacemodel.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_add_qml_module(quickshell-windowmanager
|
||||||
|
URI Quickshell.WindowManager
|
||||||
|
VERSION 0.1
|
||||||
|
DEPENDENCIES QtQuick
|
||||||
|
)
|
||||||
|
|
||||||
|
qs_add_module_deps_light(quickshell-windowmanager Quickshell)
|
||||||
|
|
||||||
|
install_qml_module(quickshell-windowmanager)
|
||||||
|
|
||||||
|
target_link_libraries(quickshell-windowmanager PRIVATE Qt::Quick)
|
||||||
|
target_link_libraries(quickshell PRIVATE quickshell-windowmanager)
|
68
src/windowmanager/test/manual/workspaces.qml
Normal file
68
src/windowmanager/test/manual/workspaces.qml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls.Fusion
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import Quickshell.WindowManager
|
||||||
|
|
||||||
|
FloatingWindow {
|
||||||
|
ColumnLayout {
|
||||||
|
Repeater {
|
||||||
|
model: WindowManager.workspaces
|
||||||
|
|
||||||
|
WrapperRectangle {
|
||||||
|
id: delegate
|
||||||
|
required property Workspace modelData;
|
||||||
|
color: modelData.active ? "limegreen" : "gray"
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Label { text: delegate.modelData.toString() }
|
||||||
|
Label { text: `Id: ${delegate.modelData.id} Name: ${delegate.modelData.name}` }
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
DisplayCheckBox {
|
||||||
|
text: "Active"
|
||||||
|
checked: delegate.modelData.active
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayCheckBox {
|
||||||
|
text: "Urgent"
|
||||||
|
checked: delegate.modelData.urgent
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayCheckBox {
|
||||||
|
text: "Should Display"
|
||||||
|
checked: delegate.modelData.shouldDisplay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Button {
|
||||||
|
text: "Activate"
|
||||||
|
enabled: delegate.modelData.canActivate
|
||||||
|
onClicked: delegate.modelData.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: "Deactivate"
|
||||||
|
enabled: delegate.modelData.canDeactivate
|
||||||
|
onClicked: delegate.modelData.deactivate()
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: "Remove"
|
||||||
|
enabled: delegate.modelData.canRemove
|
||||||
|
onClicked: delegate.modelData.remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component DisplayCheckBox: CheckBox {
|
||||||
|
enabled: false
|
||||||
|
palette.disabled.text: palette.active.text
|
||||||
|
palette.disabled.windowText: palette.active.windowText
|
||||||
|
}
|
||||||
|
}
|
18
src/windowmanager/windowmanager.cpp
Normal file
18
src/windowmanager/windowmanager.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include "windowmanager.hpp"
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace qs::wm {
|
||||||
|
|
||||||
|
std::function<WindowManager*()> WindowManager::provider;
|
||||||
|
|
||||||
|
void WindowManager::setProvider(std::function<WindowManager*()> provider) {
|
||||||
|
WindowManager::provider = std::move(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowManager* WindowManager::instance() {
|
||||||
|
static auto* instance = WindowManager::provider();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace qs::wm
|
45
src/windowmanager/windowmanager.hpp
Normal file
45
src/windowmanager/windowmanager.hpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qqmlintegration.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
#include "../core/model.hpp"
|
||||||
|
#include "workspace.hpp"
|
||||||
|
|
||||||
|
namespace qs::wm {
|
||||||
|
|
||||||
|
class WindowManager: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void setProvider(std::function<WindowManager*()> provider);
|
||||||
|
static WindowManager* instance();
|
||||||
|
|
||||||
|
[[nodiscard]] virtual UntypedObjectModel* workspaces() const {
|
||||||
|
return UntypedObjectModel::emptyInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] virtual UntypedObjectModel* workspaceGroups() const {
|
||||||
|
return UntypedObjectModel::emptyInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::function<WindowManager*()> provider;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WindowManagerQml: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
QML_NAMED_ELEMENT(WindowManager);
|
||||||
|
QML_SINGLETON;
|
||||||
|
Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT);
|
||||||
|
|
||||||
|
public:
|
||||||
|
[[nodiscard]] static UntypedObjectModel* workspaces() {
|
||||||
|
return WindowManager::instance()->workspaces();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::wm
|
16
src/windowmanager/workspace.cpp
Normal file
16
src/windowmanager/workspace.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "workspace.hpp"
|
||||||
|
|
||||||
|
#include <qlogging.h>
|
||||||
|
#include <qloggingcategory.h>
|
||||||
|
|
||||||
|
namespace qs::wm {
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(logWorkspace, "qs.wm.workspace", QtWarningMsg);
|
||||||
|
|
||||||
|
void Workspace::activate() { qCCritical(logWorkspace) << this << "cannot be activated"; }
|
||||||
|
|
||||||
|
void Workspace::deactivate() { qCCritical(logWorkspace) << this << "cannot be deactivated"; }
|
||||||
|
|
||||||
|
void Workspace::remove() { qCCritical(logWorkspace) << this << "cannot be removed"; }
|
||||||
|
|
||||||
|
} // namespace qs::wm
|
85
src/windowmanager/workspace.hpp
Normal file
85
src/windowmanager/workspace.hpp
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qcontainerfwd.h>
|
||||||
|
#include <qlist.h>
|
||||||
|
#include <qloggingcategory.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qproperty.h>
|
||||||
|
#include <qqmlintegration.h>
|
||||||
|
#include <qscreen.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
#include <qtypes.h>
|
||||||
|
|
||||||
|
namespace qs::wm {
|
||||||
|
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(logWorkspace);
|
||||||
|
|
||||||
|
class WorkspaceGroup: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(WorkspaceGroup, QList<QScreen>, bScreens);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Workspace: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
QML_ELEMENT;
|
||||||
|
QML_UNCREATABLE("");
|
||||||
|
// clang-format off
|
||||||
|
// persistent id
|
||||||
|
Q_PROPERTY(QString id READ default BINDABLE bindableId NOTIFY idChanged);
|
||||||
|
Q_PROPERTY(QString name READ default BINDABLE bindableName NOTIFY nameChanged);
|
||||||
|
// currently visible
|
||||||
|
Q_PROPERTY(bool active READ default BINDABLE bindableActive NOTIFY activeChanged);
|
||||||
|
// in workspace pickers
|
||||||
|
Q_PROPERTY(bool shouldDisplay READ default BINDABLE bindableShouldDisplay NOTIFY shouldDisplayChanged);
|
||||||
|
Q_PROPERTY(bool urgent READ default BINDABLE bindableUrgent NOTIFY urgentChanged);
|
||||||
|
Q_PROPERTY(bool canActivate READ default BINDABLE bindableCanActivate NOTIFY canActivateChanged);
|
||||||
|
Q_PROPERTY(bool canDeactivate READ default BINDABLE bindableCanDeactivate NOTIFY canDeactivateChanged);
|
||||||
|
Q_PROPERTY(bool canRemove READ default BINDABLE bindableCanRemove NOTIFY canRemoveChanged);
|
||||||
|
Q_PROPERTY(bool canSetGroup READ default BINDABLE bindableCanSetGroup NOTIFY canSetGroupChanged);
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Workspace(QObject* parent): QObject(parent) {}
|
||||||
|
|
||||||
|
Q_INVOKABLE virtual void activate();
|
||||||
|
Q_INVOKABLE virtual void deactivate();
|
||||||
|
Q_INVOKABLE virtual void remove();
|
||||||
|
|
||||||
|
[[nodiscard]] QBindable<QString> bindableId() const { return &this->bId; }
|
||||||
|
[[nodiscard]] QBindable<QString> bindableName() const { return &this->bName; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableActive() const { return &this->bActive; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableShouldDisplay() const { return &this->bShouldDisplay; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableUrgent() const { return &this->bUrgent; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableCanActivate() const { return &this->bCanActivate; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableCanDeactivate() const { return &this->bCanDeactivate; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableCanRemove() const { return &this->bCanRemove; }
|
||||||
|
[[nodiscard]] QBindable<bool> bindableCanSetGroup() const { return &this->bCanSetGroup; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void idChanged();
|
||||||
|
void nameChanged();
|
||||||
|
void activeChanged();
|
||||||
|
void shouldDisplayChanged();
|
||||||
|
void urgentChanged();
|
||||||
|
void canActivateChanged();
|
||||||
|
void canDeactivateChanged();
|
||||||
|
void canRemoveChanged();
|
||||||
|
void canSetGroupChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, QString, bId, &Workspace::idChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, QString, bName, &Workspace::nameChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bActive, &Workspace::activeChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bShouldDisplay, &Workspace::shouldDisplayChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bUrgent, &Workspace::urgentChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bCanActivate, &Workspace::canActivateChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bCanDeactivate, &Workspace::canDeactivateChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bCanRemove, &Workspace::canRemoveChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(Workspace, bool, bCanSetGroup, &Workspace::canSetGroupChanged);
|
||||||
|
//Q_OBJECT_BINDABLE_PROPERTY(Workspace, WorkspaceGroup*, bGroup);
|
||||||
|
//Q_OBJECT_BINDABLE_PROPERTY(Workspace, qint32, bIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::wm
|
1
src/windowmanager/workspacemodel.cpp
Normal file
1
src/windowmanager/workspacemodel.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "workspacemodel.hpp"
|
39
src/windowmanager/workspacemodel.hpp
Normal file
39
src/windowmanager/workspacemodel.hpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qproperty.h>
|
||||||
|
#include <qqmlintegration.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
#include <qtypes.h>
|
||||||
|
|
||||||
|
namespace qs::windowsystem {
|
||||||
|
|
||||||
|
class WorkspaceModel: public QObject {
|
||||||
|
Q_OBJECT;
|
||||||
|
QML_ELEMENT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ConflictStrategy : quint8 {
|
||||||
|
KeepFirst = 0,
|
||||||
|
ShowDuplicates,
|
||||||
|
};
|
||||||
|
Q_ENUM(ConflictStrategy);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fromChanged();
|
||||||
|
void toChanged();
|
||||||
|
void screensChanged();
|
||||||
|
void conflictStrategyChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(WorkspaceModel, qint32, bFrom, &WorkspaceModel::fromChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(WorkspaceModel, qint32, bTo, &WorkspaceModel::toChanged);
|
||||||
|
Q_OBJECT_BINDABLE_PROPERTY(
|
||||||
|
WorkspaceModel,
|
||||||
|
ConflictStrategy,
|
||||||
|
bConflictStrategy,
|
||||||
|
&WorkspaceModel::conflictStrategyChanged
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace qs::windowsystem
|
Loading…
Add table
Add a link
Reference in a new issue