plugins: expose csd functionality (#11551)
This commit is contained in:
parent
8a64168a43
commit
00423bb738
4 changed files with 73 additions and 11 deletions
|
|
@ -1,21 +1,41 @@
|
||||||
#include "ServerDecorationKDE.hpp"
|
#include "ServerDecorationKDE.hpp"
|
||||||
#include "core/Compositor.hpp"
|
#include "core/Compositor.hpp"
|
||||||
|
|
||||||
CServerDecorationKDE::CServerDecorationKDE(SP<COrgKdeKwinServerDecoration> resource_, SP<CWLSurfaceResource> surf) : m_resource(resource_) {
|
CServerDecorationKDE::CServerDecorationKDE(SP<COrgKdeKwinServerDecoration> resource_, SP<CWLSurfaceResource> surf_) : m_surf(surf_), m_resource(resource_) {
|
||||||
if UNLIKELY (!good())
|
if UNLIKELY (!good())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_resource->setRelease([this](COrgKdeKwinServerDecoration* pMgr) { PROTO::serverDecorationKDE->destroyResource(this); });
|
m_resource->setRelease([this](COrgKdeKwinServerDecoration* pMgr) { PROTO::serverDecorationKDE->destroyResource(this); });
|
||||||
m_resource->setOnDestroy([this](COrgKdeKwinServerDecoration* pMgr) { PROTO::serverDecorationKDE->destroyResource(this); });
|
m_resource->setOnDestroy([this](COrgKdeKwinServerDecoration* pMgr) { PROTO::serverDecorationKDE->destroyResource(this); });
|
||||||
|
m_resource->setRequestMode([this](COrgKdeKwinServerDecoration*, uint32_t mode) {
|
||||||
|
auto sendMode = kdeModeOnRequestCSD(mode);
|
||||||
|
m_resource->sendMode(sendMode);
|
||||||
|
mostRecentlySent = sendMode;
|
||||||
|
mostRecentlyRequested = mode;
|
||||||
|
});
|
||||||
|
|
||||||
// we send this and ignore request_mode.
|
// we send this and ignore request_mode.
|
||||||
m_resource->sendMode(ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
auto sendMode = kdeDefaultModeCSD();
|
||||||
|
m_resource->sendMode(sendMode);
|
||||||
|
mostRecentlySent = sendMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CServerDecorationKDE::good() {
|
bool CServerDecorationKDE::good() {
|
||||||
return m_resource->resource();
|
return m_resource->resource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t CServerDecorationKDE::kdeDefaultModeCSD() {
|
||||||
|
return ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CServerDecorationKDE::kdeModeOnRequestCSD(uint32_t modeRequestedByClient) {
|
||||||
|
return kdeDefaultModeCSD();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CServerDecorationKDE::kdeModeOnReleaseCSD() {
|
||||||
|
return kdeDefaultModeCSD();
|
||||||
|
}
|
||||||
|
|
||||||
CServerDecorationKDEProtocol::CServerDecorationKDEProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
CServerDecorationKDEProtocol::CServerDecorationKDEProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +47,11 @@ void CServerDecorationKDEProtocol::bindManager(wl_client* client, void* data, ui
|
||||||
RESOURCE->setCreate([this](COrgKdeKwinServerDecorationManager* pMgr, uint32_t id, wl_resource* pointer) { this->createDecoration(pMgr, id, pointer); });
|
RESOURCE->setCreate([this](COrgKdeKwinServerDecorationManager* pMgr, uint32_t id, wl_resource* pointer) { this->createDecoration(pMgr, id, pointer); });
|
||||||
|
|
||||||
// send default mode of SSD, as Hyprland will never ask for CSD. Screw Gnome and GTK.
|
// send default mode of SSD, as Hyprland will never ask for CSD. Screw Gnome and GTK.
|
||||||
RESOURCE->sendDefaultMode(ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
RESOURCE->sendDefaultMode(kdeDefaultManagerModeCSD());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CServerDecorationKDEProtocol::kdeDefaultManagerModeCSD() {
|
||||||
|
return ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServerDecorationKDEProtocol::onManagerResourceDestroy(wl_resource* res) {
|
void CServerDecorationKDEProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,18 @@ class CServerDecorationKDE {
|
||||||
public:
|
public:
|
||||||
CServerDecorationKDE(SP<COrgKdeKwinServerDecoration> resource_, SP<CWLSurfaceResource> surf);
|
CServerDecorationKDE(SP<COrgKdeKwinServerDecoration> resource_, SP<CWLSurfaceResource> surf);
|
||||||
|
|
||||||
bool good();
|
SP<CWLSurfaceResource> m_surf;
|
||||||
|
|
||||||
|
uint32_t mostRecentlySent = 0;
|
||||||
|
uint32_t mostRecentlyRequested = 0;
|
||||||
|
|
||||||
|
bool good();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint32_t kdeDefaultModeCSD();
|
||||||
|
uint32_t kdeModeOnRequestCSD(uint32_t modeRequestedByClient);
|
||||||
|
uint32_t kdeModeOnReleaseCSD();
|
||||||
|
|
||||||
SP<COrgKdeKwinServerDecoration> m_resource;
|
SP<COrgKdeKwinServerDecoration> m_resource;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -24,10 +33,12 @@ class CServerDecorationKDEProtocol : public IWaylandProtocol {
|
||||||
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onManagerResourceDestroy(wl_resource* res);
|
uint32_t kdeDefaultManagerModeCSD();
|
||||||
void destroyResource(CServerDecorationKDE* deco);
|
|
||||||
|
|
||||||
void createDecoration(COrgKdeKwinServerDecorationManager* pMgr, uint32_t id, wl_resource* surf);
|
void onManagerResourceDestroy(wl_resource* res);
|
||||||
|
void destroyResource(CServerDecorationKDE* deco);
|
||||||
|
|
||||||
|
void createDecoration(COrgKdeKwinServerDecorationManager* pMgr, uint32_t id, wl_resource* surf);
|
||||||
|
|
||||||
//
|
//
|
||||||
std::vector<UP<COrgKdeKwinServerDecorationManager>> m_managers;
|
std::vector<UP<COrgKdeKwinServerDecorationManager>> m_managers;
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,35 @@ CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resou
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGM(LOG, "setMode: {}. {} MODE_SERVER_SIDE as reply.", modeString, (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE ? "Sending" : "Ignoring and sending"));
|
LOGM(LOG, "setMode: {}. {} MODE_SERVER_SIDE as reply.", modeString, (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE ? "Sending" : "Ignoring and sending"));
|
||||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
auto sendMode = xdgModeOnRequestCSD(mode);
|
||||||
|
m_resource->sendConfigure(sendMode);
|
||||||
|
mostRecentlySent = sendMode;
|
||||||
|
mostRecentlyRequested = mode;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) {
|
m_resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) {
|
||||||
LOGM(LOG, "unsetMode. Sending MODE_SERVER_SIDE.");
|
LOGM(LOG, "unsetMode. Sending MODE_SERVER_SIDE.");
|
||||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
auto sendMode = xdgModeOnReleaseCSD();
|
||||||
|
m_resource->sendConfigure(sendMode);
|
||||||
|
mostRecentlySent = sendMode;
|
||||||
|
mostRecentlyRequested = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
auto sendMode = xdgDefaultModeCSD();
|
||||||
|
m_resource->sendConfigure(sendMode);
|
||||||
|
mostRecentlySent = sendMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
zxdgToplevelDecorationV1Mode CXDGDecoration::xdgDefaultModeCSD() {
|
||||||
|
return ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
zxdgToplevelDecorationV1Mode CXDGDecoration::xdgModeOnRequestCSD(uint32_t modeRequestedByClient) {
|
||||||
|
return xdgDefaultModeCSD();
|
||||||
|
}
|
||||||
|
|
||||||
|
zxdgToplevelDecorationV1Mode CXDGDecoration::xdgModeOnReleaseCSD() {
|
||||||
|
return xdgDefaultModeCSD();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CXDGDecoration::good() {
|
bool CXDGDecoration::good() {
|
||||||
|
|
@ -71,4 +91,4 @@ void CXDGDecorationProtocol::onGetDecoration(CZxdgDecorationManagerV1* pMgr, uin
|
||||||
m_decorations.erase(xdgToplevel);
|
m_decorations.erase(xdgToplevel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,17 @@ class CXDGDecoration {
|
||||||
public:
|
public:
|
||||||
CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel);
|
CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel);
|
||||||
|
|
||||||
|
uint32_t mostRecentlySent = 0;
|
||||||
|
uint32_t mostRecentlyRequested = 0;
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
wl_resource* toplevelResource();
|
wl_resource* toplevelResource();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
zxdgToplevelDecorationV1Mode xdgDefaultModeCSD();
|
||||||
|
zxdgToplevelDecorationV1Mode xdgModeOnRequestCSD(uint32_t modeRequestedByClient);
|
||||||
|
zxdgToplevelDecorationV1Mode xdgModeOnReleaseCSD();
|
||||||
|
|
||||||
SP<CZxdgToplevelDecorationV1> m_resource;
|
SP<CZxdgToplevelDecorationV1> m_resource;
|
||||||
wl_resource* m_toplevelResource = nullptr; // READ-ONLY.
|
wl_resource* m_toplevelResource = nullptr; // READ-ONLY.
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue