protocols: add xdg_toplevel_tag_v1 support
Adds a new windowrule to target windows by xdgTag, xdgtag:
This commit is contained in:
parent
55e953b383
commit
a4f7d7c594
11 changed files with 140 additions and 11 deletions
|
|
@ -141,6 +141,8 @@ class CXDGToplevelResource {
|
|||
WP<CXDGToplevelResource> parent;
|
||||
WP<CXDGDialogV1Resource> dialog;
|
||||
|
||||
std::optional<std::string> m_toplevelTag, m_toplevelDescription;
|
||||
|
||||
bool anyChildModal();
|
||||
|
||||
std::vector<WP<CXDGToplevelResource>> children;
|
||||
|
|
|
|||
54
src/protocols/XDGTag.cpp
Normal file
54
src/protocols/XDGTag.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "XDGTag.hpp"
|
||||
#include "XDGShell.hpp"
|
||||
|
||||
CXDGToplevelTagManagerResource::CXDGToplevelTagManagerResource(UP<CXdgToplevelTagManagerV1>&& resource) : m_resource(std::move(resource)) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
m_resource->setDestroy([this](CXdgToplevelTagManagerV1* r) { PROTO::xdgTag->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXdgToplevelTagManagerV1* r) { PROTO::xdgTag->destroyResource(this); });
|
||||
|
||||
resource->setSetToplevelTag([](CXdgToplevelTagManagerV1* r, wl_resource* toplevel, const char* tag) {
|
||||
auto TOPLEVEL = CXDGToplevelResource::fromResource(toplevel);
|
||||
|
||||
if (!TOPLEVEL) {
|
||||
r->error(-1, "Invalid toplevel handle");
|
||||
return;
|
||||
}
|
||||
|
||||
TOPLEVEL->m_toplevelTag = tag;
|
||||
});
|
||||
|
||||
resource->setSetToplevelDescription([](CXdgToplevelTagManagerV1* r, wl_resource* toplevel, const char* description) {
|
||||
auto TOPLEVEL = CXDGToplevelResource::fromResource(toplevel);
|
||||
|
||||
if (!TOPLEVEL) {
|
||||
r->error(-1, "Invalid toplevel handle");
|
||||
return;
|
||||
}
|
||||
|
||||
TOPLEVEL->m_toplevelDescription = description;
|
||||
});
|
||||
}
|
||||
|
||||
bool CXDGToplevelTagManagerResource::good() {
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXDGToplevelTagProtocol::CXDGToplevelTagProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
;
|
||||
}
|
||||
|
||||
void CXDGToplevelTagProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE =
|
||||
WP<CXDGToplevelTagManagerResource>{m_vManagers.emplace_back(makeUnique<CXDGToplevelTagManagerResource>(makeUnique<CXdgToplevelTagManagerV1>(client, ver, id)))};
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CXDGToplevelTagProtocol::destroyResource(CXDGToplevelTagManagerResource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
36
src/protocols/XDGTag.hpp
Normal file
36
src/protocols/XDGTag.hpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "WaylandProtocol.hpp"
|
||||
#include "xdg-toplevel-tag-v1.hpp"
|
||||
|
||||
class CXDGToplevelResource;
|
||||
|
||||
class CXDGToplevelTagManagerResource {
|
||||
public:
|
||||
CXDGToplevelTagManagerResource(UP<CXdgToplevelTagManagerV1>&& resource);
|
||||
|
||||
bool good();
|
||||
|
||||
private:
|
||||
UP<CXdgToplevelTagManagerV1> m_resource;
|
||||
};
|
||||
|
||||
class CXDGToplevelTagProtocol : public IWaylandProtocol {
|
||||
public:
|
||||
CXDGToplevelTagProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
||||
|
||||
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
||||
|
||||
private:
|
||||
void destroyResource(CXDGToplevelTagManagerResource* res);
|
||||
|
||||
//
|
||||
std::vector<UP<CXDGToplevelTagManagerResource>> m_vManagers;
|
||||
|
||||
friend class CXDGToplevelTagManagerResource;
|
||||
};
|
||||
|
||||
namespace PROTO {
|
||||
inline UP<CXDGToplevelTagProtocol> xdgTag;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue