From 0237e39f74a7facf51d40bc4c95f6ce8ce3cdc2e Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 1 May 2024 19:40:35 +0100 Subject: [PATCH] protocols: utilize hyprwayland-scanner 0.3.3 functions stuff like ::version(), ::client(), ::error() etc --- CMakeLists.txt | 2 +- src/protocols/AlphaModifier.cpp | 10 +++--- src/protocols/CursorShape.cpp | 6 ++-- src/protocols/ForeignToplevel.cpp | 6 ++-- src/protocols/ForeignToplevelWlr.cpp | 8 ++--- src/protocols/FractionalScale.cpp | 9 ++--- src/protocols/GammaControl.cpp | 10 +++--- src/protocols/IdleInhibit.cpp | 5 ++- src/protocols/IdleNotify.cpp | 8 ++--- src/protocols/InputMethodV2.cpp | 25 ++++++------- src/protocols/OutputPower.cpp | 9 +++-- src/protocols/PointerConstraints.cpp | 16 ++++----- src/protocols/PointerGestures.cpp | 53 +++++++++------------------- src/protocols/RelativePointer.cpp | 9 +++-- src/protocols/SessionLock.cpp | 18 +++++----- src/protocols/ShortcutsInhibit.cpp | 12 +++---- src/protocols/TearingControl.cpp | 12 +++---- src/protocols/TearingControl.hpp | 2 +- src/protocols/TextInputV3.cpp | 6 ++-- src/protocols/XDGActivation.cpp | 7 ++-- src/protocols/XDGDecoration.cpp | 9 +++-- src/protocols/XDGOutput.cpp | 11 +++--- 22 files changed, 105 insertions(+), 148 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abdcd967..675844e0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo pango pangocairo pixman-1 libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm - hyprwayland-scanner>=0.3.2 hyprlang>=0.3.2 hyprcursor>=0.1.7 + hyprwayland-scanner>=0.3.3 hyprlang>=0.3.2 hyprcursor>=0.1.7 ) file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") diff --git a/src/protocols/AlphaModifier.cpp b/src/protocols/AlphaModifier.cpp index 55349572..195e4b38 100644 --- a/src/protocols/AlphaModifier.cpp +++ b/src/protocols/AlphaModifier.cpp @@ -24,7 +24,7 @@ CAlphaModifier::CAlphaModifier(SP resource_, wlr_surf resource->setSetMultiplier([this](CWpAlphaModifierSurfaceV1* mod, uint32_t alpha) { if (!pSurface) { LOGM(ERR, "Resource {:x} tried to setMultiplier but surface is gone", (uintptr_t)mod->resource()); - wl_resource_post_error(mod->resource(), WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); + mod->error(WP_ALPHA_MODIFIER_SURFACE_V1_ERROR_NO_SURFACE, "Surface is gone"); return; } @@ -107,18 +107,16 @@ void CAlphaModifierProtocol::destroyModifier(CAlphaModifier* modifier) { void CAlphaModifierProtocol::onGetSurface(CWpAlphaModifierV1* pMgr, uint32_t id, wlr_surface* surface) { if (m_mAlphaModifiers.contains(surface)) { LOGM(ERR, "AlphaModifier already present for surface {:x}", (uintptr_t)surface); - wl_resource_post_error(pMgr->resource(), WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present"); + pMgr->error(WP_ALPHA_MODIFIER_V1_ERROR_ALREADY_CONSTRUCTED, "AlphaModifier already present"); return; } - const auto CLIENT = wl_resource_get_client(pMgr->resource()); const auto RESOURCE = - m_mAlphaModifiers - .emplace(surface, std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), surface)) + m_mAlphaModifiers.emplace(surface, std::make_unique(std::make_shared(pMgr->client(), pMgr->version(), id), surface)) .first->second.get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_mAlphaModifiers.erase(surface); return; } diff --git a/src/protocols/CursorShape.cpp b/src/protocols/CursorShape.cpp index 44f6a84f..a390f852 100644 --- a/src/protocols/CursorShape.cpp +++ b/src/protocols/CursorShape.cpp @@ -73,8 +73,8 @@ void CCursorShapeProtocol::onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint } void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = m_vDevices.emplace_back(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id)); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vDevices.emplace_back(std::make_shared(CLIENT, pMgr->version(), id)); RESOURCE->setOnDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpCursorShapeDeviceV1* p) { this->onDeviceResourceDestroy(p->resource()); }); @@ -83,7 +83,7 @@ void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape) { if ((uint32_t)shape == 0 || (uint32_t)shape > sizeof(SHAPE_NAMES)) { - wl_resource_post_error(pMgr->resource(), WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE, "The shape is invalid"); + pMgr->error(WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE, "The shape is invalid"); return; } diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp index 05720455..970b3747 100644 --- a/src/protocols/ForeignToplevel.cpp +++ b/src/protocols/ForeignToplevel.cpp @@ -44,12 +44,12 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) { if (finished) return; - const auto NEWHANDLE = PROTO::foreignToplevel->m_vHandles.emplace_back(std::make_shared( - std::make_shared(wl_resource_get_client(resource->resource()), wl_resource_get_version(resource->resource()), 0), pWindow)); + const auto NEWHANDLE = PROTO::foreignToplevel->m_vHandles.emplace_back( + std::make_shared(std::make_shared(resource->client(), resource->version(), 0), pWindow)); if (!NEWHANDLE->good()) { LOGM(ERR, "Couldn't create a foreign handle"); - wl_resource_post_no_memory(resource->resource()); + resource->noMemory(); PROTO::foreignToplevel->m_vHandles.pop_back(); return; } diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp index 3f9e64a0..35d7b01c 100644 --- a/src/protocols/ForeignToplevelWlr.cpp +++ b/src/protocols/ForeignToplevelWlr.cpp @@ -107,7 +107,7 @@ void CForeignToplevelHandleWlr::sendMonitor(CMonitor* pMonitor) { if (lastMonitorID == (int64_t)pMonitor->ID) return; - const auto CLIENT = wl_resource_get_client(resource->resource()); + const auto CLIENT = resource->client(); struct wl_resource* outputResource; @@ -184,12 +184,12 @@ void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) { if (finished) return; - const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_vHandles.emplace_back(std::make_shared( - std::make_shared(wl_resource_get_client(resource->resource()), wl_resource_get_version(resource->resource()), 0), pWindow)); + const auto NEWHANDLE = PROTO::foreignToplevelWlr->m_vHandles.emplace_back( + std::make_shared(std::make_shared(resource->client(), resource->version(), 0), pWindow)); if (!NEWHANDLE->good()) { LOGM(ERR, "Couldn't create a foreign handle"); - wl_resource_post_no_memory(resource->resource()); + resource->noMemory(); PROTO::foreignToplevelWlr->m_vHandles.pop_back(); return; } diff --git a/src/protocols/FractionalScale.cpp b/src/protocols/FractionalScale.cpp index 86662d90..f478e622 100644 --- a/src/protocols/FractionalScale.cpp +++ b/src/protocols/FractionalScale.cpp @@ -32,19 +32,16 @@ void CFractionalScaleProtocol::onManagerResourceDestroy(wl_resource* res) { void CFractionalScaleProtocol::onGetFractionalScale(CWpFractionalScaleManagerV1* pMgr, uint32_t id, wlr_surface* surface) { if (m_mAddons.contains(surface)) { LOGM(ERR, "Surface {:x} already has a fractionalScale addon", (uintptr_t)surface); - wl_resource_post_error(pMgr->resource(), WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists"); + pMgr->error(WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale already exists"); return; } - const auto PADDON = m_mAddons - .emplace(surface, - std::make_unique( - std::make_shared(wl_resource_get_client(pMgr->resource()), wl_resource_get_version(pMgr->resource()), id), surface)) + const auto PADDON = m_mAddons.emplace(surface, std::make_unique(std::make_shared(pMgr->client(), pMgr->version(), id), surface)) .first->second.get(); if (!PADDON->good()) { m_mAddons.erase(surface); - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); return; } diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp index b0f9af7a..356fd88d 100644 --- a/src/protocols/GammaControl.cpp +++ b/src/protocols/GammaControl.cpp @@ -70,7 +70,7 @@ CGammaControl::CGammaControl(SP resource_, wl_resource* out close(fd); if ((size_t)readBytes != gammaTable.size() * sizeof(uint16_t)) { - wl_resource_post_error(gamma->resource(), ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch"); + gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch"); return; } @@ -156,13 +156,11 @@ void CGammaControlProtocol::destroyGammaControl(CGammaControl* gamma) { } void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr, uint32_t id, wl_resource* output) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vGammaControllers.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), output)) - .get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vGammaControllers.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id), output)).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vGammaControllers.pop_back(); return; } diff --git a/src/protocols/IdleInhibit.cpp b/src/protocols/IdleInhibit.cpp index 0119755f..9960c00f 100644 --- a/src/protocols/IdleInhibit.cpp +++ b/src/protocols/IdleInhibit.cpp @@ -47,9 +47,8 @@ void CIdleInhibitProtocol::removeInhibitor(CIdleInhibitorResource* resource) { } void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vInhibitors.emplace_back(std::make_shared(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), surface)); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vInhibitors.emplace_back(std::make_shared(std::make_shared(CLIENT, pMgr->version(), id), surface)); RESOURCE->inhibitor = std::make_shared(RESOURCE, surface); events.newIdleInhibitor.emit(RESOURCE->inhibitor); diff --git a/src/protocols/IdleNotify.cpp b/src/protocols/IdleNotify.cpp index 950fbf06..63d01e60 100644 --- a/src/protocols/IdleNotify.cpp +++ b/src/protocols/IdleNotify.cpp @@ -77,14 +77,12 @@ void CIdleNotifyProtocol::destroyNotification(CExtIdleNotification* notif) { } void CIdleNotifyProtocol::onGetNotification(CExtIdleNotifierV1* pMgr, uint32_t id, uint32_t timeout, wl_resource* seat) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); + const auto CLIENT = pMgr->client(); const auto RESOURCE = - m_vNotifications - .emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), timeout)) - .get(); + m_vNotifications.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id), timeout)).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vNotifications.pop_back(); return; } diff --git a/src/protocols/InputMethodV2.cpp b/src/protocols/InputMethodV2.cpp index 91dac671..86601747 100644 --- a/src/protocols/InputMethodV2.cpp +++ b/src/protocols/InputMethodV2.cpp @@ -59,13 +59,13 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(wlr_keyboard* keyboard) { } void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) { - const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, wl_resource_get_client(resource->resource()))); + const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, resource->client())); resource->sendKey(SERIAL, time, key, (uint32_t)state); } void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { - const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, wl_resource_get_client(resource->resource()))); + const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, resource->client())); resource->sendModifiers(SERIAL, depressed, latched, locked, group); } @@ -79,7 +79,7 @@ SP CInputMethodKeyboardGrabV2::getOwner() { } wl_client* CInputMethodKeyboardGrabV2::client() { - return wl_resource_get_client(resource->resource()); + return resource->client(); } CInputMethodPopupV2::CInputMethodPopupV2(SP resource_, SP owner_, wlr_surface* wlrSurface) : resource(resource_), owner(owner_) { @@ -192,12 +192,11 @@ CInputMethodV2::CInputMethodV2(SP resource_) : resource(resou }); resource->setGetInputPopupSurface([this](CZwpInputMethodV2* r, uint32_t id, wl_resource* surface) { - const auto CLIENT = wl_resource_get_client(r->resource()); - const auto RESOURCE = PROTO::ime->m_vPopups.emplace_back(std::make_shared( - std::make_shared(CLIENT, wl_resource_get_version(r->resource()), id), self.lock(), wlr_surface_from_resource(surface))); + const auto RESOURCE = PROTO::ime->m_vPopups.emplace_back( + std::make_shared(std::make_shared(r->client(), r->version(), id), self.lock(), wlr_surface_from_resource(surface))); if (!RESOURCE->good()) { - wl_resource_post_no_memory(r->resource()); + r->noMemory(); PROTO::ime->m_vPopups.pop_back(); return; } @@ -210,12 +209,11 @@ CInputMethodV2::CInputMethodV2(SP resource_) : resource(resou }); resource->setGrabKeyboard([this](CZwpInputMethodV2* r, uint32_t id) { - const auto CLIENT = wl_resource_get_client(r->resource()); const auto RESOURCE = PROTO::ime->m_vGrabs.emplace_back( - std::make_shared(std::make_shared(CLIENT, wl_resource_get_version(r->resource()), id), self.lock())); + std::make_shared(std::make_shared(r->client(), r->version(), id), self.lock())); if (!RESOURCE->good()) { - wl_resource_post_no_memory(r->resource()); + r->noMemory(); PROTO::ime->m_vGrabs.pop_back(); return; } @@ -334,7 +332,7 @@ void CInputMethodV2::setKeyboard(wlr_keyboard* keyboard) { } wl_client* CInputMethodV2::client() { - return wl_resource_get_client(resource->resource()); + return resource->client(); } CInputMethodV2Protocol::CInputMethodV2Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -366,11 +364,10 @@ void CInputMethodV2Protocol::destroyResource(CInputMethodV2* ime) { } void CInputMethodV2Protocol::onGetIME(CZwpInputMethodManagerV2* mgr, wl_resource* seat, uint32_t id) { - const auto CLIENT = wl_resource_get_client(mgr->resource()); - const auto RESOURCE = m_vIMEs.emplace_back(std::make_shared(std::make_shared(CLIENT, wl_resource_get_version(mgr->resource()), id))); + const auto RESOURCE = m_vIMEs.emplace_back(std::make_shared(std::make_shared(mgr->client(), mgr->version(), id))); if (!RESOURCE->good()) { - wl_resource_post_no_memory(mgr->resource()); + mgr->noMemory(); m_vIMEs.pop_back(); return; } diff --git a/src/protocols/OutputPower.cpp b/src/protocols/OutputPower.cpp index 48e713f5..fae1a131 100644 --- a/src/protocols/OutputPower.cpp +++ b/src/protocols/OutputPower.cpp @@ -64,16 +64,15 @@ void COutputPowerProtocol::onGetOutputPower(CZwlrOutputPowerManagerV1* pMgr, uin const auto PMONITOR = g_pCompositor->getMonitorFromOutput(wlr_output_from_resource(output)); if (!PMONITOR) { - wl_resource_post_error(pMgr->resource(), 0, "Invalid output resource"); + pMgr->error(0, "Invalid output resource"); return; } - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vOutputPowers.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), PMONITOR)).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vOutputPowers.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id), PMONITOR)).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vOutputPowers.pop_back(); return; } diff --git a/src/protocols/PointerConstraints.cpp b/src/protocols/PointerConstraints.cpp index ea7f4654..bcc515eb 100644 --- a/src/protocols/PointerConstraints.cpp +++ b/src/protocols/PointerConstraints.cpp @@ -216,7 +216,7 @@ void CPointerConstraintsProtocol::destroyPointerConstraint(CPointerConstraint* h void CPointerConstraintsProtocol::onNewConstraint(SP constraint, CZwpPointerConstraintsV1* pMgr) { if (!constraint->good()) { LOGM(ERR, "Couldn't create constraint??"); - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vConstraints.pop_back(); return; } @@ -232,7 +232,7 @@ void CPointerConstraintsProtocol::onNewConstraint(SP constra if (DUPES > 1) { LOGM(ERR, "Constraint for surface duped"); - wl_resource_post_error(pMgr->resource(), ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED, "Surface already confined"); + pMgr->error(ZWP_POINTER_CONSTRAINTS_V1_ERROR_ALREADY_CONSTRAINED, "Surface already confined"); m_vConstraints.pop_back(); return; } @@ -244,18 +244,18 @@ void CPointerConstraintsProtocol::onNewConstraint(SP constra void CPointerConstraintsProtocol::onLockPointer(CZwpPointerConstraintsV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* pointer, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = m_vConstraints.emplace_back(std::make_shared( - std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), wlr_surface_from_resource(surface), region, lifetime)); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vConstraints.emplace_back( + std::make_shared(std::make_shared(CLIENT, pMgr->version(), id), wlr_surface_from_resource(surface), region, lifetime)); onNewConstraint(RESOURCE, pMgr); } void CPointerConstraintsProtocol::onConfinePointer(CZwpPointerConstraintsV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* pointer, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = m_vConstraints.emplace_back(std::make_shared( - std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), wlr_surface_from_resource(surface), region, lifetime)); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vConstraints.emplace_back( + std::make_shared(std::make_shared(CLIENT, pMgr->version(), id), wlr_surface_from_resource(surface), region, lifetime)); onNewConstraint(RESOURCE, pMgr); } diff --git a/src/protocols/PointerGestures.cpp b/src/protocols/PointerGestures.cpp index a6f3d19c..b3840093 100644 --- a/src/protocols/PointerGestures.cpp +++ b/src/protocols/PointerGestures.cpp @@ -70,36 +70,33 @@ void CPointerGesturesProtocol::onGestureDestroy(CPointerGestureHold* gesture) { } void CPointerGesturesProtocol::onGetPinchGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vPinches.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vPinches.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; } } void CPointerGesturesProtocol::onGetSwipeGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vSwipes.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vSwipes.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; } } void CPointerGesturesProtocol::onGetHoldGesture(CZwpPointerGesturesV1* pMgr, uint32_t id, wl_resource* pointer) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vHolds.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vHolds.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; } @@ -114,9 +111,7 @@ void CPointerGesturesProtocol::swipeBegin(uint32_t timeMs, uint32_t fingers) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vSwipes) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers); @@ -130,9 +125,7 @@ void CPointerGesturesProtocol::swipeUpdate(uint32_t timeMs, const Vector2D& delt const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client; for (auto& sw : m_vSwipes) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendUpdate(timeMs, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y)); @@ -148,9 +141,7 @@ void CPointerGesturesProtocol::swipeEnd(uint32_t timeMs, bool cancelled) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vSwipes) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendEnd(SERIAL, timeMs, cancelled); @@ -166,9 +157,7 @@ void CPointerGesturesProtocol::pinchBegin(uint32_t timeMs, uint32_t fingers) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vPinches) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers); @@ -182,9 +171,7 @@ void CPointerGesturesProtocol::pinchUpdate(uint32_t timeMs, const Vector2D& delt const auto FOCUSEDCLIENT = g_pCompositor->m_sSeat.seat->pointer_state.focused_client->client; for (auto& sw : m_vPinches) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendUpdate(timeMs, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y), wl_fixed_from_double(scale), wl_fixed_from_double(rotation)); @@ -200,9 +187,7 @@ void CPointerGesturesProtocol::pinchEnd(uint32_t timeMs, bool cancelled) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vPinches) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendEnd(SERIAL, timeMs, cancelled); @@ -218,9 +203,7 @@ void CPointerGesturesProtocol::holdBegin(uint32_t timeMs, uint32_t fingers) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vHolds) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendBegin(SERIAL, timeMs, g_pCompositor->m_sSeat.seat->pointer_state.focused_surface->resource, fingers); @@ -236,9 +219,7 @@ void CPointerGesturesProtocol::holdEnd(uint32_t timeMs, bool cancelled) { const auto SERIAL = wlr_seat_client_next_serial(g_pCompositor->m_sSeat.seat->pointer_state.focused_client); for (auto& sw : m_vHolds) { - const auto CLIENT = wl_resource_get_client(sw->resource->resource()); - - if (CLIENT != FOCUSEDCLIENT) + if (sw->resource->client() != FOCUSEDCLIENT) continue; sw->resource->sendEnd(SERIAL, timeMs, cancelled); diff --git a/src/protocols/RelativePointer.cpp b/src/protocols/RelativePointer.cpp index df7e2e6d..0e50641e 100644 --- a/src/protocols/RelativePointer.cpp +++ b/src/protocols/RelativePointer.cpp @@ -6,7 +6,7 @@ CRelativePointer::CRelativePointer(SP resource_) : resour if (!resource_->resource()) return; - pClient = wl_resource_get_client(resource_->resource()); + pClient = resource->client(); resource->setDestroy([this](CZwpRelativePointerV1* pMgr) { PROTO::relativePointer->destroyRelativePointer(this); }); resource->setOnDestroy([this](CZwpRelativePointerV1* pMgr) { PROTO::relativePointer->destroyRelativePointer(this); }); @@ -46,12 +46,11 @@ void CRelativePointerProtocol::destroyRelativePointer(CRelativePointer* pointer) } void CRelativePointerProtocol::onGetRelativePointer(CZwpRelativePointerManagerV1* pMgr, uint32_t id, wl_resource* pointer) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vRelativePointers.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vRelativePointers.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vRelativePointers.pop_back(); return; } diff --git a/src/protocols/SessionLock.cpp b/src/protocols/SessionLock.cpp index a33af3c5..a18b1f84 100644 --- a/src/protocols/SessionLock.cpp +++ b/src/protocols/SessionLock.cpp @@ -24,13 +24,13 @@ CSessionLockSurface::CSessionLockSurface(SP resource_, [this](void* owner, void* data) { if (pSurface->pending.buffer_width <= 0 || pSurface->pending.buffer_height <= 0) { LOGM(ERR, "SessionLock attached a null buffer"); - wl_resource_post_error(resource->resource(), EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, "Null buffer attached"); + resource->error(EXT_SESSION_LOCK_SURFACE_V1_ERROR_NULL_BUFFER, "Null buffer attached"); return; } if (!ackdConfigure) { LOGM(ERR, "SessionLock committed without an ack"); - wl_resource_post_error(resource->resource(), EXT_SESSION_LOCK_SURFACE_V1_ERROR_COMMIT_BEFORE_FIRST_ACK, "Committed surface before first ack"); + resource->error(EXT_SESSION_LOCK_SURFACE_V1_ERROR_COMMIT_BEFORE_FIRST_ACK, "Committed surface before first ack"); return; } @@ -73,8 +73,7 @@ CSessionLockSurface::~CSessionLockSurface() { } void CSessionLockSurface::sendConfigure() { - const auto CLIENT = wl_resource_get_client(resource->resource()); - const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, CLIENT)); + const auto SERIAL = wlr_seat_client_next_serial(wlr_seat_client_for_wl_client(g_pCompositor->m_sSeat.seat, resource->client())); resource->sendConfigure(SERIAL, pMonitor->vecSize.x, pMonitor->vecSize.y); } @@ -158,11 +157,11 @@ void CSessionLockProtocol::onLock(CExtSessionLockManagerV1* pMgr, uint32_t id) { LOGM(LOG, "New sessionLock with id {}", id); - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = m_vLocks.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vLocks.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vLocks.pop_back(); return; } @@ -193,12 +192,11 @@ void CSessionLockProtocol::onGetLockSurface(CExtSessionLockV1* lock, uint32_t id } } - const auto CLIENT = wl_resource_get_client(lock->resource()); const auto RESOURCE = m_vLockSurfaces.emplace_back( - std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(lock->resource()), id), PSURFACE, PMONITOR, sessionLock)); + std::make_unique(std::make_shared(lock->client(), lock->version(), id), PSURFACE, PMONITOR, sessionLock)); if (!RESOURCE->good()) { - wl_resource_post_no_memory(lock->resource()); + lock->noMemory(); m_vLockSurfaces.pop_back(); return; } diff --git a/src/protocols/ShortcutsInhibit.cpp b/src/protocols/ShortcutsInhibit.cpp index 30bc4dc2..ffc74b53 100644 --- a/src/protocols/ShortcutsInhibit.cpp +++ b/src/protocols/ShortcutsInhibit.cpp @@ -47,23 +47,21 @@ void CKeyboardShortcutsInhibitProtocol::destroyInhibitor(CKeyboardShortcutsInhib void CKeyboardShortcutsInhibitProtocol::onInhibit(CZwpKeyboardShortcutsInhibitManagerV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* seat) { wlr_surface* surf = wlr_surface_from_resource(surface); - const auto CLIENT = wl_resource_get_client(pMgr->resource()); + const auto CLIENT = pMgr->client(); for (auto& in : m_vInhibitors) { if (in->surface() != surf) continue; - wl_resource_post_error(pMgr->resource(), ZWP_KEYBOARD_SHORTCUTS_INHIBIT_MANAGER_V1_ERROR_ALREADY_INHIBITED, "Already inhibited for surface resource"); + pMgr->error(ZWP_KEYBOARD_SHORTCUTS_INHIBIT_MANAGER_V1_ERROR_ALREADY_INHIBITED, "Already inhibited for surface resource"); return; } - const auto RESOURCE = m_vInhibitors - .emplace_back(std::make_unique( - std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), surf)) - .get(); + const auto RESOURCE = + m_vInhibitors.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id), surf)).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vInhibitors.pop_back(); LOGM(ERR, "Failed to create an inhibitor resource"); return; diff --git a/src/protocols/TearingControl.cpp b/src/protocols/TearingControl.cpp index 7f0fe744..e0534735 100644 --- a/src/protocols/TearingControl.cpp +++ b/src/protocols/TearingControl.cpp @@ -13,21 +13,19 @@ void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_ RESOURCE->setOnDestroy([this](CWpTearingControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); }); RESOURCE->setDestroy([this](CWpTearingControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); }); - RESOURCE->setGetTearingControl([this](CWpTearingControlManagerV1* pMgr, uint32_t id, wl_resource* surface) { - this->onGetController(wl_resource_get_client(pMgr->resource()), pMgr->resource(), id, wlr_surface_from_resource(surface)); - }); + RESOURCE->setGetTearingControl( + [this](CWpTearingControlManagerV1* pMgr, uint32_t id, wl_resource* surface) { this->onGetController(pMgr->client(), pMgr, id, wlr_surface_from_resource(surface)); }); } void CTearingControlProtocol::onManagerResourceDestroy(wl_resource* res) { std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; }); } -void CTearingControlProtocol::onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf) { - const auto CONTROLLER = - m_vTearingControllers.emplace_back(std::make_unique(std::make_shared(client, wl_resource_get_version(resource), id), surf)).get(); +void CTearingControlProtocol::onGetController(wl_client* client, CWpTearingControlManagerV1* pMgr, uint32_t id, wlr_surface* surf) { + const auto CONTROLLER = m_vTearingControllers.emplace_back(std::make_unique(std::make_shared(client, pMgr->version(), id), surf)).get(); if (!CONTROLLER->good()) { - wl_resource_post_no_memory(resource); + pMgr->noMemory(); m_vTearingControllers.pop_back(); return; } diff --git a/src/protocols/TearingControl.hpp b/src/protocols/TearingControl.hpp index e2975462..199397a3 100644 --- a/src/protocols/TearingControl.hpp +++ b/src/protocols/TearingControl.hpp @@ -42,7 +42,7 @@ class CTearingControlProtocol : public IWaylandProtocol { private: void onManagerResourceDestroy(wl_resource* res); void onControllerDestroy(CTearingControl* control); - void onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf); + void onGetController(wl_client* client, CWpTearingControlManagerV1* pMgr, uint32_t id, wlr_surface* surf); void onWindowDestroy(PHLWINDOW pWindow); // diff --git a/src/protocols/TextInputV3.cpp b/src/protocols/TextInputV3.cpp index fbb5c3ae..fbd4a745 100644 --- a/src/protocols/TextInputV3.cpp +++ b/src/protocols/TextInputV3.cpp @@ -115,11 +115,11 @@ void CTextInputV3Protocol::destroyTextInput(CTextInputV3* input) { } void CTextInputV3Protocol::onGetTextInput(CZwpTextInputManagerV3* pMgr, uint32_t id, wl_resource* seat) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = m_vTextInputs.emplace_back(std::make_shared(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vTextInputs.emplace_back(std::make_shared(std::make_shared(CLIENT, pMgr->version(), id))); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vTextInputs.pop_back(); LOGM(ERR, "Failed to create a tiv3 resource"); return; diff --git a/src/protocols/XDGActivation.cpp b/src/protocols/XDGActivation.cpp index 6e2e32fb..2e85c0a2 100644 --- a/src/protocols/XDGActivation.cpp +++ b/src/protocols/XDGActivation.cpp @@ -91,12 +91,11 @@ void CXDGActivationProtocol::destroyToken(CXDGActivationToken* token) { } void CXDGActivationProtocol::onGetToken(CXdgActivationV1* pMgr, uint32_t id) { - const auto CLIENT = wl_resource_get_client(pMgr->resource()); - const auto RESOURCE = - m_vTokens.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id))).get(); + const auto CLIENT = pMgr->client(); + const auto RESOURCE = m_vTokens.emplace_back(std::make_unique(std::make_shared(CLIENT, pMgr->version(), id))).get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_vTokens.pop_back(); return; } diff --git a/src/protocols/XDGDecoration.cpp b/src/protocols/XDGDecoration.cpp index b62f89bc..f4d19432 100644 --- a/src/protocols/XDGDecoration.cpp +++ b/src/protocols/XDGDecoration.cpp @@ -58,18 +58,17 @@ void CXDGDecorationProtocol::destroyDecoration(CXDGDecoration* decoration) { void CXDGDecorationProtocol::onGetDecoration(CZxdgDecorationManagerV1* pMgr, uint32_t id, wl_resource* xdgToplevel) { if (m_mDecorations.contains(xdgToplevel)) { - wl_resource_post_error(pMgr->resource(), ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED, "Decoration object already exists"); + pMgr->error(ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED, "Decoration object already exists"); return; } - const auto CLIENT = wl_resource_get_client(pMgr->resource()); + const auto CLIENT = pMgr->client(); const auto RESOURCE = - m_mDecorations - .emplace(xdgToplevel, std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(pMgr->resource()), id), xdgToplevel)) + m_mDecorations.emplace(xdgToplevel, std::make_unique(std::make_shared(CLIENT, pMgr->version(), id), xdgToplevel)) .first->second.get(); if (!RESOURCE->good()) { - wl_resource_post_no_memory(pMgr->resource()); + pMgr->noMemory(); m_mDecorations.erase(xdgToplevel); return; } diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp index d472df92..37ed990d 100644 --- a/src/protocols/XDGOutput.cpp +++ b/src/protocols/XDGOutput.cpp @@ -51,10 +51,9 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 const auto PMONITOR = g_pCompositor->getMonitorFromOutput(OUTPUT); - const auto CLIENT = wl_resource_get_client(mgr->resource()); + const auto CLIENT = mgr->client(); - CXDGOutput* pXDGOutput = - m_vXDGOutputs.emplace_back(std::make_unique(std::make_shared(CLIENT, wl_resource_get_version(mgr->resource()), id), PMONITOR)).get(); + CXDGOutput* pXDGOutput = m_vXDGOutputs.emplace_back(std::make_unique(std::make_shared(CLIENT, mgr->version(), id), PMONITOR)).get(); #ifndef NO_XWAYLAND if (g_pXWaylandManager->m_sWLRXWayland && g_pXWaylandManager->m_sWLRXWayland->server && g_pXWaylandManager->m_sWLRXWayland->server->client == CLIENT) pXDGOutput->isXWayland = true; @@ -63,14 +62,14 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32 if (!pXDGOutput->resource->resource()) { m_vXDGOutputs.pop_back(); - wl_resource_post_no_memory(mgr->resource()); + mgr->noMemory(); return; } if (!PMONITOR) return; - const auto XDGVER = wl_resource_get_version(pXDGOutput->resource->resource()); + const auto XDGVER = pXDGOutput->resource->version(); if (XDGVER >= OUTPUT_NAME_SINCE_VERSION) pXDGOutput->resource->sendName(PMONITOR->szName.c_str()); @@ -120,6 +119,6 @@ void CXDGOutput::sendDetails() { else resource->sendLogicalSize(monitor->vecSize.x, monitor->vecSize.y); - if (wl_resource_get_version(resource->resource()) < OUTPUT_DONE_DEPRECATED_SINCE_VERSION) + if (resource->version() < OUTPUT_DONE_DEPRECATED_SINCE_VERSION) resource->sendDone(); } \ No newline at end of file