protocols: refactor class member vars (u-z) (#10282)
* protocols: refactor class member vars (u-z) * protocols: fix clang format
This commit is contained in:
parent
78ff20ddf0
commit
9cd5b25745
39 changed files with 985 additions and 981 deletions
|
|
@ -120,12 +120,12 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
|
|||
m_resource->setGetPopup([this](CZwlrLayerSurfaceV1* r, wl_resource* popup_) {
|
||||
auto popup = CXDGPopupResource::fromResource(popup_);
|
||||
|
||||
if (popup->taken) {
|
||||
if (popup->m_taken) {
|
||||
r->error(-1, "Parent already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
popup->taken = true;
|
||||
popup->m_taken = true;
|
||||
m_events.newPopup.emit(popup);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,23 +2,23 @@
|
|||
#include "core/Compositor.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) {
|
||||
CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CWpViewport* r) { PROTO::viewport->destroyResource(this); });
|
||||
|
||||
resource->setSetDestination([this](CWpViewport* r, int32_t x, int32_t y) {
|
||||
if UNLIKELY (!surface) {
|
||||
m_resource->setSetDestination([this](CWpViewport* r, int32_t x, int32_t y) {
|
||||
if UNLIKELY (!m_surface) {
|
||||
r->error(WP_VIEWPORT_ERROR_NO_SURFACE, "Surface is gone");
|
||||
return;
|
||||
}
|
||||
|
||||
surface->m_pending.updated.viewport = true;
|
||||
m_surface->m_pending.updated.viewport = true;
|
||||
|
||||
if (x == -1 && y == -1) {
|
||||
surface->m_pending.viewport.hasDestination = false;
|
||||
m_surface->m_pending.viewport.hasDestination = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -27,22 +27,22 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
|
|||
return;
|
||||
}
|
||||
|
||||
surface->m_pending.viewport.hasDestination = true;
|
||||
surface->m_pending.viewport.destination = {x, y};
|
||||
m_surface->m_pending.viewport.hasDestination = true;
|
||||
m_surface->m_pending.viewport.destination = {x, y};
|
||||
});
|
||||
|
||||
resource->setSetSource([this](CWpViewport* r, wl_fixed_t fx, wl_fixed_t fy, wl_fixed_t fw, wl_fixed_t fh) {
|
||||
if UNLIKELY (!surface) {
|
||||
m_resource->setSetSource([this](CWpViewport* r, wl_fixed_t fx, wl_fixed_t fy, wl_fixed_t fw, wl_fixed_t fh) {
|
||||
if UNLIKELY (!m_surface) {
|
||||
r->error(WP_VIEWPORT_ERROR_NO_SURFACE, "Surface is gone");
|
||||
return;
|
||||
}
|
||||
|
||||
surface->m_pending.updated.viewport = true;
|
||||
m_surface->m_pending.updated.viewport = true;
|
||||
|
||||
double x = wl_fixed_to_double(fx), y = wl_fixed_to_double(fy), w = wl_fixed_to_double(fw), h = wl_fixed_to_double(fh);
|
||||
|
||||
if (x == -1 && y == -1 && w == -1 && h == -1) {
|
||||
surface->m_pending.viewport.hasSource = false;
|
||||
m_surface->m_pending.viewport.hasSource = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -51,20 +51,20 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
|
|||
return;
|
||||
}
|
||||
|
||||
surface->m_pending.viewport.hasSource = true;
|
||||
surface->m_pending.viewport.source = {x, y, w, h};
|
||||
m_surface->m_pending.viewport.hasSource = true;
|
||||
m_surface->m_pending.viewport.source = {x, y, w, h};
|
||||
});
|
||||
|
||||
listeners.surfacePrecommit = surface->m_events.precommit.registerListener([this](std::any d) {
|
||||
if (!surface || !surface->m_pending.buffer)
|
||||
m_listeners.surfacePrecommit = m_surface->m_events.precommit.registerListener([this](std::any d) {
|
||||
if (!m_surface || !m_surface->m_pending.buffer)
|
||||
return;
|
||||
|
||||
if (surface->m_pending.viewport.hasSource) {
|
||||
auto& src = surface->m_pending.viewport.source;
|
||||
if (m_surface->m_pending.viewport.hasSource) {
|
||||
auto& src = m_surface->m_pending.viewport.source;
|
||||
|
||||
if (src.w + src.x > surface->m_pending.bufferSize.x || src.h + src.y > surface->m_pending.bufferSize.y) {
|
||||
resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit");
|
||||
surface->m_pending.rejected = true;
|
||||
if (src.w + src.x > m_surface->m_pending.bufferSize.x || src.h + src.y > m_surface->m_pending.bufferSize.y) {
|
||||
m_resource->error(WP_VIEWPORT_ERROR_BAD_VALUE, "Box doesn't fit");
|
||||
m_surface->m_pending.rejected = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -72,38 +72,38 @@ CViewportResource::CViewportResource(SP<CWpViewport> resource_, SP<CWLSurfaceRes
|
|||
}
|
||||
|
||||
CViewportResource::~CViewportResource() {
|
||||
if (!surface)
|
||||
if (!m_surface)
|
||||
return;
|
||||
|
||||
surface->m_pending.viewport.hasDestination = false;
|
||||
surface->m_pending.viewport.hasSource = false;
|
||||
m_surface->m_pending.viewport.hasDestination = false;
|
||||
m_surface->m_pending.viewport.hasSource = false;
|
||||
}
|
||||
|
||||
bool CViewportResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CViewporterResource::CViewporterResource(SP<CWpViewporter> resource_) : resource(resource_) {
|
||||
CViewporterResource::CViewporterResource(SP<CWpViewporter> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CWpViewporter* r) { PROTO::viewport->destroyResource(this); });
|
||||
|
||||
resource->setGetViewport([](CWpViewporter* r, uint32_t id, wl_resource* surf) {
|
||||
const auto RESOURCE = PROTO::viewport->m_vViewports.emplace_back(
|
||||
m_resource->setGetViewport([](CWpViewporter* r, uint32_t id, wl_resource* surf) {
|
||||
const auto RESOURCE = PROTO::viewport->m_viewports.emplace_back(
|
||||
makeShared<CViewportResource>(makeShared<CWpViewport>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surf)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::viewport->m_vViewports.pop_back();
|
||||
PROTO::viewport->m_viewports.pop_back();
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool CViewporterResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CViewporterProtocol::CViewporterProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -111,19 +111,19 @@ CViewporterProtocol::CViewporterProtocol(const wl_interface* iface, const int& v
|
|||
}
|
||||
|
||||
void CViewporterProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CViewporterResource>(makeShared<CWpViewporter>(client, ver, id)));
|
||||
const auto RESOURCE = m_managers.emplace_back(makeShared<CViewporterResource>(makeShared<CWpViewporter>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
m_vManagers.pop_back();
|
||||
m_managers.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CViewporterProtocol::destroyResource(CViewporterResource* resource) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CViewporterProtocol::destroyResource(CViewportResource* resource) {
|
||||
std::erase_if(m_vViewports, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_viewports, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ class CViewportResource {
|
|||
~CViewportResource();
|
||||
|
||||
bool good();
|
||||
WP<CWLSurfaceResource> surface;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
|
||||
private:
|
||||
SP<CWpViewport> resource;
|
||||
SP<CWpViewport> m_resource;
|
||||
|
||||
struct {
|
||||
CHyprSignalListener surfacePrecommit;
|
||||
} listeners;
|
||||
} m_listeners;
|
||||
};
|
||||
|
||||
class CViewporterResource {
|
||||
|
|
@ -31,7 +31,7 @@ class CViewporterResource {
|
|||
bool good();
|
||||
|
||||
private:
|
||||
SP<CWpViewporter> resource;
|
||||
SP<CWpViewporter> m_resource;
|
||||
};
|
||||
|
||||
class CViewporterProtocol : public IWaylandProtocol {
|
||||
|
|
@ -45,8 +45,8 @@ class CViewporterProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CViewportResource* resource);
|
||||
|
||||
//
|
||||
std::vector<SP<CViewporterResource>> m_vManagers;
|
||||
std::vector<SP<CViewportResource>> m_vViewports;
|
||||
std::vector<SP<CViewporterResource>> m_managers;
|
||||
std::vector<SP<CViewportResource>> m_viewports;
|
||||
|
||||
friend class CViewporterResource;
|
||||
friend class CViewportResource;
|
||||
|
|
|
|||
|
|
@ -4,47 +4,47 @@
|
|||
#include "../helpers/time/Time.hpp"
|
||||
using namespace Hyprutils::OS;
|
||||
|
||||
CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> resource_) : resource(resource_) {
|
||||
CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
m_resource->setDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
releasePressed();
|
||||
events.destroy.emit();
|
||||
m_events.destroy.emit();
|
||||
PROTO::virtualKeyboard->destroyResource(this);
|
||||
});
|
||||
resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
m_resource->setOnDestroy([this](CZwpVirtualKeyboardV1* r) {
|
||||
releasePressed();
|
||||
events.destroy.emit();
|
||||
m_events.destroy.emit();
|
||||
PROTO::virtualKeyboard->destroyResource(this);
|
||||
});
|
||||
|
||||
resource->setKey([this](CZwpVirtualKeyboardV1* r, uint32_t timeMs, uint32_t key, uint32_t state) {
|
||||
if UNLIKELY (!hasKeymap) {
|
||||
m_resource->setKey([this](CZwpVirtualKeyboardV1* r, uint32_t timeMs, uint32_t key, uint32_t state) {
|
||||
if UNLIKELY (!m_hasKeymap) {
|
||||
r->error(ZWP_VIRTUAL_KEYBOARD_V1_ERROR_NO_KEYMAP, "Key event received before a keymap was set");
|
||||
return;
|
||||
}
|
||||
|
||||
events.key.emit(IKeyboard::SKeyEvent{
|
||||
m_events.key.emit(IKeyboard::SKeyEvent{
|
||||
.timeMs = timeMs,
|
||||
.keycode = key,
|
||||
.state = (wl_keyboard_key_state)state,
|
||||
});
|
||||
|
||||
const bool CONTAINS = std::find(pressed.begin(), pressed.end(), key) != pressed.end();
|
||||
const bool CONTAINS = std::find(m_pressed.begin(), m_pressed.end(), key) != m_pressed.end();
|
||||
if (state && !CONTAINS)
|
||||
pressed.emplace_back(key);
|
||||
m_pressed.emplace_back(key);
|
||||
else if (!state && CONTAINS)
|
||||
std::erase(pressed, key);
|
||||
std::erase(m_pressed, key);
|
||||
});
|
||||
|
||||
resource->setModifiers([this](CZwpVirtualKeyboardV1* r, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
|
||||
if UNLIKELY (!hasKeymap) {
|
||||
m_resource->setModifiers([this](CZwpVirtualKeyboardV1* r, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
|
||||
if UNLIKELY (!m_hasKeymap) {
|
||||
r->error(ZWP_VIRTUAL_KEYBOARD_V1_ERROR_NO_KEYMAP, "Mods event received before a keymap was set");
|
||||
return;
|
||||
}
|
||||
|
||||
events.modifiers.emit(IKeyboard::SModifiersEvent{
|
||||
m_events.modifiers.emit(IKeyboard::SModifiersEvent{
|
||||
.depressed = depressed,
|
||||
.latched = latched,
|
||||
.locked = locked,
|
||||
|
|
@ -52,7 +52,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
|
|||
});
|
||||
});
|
||||
|
||||
resource->setKeymap([this](CZwpVirtualKeyboardV1* r, uint32_t fmt, int32_t fd, uint32_t len) {
|
||||
m_resource->setKeymap([this](CZwpVirtualKeyboardV1* r, uint32_t fmt, int32_t fd, uint32_t len) {
|
||||
auto xkbContext = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
CFileDescriptor keymapFd{fd};
|
||||
if UNLIKELY (!xkbContext) {
|
||||
|
|
@ -79,40 +79,40 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
|
|||
return;
|
||||
}
|
||||
|
||||
events.keymap.emit(IKeyboard::SKeymapEvent{
|
||||
m_events.keymap.emit(IKeyboard::SKeymapEvent{
|
||||
.keymap = xkbKeymap,
|
||||
});
|
||||
hasKeymap = true;
|
||||
m_hasKeymap = true;
|
||||
|
||||
xkb_keymap_unref(xkbKeymap);
|
||||
xkb_context_unref(xkbContext);
|
||||
});
|
||||
|
||||
name = "hl-virtual-keyboard";
|
||||
m_name = "hl-virtual-keyboard";
|
||||
}
|
||||
|
||||
CVirtualKeyboardV1Resource::~CVirtualKeyboardV1Resource() {
|
||||
events.destroy.emit();
|
||||
m_events.destroy.emit();
|
||||
}
|
||||
|
||||
bool CVirtualKeyboardV1Resource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CVirtualKeyboardV1Resource::client() {
|
||||
return resource->resource() ? resource->client() : nullptr;
|
||||
return m_resource->resource() ? m_resource->client() : nullptr;
|
||||
}
|
||||
|
||||
void CVirtualKeyboardV1Resource::releasePressed() {
|
||||
for (auto const& p : pressed) {
|
||||
events.key.emit(IKeyboard::SKeyEvent{
|
||||
for (auto const& p : m_pressed) {
|
||||
m_events.key.emit(IKeyboard::SKeyEvent{
|
||||
.timeMs = Time::millis(Time::steadyNow()),
|
||||
.keycode = p,
|
||||
.state = WL_KEYBOARD_KEY_STATE_RELEASED,
|
||||
});
|
||||
}
|
||||
|
||||
pressed.clear();
|
||||
m_pressed.clear();
|
||||
}
|
||||
|
||||
CVirtualKeyboardProtocol::CVirtualKeyboardProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -120,31 +120,31 @@ CVirtualKeyboardProtocol::CVirtualKeyboardProtocol(const wl_interface* iface, co
|
|||
}
|
||||
|
||||
void CVirtualKeyboardProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwpVirtualKeyboardManagerV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwpVirtualKeyboardManagerV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CZwpVirtualKeyboardManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
RESOURCE->setCreateVirtualKeyboard([this](CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id) { this->onCreateKeeb(pMgr, seat, id); });
|
||||
}
|
||||
|
||||
void CVirtualKeyboardProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CVirtualKeyboardProtocol::destroyResource(CVirtualKeyboardV1Resource* keeb) {
|
||||
std::erase_if(m_vKeyboards, [&](const auto& other) { return other.get() == keeb; });
|
||||
std::erase_if(m_keyboards, [&](const auto& other) { return other.get() == keeb; });
|
||||
}
|
||||
|
||||
void CVirtualKeyboardProtocol::onCreateKeeb(CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id) {
|
||||
|
||||
const auto RESOURCE = m_vKeyboards.emplace_back(makeShared<CVirtualKeyboardV1Resource>(makeShared<CZwpVirtualKeyboardV1>(pMgr->client(), pMgr->version(), id)));
|
||||
const auto RESOURCE = m_keyboards.emplace_back(makeShared<CVirtualKeyboardV1Resource>(makeShared<CZwpVirtualKeyboardV1>(pMgr->client(), pMgr->version(), id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
pMgr->noMemory();
|
||||
m_vKeyboards.pop_back();
|
||||
m_keyboards.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
LOGM(LOG, "New VKeyboard at id {}", id);
|
||||
|
||||
events.newKeyboard.emit(RESOURCE);
|
||||
m_events.newKeyboard.emit(RESOURCE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,21 +17,21 @@ class CVirtualKeyboardV1Resource {
|
|||
CSignal key;
|
||||
CSignal modifiers;
|
||||
CSignal keymap;
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
std::string name = "";
|
||||
std::string m_name = "";
|
||||
|
||||
private:
|
||||
SP<CZwpVirtualKeyboardV1> resource;
|
||||
SP<CZwpVirtualKeyboardV1> m_resource;
|
||||
|
||||
void releasePressed();
|
||||
|
||||
bool hasKeymap = false;
|
||||
bool m_hasKeymap = false;
|
||||
|
||||
std::vector<uint32_t> pressed;
|
||||
std::vector<uint32_t> m_pressed;
|
||||
};
|
||||
|
||||
class CVirtualKeyboardProtocol : public IWaylandProtocol {
|
||||
|
|
@ -42,7 +42,7 @@ class CVirtualKeyboardProtocol : public IWaylandProtocol {
|
|||
|
||||
struct {
|
||||
CSignal newKeyboard; // SP<CVirtualKeyboard>
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
private:
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
|
|
@ -50,8 +50,8 @@ class CVirtualKeyboardProtocol : public IWaylandProtocol {
|
|||
void onCreateKeeb(CZwpVirtualKeyboardManagerV1* pMgr, wl_resource* seat, uint32_t id);
|
||||
|
||||
//
|
||||
std::vector<UP<CZwpVirtualKeyboardManagerV1>> m_vManagers;
|
||||
std::vector<SP<CVirtualKeyboardV1Resource>> m_vKeyboards;
|
||||
std::vector<UP<CZwpVirtualKeyboardManagerV1>> m_managers;
|
||||
std::vector<SP<CVirtualKeyboardV1Resource>> m_keyboards;
|
||||
|
||||
friend class CVirtualKeyboardV1Resource;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
#include "VirtualPointer.hpp"
|
||||
#include "core/Output.hpp"
|
||||
|
||||
CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, PHLMONITORREF boundOutput_) : boundOutput(boundOutput_), resource(resource_) {
|
||||
CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> resource_, PHLMONITORREF boundOutput_) : m_boundOutput(boundOutput_), m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CZwlrVirtualPointerV1* r) {
|
||||
events.destroy.emit();
|
||||
m_resource->setDestroy([this](CZwlrVirtualPointerV1* r) {
|
||||
m_events.destroy.emit();
|
||||
PROTO::virtualPointer->destroyResource(this);
|
||||
});
|
||||
resource->setOnDestroy([this](CZwlrVirtualPointerV1* r) {
|
||||
events.destroy.emit();
|
||||
m_resource->setOnDestroy([this](CZwlrVirtualPointerV1* r) {
|
||||
m_events.destroy.emit();
|
||||
PROTO::virtualPointer->destroyResource(this);
|
||||
});
|
||||
|
||||
resource->setMotion([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, wl_fixed_t dx, wl_fixed_t dy) {
|
||||
events.move.emit(IPointer::SMotionEvent{
|
||||
m_resource->setMotion([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, wl_fixed_t dx, wl_fixed_t dy) {
|
||||
m_events.move.emit(IPointer::SMotionEvent{
|
||||
.timeMs = timeMs,
|
||||
.delta = {wl_fixed_to_double(dx), wl_fixed_to_double(dy)},
|
||||
.unaccel = {wl_fixed_to_double(dx), wl_fixed_to_double(dy)},
|
||||
|
|
@ -23,84 +23,84 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
|
|||
});
|
||||
});
|
||||
|
||||
resource->setMotionAbsolute([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t x, uint32_t y, uint32_t xExtent, uint32_t yExtent) {
|
||||
m_resource->setMotionAbsolute([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t x, uint32_t y, uint32_t xExtent, uint32_t yExtent) {
|
||||
if (!xExtent || !yExtent)
|
||||
return;
|
||||
|
||||
events.warp.emit(IPointer::SMotionAbsoluteEvent{
|
||||
m_events.warp.emit(IPointer::SMotionAbsoluteEvent{
|
||||
.timeMs = timeMs,
|
||||
.absolute = {(double)x / xExtent, (double)y / yExtent},
|
||||
});
|
||||
});
|
||||
|
||||
resource->setButton([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t button, uint32_t state) {
|
||||
events.button.emit(IPointer::SButtonEvent{
|
||||
m_resource->setButton([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t button, uint32_t state) {
|
||||
m_events.button.emit(IPointer::SButtonEvent{
|
||||
.timeMs = timeMs,
|
||||
.button = button,
|
||||
.state = (wl_pointer_button_state)state,
|
||||
});
|
||||
});
|
||||
|
||||
resource->setAxis([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value) {
|
||||
if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
m_resource->setAxis([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value) {
|
||||
if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis");
|
||||
return;
|
||||
}
|
||||
|
||||
axis = axis_;
|
||||
axisEvents[axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)axis, .delta = wl_fixed_to_double(value)};
|
||||
m_axis = axis_;
|
||||
m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)m_axis, .delta = wl_fixed_to_double(value)};
|
||||
});
|
||||
|
||||
resource->setFrame([this](CZwlrVirtualPointerV1* r) {
|
||||
for (auto& e : axisEvents) {
|
||||
m_resource->setFrame([this](CZwlrVirtualPointerV1* r) {
|
||||
for (auto& e : m_axisEvents) {
|
||||
if (!e.timeMs)
|
||||
continue;
|
||||
events.axis.emit(e);
|
||||
m_events.axis.emit(e);
|
||||
e.timeMs = 0;
|
||||
}
|
||||
|
||||
events.frame.emit();
|
||||
m_events.frame.emit();
|
||||
});
|
||||
|
||||
resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { axisEvents[axis].source = (wl_pointer_axis_source)source; });
|
||||
m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = (wl_pointer_axis_source)source; });
|
||||
|
||||
resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) {
|
||||
if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
m_resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) {
|
||||
if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis");
|
||||
return;
|
||||
}
|
||||
|
||||
axis = axis_;
|
||||
axisEvents[axis].timeMs = timeMs;
|
||||
axisEvents[axis].axis = (wl_pointer_axis)axis;
|
||||
axisEvents[axis].delta = 0;
|
||||
axisEvents[axis].deltaDiscrete = 0;
|
||||
m_axis = axis_;
|
||||
m_axisEvents[m_axis].timeMs = timeMs;
|
||||
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis;
|
||||
m_axisEvents[m_axis].delta = 0;
|
||||
m_axisEvents[m_axis].deltaDiscrete = 0;
|
||||
});
|
||||
|
||||
resource->setAxisDiscrete([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value, int32_t discrete) {
|
||||
if UNLIKELY (axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
m_resource->setAxisDiscrete([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_, wl_fixed_t value, int32_t discrete) {
|
||||
if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
|
||||
r->error(ZWLR_VIRTUAL_POINTER_V1_ERROR_INVALID_AXIS, "Invalid axis");
|
||||
return;
|
||||
}
|
||||
|
||||
axis = axis_;
|
||||
axisEvents[axis].timeMs = timeMs;
|
||||
axisEvents[axis].axis = (wl_pointer_axis)axis;
|
||||
axisEvents[axis].delta = wl_fixed_to_double(value);
|
||||
axisEvents[axis].deltaDiscrete = discrete * 120;
|
||||
m_axis = axis_;
|
||||
m_axisEvents[m_axis].timeMs = timeMs;
|
||||
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis;
|
||||
m_axisEvents[m_axis].delta = wl_fixed_to_double(value);
|
||||
m_axisEvents[m_axis].deltaDiscrete = discrete * 120;
|
||||
});
|
||||
}
|
||||
|
||||
CVirtualPointerV1Resource::~CVirtualPointerV1Resource() {
|
||||
events.destroy.emit();
|
||||
m_events.destroy.emit();
|
||||
}
|
||||
|
||||
bool CVirtualPointerV1Resource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CVirtualPointerV1Resource::client() {
|
||||
return resource->client();
|
||||
return m_resource->client();
|
||||
}
|
||||
|
||||
CVirtualPointerProtocol::CVirtualPointerProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -108,7 +108,7 @@ CVirtualPointerProtocol::CVirtualPointerProtocol(const wl_interface* iface, cons
|
|||
}
|
||||
|
||||
void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZwlrVirtualPointerManagerV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managers.emplace_back(makeUnique<CZwlrVirtualPointerManagerV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
RESOURCE->setDestroy([this](CZwlrVirtualPointerManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
|
|
@ -128,24 +128,24 @@ void CVirtualPointerProtocol::bindManager(wl_client* client, void* data, uint32_
|
|||
}
|
||||
|
||||
void CVirtualPointerProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CVirtualPointerProtocol::destroyResource(CVirtualPointerV1Resource* pointer) {
|
||||
std::erase_if(m_vPointers, [&](const auto& other) { return other.get() == pointer; });
|
||||
std::erase_if(m_pointers, [&](const auto& other) { return other.get() == pointer; });
|
||||
}
|
||||
|
||||
void CVirtualPointerProtocol::onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, PHLMONITORREF output) {
|
||||
|
||||
const auto RESOURCE = m_vPointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id), output));
|
||||
const auto RESOURCE = m_pointers.emplace_back(makeShared<CVirtualPointerV1Resource>(makeShared<CZwlrVirtualPointerV1>(pMgr->client(), pMgr->version(), id), output));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
pMgr->noMemory();
|
||||
m_vPointers.pop_back();
|
||||
m_pointers.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
LOGM(LOG, "New VPointer at id {}", id);
|
||||
|
||||
events.newPointer.emit(RESOURCE);
|
||||
m_events.newPointer.emit(RESOURCE);
|
||||
}
|
||||
|
|
@ -32,21 +32,21 @@ class CVirtualPointerV1Resource {
|
|||
|
||||
CSignal holdBegin;
|
||||
CSignal holdEnd;
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
std::string name;
|
||||
std::string m_name;
|
||||
|
||||
PHLMONITORREF boundOutput;
|
||||
PHLMONITORREF m_boundOutput;
|
||||
|
||||
private:
|
||||
SP<CZwlrVirtualPointerV1> resource;
|
||||
SP<CZwlrVirtualPointerV1> m_resource;
|
||||
|
||||
uint32_t axis = 0;
|
||||
uint32_t m_axis = 0;
|
||||
|
||||
std::array<IPointer::SAxisEvent, 2> axisEvents;
|
||||
std::array<IPointer::SAxisEvent, 2> m_axisEvents;
|
||||
};
|
||||
|
||||
class CVirtualPointerProtocol : public IWaylandProtocol {
|
||||
|
|
@ -57,7 +57,7 @@ class CVirtualPointerProtocol : public IWaylandProtocol {
|
|||
|
||||
struct {
|
||||
CSignal newPointer; // SP<CVirtualPointerV1Resource>
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
private:
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
|
|
@ -65,8 +65,8 @@ class CVirtualPointerProtocol : public IWaylandProtocol {
|
|||
void onCreatePointer(CZwlrVirtualPointerManagerV1* pMgr, wl_resource* seat, uint32_t id, PHLMONITORREF output);
|
||||
|
||||
//
|
||||
std::vector<UP<CZwlrVirtualPointerManagerV1>> m_vManagers;
|
||||
std::vector<SP<CVirtualPointerV1Resource>> m_vPointers;
|
||||
std::vector<UP<CZwlrVirtualPointerManagerV1>> m_managers;
|
||||
std::vector<SP<CVirtualPointerV1Resource>> m_pointers;
|
||||
|
||||
friend class CVirtualPointerV1Resource;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ static void displayDestroyInternal(struct wl_listener* listener, void* data) {
|
|||
void IWaylandProtocol::onDisplayDestroy() {
|
||||
wl_list_remove(&m_liDisplayDestroy.listener.link);
|
||||
wl_list_init(&m_liDisplayDestroy.listener.link);
|
||||
if (m_pGlobal) {
|
||||
wl_global_destroy(m_pGlobal);
|
||||
m_pGlobal = nullptr;
|
||||
if (m_global) {
|
||||
wl_global_destroy(m_global);
|
||||
m_global = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name) :
|
||||
m_szName(name), m_pGlobal(wl_global_create(g_pCompositor->m_wlDisplay, iface, ver, this, &bindManagerInternal)) {
|
||||
m_name(name), m_global(wl_global_create(g_pCompositor->m_wlDisplay, iface, ver, this, &bindManagerInternal)) {
|
||||
|
||||
if UNLIKELY (!m_pGlobal) {
|
||||
LOGM(ERR, "could not create a global [{}]", m_szName);
|
||||
if UNLIKELY (!m_global) {
|
||||
LOGM(ERR, "could not create a global [{}]", m_name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, co
|
|||
m_liDisplayDestroy.parent = this;
|
||||
wl_display_add_destroy_listener(g_pCompositor->m_wlDisplay, &m_liDisplayDestroy.listener);
|
||||
|
||||
LOGM(LOG, "Registered global [{}]", m_szName);
|
||||
LOGM(LOG, "Registered global [{}]", m_name);
|
||||
}
|
||||
|
||||
IWaylandProtocol::~IWaylandProtocol() {
|
||||
|
|
@ -41,10 +41,10 @@ IWaylandProtocol::~IWaylandProtocol() {
|
|||
}
|
||||
|
||||
void IWaylandProtocol::removeGlobal() {
|
||||
if (m_pGlobal)
|
||||
wl_global_remove(m_pGlobal);
|
||||
if (m_global)
|
||||
wl_global_remove(m_global);
|
||||
}
|
||||
|
||||
wl_global* IWaylandProtocol::getGlobal() {
|
||||
return m_pGlobal;
|
||||
return m_global;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,6 @@ class IWaylandProtocol {
|
|||
SIWaylandProtocolDestroyWrapper m_liDisplayDestroy;
|
||||
|
||||
private:
|
||||
std::string m_szName;
|
||||
wl_global* m_pGlobal = nullptr;
|
||||
std::string m_name;
|
||||
wl_global* m_global = nullptr;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,43 +4,43 @@
|
|||
#include "core/Compositor.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) : resource(resource_) {
|
||||
CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!resource_->resource())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); });
|
||||
resource->setOnDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); });
|
||||
m_resource->setDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); });
|
||||
m_resource->setOnDestroy([this](CXdgActivationTokenV1* r) { PROTO::activation->destroyToken(this); });
|
||||
|
||||
resource->setSetSerial([this](CXdgActivationTokenV1* r, uint32_t serial_, wl_resource* seat) { serial = serial_; });
|
||||
m_resource->setSetSerial([this](CXdgActivationTokenV1* r, uint32_t serial_, wl_resource* seat) { m_serial = serial_; });
|
||||
|
||||
resource->setSetAppId([this](CXdgActivationTokenV1* r, const char* appid) { appID = appid; });
|
||||
m_resource->setSetAppId([this](CXdgActivationTokenV1* r, const char* appid) { m_appID = appid; });
|
||||
|
||||
resource->setCommit([this](CXdgActivationTokenV1* r) {
|
||||
m_resource->setCommit([this](CXdgActivationTokenV1* r) {
|
||||
// TODO: should we send a protocol error of already_used here
|
||||
// if it was used? the protocol spec doesn't say _when_ it should be sent...
|
||||
if UNLIKELY (committed) {
|
||||
if UNLIKELY (m_committed) {
|
||||
LOGM(WARN, "possible protocol error, two commits from one token. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
committed = true;
|
||||
m_committed = true;
|
||||
// send done with a new token
|
||||
token = g_pTokenManager->registerNewToken({}, std::chrono::months{12});
|
||||
m_token = g_pTokenManager->registerNewToken({}, std::chrono::months{12});
|
||||
|
||||
LOGM(LOG, "assigned new xdg-activation token {}", token);
|
||||
LOGM(LOG, "assigned new xdg-activation token {}", m_token);
|
||||
|
||||
resource->sendDone(token.c_str());
|
||||
m_resource->sendDone(m_token.c_str());
|
||||
|
||||
PROTO::activation->m_vSentTokens.push_back({token, resource->client()});
|
||||
PROTO::activation->m_sentTokens.push_back({m_token, m_resource->client()});
|
||||
|
||||
auto count = std::count_if(PROTO::activation->m_vSentTokens.begin(), PROTO::activation->m_vSentTokens.end(),
|
||||
[this](const auto& other) { return other.client == resource->client(); });
|
||||
auto count = std::count_if(PROTO::activation->m_sentTokens.begin(), PROTO::activation->m_sentTokens.end(),
|
||||
[this](const auto& other) { return other.client == m_resource->client(); });
|
||||
|
||||
if UNLIKELY (count > 10) {
|
||||
// remove first token. Too many, dear app.
|
||||
for (auto i = PROTO::activation->m_vSentTokens.begin(); i != PROTO::activation->m_vSentTokens.end(); ++i) {
|
||||
if (i->client == resource->client()) {
|
||||
PROTO::activation->m_vSentTokens.erase(i);
|
||||
for (auto i = PROTO::activation->m_sentTokens.begin(); i != PROTO::activation->m_sentTokens.end(); ++i) {
|
||||
if (i->client == m_resource->client()) {
|
||||
PROTO::activation->m_sentTokens.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -49,12 +49,12 @@ CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) :
|
|||
}
|
||||
|
||||
CXDGActivationToken::~CXDGActivationToken() {
|
||||
if (committed)
|
||||
g_pTokenManager->removeToken(g_pTokenManager->getToken(token));
|
||||
if (m_committed)
|
||||
g_pTokenManager->removeToken(g_pTokenManager->getToken(m_token));
|
||||
}
|
||||
|
||||
bool CXDGActivationToken::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXDGActivationProtocol::CXDGActivationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -62,21 +62,21 @@ CXDGActivationProtocol::CXDGActivationProtocol(const wl_interface* iface, const
|
|||
}
|
||||
|
||||
void CXDGActivationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CXdgActivationV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managers.emplace_back(makeUnique<CXdgActivationV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CXdgActivationV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
RESOURCE->setDestroy([this](CXdgActivationV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||
RESOURCE->setGetActivationToken([this](CXdgActivationV1* pMgr, uint32_t id) { this->onGetToken(pMgr, id); });
|
||||
RESOURCE->setActivate([this](CXdgActivationV1* pMgr, const char* token, wl_resource* surface) {
|
||||
auto TOKEN = std::find_if(m_vSentTokens.begin(), m_vSentTokens.end(), [token](const auto& t) { return t.token == token; });
|
||||
auto TOKEN = std::find_if(m_sentTokens.begin(), m_sentTokens.end(), [token](const auto& t) { return t.token == token; });
|
||||
|
||||
if UNLIKELY (TOKEN == m_vSentTokens.end()) {
|
||||
if UNLIKELY (TOKEN == m_sentTokens.end()) {
|
||||
LOGM(WARN, "activate event for non-existent token {}??", token);
|
||||
return;
|
||||
}
|
||||
|
||||
// remove token. It's been now spent.
|
||||
m_vSentTokens.erase(TOKEN);
|
||||
m_sentTokens.erase(TOKEN);
|
||||
|
||||
SP<CWLSurfaceResource> surf = CWLSurfaceResource::fromResource(surface);
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(surf);
|
||||
|
|
@ -91,20 +91,20 @@ void CXDGActivationProtocol::bindManager(wl_client* client, void* data, uint32_t
|
|||
}
|
||||
|
||||
void CXDGActivationProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CXDGActivationProtocol::destroyToken(CXDGActivationToken* token) {
|
||||
std::erase_if(m_vTokens, [&](const auto& other) { return other.get() == token; });
|
||||
std::erase_if(m_tokens, [&](const auto& other) { return other.get() == token; });
|
||||
}
|
||||
|
||||
void CXDGActivationProtocol::onGetToken(CXdgActivationV1* pMgr, uint32_t id) {
|
||||
const auto CLIENT = pMgr->client();
|
||||
const auto RESOURCE = m_vTokens.emplace_back(makeUnique<CXDGActivationToken>(makeShared<CXdgActivationTokenV1>(CLIENT, pMgr->version(), id))).get();
|
||||
const auto RESOURCE = m_tokens.emplace_back(makeUnique<CXDGActivationToken>(makeShared<CXdgActivationTokenV1>(CLIENT, pMgr->version(), id))).get();
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
pMgr->noMemory();
|
||||
m_vTokens.pop_back();
|
||||
m_tokens.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,13 +13,13 @@ class CXDGActivationToken {
|
|||
bool good();
|
||||
|
||||
private:
|
||||
SP<CXdgActivationTokenV1> resource;
|
||||
SP<CXdgActivationTokenV1> m_resource;
|
||||
|
||||
uint32_t serial = 0;
|
||||
std::string appID = "";
|
||||
bool committed = false;
|
||||
uint32_t m_serial = 0;
|
||||
std::string m_appID = "";
|
||||
bool m_committed = false;
|
||||
|
||||
std::string token = "";
|
||||
std::string m_token = "";
|
||||
|
||||
friend class CXDGActivationProtocol;
|
||||
};
|
||||
|
|
@ -39,11 +39,11 @@ class CXDGActivationProtocol : public IWaylandProtocol {
|
|||
std::string token;
|
||||
wl_client* client = nullptr; // READ-ONLY: can be dead
|
||||
};
|
||||
std::vector<SSentToken> m_vSentTokens;
|
||||
std::vector<SSentToken> m_sentTokens;
|
||||
|
||||
//
|
||||
std::vector<UP<CXdgActivationV1>> m_vManagers;
|
||||
std::vector<UP<CXDGActivationToken>> m_vTokens;
|
||||
std::vector<UP<CXdgActivationV1>> m_managers;
|
||||
std::vector<UP<CXDGActivationToken>> m_tokens;
|
||||
|
||||
friend class CXDGActivationToken;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ CXDGSystemBellProtocol::CXDGSystemBellProtocol(const wl_interface* iface, const
|
|||
}
|
||||
|
||||
void CXDGSystemBellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = WP<CXDGSystemBellManagerResource>{m_vManagers.emplace_back(makeUnique<CXDGSystemBellManagerResource>(makeUnique<CXdgSystemBellV1>(client, ver, id)))};
|
||||
const auto RESOURCE = WP<CXDGSystemBellManagerResource>{m_managers.emplace_back(makeUnique<CXDGSystemBellManagerResource>(makeUnique<CXdgSystemBellV1>(client, ver, id)))};
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
|
|
@ -68,5 +68,5 @@ void CXDGSystemBellProtocol::bindManager(wl_client* client, void* data, uint32_t
|
|||
}
|
||||
|
||||
void CXDGSystemBellProtocol::destroyResource(CXDGSystemBellManagerResource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class CXDGSystemBellProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CXDGSystemBellManagerResource* res);
|
||||
|
||||
//
|
||||
std::vector<UP<CXDGSystemBellManagerResource>> m_vManagers;
|
||||
std::vector<UP<CXDGSystemBellManagerResource>> m_managers;
|
||||
|
||||
friend class CXDGSystemBellManagerResource;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "XDGDecoration.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel) : resource(resource_), pToplevelResource(toplevel) {
|
||||
if UNLIKELY (!resource->resource())
|
||||
CXDGDecoration::CXDGDecoration(SP<CZxdgToplevelDecorationV1> resource_, wl_resource* toplevel) : m_resource(resource_), m_toplevelResource(toplevel) {
|
||||
if UNLIKELY (!m_resource->resource())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); });
|
||||
resource->setOnDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); });
|
||||
m_resource->setDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); });
|
||||
m_resource->setOnDestroy([this](CZxdgToplevelDecorationV1* pMgr) { PROTO::xdgDecoration->destroyDecoration(this); });
|
||||
|
||||
resource->setSetMode([this](CZxdgToplevelDecorationV1*, zxdgToplevelDecorationV1Mode mode) {
|
||||
m_resource->setSetMode([this](CZxdgToplevelDecorationV1*, zxdgToplevelDecorationV1Mode mode) {
|
||||
std::string modeString;
|
||||
switch (mode) {
|
||||
case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: modeString = "MODE_CLIENT_SIDE"; break;
|
||||
|
|
@ -17,23 +17,23 @@ 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"));
|
||||
resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
});
|
||||
|
||||
resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) {
|
||||
m_resource->setUnsetMode([this](CZxdgToplevelDecorationV1*) {
|
||||
LOGM(LOG, "unsetMode. Sending MODE_SERVER_SIDE.");
|
||||
resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
});
|
||||
|
||||
resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
m_resource->sendConfigure(ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
bool CXDGDecoration::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_resource* CXDGDecoration::toplevelResource() {
|
||||
return pToplevelResource;
|
||||
return m_toplevelResource;
|
||||
}
|
||||
|
||||
CXDGDecorationProtocol::CXDGDecorationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -41,7 +41,7 @@ CXDGDecorationProtocol::CXDGDecorationProtocol(const wl_interface* iface, const
|
|||
}
|
||||
|
||||
void CXDGDecorationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeUnique<CZxdgDecorationManagerV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managers.emplace_back(makeUnique<CZxdgDecorationManagerV1>(client, ver, id)).get();
|
||||
RESOURCE->setOnDestroy([this](CZxdgDecorationManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||
|
||||
RESOURCE->setDestroy([this](CZxdgDecorationManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||
|
|
@ -49,26 +49,26 @@ void CXDGDecorationProtocol::bindManager(wl_client* client, void* data, uint32_t
|
|||
}
|
||||
|
||||
void CXDGDecorationProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CXDGDecorationProtocol::destroyDecoration(CXDGDecoration* decoration) {
|
||||
m_mDecorations.erase(decoration->toplevelResource());
|
||||
m_decorations.erase(decoration->toplevelResource());
|
||||
}
|
||||
|
||||
void CXDGDecorationProtocol::onGetDecoration(CZxdgDecorationManagerV1* pMgr, uint32_t id, wl_resource* xdgToplevel) {
|
||||
if UNLIKELY (m_mDecorations.contains(xdgToplevel)) {
|
||||
if UNLIKELY (m_decorations.contains(xdgToplevel)) {
|
||||
pMgr->error(ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED, "Decoration object already exists");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto CLIENT = pMgr->client();
|
||||
const auto RESOURCE =
|
||||
m_mDecorations.emplace(xdgToplevel, makeUnique<CXDGDecoration>(makeShared<CZxdgToplevelDecorationV1>(CLIENT, pMgr->version(), id), xdgToplevel)).first->second.get();
|
||||
m_decorations.emplace(xdgToplevel, makeUnique<CXDGDecoration>(makeShared<CZxdgToplevelDecorationV1>(CLIENT, pMgr->version(), id), xdgToplevel)).first->second.get();
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
pMgr->noMemory();
|
||||
m_mDecorations.erase(xdgToplevel);
|
||||
m_decorations.erase(xdgToplevel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ class CXDGDecoration {
|
|||
wl_resource* toplevelResource();
|
||||
|
||||
private:
|
||||
SP<CZxdgToplevelDecorationV1> resource;
|
||||
wl_resource* pToplevelResource = nullptr; // READ-ONLY.
|
||||
SP<CZxdgToplevelDecorationV1> m_resource;
|
||||
wl_resource* m_toplevelResource = nullptr; // READ-ONLY.
|
||||
};
|
||||
|
||||
class CXDGDecorationProtocol : public IWaylandProtocol {
|
||||
|
|
@ -29,8 +29,8 @@ class CXDGDecorationProtocol : public IWaylandProtocol {
|
|||
void onGetDecoration(CZxdgDecorationManagerV1* pMgr, uint32_t id, wl_resource* xdgToplevel);
|
||||
|
||||
//
|
||||
std::vector<UP<CZxdgDecorationManagerV1>> m_vManagers;
|
||||
std::unordered_map<wl_resource*, UP<CXDGDecoration>> m_mDecorations; // xdg_toplevel -> deco
|
||||
std::vector<UP<CZxdgDecorationManagerV1>> m_managers;
|
||||
std::unordered_map<wl_resource*, UP<CXDGDecoration>> m_decorations; // xdg_toplevel -> deco
|
||||
|
||||
friend class CXDGDecoration;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,29 +4,29 @@
|
|||
#include "../Compositor.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
CXDGDialogV1Resource::CXDGDialogV1Resource(SP<CXdgDialogV1> resource_, SP<CXDGToplevelResource> toplevel_) : resource(resource_), toplevel(toplevel_) {
|
||||
CXDGDialogV1Resource::CXDGDialogV1Resource(SP<CXdgDialogV1> resource_, SP<CXDGToplevelResource> toplevel_) : m_resource(resource_), m_toplevel(toplevel_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXdgDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
|
||||
resource->setSetModal([this](CXdgDialogV1* r) {
|
||||
m_resource->setSetModal([this](CXdgDialogV1* r) {
|
||||
modal = true;
|
||||
updateWindow();
|
||||
});
|
||||
|
||||
resource->setUnsetModal([this](CXdgDialogV1* r) {
|
||||
m_resource->setUnsetModal([this](CXdgDialogV1* r) {
|
||||
modal = false;
|
||||
updateWindow();
|
||||
});
|
||||
}
|
||||
|
||||
void CXDGDialogV1Resource::updateWindow() {
|
||||
if UNLIKELY (!toplevel || !toplevel->parent || !toplevel->parent->owner)
|
||||
if UNLIKELY (!m_toplevel || !m_toplevel->m_parent || !m_toplevel->m_parent->m_owner)
|
||||
return;
|
||||
|
||||
auto HLSurface = CWLSurface::fromResource(toplevel->parent->owner->surface.lock());
|
||||
auto HLSurface = CWLSurface::fromResource(m_toplevel->m_parent->m_owner->m_surface.lock());
|
||||
if UNLIKELY (!HLSurface || !HLSurface->getWindow())
|
||||
return;
|
||||
|
||||
|
|
@ -34,36 +34,36 @@ void CXDGDialogV1Resource::updateWindow() {
|
|||
}
|
||||
|
||||
bool CXDGDialogV1Resource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXDGWmDialogManagerResource::CXDGWmDialogManagerResource(SP<CXdgWmDialogV1> resource_) : resource(resource_) {
|
||||
CXDGWmDialogManagerResource::CXDGWmDialogManagerResource(SP<CXdgWmDialogV1> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXdgWmDialogV1* r) { PROTO::xdgDialog->destroyResource(this); });
|
||||
|
||||
resource->setGetXdgDialog([](CXdgWmDialogV1* r, uint32_t id, wl_resource* toplevel) {
|
||||
m_resource->setGetXdgDialog([](CXdgWmDialogV1* r, uint32_t id, wl_resource* toplevel) {
|
||||
auto tl = CXDGToplevelResource::fromResource(toplevel);
|
||||
if UNLIKELY (!tl) {
|
||||
r->error(-1, "Toplevel inert");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto RESOURCE = PROTO::xdgDialog->m_vDialogs.emplace_back(makeShared<CXDGDialogV1Resource>(makeShared<CXdgDialogV1>(r->client(), r->version(), id), tl));
|
||||
const auto RESOURCE = PROTO::xdgDialog->m_dialogs.emplace_back(makeShared<CXDGDialogV1Resource>(makeShared<CXdgDialogV1>(r->client(), r->version(), id), tl));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
return;
|
||||
}
|
||||
|
||||
tl->dialog = RESOURCE;
|
||||
tl->m_dialog = RESOURCE;
|
||||
});
|
||||
}
|
||||
|
||||
bool CXDGWmDialogManagerResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXDGDialogProtocol::CXDGDialogProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -71,7 +71,7 @@ CXDGDialogProtocol::CXDGDialogProtocol(const wl_interface* iface, const int& ver
|
|||
}
|
||||
|
||||
void CXDGDialogProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXDGWmDialogManagerResource>(makeShared<CXdgWmDialogV1>(client, ver, id)));
|
||||
const auto RESOURCE = m_managers.emplace_back(makeShared<CXDGWmDialogManagerResource>(makeShared<CXdgWmDialogV1>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
|
|
@ -80,9 +80,9 @@ void CXDGDialogProtocol::bindManager(wl_client* client, void* data, uint32_t ver
|
|||
}
|
||||
|
||||
void CXDGDialogProtocol::destroyResource(CXDGWmDialogManagerResource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
|
||||
void CXDGDialogProtocol::destroyResource(CXDGDialogV1Resource* res) {
|
||||
std::erase_if(m_vDialogs, [&](const auto& other) { return other.get() == res; });
|
||||
std::erase_if(m_dialogs, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ class CXDGDialogV1Resource {
|
|||
bool modal = false;
|
||||
|
||||
private:
|
||||
SP<CXdgDialogV1> resource;
|
||||
WP<CXDGToplevelResource> toplevel;
|
||||
SP<CXdgDialogV1> m_resource;
|
||||
WP<CXDGToplevelResource> m_toplevel;
|
||||
|
||||
void updateWindow();
|
||||
};
|
||||
|
|
@ -29,7 +29,7 @@ class CXDGWmDialogManagerResource {
|
|||
bool good();
|
||||
|
||||
private:
|
||||
SP<CXdgWmDialogV1> resource;
|
||||
SP<CXdgWmDialogV1> m_resource;
|
||||
};
|
||||
|
||||
class CXDGDialogProtocol : public IWaylandProtocol {
|
||||
|
|
@ -44,8 +44,8 @@ class CXDGDialogProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CXDGDialogV1Resource* res);
|
||||
|
||||
//
|
||||
std::vector<SP<CXDGWmDialogManagerResource>> m_vManagers;
|
||||
std::vector<SP<CXDGDialogV1Resource>> m_vDialogs;
|
||||
std::vector<SP<CXDGWmDialogManagerResource>> m_managers;
|
||||
std::vector<SP<CXDGDialogV1Resource>> m_dialogs;
|
||||
|
||||
friend class CXDGWmDialogManagerResource;
|
||||
friend class CXDGDialogV1Resource;
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@
|
|||
//
|
||||
|
||||
void CXDGOutputProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vManagerResources, [&](const auto& other) { return other->resource() == res; });
|
||||
std::erase_if(m_managerResources, [&](const auto& other) { return other->resource() == res; });
|
||||
}
|
||||
|
||||
void CXDGOutputProtocol::onOutputResourceDestroy(wl_resource* res) {
|
||||
std::erase_if(m_vXDGOutputs, [&](const auto& other) { return other->resource->resource() == res; });
|
||||
std::erase_if(m_xdgOutputs, [&](const auto& other) { return other->m_resource->resource() == res; });
|
||||
}
|
||||
|
||||
void CXDGOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagerResources.emplace_back(makeUnique<CZxdgOutputManagerV1>(client, ver, id)).get();
|
||||
const auto RESOURCE = m_managerResources.emplace_back(makeUnique<CZxdgOutputManagerV1>(client, ver, id)).get();
|
||||
|
||||
if UNLIKELY (!RESOURCE->resource()) {
|
||||
LOGM(LOG, "Couldn't bind XDGOutputMgr");
|
||||
|
|
@ -45,34 +45,34 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32
|
|||
const auto PMONITOR = OUTPUT->m_monitor.lock();
|
||||
const auto CLIENT = mgr->client();
|
||||
|
||||
CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get();
|
||||
CXDGOutput* pXDGOutput = m_xdgOutputs.emplace_back(makeUnique<CXDGOutput>(makeShared<CZxdgOutputV1>(CLIENT, mgr->version(), id), PMONITOR)).get();
|
||||
#ifndef NO_XWAYLAND
|
||||
if (g_pXWayland && g_pXWayland->pServer && g_pXWayland->pServer->xwaylandClient == CLIENT)
|
||||
pXDGOutput->isXWayland = true;
|
||||
pXDGOutput->m_isXWayland = true;
|
||||
#endif
|
||||
pXDGOutput->client = CLIENT;
|
||||
pXDGOutput->m_client = CLIENT;
|
||||
|
||||
pXDGOutput->outputProto = OUTPUT->m_owner;
|
||||
pXDGOutput->m_outputProto = OUTPUT->m_owner;
|
||||
|
||||
if UNLIKELY (!pXDGOutput->resource->resource()) {
|
||||
m_vXDGOutputs.pop_back();
|
||||
if UNLIKELY (!pXDGOutput->m_resource->resource()) {
|
||||
m_xdgOutputs.pop_back();
|
||||
mgr->noMemory();
|
||||
return;
|
||||
}
|
||||
|
||||
if UNLIKELY (!PMONITOR) {
|
||||
LOGM(ERR, "New xdg_output from client {:x} ({}) has no CMonitor?!", (uintptr_t)CLIENT, pXDGOutput->isXWayland ? "xwayland" : "not xwayland");
|
||||
LOGM(ERR, "New xdg_output from client {:x} ({}) has no CMonitor?!", (uintptr_t)CLIENT, pXDGOutput->m_isXWayland ? "xwayland" : "not xwayland");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGM(LOG, "New xdg_output for {}: client {:x} ({})", PMONITOR->m_name, (uintptr_t)CLIENT, pXDGOutput->isXWayland ? "xwayland" : "not xwayland");
|
||||
LOGM(LOG, "New xdg_output for {}: client {:x} ({})", PMONITOR->m_name, (uintptr_t)CLIENT, pXDGOutput->m_isXWayland ? "xwayland" : "not xwayland");
|
||||
|
||||
const auto XDGVER = pXDGOutput->resource->version();
|
||||
const auto XDGVER = pXDGOutput->m_resource->version();
|
||||
|
||||
if (XDGVER >= OUTPUT_NAME_SINCE_VERSION)
|
||||
pXDGOutput->resource->sendName(PMONITOR->m_name.c_str());
|
||||
pXDGOutput->m_resource->sendName(PMONITOR->m_name.c_str());
|
||||
if (XDGVER >= OUTPUT_DESCRIPTION_SINCE_VERSION && !PMONITOR->m_output->description.empty())
|
||||
pXDGOutput->resource->sendDescription(PMONITOR->m_output->description.c_str());
|
||||
pXDGOutput->m_resource->sendDescription(PMONITOR->m_output->description.c_str());
|
||||
|
||||
pXDGOutput->sendDetails();
|
||||
|
||||
|
|
@ -84,40 +84,40 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32
|
|||
void CXDGOutputProtocol::updateAllOutputs() {
|
||||
LOGM(LOG, "updating all xdg_output heads");
|
||||
|
||||
for (auto const& o : m_vXDGOutputs) {
|
||||
if (!o->monitor)
|
||||
for (auto const& o : m_xdgOutputs) {
|
||||
if (!o->m_monitor)
|
||||
continue;
|
||||
|
||||
o->sendDetails();
|
||||
|
||||
o->monitor->scheduleDone();
|
||||
o->m_monitor->scheduleDone();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, PHLMONITOR monitor_) : monitor(monitor_), resource(resource_) {
|
||||
if UNLIKELY (!resource->resource())
|
||||
CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, PHLMONITOR monitor_) : m_monitor(monitor_), m_resource(resource_) {
|
||||
if UNLIKELY (!m_resource->resource())
|
||||
return;
|
||||
|
||||
resource->setDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); });
|
||||
resource->setOnDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); });
|
||||
m_resource->setDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); });
|
||||
m_resource->setOnDestroy([](CZxdgOutputV1* pMgr) { PROTO::xdgOutput->onOutputResourceDestroy(pMgr->resource()); });
|
||||
}
|
||||
|
||||
void CXDGOutput::sendDetails() {
|
||||
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
|
||||
|
||||
if UNLIKELY (!monitor || !outputProto || outputProto->isDefunct())
|
||||
if UNLIKELY (!m_monitor || !m_outputProto || m_outputProto->isDefunct())
|
||||
return;
|
||||
|
||||
const auto POS = isXWayland ? monitor->m_xwaylandPosition : monitor->m_position;
|
||||
resource->sendLogicalPosition(POS.x, POS.y);
|
||||
const auto POS = m_isXWayland ? m_monitor->m_xwaylandPosition : m_monitor->m_position;
|
||||
m_resource->sendLogicalPosition(POS.x, POS.y);
|
||||
|
||||
if (*PXWLFORCESCALEZERO && isXWayland)
|
||||
resource->sendLogicalSize(monitor->m_transformedSize.x, monitor->m_transformedSize.y);
|
||||
if (*PXWLFORCESCALEZERO && m_isXWayland)
|
||||
m_resource->sendLogicalSize(m_monitor->m_transformedSize.x, m_monitor->m_transformedSize.y);
|
||||
else
|
||||
resource->sendLogicalSize(monitor->m_size.x, monitor->m_size.y);
|
||||
m_resource->sendLogicalSize(m_monitor->m_size.x, m_monitor->m_size.y);
|
||||
|
||||
if (resource->version() < OUTPUT_DONE_DEPRECATED_SINCE_VERSION)
|
||||
resource->sendDone();
|
||||
if (m_resource->version() < OUTPUT_DONE_DEPRECATED_SINCE_VERSION)
|
||||
m_resource->sendDone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ class CXDGOutput {
|
|||
void sendDetails();
|
||||
|
||||
private:
|
||||
PHLMONITORREF monitor;
|
||||
SP<CZxdgOutputV1> resource;
|
||||
WP<CWLOutputProtocol> outputProto;
|
||||
PHLMONITORREF m_monitor;
|
||||
SP<CZxdgOutputV1> m_resource;
|
||||
WP<CWLOutputProtocol> m_outputProto;
|
||||
|
||||
std::optional<Vector2D> overridePosition;
|
||||
|
||||
wl_client* client = nullptr;
|
||||
bool isXWayland = false;
|
||||
wl_client* m_client = nullptr;
|
||||
bool m_isXWayland = false;
|
||||
|
||||
friend class CXDGOutputProtocol;
|
||||
};
|
||||
|
|
@ -40,8 +38,8 @@ class CXDGOutputProtocol : public IWaylandProtocol {
|
|||
void onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource);
|
||||
|
||||
//
|
||||
std::vector<UP<CZxdgOutputManagerV1>> m_vManagerResources;
|
||||
std::vector<UP<CXDGOutput>> m_vXDGOutputs;
|
||||
std::vector<UP<CZxdgOutputManagerV1>> m_managerResources;
|
||||
std::vector<UP<CXDGOutput>> m_xdgOutputs;
|
||||
|
||||
friend class CXDGOutput;
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -40,7 +40,7 @@ class CXDGPositionerRules {
|
|||
CBox getPosition(CBox constraint, const Vector2D& parentPos);
|
||||
|
||||
private:
|
||||
SXDGPositionerState state;
|
||||
SXDGPositionerState m_state;
|
||||
};
|
||||
|
||||
class CXDGPopupResource {
|
||||
|
|
@ -54,19 +54,19 @@ class CXDGPopupResource {
|
|||
|
||||
void applyPositioning(const CBox& availableBox, const Vector2D& t1coord /* relative to box */);
|
||||
|
||||
WP<CXDGSurfaceResource> surface;
|
||||
WP<CXDGSurfaceResource> parent;
|
||||
WP<CXDGPopupResource> self;
|
||||
WP<CXDGSurfaceResource> m_surface;
|
||||
WP<CXDGSurfaceResource> m_parent;
|
||||
WP<CXDGPopupResource> m_self;
|
||||
|
||||
bool taken = false;
|
||||
bool m_taken = false;
|
||||
|
||||
CBox geometry;
|
||||
CBox m_geometry;
|
||||
|
||||
struct {
|
||||
CSignal reposition;
|
||||
CSignal dismissed;
|
||||
CSignal destroy; // only the role
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
// schedules a configure event
|
||||
void configure(const CBox& box);
|
||||
|
|
@ -75,13 +75,13 @@ class CXDGPopupResource {
|
|||
void repositioned();
|
||||
|
||||
private:
|
||||
SP<CXdgPopup> resource;
|
||||
SP<CXdgPopup> m_resource;
|
||||
|
||||
uint32_t lastRepositionToken = 0;
|
||||
uint32_t m_lastRepositionToken = 0;
|
||||
|
||||
Vector2D accumulateParentOffset();
|
||||
|
||||
CXDGPositionerRules positionerRules;
|
||||
CXDGPositionerRules m_positionerRules;
|
||||
};
|
||||
|
||||
class CXDGToplevelResource {
|
||||
|
|
@ -91,10 +91,10 @@ class CXDGToplevelResource {
|
|||
|
||||
static SP<CXDGToplevelResource> fromResource(wl_resource*);
|
||||
|
||||
WP<CXDGSurfaceResource> owner;
|
||||
WP<CXDGToplevelResource> self;
|
||||
WP<CXDGSurfaceResource> m_owner;
|
||||
WP<CXDGToplevelResource> m_self;
|
||||
|
||||
PHLWINDOWREF window;
|
||||
PHLWINDOWREF m_window;
|
||||
|
||||
bool good();
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ class CXDGToplevelResource {
|
|||
CSignal stateChanged; // maximized, fs, minimized, etc.
|
||||
CSignal metadataChanged; // title, appid
|
||||
CSignal destroy; // only the role
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
struct {
|
||||
std::string title;
|
||||
|
|
@ -126,29 +126,30 @@ class CXDGToplevelResource {
|
|||
std::optional<bool> requestsFullscreen;
|
||||
std::optional<MONITORID> requestsFullscreenMonitor;
|
||||
std::optional<bool> requestsMinimize;
|
||||
} state;
|
||||
} m_state;
|
||||
|
||||
struct {
|
||||
Vector2D size;
|
||||
std::vector<xdgToplevelState> states;
|
||||
} pendingApply;
|
||||
} m_pendingApply;
|
||||
|
||||
struct {
|
||||
Vector2D minSize = {1, 1};
|
||||
Vector2D maxSize = {1337420, 694200};
|
||||
} pending, current;
|
||||
} m_pending, m_current;
|
||||
|
||||
WP<CXDGToplevelResource> parent;
|
||||
WP<CXDGDialogV1Resource> dialog;
|
||||
WP<CXDGToplevelResource> m_parent;
|
||||
WP<CXDGDialogV1Resource> m_dialog;
|
||||
|
||||
std::optional<std::string> m_toplevelTag, m_toplevelDescription;
|
||||
std::optional<std::string> m_toplevelTag;
|
||||
std::optional<std::string> m_toplevelDescription;
|
||||
|
||||
bool anyChildModal();
|
||||
|
||||
std::vector<WP<CXDGToplevelResource>> children;
|
||||
std::vector<WP<CXDGToplevelResource>> m_children;
|
||||
|
||||
private:
|
||||
SP<CXdgToplevel> resource;
|
||||
SP<CXdgToplevel> m_resource;
|
||||
void applyState();
|
||||
};
|
||||
|
||||
|
|
@ -160,7 +161,7 @@ class CXDGSurfaceRole : public ISurfaceRole {
|
|||
return SURFACE_ROLE_XDG_SHELL;
|
||||
}
|
||||
|
||||
WP<CXDGSurfaceResource> xdgSurface;
|
||||
WP<CXDGSurfaceResource> m_xdgSurface;
|
||||
};
|
||||
|
||||
class CXDGSurfaceResource {
|
||||
|
|
@ -172,17 +173,17 @@ class CXDGSurfaceResource {
|
|||
|
||||
bool good();
|
||||
|
||||
WP<CXDGWMBase> owner;
|
||||
WP<CWLSurfaceResource> surface;
|
||||
WP<CXDGWMBase> m_owner;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
|
||||
WP<CXDGToplevelResource> toplevel;
|
||||
WP<CXDGPopupResource> popup;
|
||||
WP<CXDGToplevelResource> m_toplevel;
|
||||
WP<CXDGPopupResource> m_popup;
|
||||
|
||||
WP<CXDGSurfaceResource> self;
|
||||
WP<CXDGSurfaceResource> m_self;
|
||||
|
||||
struct {
|
||||
CBox geometry;
|
||||
} pending, current;
|
||||
} m_pending, m_current;
|
||||
|
||||
struct {
|
||||
CSignal ack;
|
||||
|
|
@ -191,30 +192,30 @@ class CXDGSurfaceResource {
|
|||
CSignal unmap;
|
||||
CSignal destroy;
|
||||
CSignal newPopup; // SP<CXDGPopupResource>
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
bool initialCommit = true;
|
||||
bool mapped = false;
|
||||
bool m_initialCommit = true;
|
||||
bool m_mapped = false;
|
||||
|
||||
uint32_t scheduleConfigure();
|
||||
// do not call directly
|
||||
void configure();
|
||||
|
||||
private:
|
||||
SP<CXdgSurface> resource;
|
||||
SP<CXdgSurface> m_resource;
|
||||
|
||||
uint32_t lastConfigureSerial = 0;
|
||||
uint32_t scheduledSerial = 0;
|
||||
uint32_t m_lastConfigureSerial = 0;
|
||||
uint32_t m_scheduledSerial = 0;
|
||||
|
||||
wl_event_source* configureSource = nullptr;
|
||||
wl_event_source* m_configureSource = nullptr;
|
||||
|
||||
//
|
||||
std::vector<WP<CXDGPopupResource>> popups;
|
||||
std::vector<WP<CXDGPopupResource>> m_popups;
|
||||
|
||||
struct {
|
||||
CHyprSignalListener surfaceDestroy;
|
||||
CHyprSignalListener surfaceCommit;
|
||||
} listeners;
|
||||
} m_listeners;
|
||||
|
||||
friend class CXDGPopupResource;
|
||||
friend class CXDGToplevelResource;
|
||||
|
|
@ -228,13 +229,13 @@ class CXDGPositionerResource {
|
|||
|
||||
bool good();
|
||||
|
||||
SXDGPositionerState state;
|
||||
SXDGPositionerState m_state;
|
||||
|
||||
WP<CXDGWMBase> owner;
|
||||
WP<CXDGPositionerResource> self;
|
||||
WP<CXDGWMBase> m_owner;
|
||||
WP<CXDGPositionerResource> m_self;
|
||||
|
||||
private:
|
||||
SP<CXdgPositioner> resource;
|
||||
SP<CXdgPositioner> m_resource;
|
||||
};
|
||||
|
||||
class CXDGWMBase {
|
||||
|
|
@ -245,18 +246,18 @@ class CXDGWMBase {
|
|||
wl_client* client();
|
||||
void ping();
|
||||
|
||||
std::vector<WP<CXDGPositionerResource>> positioners;
|
||||
std::vector<WP<CXDGSurfaceResource>> surfaces;
|
||||
std::vector<WP<CXDGPositionerResource>> m_positioners;
|
||||
std::vector<WP<CXDGSurfaceResource>> m_surfaces;
|
||||
|
||||
WP<CXDGWMBase> self;
|
||||
WP<CXDGWMBase> m_self;
|
||||
|
||||
struct {
|
||||
CSignal pong;
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
private:
|
||||
SP<CXdgWmBase> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SP<CXdgWmBase> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
};
|
||||
|
||||
class CXDGShellProtocol : public IWaylandProtocol {
|
||||
|
|
@ -273,16 +274,16 @@ class CXDGShellProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CXDGPopupResource* resource);
|
||||
|
||||
//
|
||||
std::vector<SP<CXDGWMBase>> m_vWMBases;
|
||||
std::vector<SP<CXDGPositionerResource>> m_vPositioners;
|
||||
std::vector<SP<CXDGSurfaceResource>> m_vSurfaces;
|
||||
std::vector<SP<CXDGToplevelResource>> m_vToplevels;
|
||||
std::vector<SP<CXDGPopupResource>> m_vPopups;
|
||||
std::vector<SP<CXDGWMBase>> m_wmBases;
|
||||
std::vector<SP<CXDGPositionerResource>> m_positioners;
|
||||
std::vector<SP<CXDGSurfaceResource>> m_surfaces;
|
||||
std::vector<SP<CXDGToplevelResource>> m_toplevels;
|
||||
std::vector<SP<CXDGPopupResource>> m_popups;
|
||||
|
||||
// current popup grab
|
||||
WP<CXDGPopupResource> grabOwner;
|
||||
SP<CSeatGrab> grab;
|
||||
std::vector<WP<CXDGPopupResource>> grabbed;
|
||||
WP<CXDGPopupResource> m_grabOwner;
|
||||
SP<CSeatGrab> m_grab;
|
||||
std::vector<WP<CXDGPopupResource>> m_grabbed;
|
||||
|
||||
void addOrStartGrab(SP<CXDGPopupResource> popup);
|
||||
void onPopupDestroy(WP<CXDGPopupResource> popup);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ CXDGToplevelTagProtocol::CXDGToplevelTagProtocol(const wl_interface* iface, cons
|
|||
|
||||
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)))};
|
||||
WP<CXDGToplevelTagManagerResource>{m_managers.emplace_back(makeUnique<CXDGToplevelTagManagerResource>(makeUnique<CXdgToplevelTagManagerV1>(client, ver, id)))};
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
|
|
@ -50,5 +50,5 @@ void CXDGToplevelTagProtocol::bindManager(wl_client* client, void* data, uint32_
|
|||
}
|
||||
|
||||
void CXDGToplevelTagProtocol::destroyResource(CXDGToplevelTagManagerResource* res) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == res; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == res; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class CXDGToplevelTagProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CXDGToplevelTagManagerResource* res);
|
||||
|
||||
//
|
||||
std::vector<UP<CXDGToplevelTagManagerResource>> m_vManagers;
|
||||
std::vector<UP<CXDGToplevelTagManagerResource>> m_managers;
|
||||
|
||||
friend class CXDGToplevelTagManagerResource;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,24 +2,24 @@
|
|||
#include "core/Compositor.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) {
|
||||
CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CXwaylandSurfaceV1* r) {
|
||||
m_resource->setDestroy([this](CXwaylandSurfaceV1* r) {
|
||||
events.destroy.emit();
|
||||
PROTO::xwaylandShell->destroyResource(this);
|
||||
});
|
||||
resource->setOnDestroy([this](CXwaylandSurfaceV1* r) {
|
||||
m_resource->setOnDestroy([this](CXwaylandSurfaceV1* r) {
|
||||
events.destroy.emit();
|
||||
PROTO::xwaylandShell->destroyResource(this);
|
||||
});
|
||||
|
||||
pClient = resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) {
|
||||
serial = (((uint64_t)hi) << 32) + lo;
|
||||
PROTO::xwaylandShell->events.newSurface.emit(self.lock());
|
||||
m_resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) {
|
||||
m_serial = (((uint64_t)hi) << 32) + lo;
|
||||
PROTO::xwaylandShell->m_events.newSurface.emit(m_self.lock());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -28,36 +28,36 @@ CXWaylandSurfaceResource::~CXWaylandSurfaceResource() {
|
|||
}
|
||||
|
||||
bool CXWaylandSurfaceResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CXWaylandSurfaceResource::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) : resource(resource_) {
|
||||
CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->setDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); });
|
||||
|
||||
resource->setGetXwaylandSurface([](CXwaylandShellV1* r, uint32_t id, wl_resource* surface) {
|
||||
const auto RESOURCE = PROTO::xwaylandShell->m_vSurfaces.emplace_back(
|
||||
m_resource->setGetXwaylandSurface([](CXwaylandShellV1* r, uint32_t id, wl_resource* surface) {
|
||||
const auto RESOURCE = PROTO::xwaylandShell->m_surfaces.emplace_back(
|
||||
makeShared<CXWaylandSurfaceResource>(makeShared<CXwaylandSurfaceV1>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surface)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xwaylandShell->m_vSurfaces.pop_back();
|
||||
PROTO::xwaylandShell->m_surfaces.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
}
|
||||
|
||||
bool CXWaylandShellResource::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXWaylandShellProtocol::CXWaylandShellProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -65,19 +65,19 @@ CXWaylandShellProtocol::CXWaylandShellProtocol(const wl_interface* iface, const
|
|||
}
|
||||
|
||||
void CXWaylandShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXWaylandShellResource>(makeShared<CXwaylandShellV1>(client, ver, id)));
|
||||
const auto RESOURCE = m_managers.emplace_back(makeShared<CXWaylandShellResource>(makeShared<CXwaylandShellV1>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
m_vManagers.pop_back();
|
||||
m_managers.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CXWaylandShellProtocol::destroyResource(CXWaylandShellResource* resource) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXWaylandShellProtocol::destroyResource(CXWaylandSurfaceResource* resource) {
|
||||
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ class CXWaylandSurfaceResource {
|
|||
CSignal destroy;
|
||||
} events;
|
||||
|
||||
uint64_t serial = 0;
|
||||
WP<CWLSurfaceResource> surface;
|
||||
uint64_t m_serial = 0;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
|
||||
WP<CXWaylandSurfaceResource> self;
|
||||
WP<CXWaylandSurfaceResource> m_self;
|
||||
|
||||
private:
|
||||
SP<CXwaylandSurfaceV1> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SP<CXwaylandSurfaceV1> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
};
|
||||
|
||||
class CXWaylandShellResource {
|
||||
|
|
@ -37,7 +37,7 @@ class CXWaylandShellResource {
|
|||
bool good();
|
||||
|
||||
private:
|
||||
SP<CXwaylandShellV1> resource;
|
||||
SP<CXwaylandShellV1> m_resource;
|
||||
};
|
||||
|
||||
class CXWaylandShellProtocol : public IWaylandProtocol {
|
||||
|
|
@ -48,15 +48,15 @@ class CXWaylandShellProtocol : public IWaylandProtocol {
|
|||
|
||||
struct {
|
||||
CSignal newSurface; // SP<CXWaylandSurfaceResource>. Fired when it sets a serial, otherwise it's useless
|
||||
} events;
|
||||
} m_events;
|
||||
|
||||
private:
|
||||
void destroyResource(CXWaylandSurfaceResource* resource);
|
||||
void destroyResource(CXWaylandShellResource* resource);
|
||||
|
||||
//
|
||||
std::vector<SP<CXWaylandShellResource>> m_vManagers;
|
||||
std::vector<SP<CXWaylandSurfaceResource>> m_vSurfaces;
|
||||
std::vector<SP<CXWaylandShellResource>> m_managers;
|
||||
std::vector<SP<CXWaylandSurfaceResource>> m_surfaces;
|
||||
|
||||
friend class CXWaylandSurfaceResource;
|
||||
friend class CXWaylandShellResource;
|
||||
|
|
|
|||
|
|
@ -31,54 +31,54 @@ static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primar
|
|||
return (wpColorManagerV1Primaries)(primaries + 1);
|
||||
}
|
||||
|
||||
CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(resource_) {
|
||||
CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC);
|
||||
resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME);
|
||||
resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES);
|
||||
resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES);
|
||||
resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES);
|
||||
m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC);
|
||||
m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME);
|
||||
m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES);
|
||||
m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES);
|
||||
m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES);
|
||||
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020);
|
||||
// resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3);
|
||||
resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3);
|
||||
m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB);
|
||||
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22);
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28);
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG);
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB);
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ);
|
||||
resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ);
|
||||
m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR);
|
||||
|
||||
resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
|
||||
m_resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
|
||||
// resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE);
|
||||
// resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE);
|
||||
// resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC);
|
||||
|
||||
resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); });
|
||||
resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) {
|
||||
m_resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); });
|
||||
m_resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) {
|
||||
LOGM(TRACE, "Get output for id={}, output={}", id, (uintptr_t)output);
|
||||
const auto RESOURCE =
|
||||
PROTO::xxColorManagement->m_vOutputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id)));
|
||||
PROTO::xxColorManagement->m_outputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vOutputs.pop_back();
|
||||
PROTO::xxColorManagement->m_outputs.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) {
|
||||
m_resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) {
|
||||
LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface);
|
||||
auto SURF = CWLSurfaceResource::fromResource(surface);
|
||||
|
||||
|
|
@ -94,16 +94,16 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res
|
|||
}
|
||||
|
||||
const auto RESOURCE =
|
||||
PROTO::xxColorManagement->m_vSurfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF));
|
||||
PROTO::xxColorManagement->m_surfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF));
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vSurfaces.pop_back();
|
||||
PROTO::xxColorManagement->m_surfaces.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) {
|
||||
m_resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) {
|
||||
LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface);
|
||||
auto SURF = CWLSurfaceResource::fromResource(surface);
|
||||
|
||||
|
|
@ -113,118 +113,118 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res
|
|||
return;
|
||||
}
|
||||
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_vFeedbackSurfaces.emplace_back(
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_feedbackSurfaces.emplace_back(
|
||||
makeShared<CXXColorManagementFeedbackSurface>(makeShared<CXxColorManagementFeedbackSurfaceV4>(r->client(), r->version(), id), SURF));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vFeedbackSurfaces.pop_back();
|
||||
PROTO::xxColorManagement->m_feedbackSurfaces.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) {
|
||||
m_resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) {
|
||||
LOGM(WARN, "New ICC creator for id={} (unsupported)", id);
|
||||
r->error(XX_COLOR_MANAGER_V4_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
|
||||
});
|
||||
resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) {
|
||||
m_resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) {
|
||||
LOGM(TRACE, "New parametric creator for id={}", id);
|
||||
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_vParametricCreators.emplace_back(
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_parametricCreators.emplace_back(
|
||||
makeShared<CXXColorManagementParametricCreator>(makeShared<CXxImageDescriptionCreatorParamsV4>(r->client(), r->version(), id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vParametricCreators.pop_back();
|
||||
PROTO::xxColorManagement->m_parametricCreators.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
|
||||
resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
}
|
||||
|
||||
bool CXXColorManager::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : resource(resource_) {
|
||||
CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
pClient = resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
m_resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
|
||||
resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) {
|
||||
m_resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) {
|
||||
LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id);
|
||||
if (imageDescription.valid())
|
||||
PROTO::xxColorManagement->destroyResource(imageDescription.get());
|
||||
if (m_imageDescription.valid())
|
||||
PROTO::xxColorManagement->destroyResource(m_imageDescription.get());
|
||||
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back(
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back(
|
||||
makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vImageDescriptions.pop_back();
|
||||
PROTO::xxColorManagement->m_imageDescriptions.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
});
|
||||
}
|
||||
|
||||
bool CXXColorManagementOutput::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CXXColorManagementOutput::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : surface(surface_) {
|
||||
CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : m_surface(surface_) {
|
||||
// only for frog cm untill wayland cm is adopted
|
||||
}
|
||||
|
||||
CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) {
|
||||
CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
pClient = resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
if (!surface->m_colorManagement.valid()) {
|
||||
if (!m_surface->m_colorManagement.valid()) {
|
||||
const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(surface_));
|
||||
if UNLIKELY (!RESOURCE) {
|
||||
resource->noMemory();
|
||||
m_resource->noMemory();
|
||||
PROTO::colorManagement->m_surfaces.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
|
||||
surface->m_colorManagement = RESOURCE;
|
||||
m_surface->m_colorManagement = RESOURCE;
|
||||
|
||||
resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface);
|
||||
if (surface.valid())
|
||||
PROTO::colorManagement->destroyResource(surface->m_colorManagement.get());
|
||||
m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)m_surface);
|
||||
if (m_surface.valid())
|
||||
PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get());
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
} else
|
||||
resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface);
|
||||
m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface);
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
|
||||
resource->setDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface);
|
||||
m_resource->setDestroy([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface);
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
|
||||
resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) {
|
||||
m_resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) {
|
||||
LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent);
|
||||
|
||||
const auto PO = (CXxImageDescriptionV4*)wl_resource_get_user_data(image_description);
|
||||
|
|
@ -237,35 +237,35 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
|
|||
return;
|
||||
}
|
||||
|
||||
const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_vImageDescriptions.begin(), PROTO::xxColorManagement->m_vImageDescriptions.end(),
|
||||
const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_imageDescriptions.begin(), PROTO::xxColorManagement->m_imageDescriptions.end(),
|
||||
[&](const auto& other) { return other->resource()->resource() == image_description; });
|
||||
if (imageDescription == PROTO::xxColorManagement->m_vImageDescriptions.end()) {
|
||||
if (imageDescription == PROTO::xxColorManagement->m_imageDescriptions.end()) {
|
||||
r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (surface.valid()) {
|
||||
surface->m_colorManagement->m_imageDescription = imageDescription->get()->settings;
|
||||
surface->m_colorManagement->setHasImageDescription(true);
|
||||
if (m_surface.valid()) {
|
||||
m_surface->m_colorManagement->m_imageDescription = imageDescription->get()->m_settings;
|
||||
m_surface->m_colorManagement->setHasImageDescription(true);
|
||||
} else
|
||||
LOGM(ERR, "Set image description for invalid surface");
|
||||
});
|
||||
resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) {
|
||||
m_resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) {
|
||||
LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r);
|
||||
if (surface.valid()) {
|
||||
surface->m_colorManagement->m_imageDescription = SImageDescription{};
|
||||
surface->m_colorManagement->setHasImageDescription(false);
|
||||
if (m_surface.valid()) {
|
||||
m_surface->m_colorManagement->m_imageDescription = SImageDescription{};
|
||||
m_surface->m_colorManagement->setHasImageDescription(false);
|
||||
} else
|
||||
LOGM(ERR, "Unset image description for invalid surface");
|
||||
});
|
||||
}
|
||||
|
||||
bool CXXColorManagementSurface::good() {
|
||||
return resource && resource->resource();
|
||||
return m_resource && m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CXXColorManagementSurface::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
const SImageDescription& CXXColorManagementSurface::imageDescription() {
|
||||
|
|
@ -297,104 +297,104 @@ bool CXXColorManagementSurface::needsHdrMetadataUpdate() {
|
|||
}
|
||||
|
||||
CXXColorManagementFeedbackSurface::CXXColorManagementFeedbackSurface(SP<CXxColorManagementFeedbackSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) :
|
||||
surface(surface_), resource(resource_) {
|
||||
m_surface(surface_), m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
pClient = resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface);
|
||||
m_resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface);
|
||||
if (m_currentPreferred.valid())
|
||||
PROTO::xxColorManagement->destroyResource(m_currentPreferred.get());
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface);
|
||||
m_resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) {
|
||||
LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface);
|
||||
if (m_currentPreferred.valid())
|
||||
PROTO::xxColorManagement->destroyResource(m_currentPreferred.get());
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
|
||||
resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) {
|
||||
m_resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) {
|
||||
LOGM(TRACE, "Get preferred for id {}", id);
|
||||
|
||||
if (m_currentPreferred.valid())
|
||||
PROTO::xxColorManagement->destroyResource(m_currentPreferred.get());
|
||||
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back(
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back(
|
||||
makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vImageDescriptions.pop_back();
|
||||
PROTO::xxColorManagement->m_imageDescriptions.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
m_currentPreferred = RESOURCE;
|
||||
|
||||
m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription();
|
||||
m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription();
|
||||
|
||||
RESOURCE->resource()->sendReady(id);
|
||||
});
|
||||
}
|
||||
|
||||
bool CXXColorManagementFeedbackSurface::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CXXColorManagementFeedbackSurface::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : resource(resource_) {
|
||||
CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : m_resource(resource_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
//
|
||||
pClient = resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
|
||||
resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) {
|
||||
m_resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) {
|
||||
LOGM(TRACE, "Create image description from params for id {}", id);
|
||||
|
||||
// FIXME actually check completeness
|
||||
if (!valuesSet) {
|
||||
if (!m_valuesSet) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCOMPLETE_SET, "Missing required settings");
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME actually check consistency
|
||||
if (!valuesSet) {
|
||||
if (!m_valuesSet) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCONSISTENT_SET, "Set is not consistent");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back(
|
||||
const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back(
|
||||
makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), false));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
r->noMemory();
|
||||
PROTO::xxColorManagement->m_vImageDescriptions.pop_back();
|
||||
PROTO::xxColorManagement->m_imageDescriptions.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME actually check support
|
||||
if (!valuesSet) {
|
||||
if (!m_valuesSet) {
|
||||
RESOURCE->resource()->sendFailed(XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, "unsupported");
|
||||
return;
|
||||
}
|
||||
|
||||
RESOURCE->self = RESOURCE;
|
||||
RESOURCE->settings = settings;
|
||||
RESOURCE->m_self = RESOURCE;
|
||||
RESOURCE->m_settings = m_settings;
|
||||
RESOURCE->resource()->sendReady(id);
|
||||
|
||||
PROTO::xxColorManagement->destroyResource(this);
|
||||
});
|
||||
resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) {
|
||||
m_resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) {
|
||||
LOGM(TRACE, "Set image description transfer function to {}", tf);
|
||||
if (valuesSet & PC_TF) {
|
||||
if (m_valuesSet & PC_TF) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function already set");
|
||||
return;
|
||||
}
|
||||
|
|
@ -409,21 +409,21 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
|
|||
default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return;
|
||||
}
|
||||
|
||||
settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf));
|
||||
valuesSet |= PC_TF;
|
||||
m_settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf));
|
||||
m_valuesSet |= PC_TF;
|
||||
});
|
||||
resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) {
|
||||
m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) {
|
||||
LOGM(TRACE, "Set image description tf power to {}", eexp);
|
||||
if (valuesSet & PC_TF_POWER) {
|
||||
if (m_valuesSet & PC_TF_POWER) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function power already set");
|
||||
return;
|
||||
}
|
||||
settings.transferFunctionPower = eexp / 10000.0f;
|
||||
valuesSet |= PC_TF_POWER;
|
||||
m_settings.transferFunctionPower = eexp / 10000.0f;
|
||||
m_valuesSet |= PC_TF_POWER;
|
||||
});
|
||||
resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) {
|
||||
m_resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) {
|
||||
LOGM(TRACE, "Set image description primaries by name {}", primaries);
|
||||
if (valuesSet & PC_PRIMARIES) {
|
||||
if (m_valuesSet & PC_PRIMARIES) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set");
|
||||
return;
|
||||
}
|
||||
|
|
@ -438,29 +438,29 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
|
|||
case XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3:
|
||||
case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3:
|
||||
case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB:
|
||||
settings.primariesNameSet = true;
|
||||
settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries));
|
||||
settings.primaries = getPrimaries(settings.primariesNamed);
|
||||
valuesSet |= PC_PRIMARIES;
|
||||
m_settings.primariesNameSet = true;
|
||||
m_settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries));
|
||||
m_settings.primaries = getPrimaries(m_settings.primariesNamed);
|
||||
m_valuesSet |= PC_PRIMARIES;
|
||||
break;
|
||||
default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES, "Unsupported primaries");
|
||||
}
|
||||
});
|
||||
resource->setSetPrimaries(
|
||||
m_resource->setSetPrimaries(
|
||||
[this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
|
||||
LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
if (valuesSet & PC_PRIMARIES) {
|
||||
if (m_valuesSet & PC_PRIMARIES) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set");
|
||||
return;
|
||||
}
|
||||
settings.primariesNameSet = false;
|
||||
settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}};
|
||||
valuesSet |= PC_PRIMARIES;
|
||||
m_settings.primariesNameSet = false;
|
||||
m_settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}};
|
||||
m_valuesSet |= PC_PRIMARIES;
|
||||
});
|
||||
resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) {
|
||||
m_resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) {
|
||||
auto min = min_lum / 10000.0f;
|
||||
LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum);
|
||||
if (valuesSet & PC_LUMINANCES) {
|
||||
if (m_valuesSet & PC_LUMINANCES) {
|
||||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Luminances already set");
|
||||
return;
|
||||
}
|
||||
|
|
@ -468,20 +468,20 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
|
|||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances");
|
||||
return;
|
||||
}
|
||||
settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum};
|
||||
valuesSet |= PC_LUMINANCES;
|
||||
m_settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum};
|
||||
m_valuesSet |= PC_LUMINANCES;
|
||||
});
|
||||
resource->setSetMasteringDisplayPrimaries(
|
||||
m_resource->setSetMasteringDisplayPrimaries(
|
||||
[this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) {
|
||||
LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y);
|
||||
// if (valuesSet & PC_MASTERING_PRIMARIES) {
|
||||
// r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Mastering primaries already set");
|
||||
// return;
|
||||
// }
|
||||
settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}};
|
||||
valuesSet |= PC_MASTERING_PRIMARIES;
|
||||
m_settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}};
|
||||
m_valuesSet |= PC_MASTERING_PRIMARIES;
|
||||
});
|
||||
resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) {
|
||||
m_resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) {
|
||||
auto min = min_lum / 10000.0f;
|
||||
LOGM(TRACE, "Set image description mastering luminances to {} - {}", min, max_lum);
|
||||
// if (valuesSet & PC_MASTERING_LUMINANCES) {
|
||||
|
|
@ -492,35 +492,35 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
|
|||
r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances");
|
||||
return;
|
||||
}
|
||||
settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum};
|
||||
valuesSet |= PC_MASTERING_LUMINANCES;
|
||||
m_settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum};
|
||||
m_valuesSet |= PC_MASTERING_LUMINANCES;
|
||||
});
|
||||
resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) {
|
||||
m_resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) {
|
||||
LOGM(TRACE, "Set image description max content light level to {}", max_cll);
|
||||
// if (valuesSet & PC_CLL) {
|
||||
// r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max CLL already set");
|
||||
// return;
|
||||
// }
|
||||
settings.maxCLL = max_cll;
|
||||
valuesSet |= PC_CLL;
|
||||
m_settings.maxCLL = max_cll;
|
||||
m_valuesSet |= PC_CLL;
|
||||
});
|
||||
resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) {
|
||||
m_resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) {
|
||||
LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall);
|
||||
// if (valuesSet & PC_FALL) {
|
||||
// r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max FALL already set");
|
||||
// return;
|
||||
// }
|
||||
settings.maxFALL = max_fall;
|
||||
valuesSet |= PC_FALL;
|
||||
m_settings.maxFALL = max_fall;
|
||||
m_valuesSet |= PC_FALL;
|
||||
});
|
||||
}
|
||||
|
||||
bool CXXColorManagementParametricCreator::good() {
|
||||
return resource->resource();
|
||||
return m_resource->resource();
|
||||
}
|
||||
|
||||
wl_client* CXXColorManagementParametricCreator::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxImageDescriptionV4> resource_, bool allowGetInformation) :
|
||||
|
|
@ -528,7 +528,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma
|
|||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
pClient = m_resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
m_resource->setDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
m_resource->setOnDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); });
|
||||
|
|
@ -540,7 +540,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma
|
|||
return;
|
||||
}
|
||||
|
||||
auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), settings);
|
||||
auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), m_settings);
|
||||
|
||||
if UNLIKELY (!RESOURCE->good())
|
||||
r->noMemory();
|
||||
|
|
@ -555,7 +555,7 @@ bool CXXColorManagementImageDescription::good() {
|
|||
}
|
||||
|
||||
wl_client* CXXColorManagementImageDescription::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() {
|
||||
|
|
@ -563,33 +563,34 @@ SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() {
|
|||
}
|
||||
|
||||
CXXColorManagementImageDescriptionInfo::CXXColorManagementImageDescriptionInfo(SP<CXxImageDescriptionInfoV4> resource_, const SImageDescription& settings_) :
|
||||
m_resource(resource_), settings(settings_) {
|
||||
m_resource(resource_), m_settings(settings_) {
|
||||
if UNLIKELY (!good())
|
||||
return;
|
||||
|
||||
pClient = m_resource->client();
|
||||
m_client = m_resource->client();
|
||||
|
||||
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); };
|
||||
|
||||
if (settings.icc.fd >= 0)
|
||||
m_resource->sendIccFile(settings.icc.fd, settings.icc.length);
|
||||
if (m_settings.icc.fd >= 0)
|
||||
m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);
|
||||
|
||||
// send preferred client paramateres
|
||||
m_resource->sendPrimaries(toProto(settings.primaries.red.x), toProto(settings.primaries.red.y), toProto(settings.primaries.green.x), toProto(settings.primaries.green.y),
|
||||
toProto(settings.primaries.blue.x), toProto(settings.primaries.blue.y), toProto(settings.primaries.white.x), toProto(settings.primaries.white.y));
|
||||
if (settings.primariesNameSet)
|
||||
m_resource->sendPrimariesNamed(settings.primariesNamed);
|
||||
m_resource->sendTfPower(std::round(settings.transferFunctionPower * 10000));
|
||||
m_resource->sendTfNamed(settings.transferFunction);
|
||||
m_resource->sendLuminances(std::round(settings.luminances.min * 10000), settings.luminances.max, settings.luminances.reference);
|
||||
m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x),
|
||||
toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y),
|
||||
toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y));
|
||||
if (m_settings.primariesNameSet)
|
||||
m_resource->sendPrimariesNamed(m_settings.primariesNamed);
|
||||
m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));
|
||||
m_resource->sendTfNamed(m_settings.transferFunction);
|
||||
m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference);
|
||||
|
||||
// send expexted display paramateres
|
||||
m_resource->sendTargetPrimaries(toProto(settings.masteringPrimaries.red.x), toProto(settings.masteringPrimaries.red.y), toProto(settings.masteringPrimaries.green.x),
|
||||
toProto(settings.masteringPrimaries.green.y), toProto(settings.masteringPrimaries.blue.x), toProto(settings.masteringPrimaries.blue.y),
|
||||
toProto(settings.masteringPrimaries.white.x), toProto(settings.masteringPrimaries.white.y));
|
||||
m_resource->sendTargetLuminance(std::round(settings.masteringLuminances.min * 10000), settings.masteringLuminances.max);
|
||||
m_resource->sendTargetMaxCll(settings.maxCLL);
|
||||
m_resource->sendTargetMaxFall(settings.maxFALL);
|
||||
m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x),
|
||||
toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y),
|
||||
toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y));
|
||||
m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max);
|
||||
m_resource->sendTargetMaxCll(m_settings.maxCLL);
|
||||
m_resource->sendTargetMaxFall(m_settings.maxFALL);
|
||||
|
||||
m_resource->sendDone();
|
||||
}
|
||||
|
|
@ -599,7 +600,7 @@ bool CXXColorManagementImageDescriptionInfo::good() {
|
|||
}
|
||||
|
||||
wl_client* CXXColorManagementImageDescriptionInfo::client() {
|
||||
return pClient;
|
||||
return m_client;
|
||||
}
|
||||
|
||||
CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
|
@ -607,11 +608,11 @@ CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface
|
|||
}
|
||||
|
||||
void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id)));
|
||||
const auto RESOURCE = m_managers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id)));
|
||||
|
||||
if UNLIKELY (!RESOURCE->good()) {
|
||||
wl_client_post_no_memory(client);
|
||||
m_vManagers.pop_back();
|
||||
m_managers.pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -619,31 +620,31 @@ void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint
|
|||
}
|
||||
|
||||
void CXXColorManagementProtocol::onImagePreferredChanged() {
|
||||
for (auto const& feedback : m_vFeedbackSurfaces) {
|
||||
feedback->resource->sendPreferredChanged();
|
||||
for (auto const& feedback : m_feedbackSurfaces) {
|
||||
feedback->m_resource->sendPreferredChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManager* resource) {
|
||||
std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManagementOutput* resource) {
|
||||
std::erase_if(m_vOutputs, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_outputs, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManagementSurface* resource) {
|
||||
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManagementFeedbackSurface* resource) {
|
||||
std::erase_if(m_vFeedbackSurfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_feedbackSurfaces, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManagementParametricCreator* resource) {
|
||||
std::erase_if(m_vParametricCreators, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_parametricCreators, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
||||
void CXXColorManagementProtocol::destroyResource(CXXColorManagementImageDescription* resource) {
|
||||
std::erase_if(m_vImageDescriptions, [&](const auto& other) { return other.get() == resource; });
|
||||
std::erase_if(m_imageDescriptions, [&](const auto& other) { return other.get() == resource; });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class CXXColorManager {
|
|||
bool good();
|
||||
|
||||
private:
|
||||
SP<CXxColorManagerV4> resource;
|
||||
SP<CXxColorManagerV4> m_resource;
|
||||
};
|
||||
|
||||
class CXXColorManagementOutput {
|
||||
|
|
@ -30,12 +30,12 @@ class CXXColorManagementOutput {
|
|||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
WP<CXXColorManagementOutput> self;
|
||||
WP<CXXColorManagementImageDescription> imageDescription;
|
||||
WP<CXXColorManagementOutput> m_self;
|
||||
WP<CXXColorManagementImageDescription> m_imageDescription;
|
||||
|
||||
private:
|
||||
SP<CXxColorManagementOutputV4> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SP<CXxColorManagementOutputV4> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
|
||||
friend class CXXColorManagementProtocol;
|
||||
friend class CXXColorManagementImageDescription;
|
||||
|
|
@ -49,8 +49,8 @@ class CXXColorManagementSurface {
|
|||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
WP<CXXColorManagementSurface> self;
|
||||
WP<CWLSurfaceResource> surface;
|
||||
WP<CXXColorManagementSurface> m_self;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
|
||||
const NColorManagement::SImageDescription& imageDescription();
|
||||
bool hasImageDescription();
|
||||
|
|
@ -60,8 +60,8 @@ class CXXColorManagementSurface {
|
|||
bool needsHdrMetadataUpdate();
|
||||
|
||||
private:
|
||||
SP<CXxColorManagementSurfaceV4> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SP<CXxColorManagementSurfaceV4> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
NColorManagement::SImageDescription m_imageDescription;
|
||||
bool m_hasImageDescription = false;
|
||||
bool m_needsNewMetadata = false;
|
||||
|
|
@ -77,12 +77,12 @@ class CXXColorManagementFeedbackSurface {
|
|||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
WP<CXXColorManagementFeedbackSurface> self;
|
||||
WP<CWLSurfaceResource> surface;
|
||||
WP<CXXColorManagementFeedbackSurface> m_self;
|
||||
WP<CWLSurfaceResource> m_surface;
|
||||
|
||||
private:
|
||||
SP<CXxColorManagementFeedbackSurfaceV4> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
SP<CXxColorManagementFeedbackSurfaceV4> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
|
||||
WP<CXXColorManagementImageDescription> m_currentPreferred;
|
||||
|
||||
|
|
@ -96,9 +96,9 @@ class CXXColorManagementParametricCreator {
|
|||
bool good();
|
||||
wl_client* client();
|
||||
|
||||
WP<CXXColorManagementParametricCreator> self;
|
||||
WP<CXXColorManagementParametricCreator> m_self;
|
||||
|
||||
NColorManagement::SImageDescription settings;
|
||||
NColorManagement::SImageDescription m_settings;
|
||||
|
||||
private:
|
||||
enum eValuesSet : uint32_t { // NOLINT
|
||||
|
|
@ -112,9 +112,9 @@ class CXXColorManagementParametricCreator {
|
|||
PC_FALL = (1 << 7),
|
||||
};
|
||||
|
||||
SP<CXxImageDescriptionCreatorParamsV4> resource;
|
||||
wl_client* pClient = nullptr;
|
||||
uint32_t valuesSet = 0; // enum eValuesSet
|
||||
SP<CXxImageDescriptionCreatorParamsV4> m_resource;
|
||||
wl_client* m_client = nullptr;
|
||||
uint32_t m_valuesSet = 0; // enum eValuesSet
|
||||
};
|
||||
|
||||
class CXXColorManagementImageDescription {
|
||||
|
|
@ -125,13 +125,13 @@ class CXXColorManagementImageDescription {
|
|||
wl_client* client();
|
||||
SP<CXxImageDescriptionV4> resource();
|
||||
|
||||
WP<CXXColorManagementImageDescription> self;
|
||||
WP<CXXColorManagementImageDescription> m_self;
|
||||
|
||||
NColorManagement::SImageDescription settings;
|
||||
NColorManagement::SImageDescription m_settings;
|
||||
|
||||
private:
|
||||
SP<CXxImageDescriptionV4> m_resource;
|
||||
wl_client* pClient = nullptr;
|
||||
wl_client* m_client = nullptr;
|
||||
bool m_allowGetInformation = false;
|
||||
|
||||
friend class CXXColorManagementOutput;
|
||||
|
|
@ -146,8 +146,8 @@ class CXXColorManagementImageDescriptionInfo {
|
|||
|
||||
private:
|
||||
SP<CXxImageDescriptionInfoV4> m_resource;
|
||||
wl_client* pClient = nullptr;
|
||||
NColorManagement::SImageDescription settings;
|
||||
wl_client* m_client = nullptr;
|
||||
NColorManagement::SImageDescription m_settings;
|
||||
};
|
||||
|
||||
class CXXColorManagementProtocol : public IWaylandProtocol {
|
||||
|
|
@ -166,12 +166,12 @@ class CXXColorManagementProtocol : public IWaylandProtocol {
|
|||
void destroyResource(CXXColorManagementParametricCreator* resource);
|
||||
void destroyResource(CXXColorManagementImageDescription* resource);
|
||||
|
||||
std::vector<SP<CXXColorManager>> m_vManagers;
|
||||
std::vector<SP<CXXColorManagementOutput>> m_vOutputs;
|
||||
std::vector<SP<CXXColorManagementSurface>> m_vSurfaces;
|
||||
std::vector<SP<CXXColorManagementFeedbackSurface>> m_vFeedbackSurfaces;
|
||||
std::vector<SP<CXXColorManagementParametricCreator>> m_vParametricCreators;
|
||||
std::vector<SP<CXXColorManagementImageDescription>> m_vImageDescriptions;
|
||||
std::vector<SP<CXXColorManager>> m_managers;
|
||||
std::vector<SP<CXXColorManagementOutput>> m_outputs;
|
||||
std::vector<SP<CXXColorManagementSurface>> m_surfaces;
|
||||
std::vector<SP<CXXColorManagementFeedbackSurface>> m_feedbackSurfaces;
|
||||
std::vector<SP<CXXColorManagementParametricCreator>> m_parametricCreators;
|
||||
std::vector<SP<CXXColorManagementImageDescription>> m_imageDescriptions;
|
||||
|
||||
friend class CXXColorManager;
|
||||
friend class CXXColorManagementOutput;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue