protocols: refactor class member vars (u-z) (#10282)
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run

* protocols: refactor class member vars (u-z)

* protocols: fix clang format
This commit is contained in:
davc0n 2025-05-04 23:39:00 +02:00 committed by GitHub
parent 78ff20ddf0
commit 9cd5b25745
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 985 additions and 981 deletions

View file

@ -1050,7 +1050,7 @@ Vector2D CCompositor::vectorToSurfaceLocal(const Vector2D& vec, PHLWINDOW pWindo
},
&iterData);
CBox geom = pWindow->m_xdgSurface->current.geometry;
CBox geom = pWindow->m_xdgSurface->m_current.geometry;
if (std::get<1>(iterData) == Vector2D{-1337, -1337})
return vec - pWindow->m_realPosition->goal();
@ -1879,7 +1879,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(PHLWINDOW pWindow) {
*pWindow->m_borderFadeAnimationProgress = 1.f;
};
const bool IS_SHADOWED_BY_MODAL = pWindow->m_xdgSurface && pWindow->m_xdgSurface->toplevel && pWindow->m_xdgSurface->toplevel->anyChildModal();
const bool IS_SHADOWED_BY_MODAL = pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel && pWindow->m_xdgSurface->m_toplevel->anyChildModal();
// border
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);

View file

@ -36,9 +36,9 @@ UP<CPopup> CPopup::create(SP<CXDGPopupResource> resource, WP<CPopup> pOwner) {
popup->m_parent = pOwner;
popup->m_self = popup;
popup->m_wlSurface = CWLSurface::create();
popup->m_wlSurface->assign(resource->surface->surface.lock(), popup.get());
popup->m_wlSurface->assign(resource->m_surface->m_surface.lock(), popup.get());
popup->m_lastSize = resource->surface->current.geometry.size();
popup->m_lastSize = resource->m_surface->m_current.geometry.size();
popup->reposition();
popup->initAllSignals();
@ -54,7 +54,8 @@ void CPopup::initAllSignals() {
if (!m_resource) {
if (!m_windowOwner.expired())
m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
m_listeners.newPopup =
m_windowOwner->m_xdgSurface->m_events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else if (!m_layerOwner.expired())
m_listeners.newPopup =
m_layerOwner->m_layerSurface->m_events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
@ -64,13 +65,13 @@ void CPopup::initAllSignals() {
return;
}
m_listeners.reposition = m_resource->events.reposition.registerListener([this](std::any d) { this->onReposition(); });
m_listeners.map = m_resource->surface->events.map.registerListener([this](std::any d) { this->onMap(); });
m_listeners.unmap = m_resource->surface->events.unmap.registerListener([this](std::any d) { this->onUnmap(); });
m_listeners.dismissed = m_resource->events.dismissed.registerListener([this](std::any d) { this->onUnmap(); });
m_listeners.destroy = m_resource->surface->events.destroy.registerListener([this](std::any d) { this->onDestroy(); });
m_listeners.commit = m_resource->surface->events.commit.registerListener([this](std::any d) { this->onCommit(); });
m_listeners.newPopup = m_resource->surface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
m_listeners.reposition = m_resource->m_events.reposition.registerListener([this](std::any d) { this->onReposition(); });
m_listeners.map = m_resource->m_surface->m_events.map.registerListener([this](std::any d) { this->onMap(); });
m_listeners.unmap = m_resource->m_surface->m_events.unmap.registerListener([this](std::any d) { this->onUnmap(); });
m_listeners.dismissed = m_resource->m_events.dismissed.registerListener([this](std::any d) { this->onUnmap(); });
m_listeners.destroy = m_resource->m_surface->m_events.destroy.registerListener([this](std::any d) { this->onDestroy(); });
m_listeners.commit = m_resource->m_surface->m_events.commit.registerListener([this](std::any d) { this->onCommit(); });
m_listeners.newPopup = m_resource->m_surface->m_events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
}
void CPopup::onNewPopup(SP<CXDGPopupResource> popup) {
@ -93,7 +94,7 @@ void CPopup::onMap() {
return;
m_mapped = true;
m_lastSize = m_resource->surface->surface->m_current.size;
m_lastSize = m_resource->m_surface->m_surface->m_current.size;
const auto COORDS = coordsGlobal();
const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
@ -110,7 +111,7 @@ void CPopup::onMap() {
//unconstrain();
sendScale();
m_resource->surface->surface->enter(PMONITOR->m_self.lock());
m_resource->m_surface->m_surface->enter(PMONITOR->m_self.lock());
if (!m_layerOwner.expired() && m_layerOwner->m_layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_layerOwner->m_layer));
@ -120,7 +121,7 @@ void CPopup::onUnmap() {
if (!m_mapped)
return;
if (!m_resource || !m_resource->surface) {
if (!m_resource || !m_resource->m_surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and unmaps??");
onDestroy();
return;
@ -128,7 +129,7 @@ void CPopup::onUnmap() {
m_mapped = false;
m_lastSize = m_resource->surface->surface->m_current.size;
m_lastSize = m_resource->m_surface->m_surface->m_current.size;
const auto COORDS = coordsGlobal();
@ -160,19 +161,19 @@ void CPopup::onUnmap() {
}
void CPopup::onCommit(bool ignoreSiblings) {
if (!m_resource || !m_resource->surface) {
if (!m_resource || !m_resource->m_surface) {
Debug::log(ERR, "CPopup: orphaned (no surface/resource) and commits??");
onDestroy();
return;
}
if (m_resource->surface->initialCommit) {
m_resource->surface->scheduleConfigure();
if (m_resource->m_surface->m_initialCommit) {
m_resource->m_surface->scheduleConfigure();
return;
}
if (!m_windowOwner.expired() && (!m_windowOwner->m_isMapped || !m_windowOwner->m_workspace->m_visible)) {
m_lastSize = m_resource->surface->surface->m_current.size;
m_lastSize = m_resource->m_surface->m_surface->m_current.size;
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
if (*PLOGDAMAGE)
@ -180,16 +181,16 @@ void CPopup::onCommit(bool ignoreSiblings) {
return;
}
if (!m_resource->surface->mapped)
if (!m_resource->m_surface->m_mapped)
return;
const auto COORDS = coordsGlobal();
const auto COORDSLOCAL = coordsRelativeToParent();
if (m_lastSize != m_resource->surface->surface->m_current.size || m_requestedReposition || m_lastPos != COORDSLOCAL) {
if (m_lastSize != m_resource->m_surface->m_surface->m_current.size || m_requestedReposition || m_lastPos != COORDSLOCAL) {
CBox box = {localToGlobal(m_lastPos), m_lastSize};
g_pHyprRenderer->damageBox(box);
m_lastSize = m_resource->surface->surface->m_current.size;
m_lastSize = m_resource->m_surface->m_surface->m_current.size;
box = {COORDS, m_lastSize};
g_pHyprRenderer->damageBox(box);
@ -242,12 +243,12 @@ Vector2D CPopup::coordsRelativeToParent() {
return {};
WP<CPopup> current = m_self;
offset -= current->m_resource->surface->current.geometry.pos();
offset -= current->m_resource->m_surface->m_current.geometry.pos();
while (current->m_parent && current->m_resource) {
offset += current->m_wlSurface->resource()->m_current.offset;
offset += current->m_resource->geometry.pos();
offset += current->m_resource->m_geometry.pos();
current = current->m_parent;
}
@ -351,10 +352,10 @@ WP<CPopup> CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
continue;
if (!allowsInput) {
const bool HASSURFACE = p->m_resource && p->m_resource->surface;
const bool HASSURFACE = p->m_resource && p->m_resource->m_surface;
Vector2D offset = HASSURFACE ? p->m_resource->surface->current.geometry.pos() : Vector2D{};
Vector2D size = HASSURFACE ? p->m_resource->surface->current.geometry.size() : p->size();
Vector2D offset = HASSURFACE ? p->m_resource->m_surface->m_current.geometry.pos() : Vector2D{};
Vector2D size = HASSURFACE ? p->m_resource->m_surface->m_current.geometry.size() : p->size();
if (size == Vector2D{})
size = p->size();

View file

@ -62,8 +62,8 @@ PHLWINDOW CWindow::create(SP<CXWaylandSurface> surface) {
PHLWINDOW CWindow::create(SP<CXDGSurfaceResource> resource) {
PHLWINDOW pWindow = SP<CWindow>(new CWindow(resource));
pWindow->m_self = pWindow;
resource->toplevel->window = pWindow;
pWindow->m_self = pWindow;
resource->m_toplevel->m_window = pWindow;
g_pAnimationManager->createAnimation(Vector2D(0, 0), pWindow->m_realPosition, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), pWindow, AVARDAMAGE_ENTIRE);
g_pAnimationManager->createAnimation(Vector2D(0, 0), pWindow->m_realSize, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), pWindow, AVARDAMAGE_ENTIRE);
@ -80,7 +80,7 @@ PHLWINDOW CWindow::create(SP<CXDGSurfaceResource> resource) {
pWindow->addWindowDeco(makeUnique<CHyprDropShadowDecoration>(pWindow));
pWindow->addWindowDeco(makeUnique<CHyprBorderDecoration>(pWindow));
pWindow->m_wlSurface->assign(pWindow->m_xdgSurface->surface.lock(), pWindow);
pWindow->m_wlSurface->assign(pWindow->m_xdgSurface->m_surface.lock(), pWindow);
return pWindow;
}
@ -88,13 +88,13 @@ PHLWINDOW CWindow::create(SP<CXDGSurfaceResource> resource) {
CWindow::CWindow(SP<CXDGSurfaceResource> resource) : m_xdgSurface(resource) {
m_wlSurface = CWLSurface::create();
m_listeners.map = m_xdgSurface->events.map.registerListener([this](std::any d) { Events::listener_mapWindow(this, nullptr); });
m_listeners.ack = m_xdgSurface->events.ack.registerListener([this](std::any d) { onAck(std::any_cast<uint32_t>(d)); });
m_listeners.unmap = m_xdgSurface->events.unmap.registerListener([this](std::any d) { Events::listener_unmapWindow(this, nullptr); });
m_listeners.destroy = m_xdgSurface->events.destroy.registerListener([this](std::any d) { Events::listener_destroyWindow(this, nullptr); });
m_listeners.commit = m_xdgSurface->events.commit.registerListener([this](std::any d) { Events::listener_commitWindow(this, nullptr); });
m_listeners.updateState = m_xdgSurface->toplevel->events.stateChanged.registerListener([this](std::any d) { onUpdateState(); });
m_listeners.updateMetadata = m_xdgSurface->toplevel->events.metadataChanged.registerListener([this](std::any d) { onUpdateMeta(); });
m_listeners.map = m_xdgSurface->m_events.map.registerListener([this](std::any d) { Events::listener_mapWindow(this, nullptr); });
m_listeners.ack = m_xdgSurface->m_events.ack.registerListener([this](std::any d) { onAck(std::any_cast<uint32_t>(d)); });
m_listeners.unmap = m_xdgSurface->m_events.unmap.registerListener([this](std::any d) { Events::listener_unmapWindow(this, nullptr); });
m_listeners.destroy = m_xdgSurface->m_events.destroy.registerListener([this](std::any d) { Events::listener_destroyWindow(this, nullptr); });
m_listeners.commit = m_xdgSurface->m_events.commit.registerListener([this](std::any d) { Events::listener_commitWindow(this, nullptr); });
m_listeners.updateState = m_xdgSurface->m_toplevel->m_events.stateChanged.registerListener([this](std::any d) { onUpdateState(); });
m_listeners.updateMetadata = m_xdgSurface->m_toplevel->m_events.metadataChanged.registerListener([this](std::any d) { onUpdateMeta(); });
}
CWindow::CWindow(SP<CXWaylandSurface> surface) : m_xwaylandSurface(surface) {
@ -344,10 +344,10 @@ bool CWindow::checkInputOnDecos(const eInputType type, const Vector2D& mouseCoor
pid_t CWindow::getPID() {
pid_t PID = -1;
if (!m_isX11) {
if (!m_xdgSurface || !m_xdgSurface->owner /* happens at unmap */)
if (!m_xdgSurface || !m_xdgSurface->m_owner /* happens at unmap */)
return -1;
wl_client_get_credentials(m_xdgSurface->owner->client(), &PID, nullptr, nullptr);
wl_client_get_credentials(m_xdgSurface->m_owner->client(), &PID, nullptr, nullptr);
} else {
if (!m_xwaylandSurface)
return -1;
@ -1166,8 +1166,8 @@ bool CWindow::opaque() {
return false;
// TODO: this is wrong
const auto EXTENTS = m_xdgSurface->surface->m_current.opaque.getExtents();
if (EXTENTS.w >= m_xdgSurface->surface->m_current.bufferSize.x && EXTENTS.h >= m_xdgSurface->surface->m_current.bufferSize.y)
const auto EXTENTS = m_xdgSurface->m_surface->m_current.opaque.getExtents();
if (EXTENTS.w >= m_xdgSurface->m_surface->m_current.bufferSize.x && EXTENTS.h >= m_xdgSurface->m_surface->m_current.bufferSize.y)
return true;
return m_wlSurface->resource()->m_current.texture->m_bOpaque;
@ -1238,10 +1238,10 @@ void CWindow::setSuspended(bool suspend) {
if (suspend == m_suspended)
return;
if (m_isX11 || !m_xdgSurface || !m_xdgSurface->toplevel)
if (m_isX11 || !m_xdgSurface || !m_xdgSurface->m_toplevel)
return;
m_xdgSurface->toplevel->setSuspeneded(suspend);
m_xdgSurface->m_toplevel->setSuspeneded(suspend);
m_suspended = suspend;
}
@ -1418,9 +1418,9 @@ void CWindow::activate(bool force) {
}
void CWindow::onUpdateState() {
std::optional<bool> requestsFS = m_xdgSurface ? m_xdgSurface->toplevel->state.requestsFullscreen : m_xwaylandSurface->state.requestsFullscreen;
std::optional<MONITORID> requestsID = m_xdgSurface ? m_xdgSurface->toplevel->state.requestsFullscreenMonitor : MONITOR_INVALID;
std::optional<bool> requestsMX = m_xdgSurface ? m_xdgSurface->toplevel->state.requestsMaximize : m_xwaylandSurface->state.requestsMaximize;
std::optional<bool> requestsFS = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsFullscreen : m_xwaylandSurface->state.requestsFullscreen;
std::optional<MONITORID> requestsID = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsFullscreenMonitor : MONITOR_INVALID;
std::optional<bool> requestsMX = m_xdgSurface ? m_xdgSurface->m_toplevel->m_state.requestsMaximize : m_xwaylandSurface->state.requestsMaximize;
if (requestsFS.has_value() && !(m_suppressedEvents & SUPPRESS_FULLSCREEN)) {
if (requestsID.has_value() && (requestsID.value() != MONITOR_INVALID) && !(m_suppressedEvents & SUPPRESS_FULLSCREEN_OUTPUT)) {
@ -1491,8 +1491,8 @@ void CWindow::onUpdateMeta() {
std::string CWindow::fetchTitle() {
if (!m_isX11) {
if (m_xdgSurface && m_xdgSurface->toplevel)
return m_xdgSurface->toplevel->state.title;
if (m_xdgSurface && m_xdgSurface->m_toplevel)
return m_xdgSurface->m_toplevel->m_state.title;
} else {
if (m_xwaylandSurface)
return m_xwaylandSurface->state.title;
@ -1503,8 +1503,8 @@ std::string CWindow::fetchTitle() {
std::string CWindow::fetchClass() {
if (!m_isX11) {
if (m_xdgSurface && m_xdgSurface->toplevel)
return m_xdgSurface->toplevel->state.appid;
if (m_xdgSurface && m_xdgSurface->m_toplevel)
return m_xdgSurface->m_toplevel->m_state.appid;
} else {
if (m_xwaylandSurface)
return m_xwaylandSurface->state.appid;
@ -1676,10 +1676,10 @@ bool CWindow::isModal() {
}
Vector2D CWindow::requestedMinSize() {
if ((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && !m_xdgSurface->toplevel))
if ((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && !m_xdgSurface->m_toplevel))
return Vector2D(1, 1);
Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->min_width, m_xwaylandSurface->sizeHints->min_height) : m_xdgSurface->toplevel->layoutMinSize();
Vector2D minSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->min_width, m_xwaylandSurface->sizeHints->min_height) : m_xdgSurface->m_toplevel->layoutMinSize();
minSize = minSize.clamp({1, 1});
@ -1688,10 +1688,10 @@ Vector2D CWindow::requestedMinSize() {
Vector2D CWindow::requestedMaxSize() {
constexpr int NO_MAX_SIZE_LIMIT = 99999;
if (((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->toplevel)) || m_windowData.noMaxSize.valueOrDefault()))
if (((m_isX11 && !m_xwaylandSurface->sizeHints) || (!m_isX11 && (!m_xdgSurface || !m_xdgSurface->m_toplevel)) || m_windowData.noMaxSize.valueOrDefault()))
return Vector2D(NO_MAX_SIZE_LIMIT, NO_MAX_SIZE_LIMIT);
Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->max_width, m_xwaylandSurface->sizeHints->max_height) : m_xdgSurface->toplevel->layoutMaxSize();
Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->sizeHints->max_width, m_xwaylandSurface->sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize();
if (maxSize.x < 5)
maxSize.x = NO_MAX_SIZE_LIMIT;
@ -1767,8 +1767,8 @@ void CWindow::sendWindowSize(bool force) {
if (m_isX11 && m_xwaylandSurface)
m_xwaylandSurface->configure({REPORTPOS, REPORTSIZE});
else if (m_xdgSurface && m_xdgSurface->toplevel)
m_pendingSizeAcks.emplace_back(m_xdgSurface->toplevel->setSize(REPORTSIZE), REPORTPOS.floor());
else if (m_xdgSurface && m_xdgSurface->m_toplevel)
m_pendingSizeAcks.emplace_back(m_xdgSurface->m_toplevel->setSize(REPORTSIZE), REPORTPOS.floor());
}
NContentType::eContentType CWindow::getContentType() {
@ -1795,8 +1795,8 @@ void CWindow::deactivateGroupMembers() {
// because X is weird, keep the behavior for wayland windows
// also its not really needed for xwayland windows
// ref: #9760 #9294
if (!curr->m_isX11 && curr->m_xdgSurface && curr->m_xdgSurface->toplevel)
curr->m_xdgSurface->toplevel->setActive(false);
if (!curr->m_isX11 && curr->m_xdgSurface && curr->m_xdgSurface->m_toplevel)
curr->m_xdgSurface->m_toplevel->setActive(false);
}
curr = curr->m_groupData.pNextWindow.lock();
@ -1810,15 +1810,15 @@ bool CWindow::isNotResponding() {
}
std::optional<std::string> CWindow::xdgTag() {
if (!m_xdgSurface || !m_xdgSurface->toplevel)
if (!m_xdgSurface || !m_xdgSurface->m_toplevel)
return std::nullopt;
return m_xdgSurface->toplevel->m_toplevelTag;
return m_xdgSurface->m_toplevel->m_toplevelTag;
}
std::optional<std::string> CWindow::xdgDescription() {
if (!m_xdgSurface || !m_xdgSurface->toplevel)
if (!m_xdgSurface || !m_xdgSurface->m_toplevel)
return std::nullopt;
return m_xdgSurface->toplevel->m_toplevelDescription;
return m_xdgSurface->m_toplevel->m_toplevelDescription;
}

View file

@ -14,13 +14,13 @@ CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : m_key
if (!keeb_)
return;
m_listeners.destroy = keeb_->events.destroy.registerListener([this](std::any d) {
m_listeners.destroy = keeb_->m_events.destroy.registerListener([this](std::any d) {
m_keyboard.reset();
m_events.destroy.emit();
});
m_listeners.key = keeb_->events.key.registerListener([this](std::any d) { m_keyboardEvents.key.emit(d); });
m_listeners.modifiers = keeb_->events.modifiers.registerListener([this](std::any d) {
m_listeners.key = keeb_->m_events.key.registerListener([this](std::any d) { m_keyboardEvents.key.emit(d); });
m_listeners.modifiers = keeb_->m_events.modifiers.registerListener([this](std::any d) {
auto E = std::any_cast<SModifiersEvent>(d);
updateModifiers(E.depressed, E.latched, E.locked, E.group);
m_keyboardEvents.modifiers.emit(SModifiersEvent{
@ -30,7 +30,7 @@ CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : m_key
.group = m_modifiersState.group,
});
});
m_listeners.keymap = keeb_->events.keymap.registerListener([this](std::any d) {
m_listeners.keymap = keeb_->m_events.keymap.registerListener([this](std::any d) {
auto E = std::any_cast<SKeymapEvent>(d);
if (m_xkbKeymap)
xkb_keymap_unref(m_xkbKeymap);
@ -41,7 +41,7 @@ CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : m_key
m_keyboardEvents.keymap.emit(d);
});
m_deviceName = keeb_->name;
m_deviceName = keeb_->m_name;
}
bool CVirtualKeyboard::isVirtual() {

View file

@ -14,37 +14,37 @@ CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : m_poi
if UNLIKELY (!resource->good())
return;
m_listeners.destroy = m_pointer->events.destroy.registerListener([this](std::any d) {
m_listeners.destroy = m_pointer->m_events.destroy.registerListener([this](std::any d) {
m_pointer.reset();
m_events.destroy.emit();
});
m_listeners.motion = m_pointer->events.move.registerListener([this](std::any d) {
m_listeners.motion = m_pointer->m_events.move.registerListener([this](std::any d) {
auto E = std::any_cast<SMotionEvent>(d);
E.device = m_self.lock();
m_pointerEvents.motion.emit(E);
});
m_listeners.motionAbsolute = m_pointer->events.warp.registerListener([this](std::any d) {
m_listeners.motionAbsolute = m_pointer->m_events.warp.registerListener([this](std::any d) {
// we need to unpack the event and add our device here because it's required to calculate the position correctly
auto E = std::any_cast<SMotionAbsoluteEvent>(d);
E.device = m_self.lock();
m_pointerEvents.motionAbsolute.emit(E);
});
m_listeners.button = m_pointer->events.button.registerListener([this](std::any d) { m_pointerEvents.button.emit(d); });
m_listeners.axis = m_pointer->events.axis.registerListener([this](std::any d) { m_pointerEvents.axis.emit(d); });
m_listeners.frame = m_pointer->events.frame.registerListener([this](std::any d) { m_pointerEvents.frame.emit(); });
m_listeners.swipeBegin = m_pointer->events.swipeBegin.registerListener([this](std::any d) { m_pointerEvents.swipeBegin.emit(d); });
m_listeners.swipeEnd = m_pointer->events.swipeEnd.registerListener([this](std::any d) { m_pointerEvents.swipeEnd.emit(d); });
m_listeners.swipeUpdate = m_pointer->events.swipeUpdate.registerListener([this](std::any d) { m_pointerEvents.swipeUpdate.emit(d); });
m_listeners.pinchBegin = m_pointer->events.pinchBegin.registerListener([this](std::any d) { m_pointerEvents.pinchBegin.emit(d); });
m_listeners.pinchEnd = m_pointer->events.pinchEnd.registerListener([this](std::any d) { m_pointerEvents.pinchEnd.emit(d); });
m_listeners.pinchUpdate = m_pointer->events.pinchUpdate.registerListener([this](std::any d) { m_pointerEvents.pinchUpdate.emit(d); });
m_listeners.holdBegin = m_pointer->events.holdBegin.registerListener([this](std::any d) { m_pointerEvents.holdBegin.emit(d); });
m_listeners.holdEnd = m_pointer->events.holdEnd.registerListener([this](std::any d) { m_pointerEvents.holdEnd.emit(d); });
m_listeners.button = m_pointer->m_events.button.registerListener([this](std::any d) { m_pointerEvents.button.emit(d); });
m_listeners.axis = m_pointer->m_events.axis.registerListener([this](std::any d) { m_pointerEvents.axis.emit(d); });
m_listeners.frame = m_pointer->m_events.frame.registerListener([this](std::any d) { m_pointerEvents.frame.emit(); });
m_listeners.swipeBegin = m_pointer->m_events.swipeBegin.registerListener([this](std::any d) { m_pointerEvents.swipeBegin.emit(d); });
m_listeners.swipeEnd = m_pointer->m_events.swipeEnd.registerListener([this](std::any d) { m_pointerEvents.swipeEnd.emit(d); });
m_listeners.swipeUpdate = m_pointer->m_events.swipeUpdate.registerListener([this](std::any d) { m_pointerEvents.swipeUpdate.emit(d); });
m_listeners.pinchBegin = m_pointer->m_events.pinchBegin.registerListener([this](std::any d) { m_pointerEvents.pinchBegin.emit(d); });
m_listeners.pinchEnd = m_pointer->m_events.pinchEnd.registerListener([this](std::any d) { m_pointerEvents.pinchEnd.emit(d); });
m_listeners.pinchUpdate = m_pointer->m_events.pinchUpdate.registerListener([this](std::any d) { m_pointerEvents.pinchUpdate.emit(d); });
m_listeners.holdBegin = m_pointer->m_events.holdBegin.registerListener([this](std::any d) { m_pointerEvents.holdBegin.emit(d); });
m_listeners.holdEnd = m_pointer->m_events.holdEnd.registerListener([this](std::any d) { m_pointerEvents.holdEnd.emit(d); });
m_boundOutput = resource->boundOutput ? resource->boundOutput->m_name : "";
m_boundOutput = resource->m_boundOutput ? resource->m_boundOutput->m_name : "";
m_deviceName = m_pointer->name;
m_deviceName = m_pointer->m_name;
}
bool CVirtualPointer::isVirtual() {

View file

@ -852,12 +852,12 @@ void Events::listener_unmapWindow(void* owner, void* data) {
void Events::listener_commitWindow(void* owner, void* data) {
PHLWINDOW PWINDOW = ((CWindow*)owner)->m_self.lock();
if (!PWINDOW->m_isX11 && PWINDOW->m_xdgSurface->initialCommit) {
if (!PWINDOW->m_isX11 && PWINDOW->m_xdgSurface->m_initialCommit) {
Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow(PWINDOW);
Debug::log(LOG, "Layout predicts size {} for {}", predSize, PWINDOW);
PWINDOW->m_xdgSurface->toplevel->setSize(predSize);
PWINDOW->m_xdgSurface->m_toplevel->setSize(predSize);
return;
}
@ -867,8 +867,8 @@ void Events::listener_commitWindow(void* owner, void* data) {
PWINDOW->m_reportedSize = PWINDOW->m_pendingReportedSize; // apply pending size. We pinged, the window ponged.
if (!PWINDOW->m_isX11 && !PWINDOW->isFullscreen() && PWINDOW->m_isFloating) {
const auto MINSIZE = PWINDOW->m_xdgSurface->toplevel->layoutMinSize();
const auto MAXSIZE = PWINDOW->m_xdgSurface->toplevel->layoutMaxSize();
const auto MINSIZE = PWINDOW->m_xdgSurface->m_toplevel->layoutMinSize();
const auto MAXSIZE = PWINDOW->m_xdgSurface->m_toplevel->layoutMaxSize();
PWINDOW->clampWindowSize(MINSIZE, MAXSIZE > Vector2D{1, 1} ? std::optional<Vector2D>{MAXSIZE} : std::nullopt);
g_pHyprRenderer->damageWindow(PWINDOW);

View file

@ -161,9 +161,9 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
// TODO: detect a popup in a more consistent way.
if ((desiredGeometry.x == 0 && desiredGeometry.y == 0) || !visible || !pWindow->m_isX11) {
// if the pos isn't set, fall back to the center placement if it's not a child, otherwise middle of parent if available
if (!pWindow->m_isX11 && pWindow->m_xdgSurface->toplevel->parent && validMapped(pWindow->m_xdgSurface->toplevel->parent->window))
*pWindow->m_realPosition = pWindow->m_xdgSurface->toplevel->parent->window->m_realPosition->goal() +
pWindow->m_xdgSurface->toplevel->parent->window->m_realSize->goal() / 2.F - desiredGeometry.size() / 2.F;
if (!pWindow->m_isX11 && pWindow->m_xdgSurface->m_toplevel->m_parent && validMapped(pWindow->m_xdgSurface->m_toplevel->m_parent->m_window))
*pWindow->m_realPosition = pWindow->m_xdgSurface->m_toplevel->m_parent->m_window->m_realPosition->goal() +
pWindow->m_xdgSurface->m_toplevel->m_parent->m_window->m_realSize->goal() / 2.F - desiredGeometry.size() / 2.F;
else
*pWindow->m_realPosition = PMONITOR->m_position + PMONITOR->m_size / 2.F - desiredGeometry.size() / 2.F;
} else {
@ -933,7 +933,7 @@ Vector2D IHyprLayout::predictSizeForNewWindow(PHLWINDOW pWindow) {
else
sizePredicted = predictSizeForNewWindowFloating(pWindow);
Vector2D maxSize = pWindow->m_xdgSurface->toplevel->pending.maxSize;
Vector2D maxSize = pWindow->m_xdgSurface->m_toplevel->m_pending.maxSize;
if ((maxSize.x > 0 && maxSize.x < sizePredicted.x) || (maxSize.y > 0 && maxSize.y < sizePredicted.y))
sizePredicted = {};

View file

@ -136,7 +136,7 @@ SP<CANRManager::SANRData> CANRManager::dataFor(PHLWINDOW pWindow) {
if (pWindow->m_xwaylandSurface)
it = std::ranges::find_if(m_data, [&pWindow](const auto& data) { return data->xwaylandSurface && data->xwaylandSurface == pWindow->m_xwaylandSurface; });
else if (pWindow->m_xdgSurface)
it = std::ranges::find_if(m_data, [&pWindow](const auto& data) { return data->xdgBase && data->xdgBase == pWindow->m_xdgSurface->owner; });
it = std::ranges::find_if(m_data, [&pWindow](const auto& data) { return data->xdgBase && data->xdgBase == pWindow->m_xdgSurface->m_owner; });
return it == m_data.end() ? nullptr : *it;
}
@ -150,7 +150,8 @@ SP<CANRManager::SANRData> CANRManager::dataFor(SP<CXWaylandSurface> pXwaylandSur
return it == m_data.end() ? nullptr : *it;
}
CANRManager::SANRData::SANRData(PHLWINDOW pWindow) : xwaylandSurface(pWindow->m_xwaylandSurface), xdgBase(pWindow->m_xdgSurface ? pWindow->m_xdgSurface->owner : WP<CXDGWMBase>{}) {
CANRManager::SANRData::SANRData(PHLWINDOW pWindow) :
xwaylandSurface(pWindow->m_xwaylandSurface), xdgBase(pWindow->m_xdgSurface ? pWindow->m_xdgSurface->m_owner : WP<CXDGWMBase>{}) {
;
}
@ -201,7 +202,7 @@ bool CANRManager::SANRData::fitsWindow(PHLWINDOW pWindow) const {
if (pWindow->m_xwaylandSurface)
return pWindow->m_xwaylandSurface == xwaylandSurface;
else if (pWindow->m_xdgSurface)
return pWindow->m_xdgSurface->owner == xdgBase && xdgBase;
return pWindow->m_xdgSurface->m_owner == xdgBase && xdgBase;
return false;
}

View file

@ -48,8 +48,8 @@ void CHyprXWaylandManager::activateSurface(SP<CWLSurfaceResource> pSurface, bool
}
PWINDOW->m_xwaylandSurface->activate(activate);
}
} else if (PWINDOW->m_xdgSurface && PWINDOW->m_xdgSurface->toplevel)
PWINDOW->m_xdgSurface->toplevel->setActive(activate);
} else if (PWINDOW->m_xdgSurface && PWINDOW->m_xdgSurface->m_toplevel)
PWINDOW->m_xdgSurface->m_toplevel->setActive(activate);
}
void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
@ -65,8 +65,8 @@ void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
pWindow->m_xwaylandSurface->activate(activate);
} else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->toplevel)
pWindow->m_xdgSurface->toplevel->setActive(activate);
} else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel)
pWindow->m_xdgSurface->m_toplevel->setActive(activate);
if (activate) {
g_pCompositor->m_lastFocus = getWindowSurface(pWindow);
@ -86,7 +86,7 @@ CBox CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow) {
if (pWindow->m_isX11)
box = pWindow->m_xwaylandSurface->geometry;
else if (pWindow->m_xdgSurface)
box = pWindow->m_xdgSurface->current.geometry;
box = pWindow->m_xdgSurface->m_current.geometry;
return box;
}
@ -94,8 +94,8 @@ CBox CHyprXWaylandManager::getGeometryForWindow(PHLWINDOW pWindow) {
void CHyprXWaylandManager::sendCloseWindow(PHLWINDOW pWindow) {
if (pWindow->m_isX11)
pWindow->m_xwaylandSurface->close();
else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->toplevel)
pWindow->m_xdgSurface->toplevel->close();
else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel)
pWindow->m_xdgSurface->m_toplevel->close();
}
bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) {
@ -124,11 +124,11 @@ bool CHyprXWaylandManager::shouldBeFloated(PHLWINDOW pWindow, bool pending) {
(SIZEHINTS && (SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height)))
return true;
} else {
if (!pWindow->m_xdgSurface || !pWindow->m_xdgSurface->toplevel)
if (!pWindow->m_xdgSurface || !pWindow->m_xdgSurface->m_toplevel)
return false;
const auto PSTATE = pending ? &pWindow->m_xdgSurface->toplevel->pending : &pWindow->m_xdgSurface->toplevel->current;
if (pWindow->m_xdgSurface->toplevel->parent ||
const auto PSTATE = pending ? &pWindow->m_xdgSurface->m_toplevel->m_pending : &pWindow->m_xdgSurface->m_toplevel->m_current;
if (pWindow->m_xdgSurface->m_toplevel->m_parent ||
(PSTATE->minSize.x != 0 && PSTATE->minSize.y != 0 && (PSTATE->minSize.x == PSTATE->maxSize.x || PSTATE->minSize.y == PSTATE->maxSize.y)))
return true;
}
@ -160,8 +160,8 @@ void CHyprXWaylandManager::setWindowFullscreen(PHLWINDOW pWindow, bool fullscree
if (pWindow->m_isX11)
pWindow->m_xwaylandSurface->setFullscreen(fullscreen);
else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->toplevel)
pWindow->m_xdgSurface->toplevel->setFullscreen(fullscreen);
else if (pWindow->m_xdgSurface && pWindow->m_xdgSurface->m_toplevel)
pWindow->m_xdgSurface->m_toplevel->setFullscreen(fullscreen);
}
Vector2D CHyprXWaylandManager::waylandToXWaylandCoords(const Vector2D& coord) {

View file

@ -66,11 +66,11 @@ CInputManager::CInputManager() {
});
m_listeners.newIdleInhibitor = PROTO::idleInhibit->m_events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); });
m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) {
m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->m_events.newKeyboard.registerListener([this](std::any data) {
this->newVirtualKeyboard(std::any_cast<SP<CVirtualKeyboardV1Resource>>(data));
updateCapabilities();
});
m_listeners.newVirtualMouse = PROTO::virtualPointer->events.newPointer.registerListener([this](std::any data) {
m_listeners.newVirtualMouse = PROTO::virtualPointer->m_events.newPointer.registerListener([this](std::any data) {
this->newVirtualMouse(std::any_cast<SP<CVirtualPointerV1Resource>>(data));
updateCapabilities();
});
@ -491,7 +491,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
if (pFoundWindow && !pFoundWindow->m_isX11 && surfacePos != Vector2D(-1337, -1337)) {
// calc for oversized windows... fucking bullshit.
CBox geom = pFoundWindow->m_xdgSurface->current.geometry;
CBox geom = pFoundWindow->m_xdgSurface->m_current.geometry;
surfaceLocal = mouseCoords - surfacePos + geom.pos();
}

View file

@ -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);
});

View file

@ -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; });
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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;
};

View file

@ -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);
}

View file

@ -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;
};

View file

@ -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;
}

View file

@ -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;
};

View file

@ -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;
}
}

View file

@ -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;
};

View file

@ -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; });
}

View file

@ -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;
};

View file

@ -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;
}
}

View file

@ -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;
};

View file

@ -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; });
}

View file

@ -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;

View file

@ -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();
}

View file

@ -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

View file

@ -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);

View file

@ -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; });
}

View file

@ -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;
};

View file

@ -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; });
}

View file

@ -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;

View file

@ -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; });
}

View file

@ -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;

View file

@ -623,7 +623,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_POPUP) {
if (!pWindow->m_isX11) {
CBox geom = pWindow->m_xdgSurface->current.geometry;
CBox geom = pWindow->m_xdgSurface->m_current.geometry;
renderdata.pos -= geom.pos();
renderdata.dontRound = true; // don't round popups
@ -1108,7 +1108,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
if (!main || !pWindow)
return;
CBox geom = pWindow->m_xdgSurface->current.geometry;
CBox geom = pWindow->m_xdgSurface->m_current.geometry;
// ignore X and Y, adjust uv
if (geom.x != 0 || geom.y != 0 || geom.width > projSizeUnscaled.x || geom.height > projSizeUnscaled.y) {

View file

@ -361,10 +361,10 @@ void CXWM::handleClientMessage(xcb_client_message_event_t* e) {
if (!res)
continue;
if (res->serial != XSURF->wlSerial || !XSURF->wlSerial)
if (res->m_serial != XSURF->wlSerial || !XSURF->wlSerial)
continue;
associate(XSURF, res->surface.lock());
associate(XSURF, res->m_surface.lock());
break;
}
@ -958,7 +958,7 @@ CXWM::CXWM() : connection(g_pXWayland->pServer->xwmFDs[0].get()) {
initSelection();
listeners.newWLSurface = PROTO::compositor->m_events.newSurface.registerListener([this](std::any d) { onNewSurface(std::any_cast<SP<CWLSurfaceResource>>(d)); });
listeners.newXShellSurface = PROTO::xwaylandShell->events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); });
listeners.newXShellSurface = PROTO::xwaylandShell->m_events.newSurface.registerListener([this](std::any d) { onNewResource(std::any_cast<SP<CXWaylandSurfaceResource>>(d)); });
createWMWindow();
@ -1067,10 +1067,10 @@ void CXWM::onNewResource(SP<CXWaylandSurfaceResource> resource) {
shellResources.emplace_back(resource);
for (auto const& surf : surfaces) {
if (surf->resource || surf->wlSerial != resource->serial)
if (surf->resource || surf->wlSerial != resource->m_serial)
continue;
associate(surf, resource->surface.lock());
associate(surf, resource->m_surface.lock());
break;
}
}