refactor: Use new hyprutils casts (#11377)

This commit is contained in:
Kamikadze 2025-08-14 19:44:56 +05:00 committed by GitHub
parent aa6a78f0a4
commit beee22a95e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
116 changed files with 715 additions and 696 deletions

View file

@ -27,7 +27,7 @@ void CAlphaModifier::setResource(UP<CWpAlphaModifierSurfaceV1>&& resource) {
return;
}
m_alpha = alpha / (float)UINT32_MAX;
m_alpha = alpha / sc<float>(UINT32_MAX);
});
m_listeners.surfaceCommitted = m_surface->m_events.commit.listen([this] {

View file

@ -272,7 +272,7 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
m_resource->setSetImageDescription([this](CWpColorManagementSurfaceV1* 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 = (CWpImageDescriptionV1*)wl_resource_get_user_data(image_description);
const auto PO = sc<CWpImageDescriptionV1*>(wl_resource_get_user_data(image_description));
if (!PO) { // FIXME check validity
r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description creation failed");
return;
@ -560,7 +560,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
default: r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INVALID_TF, "Unsupported transfer function"); return;
}
m_settings.transferFunction = convertTransferFunction((wpColorManagerV1TransferFunction)tf);
m_settings.transferFunction = convertTransferFunction(sc<wpColorManagerV1TransferFunction>(tf));
m_valuesSet |= PC_TF;
});
m_resource->setSetTfPower([this](CWpImageDescriptionCreatorParamsV1* r, uint32_t eexp) {
@ -605,7 +605,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
}
m_settings.primariesNameSet = true;
m_settings.primariesNamed = convertPrimaries((wpColorManagerV1Primaries)primaries);
m_settings.primariesNamed = convertPrimaries(sc<wpColorManagerV1Primaries>(primaries));
m_settings.primaries = getPrimaries(m_settings.primariesNamed);
m_valuesSet |= PC_PRIMARIES;
});
@ -755,7 +755,7 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CW
m_client = m_resource->client();
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); };
const auto toProto = [](float value) { return sc<int32_t>(std::round(value * 10000)); };
if (m_settings.icc.fd >= 0)
m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);

View file

@ -41,7 +41,7 @@ void CCursorShapeProtocol::createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr
}
void CCursorShapeProtocol::onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape) {
if UNLIKELY ((uint32_t)shape == 0 || (uint32_t)shape >= CURSOR_SHAPE_NAMES.size()) {
if UNLIKELY (sc<uint32_t>(shape) == 0 || sc<uint32_t>(shape) >= CURSOR_SHAPE_NAMES.size()) {
pMgr->error(WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE, "The shape is invalid");
return;
}

View file

@ -147,7 +147,7 @@ bool CDRMLeaseRequestResource::good() {
}
SP<CDRMLeaseConnectorResource> CDRMLeaseConnectorResource::fromResource(wl_resource* res) {
auto data = (CDRMLeaseConnectorResource*)(((CWpDrmLeaseConnectorV1*)wl_resource_get_user_data(res))->data());
auto data = sc<CDRMLeaseConnectorResource*>(sc<CWpDrmLeaseConnectorV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -181,7 +181,7 @@ void CDRMLeaseConnectorResource::sendData() {
m_resource->sendName(m_monitor->m_name.c_str());
m_resource->sendDescription(m_monitor->m_description.c_str());
auto AQDRMOutput = (Aquamarine::CDRMOutput*)m_monitor->m_output.get();
auto AQDRMOutput = sc<Aquamarine::CDRMOutput*>(m_monitor->m_output.get());
m_resource->sendConnectorId(AQDRMOutput->getConnectorID());
m_resource->sendDone();
@ -265,7 +265,7 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver,
if (backend_->type() != Aquamarine::AQ_BACKEND_DRM)
return;
m_backend = ((Aquamarine::CDRMBackend*)backend_.get())->self.lock();
m_backend = sc<Aquamarine::CDRMBackend*>(backend_.get())->self.lock();
m_deviceName = m_backend->gpuName;
CFileDescriptor fd{m_backend->getNonMasterFD()};

View file

@ -61,7 +61,7 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
}
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
m_pendingAcquire = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo};
m_pendingAcquire = {timeline->m_timeline, (sc<uint64_t>(hi) << 32) | sc<uint64_t>(lo)};
});
m_resource->setSetReleasePoint([this](CWpLinuxDrmSyncobjSurfaceV1* r, wl_resource* timeline_, uint32_t hi, uint32_t lo) {
@ -71,7 +71,7 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
}
auto timeline = CDRMSyncobjTimelineResource::fromResource(timeline_);
m_pendingRelease = {timeline->m_timeline, ((uint64_t)hi << 32) | (uint64_t)lo};
m_pendingRelease = {timeline->m_timeline, (sc<uint64_t>(hi) << 32) | sc<uint64_t>(lo)};
});
m_listeners.surfacePrecommit = m_surface->m_events.precommit.listen([this] {

View file

@ -65,7 +65,7 @@ CWLRDataSource::~CWLRDataSource() {
}
SP<CWLRDataSource> CWLRDataSource::fromResource(wl_resource* res) {
auto data = (CWLRDataSource*)(((CZwlrDataControlSourceV1*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLRDataSource*>(sc<CZwlrDataControlSourceV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}

View file

@ -20,7 +20,7 @@ CExtWorkspaceGroupResource::CExtWorkspaceGroupResource(WP<CExtWorkspaceManagerRe
m_resource->setOnDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); });
m_resource->setDestroy([this](auto) { PROTO::extWorkspace->destroyGroup(m_self); });
m_resource->sendCapabilities(static_cast<extWorkspaceGroupHandleV1GroupCapabilities>(0));
m_resource->sendCapabilities(sc<extWorkspaceGroupHandleV1GroupCapabilities>(0));
const auto& output = PROTO::outputs.at(m_monitor->m_name);
@ -41,8 +41,8 @@ bool CExtWorkspaceGroupResource::good() const {
}
WP<CExtWorkspaceGroupResource> CExtWorkspaceGroupResource::fromResource(wl_resource* resource) {
auto handle = static_cast<CExtWorkspaceGroupHandleV1*>(wl_resource_get_user_data(resource))->data();
auto data = static_cast<CExtWorkspaceGroupResource*>(handle);
auto handle = sc<CExtWorkspaceGroupHandleV1*>(wl_resource_get_user_data(resource))->data();
auto data = sc<CExtWorkspaceGroupResource*>(handle);
return data ? data->m_self : WP<CExtWorkspaceGroupResource>();
}
@ -105,7 +105,7 @@ CExtWorkspaceResource::CExtWorkspaceResource(WP<CExtWorkspaceManagerResource> ma
id += UINT32_MAX - 1337;
if (id > 0)
*static_cast<uint32_t*>(wl_array_add(&coordinates, sizeof(uint32_t))) = id;
*sc<uint32_t*>(wl_array_add(&coordinates, sizeof(uint32_t))) = id;
m_resource->sendCoordinates(&coordinates);
wl_array_release(&coordinates);
@ -142,7 +142,7 @@ void CExtWorkspaceResource::sendState() {
if (m_workspace->m_isSpecialWorkspace)
state |= EXT_WORKSPACE_HANDLE_V1_STATE_HIDDEN;
m_resource->sendState(static_cast<extWorkspaceHandleV1State>(state));
m_resource->sendState(sc<extWorkspaceHandleV1State>(state));
if (m_manager)
m_manager->scheduleDone();
@ -158,7 +158,7 @@ void CExtWorkspaceResource::sendCapabilities() {
if (active && m_workspace->m_isSpecialWorkspace)
capabilities |= EXT_WORKSPACE_HANDLE_V1_WORKSPACE_CAPABILITIES_DEACTIVATE;
m_resource->sendCapabilities(static_cast<extWorkspaceHandleV1WorkspaceCapabilities>(capabilities));
m_resource->sendCapabilities(sc<extWorkspaceHandleV1WorkspaceCapabilities>(capabilities));
if (m_manager)
m_manager->scheduleDone();

View file

@ -55,7 +55,7 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
return;
}
const auto IDENTIFIER = std::format("{:08x}->{:016x}", static_cast<uint32_t>((uintptr_t)this & 0xFFFFFFFF), (uintptr_t)pWindow.get());
const auto IDENTIFIER = std::format("{:08x}->{:016x}", sc<uint32_t>(rc<uintptr_t>(this) & 0xFFFFFFFF), rc<uintptr_t>(pWindow.get()));
LOGM(LOG, "Newly mapped window gets an identifier of {}", IDENTIFIER);
m_resource->sendToplevel(NEWHANDLE->m_resource.get());
@ -172,6 +172,6 @@ bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {
}
PHLWINDOW CForeignToplevelProtocol::windowFromHandleResource(wl_resource* res) {
auto data = (CForeignToplevelHandle*)(((CExtForeignToplevelHandleV1*)wl_resource_get_user_data(res))->data());
auto data = sc<CForeignToplevelHandle*>(sc<CExtForeignToplevelHandleV1*>(wl_resource_get_user_data(res))->data());
return data ? data->window() : nullptr;
}

View file

@ -109,7 +109,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
if UNLIKELY (!PWINDOW->m_isMapped)
return;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", (uintptr_t)PWINDOW.get())});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},1", rc<uintptr_t>(PWINDOW.get()))});
});
m_resource->setUnsetMinimized([this](CZwlrForeignToplevelHandleV1* p) {
@ -121,7 +121,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
if UNLIKELY (!PWINDOW->m_isMapped)
return;
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", (uintptr_t)PWINDOW.get())});
g_pEventManager->postEvent(SHyprIPCEvent{.event = "minimized", .data = std::format("{:x},0", rc<uintptr_t>(PWINDOW.get()))});
});
m_resource->setClose([this](CZwlrForeignToplevelHandleV1* p) {
@ -179,12 +179,12 @@ void CForeignToplevelHandleWlr::sendState() {
wl_array_init(&state);
if (PWINDOW == g_pCompositor->m_lastWindow) {
auto p = (uint32_t*)wl_array_add(&state, sizeof(uint32_t));
auto p = sc<uint32_t*>(wl_array_add(&state, sizeof(uint32_t)));
*p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_ACTIVATED;
}
if (PWINDOW->isFullscreen()) {
auto p = (uint32_t*)wl_array_add(&state, sizeof(uint32_t));
auto p = sc<uint32_t*>(wl_array_add(&state, sizeof(uint32_t)));
if (PWINDOW->isEffectiveInternalFSMode(FSMODE_FULLSCREEN))
*p = ZWLR_FOREIGN_TOPLEVEL_HANDLE_V1_STATE_FULLSCREEN;
else
@ -424,7 +424,7 @@ void CForeignToplevelWlrProtocol::destroyHandle(CForeignToplevelHandleWlr* handl
}
PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res) {
auto data = (CForeignToplevelHandleWlr*)(((CZwlrForeignToplevelHandleV1*)wl_resource_get_user_data(res))->data());
auto data = sc<CForeignToplevelHandleWlr*>(sc<CZwlrForeignToplevelHandleV1*>(wl_resource_get_user_data(res))->data());
return data ? data->window() : nullptr;
}

View file

@ -19,7 +19,7 @@ static wpColorManagerV1TransferFunction getWPTransferFunction(frogColorManagedSu
}
static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries primaries) {
return (wpColorManagerV1Primaries)(primaries + 1);
return sc<wpColorManagerV1Primaries>(primaries + 1);
}
CFrogColorManager::CFrogColorManager(SP<CFrogColorManagementFactoryV1> resource_) : m_resource(resource_) {

View file

@ -80,10 +80,10 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
moreBytes = read(gammaFd.get(), buf, BUF_SIZE);
}
if (readBytes < 0 || (size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes != 0) {
if (readBytes < 0 || sc<size_t>(readBytes) != m_gammaTable.size() * sizeof(uint16_t) || moreBytes != 0) {
LOGM(ERR, "Failed to read bytes");
if ((size_t)readBytes != m_gammaTable.size() * sizeof(uint16_t) || moreBytes > 0) {
if (sc<size_t>(readBytes) != m_gammaTable.size() * sizeof(uint16_t) || moreBytes > 0) {
gamma->error(ZWLR_GAMMA_CONTROL_V1_ERROR_INVALID_GAMMA, "Gamma ramps size mismatch");
return;
}

View file

@ -3,7 +3,7 @@
static int onTimer(SP<CEventLoopTimer> self, void* data) {
const auto NOTIF = (CExtIdleNotification*)data;
const auto NOTIF = sc<CExtIdleNotification*>(data);
NOTIF->onTimerFired();

View file

@ -58,7 +58,7 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(SP<IKeyboard> keyboard) {
void CInputMethodKeyboardGrabV2::sendKey(uint32_t time, uint32_t key, wl_keyboard_key_state state) {
const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client()));
m_resource->sendKey(SERIAL, time, key, (uint32_t)state);
m_resource->sendKey(SERIAL, time, key, sc<uint32_t>(state));
}
void CInputMethodKeyboardGrabV2::sendMods(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) {
@ -243,11 +243,11 @@ void CInputMethodV2::surroundingText(const std::string& text, uint32_t cursor, u
}
void CInputMethodV2::textChangeCause(zwpTextInputV3ChangeCause changeCause) {
m_resource->sendTextChangeCause((uint32_t)changeCause);
m_resource->sendTextChangeCause(changeCause);
}
void CInputMethodV2::textContentType(zwpTextInputV3ContentHint hint, zwpTextInputV3ContentPurpose purpose) {
m_resource->sendContentType((uint32_t)hint, (uint32_t)purpose);
m_resource->sendContentType(hint, purpose);
}
void CInputMethodV2::done() {

View file

@ -11,7 +11,7 @@ void CLayerShellResource::SState::reset() {
exclusive = 0;
interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
exclusiveEdge = (zwlrLayerSurfaceV1Anchor)0;
exclusiveEdge = sc<zwlrLayerSurfaceV1Anchor>(0);
desiredSize = {};
margin = {0, 0, 0, 0};
}
@ -84,7 +84,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
m_resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) {
m_pending.committed |= STATE_SIZE;
m_pending.desiredSize = {(int)x, (int)y};
m_pending.desiredSize = {sc<int>(x), sc<int>(y)};
});
m_resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
@ -150,7 +150,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
}
m_pending.committed |= STATE_LAYER;
m_pending.layer = (zwlrLayerShellV1Layer)layer;
m_pending.layer = sc<zwlrLayerShellV1Layer>(layer);
});
m_resource->setSetExclusiveEdge([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {

View file

@ -58,7 +58,7 @@ class CLayerShellResource {
Vector2D desiredSize;
zwlrLayerSurfaceV1KeyboardInteractivity interactivity = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
zwlrLayerShellV1Layer layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
zwlrLayerSurfaceV1Anchor exclusiveEdge = (zwlrLayerSurfaceV1Anchor)0;
zwlrLayerSurfaceV1Anchor exclusiveEdge = sc<zwlrLayerSurfaceV1Anchor>(0);
uint32_t committed = 0;
struct {

View file

@ -80,7 +80,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
CFileDescriptor fds[2];
allocateSHMFilePair(m_tableSize, fds[0], fds[1]);
auto arr = (SDMABUFFormatTableEntry*)mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0);
auto arr = sc<SDMABUFFormatTableEntry*>(mmap(nullptr, m_tableSize, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0].get(), 0));
if (arr == MAP_FAILED) {
LOGM(ERR, "mmap failed");
@ -150,7 +150,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(UP<CZwpLinuxBufferParamsV
m_attrs->fds[plane] = fd;
m_attrs->strides[plane] = stride;
m_attrs->offsets[plane] = offset;
m_attrs->modifier = ((uint64_t)modHi << 32) | modLo;
m_attrs->modifier = (sc<uint64_t>(modHi) << 32) | modLo;
});
m_resource->setCreate([this](CZwpLinuxBufferParamsV1* r, int32_t w, int32_t h, uint32_t fmt, zwpLinuxBufferParamsV1Flags flags) {
@ -279,11 +279,11 @@ bool CLinuxDMABUFParamsResource::verify() {
return false;
}
for (size_t i = 0; i < (size_t)m_attrs->planes; ++i) {
if ((uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i) * m_attrs->size.y > UINT32_MAX) {
for (size_t i = 0; i < sc<size_t>(m_attrs->planes); ++i) {
if (sc<uint64_t>(m_attrs->offsets.at(i)) + sc<uint64_t>(m_attrs->strides.at(i)) * m_attrs->size.y > UINT32_MAX) {
m_resource->error(ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, (uint64_t)m_attrs->offsets.at(i),
(uint64_t)m_attrs->strides.at(i), m_attrs->size.y, (uint64_t)m_attrs->offsets.at(i) + (uint64_t)m_attrs->strides.at(i)));
std::format("size overflow on plane {}: offset {} + stride {} * height {} = {}, overflows UINT32_MAX", i, sc<uint64_t>(m_attrs->offsets.at(i)),
sc<uint64_t>(m_attrs->strides.at(i)), m_attrs->size.y, sc<uint64_t>(m_attrs->offsets.at(i)) + sc<uint64_t>(m_attrs->strides.at(i))));
return false;
}
}
@ -311,11 +311,11 @@ bool CLinuxDMABUFFeedbackResource::good() {
void CLinuxDMABUFFeedbackResource::sendTranche(SDMABUFTranche& tranche) {
struct wl_array deviceArr = {
.size = sizeof(tranche.device),
.data = (void*)&tranche.device,
.data = sc<void*>(&tranche.device),
};
m_resource->sendTrancheTargetDevice(&deviceArr);
m_resource->sendTrancheFlags((zwpLinuxDmabufFeedbackV1TrancheFlags)tranche.flags);
m_resource->sendTrancheFlags(sc<zwpLinuxDmabufFeedbackV1TrancheFlags>(tranche.flags));
wl_array indices = {
.size = tranche.indices.size() * sizeof(tranche.indices.at(0)),
@ -332,7 +332,7 @@ void CLinuxDMABUFFeedbackResource::sendDefaultFeedback() {
struct wl_array deviceArr = {
.size = sizeof(mainDevice),
.data = (void*)&mainDevice,
.data = sc<void*>(&mainDevice),
};
m_resource->sendMainDevice(&deviceArr);
@ -577,7 +577,7 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
struct wl_array deviceArr = {
.size = sizeof(m_mainDevice),
.data = (void*)&m_mainDevice,
.data = sc<void*>(&m_mainDevice),
};
feedbackResource->m_resource->sendMainDevice(&deviceArr);

View file

@ -480,7 +480,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
}
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_CUSTOM_MODE;
m_state.customMode = {{w, h}, (uint32_t)refresh};
m_state.customMode = {{w, h}, sc<uint32_t>(refresh)};
LOGM(LOG, " | configHead for {}: set custom mode to {}x{}@{}", m_monitor->m_name, w, h, refresh);
});
@ -519,7 +519,7 @@ COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHe
}
m_state.committedProperties |= OUTPUT_HEAD_COMMITTED_TRANSFORM;
m_state.transform = (wl_output_transform)transform;
m_state.transform = sc<wl_output_transform>(transform);
LOGM(LOG, " | configHead for {}: set transform to {}", m_monitor->m_name, transform);
});

View file

@ -65,8 +65,8 @@ void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const T
tv_sec = TIMESPEC.tv_sec >> 32;
if (data->m_wasPresented)
m_resource->sendPresented((uint32_t)tv_sec, (uint32_t)(TIMESPEC.tv_sec & 0xFFFFFFFF), (uint32_t)(TIMESPEC.tv_nsec), untilRefreshNs, (uint32_t)(seq >> 32),
(uint32_t)(seq & 0xFFFFFFFF), (wpPresentationFeedbackKind)flags);
m_resource->sendPresented(sc<uint32_t>(tv_sec), sc<uint32_t>(TIMESPEC.tv_sec & 0xFFFFFFFF), sc<uint32_t>(TIMESPEC.tv_nsec), untilRefreshNs, sc<uint32_t>(seq >> 32),
sc<uint32_t>(seq & 0xFFFFFFFF), sc<wpPresentationFeedbackKind>(flags));
else
m_resource->sendDiscarded();

View file

@ -66,7 +66,7 @@ CPrimarySelectionSource::~CPrimarySelectionSource() {
}
SP<CPrimarySelectionSource> CPrimarySelectionSource::fromResource(wl_resource* res) {
auto data = (CPrimarySelectionSource*)(((CZwpPrimarySelectionSourceV1*)wl_resource_get_user_data(res))->data());
auto data = sc<CPrimarySelectionSource*>(sc<CZwpPrimarySelectionSourceV1*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}

View file

@ -63,7 +63,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t
m_dmabufFormat = m_monitor->m_output->state->state().drmFormat;
if (box_.width == 0 && box_.height == 0)
m_box = {0, 0, (int)(m_monitor->m_size.x), (int)(m_monitor->m_size.y)};
m_box = {0, 0, sc<int>(m_monitor->m_size.x), sc<int>(m_monitor->m_size.y)};
else
m_box = box_;
@ -133,7 +133,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
PROTO::screencopy->destroyResource(this);
return;
} else if ((int)attrs.stride != m_shmStride) {
} else if (attrs.stride != m_shmStride) {
LOGM(ERR, "Invalid buffer shm stride in {:x}", (uintptr_t)pFrame);
m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
PROTO::screencopy->destroyResource(this);
@ -172,7 +172,7 @@ void CScreencopyFrame::share() {
return;
}
m_resource->sendFlags((zwlrScreencopyFrameV1Flags)0);
m_resource->sendFlags(sc<zwlrScreencopyFrameV1Flags>(0));
if (m_withDamage) {
// TODO: add a damage ring for this.
m_resource->sendDamage(0, 0, m_buffer->size.x, m_buffer->size.y);
@ -377,12 +377,12 @@ bool CScreencopyFrame::copyShm() {
// This could be optimized by using a pixel buffer object to make this async,
// but really clients should just use a dma buffer anyways.
if (packStride == (uint32_t)shm.stride) {
if (packStride == sc<uint32_t>(shm.stride)) {
glReadPixels(0, 0, m_box.w, m_box.h, glFormat, PFORMAT->glType, pixelData);
} else {
for (size_t i = 0; i < m_box.h; ++i) {
uint32_t y = i;
glReadPixels(0, y, m_box.w, 1, glFormat, PFORMAT->glType, ((unsigned char*)pixelData) + i * shm.stride);
glReadPixels(0, y, m_box.w, 1, glFormat, PFORMAT->glType, pixelData + i * shm.stride);
}
}
@ -446,11 +446,11 @@ void CScreencopyClient::onTick() {
const bool FRAMEAWAITING = std::ranges::any_of(PROTO::screencopy->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; });
if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner}));
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)});
m_sentScreencast = true;
} else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner}));
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)});
m_sentScreencast = false;
}

View file

@ -4,14 +4,14 @@
using namespace Hyprutils::OS;
static int onListenFdEvent(int fd, uint32_t mask, void* data) {
auto sc = (CSecurityContext*)data;
sc->onListen(mask);
auto secCtx = sc<CSecurityContext*>(data);
secCtx->onListen(mask);
return 0;
}
static int onCloseFdEvent(int fd, uint32_t mask, void* data) {
auto sc = (CSecurityContext*)data;
sc->onClose(mask);
auto secCtx = sc<CSecurityContext*>(data);
secCtx->onClose(mask);
return 0;
}

View file

@ -12,7 +12,7 @@ CSinglePixelBuffer::CSinglePixelBuffer(uint32_t id, wl_client* client, CHyprColo
m_opaque = col_.a >= 1.F;
m_texture = makeShared<CTexture>(DRM_FORMAT_ARGB8888, (uint8_t*)&m_color, 4, Vector2D{1, 1});
m_texture = makeShared<CTexture>(DRM_FORMAT_ARGB8888, rc<uint8_t*>(&m_color), 4, Vector2D{1, 1});
m_resource = CWLBufferResource::create(makeShared<CWlBuffer>(client, 1, id));
@ -50,7 +50,7 @@ Aquamarine::SDMABUFAttrs CSinglePixelBuffer::dmabuf() {
}
std::tuple<uint8_t*, uint32_t, size_t> CSinglePixelBuffer::beginDataPtr(uint32_t flags) {
return {(uint8_t*)&m_color, DRM_FORMAT_ARGB8888, 4};
return {rc<uint8_t*>(&m_color), DRM_FORMAT_ARGB8888, 4};
}
void CSinglePixelBuffer::endDataPtr() {
@ -87,8 +87,8 @@ CSinglePixelBufferManagerResource::CSinglePixelBufferManagerResource(UP<CWpSingl
m_resource->setOnDestroy([this](CWpSinglePixelBufferManagerV1* r) { PROTO::singlePixel->destroyResource(this); });
m_resource->setCreateU32RgbaBuffer([this](CWpSinglePixelBufferManagerV1* res, uint32_t id, uint32_t r, uint32_t g, uint32_t b, uint32_t a) {
CHyprColor color{r / (float)std::numeric_limits<uint32_t>::max(), g / (float)std::numeric_limits<uint32_t>::max(), b / (float)std::numeric_limits<uint32_t>::max(),
a / (float)std::numeric_limits<uint32_t>::max()};
CHyprColor color{r / sc<float>(std::numeric_limits<uint32_t>::max()), g / sc<float>(std::numeric_limits<uint32_t>::max()),
b / sc<float>(std::numeric_limits<uint32_t>::max()), a / sc<float>(std::numeric_limits<uint32_t>::max())};
const auto& RESOURCE = PROTO::singlePixel->m_buffers.emplace_back(makeUnique<CSinglePixelBufferResource>(id, m_resource->client(), color));
if UNLIKELY (!RESOURCE->good()) {

View file

@ -210,7 +210,7 @@ void CTabletToolV2Resource::queueFrame() {
if (m_frameSource)
return;
m_frameSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this);
m_frameSource = wl_event_loop_add_idle(g_pCompositor->m_wlEventLoop, [](void* data) { sc<CTabletToolV2Resource*>(data)->sendFrame(false); }, this);
}
void CTabletToolV2Resource::sendFrame(bool removeSource) {
@ -604,7 +604,7 @@ void CTabletV2Protocol::buttonTool(SP<CTabletTool> tool, uint32_t button, uint32
continue;
auto serial = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(t->m_resource->client()));
t->m_resource->sendButton(serial, button, (zwpTabletToolV2ButtonState)state);
t->m_resource->sendButton(serial, button, sc<zwpTabletToolV2ButtonState>(state));
t->queueFrame();
}
}

View file

@ -37,8 +37,8 @@ CTextInputV1::CTextInputV1(SP<CZwpTextInputV1> resource_) : m_resource(resource_
[this](CZwpTextInputV1* pMgr, const char* text, uint32_t cursor, uint32_t anchor) { m_pendingSurrounding = {true, std::string(text), cursor, anchor}; });
m_resource->setSetContentType([this](CZwpTextInputV1* pMgr, uint32_t hint, uint32_t purpose) {
m_pendingContentType = {true, hint == (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_HINT_DEFAULT ? (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_HINT_NONE : hint,
purpose > (uint32_t)ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD ? hint + 1 : hint};
m_pendingContentType = {true, hint == sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_HINT_DEFAULT) ? sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_HINT_NONE) : hint,
purpose > sc<uint32_t>(ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_PASSWORD) ? hint + 1 : hint};
});
m_resource->setSetCursorRectangle([this](CZwpTextInputV1* pMgr, int32_t x, int32_t y, int32_t width, int32_t height) { m_cursorRectangle = CBox{x, y, width, height}; });

View file

@ -60,11 +60,11 @@ void CToplevelExportClient::onTick() {
const bool FRAMEAWAITING = std::ranges::any_of(PROTO::toplevelExport->m_frames, [&](const auto& frame) { return frame->m_client.get() == this; });
if (m_framesInLastHalfSecond > 3 && !m_sentScreencast) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner}));
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{1, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "1," + std::to_string(m_clientOwner)});
m_sentScreencast = true;
} else if (m_framesInLastHalfSecond < 4 && m_sentScreencast && LASTFRAMEDELTA > 1.0 && !FRAMEAWAITING) {
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, (uint64_t)m_framesInLastHalfSecond, (uint64_t)m_clientOwner}));
EMIT_HOOK_EVENT("screencast", (std::vector<uint64_t>{0, sc<uint64_t>(m_framesInLastHalfSecond), sc<uint64_t>(m_clientOwner)}));
g_pEventManager->postEvent(SHyprIPCEvent{"screencast", "0," + std::to_string(m_clientOwner)});
m_sentScreencast = false;
}
@ -116,7 +116,7 @@ CToplevelExportFrame::CToplevelExportFrame(SP<CHyprlandToplevelExportFrameV1> re
m_dmabufFormat = PMONITOR->m_output->state->state().drmFormat;
m_box = {0, 0, (int)(m_window->m_realSize->value().x * PMONITOR->m_scale), (int)(m_window->m_realSize->value().y * PMONITOR->m_scale)};
m_box = {0, 0, sc<int>(m_window->m_realSize->value().x * PMONITOR->m_scale), sc<int>(m_window->m_realSize->value().y * PMONITOR->m_scale)};
m_box.transform(wlTransformToHyprutils(PMONITOR->m_transform), PMONITOR->m_transformedSize.x, PMONITOR->m_transformedSize.y).round();
@ -180,7 +180,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou
m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
PROTO::toplevelExport->destroyResource(this);
return;
} else if ((int)attrs.stride != m_shmStride) {
} else if (attrs.stride != m_shmStride) {
m_resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
PROTO::toplevelExport->destroyResource(this);
return;
@ -217,7 +217,7 @@ void CToplevelExportFrame::share() {
}
}
m_resource->sendFlags((hyprlandToplevelExportFrameV1Flags)0);
m_resource->sendFlags(sc<hyprlandToplevelExportFrameV1Flags>(0));
if (!m_ignoreDamage)
m_resource->sendDamage(0, 0, m_box.width, m_box.height);

View file

@ -29,7 +29,7 @@ CToplevelMappingManager::CToplevelMappingManager(SP<CHyprlandToplevelMappingMana
if (!WINDOW)
NEWHANDLE->m_resource->sendFailed();
else
NEWHANDLE->m_resource->sendWindowAddress((uint64_t)WINDOW.get() >> 32 & 0xFFFFFFFF, (uint64_t)WINDOW.get() & 0xFFFFFFFF);
NEWHANDLE->m_resource->sendWindowAddress(rc<uint64_t>(WINDOW.get()) >> 32 & 0xFFFFFFFF, rc<uint64_t>(WINDOW.get()) & 0xFFFFFFFF);
});
m_resource->setGetWindowForToplevelWlr([this](CHyprlandToplevelMappingManagerV1* mgr, uint32_t handle, wl_resource* toplevel) {
const auto NEWHANDLE = PROTO::toplevelMapping->m_handles.emplace_back(
@ -48,7 +48,7 @@ CToplevelMappingManager::CToplevelMappingManager(SP<CHyprlandToplevelMappingMana
if (!WINDOW)
NEWHANDLE->m_resource->sendFailed();
else
NEWHANDLE->m_resource->sendWindowAddress((uint64_t)WINDOW.get() >> 32 & 0xFFFFFFFF, (uint64_t)WINDOW.get() & 0xFFFFFFFF);
NEWHANDLE->m_resource->sendWindowAddress(rc<uint64_t>(WINDOW.get()) >> 32 & 0xFFFFFFFF, rc<uint64_t>(WINDOW.get()) & 0xFFFFFFFF);
});
}

View file

@ -47,7 +47,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
m_events.key.emit(IKeyboard::SKeyEvent{
.timeMs = timeMs,
.keycode = key,
.state = (wl_keyboard_key_state)state,
.state = sc<wl_keyboard_key_state>(state),
});
const bool CONTAINS = std::ranges::contains(m_pressed, key);
@ -88,7 +88,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
return;
}
auto xkbKeymap = xkb_keymap_new_from_string(xkbContext, (const char*)keymapData, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
auto xkbKeymap = xkb_keymap_new_from_string(xkbContext, sc<const char*>(keymapData), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
munmap(keymapData, len);
if UNLIKELY (!xkbKeymap) {

View file

@ -29,7 +29,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.warp.emit(IPointer::SMotionAbsoluteEvent{
.timeMs = timeMs,
.absolute = {(double)x / xExtent, (double)y / yExtent},
.absolute = {sc<double>(x) / xExtent, sc<double>(y) / yExtent},
});
});
@ -37,7 +37,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.button.emit(IPointer::SButtonEvent{
.timeMs = timeMs,
.button = button,
.state = (wl_pointer_button_state)state,
.state = sc<wl_pointer_button_state>(state),
});
});
@ -48,7 +48,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
}
m_axis = axis_;
m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = (wl_pointer_axis)m_axis, .delta = wl_fixed_to_double(value)};
m_axisEvents[m_axis] = IPointer::SAxisEvent{.timeMs = timeMs, .axis = sc<wl_pointer_axis>(m_axis), .delta = wl_fixed_to_double(value)};
});
m_resource->setFrame([this](CZwlrVirtualPointerV1* r) {
@ -62,7 +62,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_events.frame.emit();
});
m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = (wl_pointer_axis_source)source; });
m_resource->setAxisSource([this](CZwlrVirtualPointerV1* r, uint32_t source) { m_axisEvents[m_axis].source = sc<wl_pointer_axis_source>(source); });
m_resource->setAxisStop([this](CZwlrVirtualPointerV1* r, uint32_t timeMs, uint32_t axis_) {
if UNLIKELY (m_axis > WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
@ -72,7 +72,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_axis = axis_;
m_axisEvents[m_axis].timeMs = timeMs;
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis;
m_axisEvents[m_axis].axis = sc<wl_pointer_axis>(m_axis);
m_axisEvents[m_axis].delta = 0;
m_axisEvents[m_axis].deltaDiscrete = 0;
});
@ -85,7 +85,7 @@ CVirtualPointerV1Resource::CVirtualPointerV1Resource(SP<CZwlrVirtualPointerV1> r
m_axis = axis_;
m_axisEvents[m_axis].timeMs = timeMs;
m_axisEvents[m_axis].axis = (wl_pointer_axis)m_axis;
m_axisEvents[m_axis].axis = sc<wl_pointer_axis>(m_axis);
m_axisEvents[m_axis].delta = wl_fixed_to_double(value);
m_axisEvents[m_axis].deltaDiscrete = discrete * 120;
});

View file

@ -2,7 +2,7 @@
#include "../Compositor.hpp"
static void bindManagerInternal(wl_client* client, void* data, uint32_t ver, uint32_t id) {
((IWaylandProtocol*)data)->bindManager(client, data, ver, id);
sc<IWaylandProtocol*>(data)->bindManager(client, data, ver, id);
}
static void displayDestroyInternal(struct wl_listener* listener, void* data) {

View file

@ -37,7 +37,7 @@ CXDGSystemBellManagerResource::CXDGSystemBellManagerResource(UP<CXdgSystemBellV1
if (w->m_wlSurface->resource() == SURFACE) {
g_pEventManager->postEvent(SHyprIPCEvent{
.event = "bell",
.data = std::format("{:x}", (uintptr_t)w.get()),
.data = std::format("{:x}", rc<uintptr_t>(w.get())),
});
return;
}

View file

@ -99,7 +99,7 @@ Vector2D CXDGPopupResource::accumulateParentOffset() {
}
SP<CXDGPopupResource> CXDGPopupResource::fromResource(wl_resource* res) {
auto data = (CXDGPopupResource*)(((CXdgPopup*)wl_resource_get_user_data(res))->data());
auto data = sc<CXDGPopupResource*>(sc<CXdgPopup*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -146,9 +146,9 @@ CXDGToplevelResource::CXDGToplevelResource(SP<CXdgToplevel> resource_, SP<CXDGSu
if (m_resource->version() >= 5) {
wl_array arr;
wl_array_init(&arr);
auto p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t));
auto p = sc<uint32_t*>(wl_array_add(&arr, sizeof(uint32_t)));
*p = XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN;
p = (uint32_t*)wl_array_add(&arr, sizeof(uint32_t));
p = sc<uint32_t*>(wl_array_add(&arr, sizeof(uint32_t)));
*p = XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE;
m_resource->sendWmCapabilities(&arr);
wl_array_release(&arr);
@ -239,7 +239,7 @@ CXDGToplevelResource::~CXDGToplevelResource() {
}
SP<CXDGToplevelResource> CXDGToplevelResource::fromResource(wl_resource* res) {
auto data = (CXDGToplevelResource*)(((CXdgToplevel*)wl_resource_get_user_data(res))->data());
auto data = sc<CXDGToplevelResource*>(sc<CXdgToplevel*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -491,12 +491,12 @@ bool CXDGSurfaceResource::good() {
}
SP<CXDGSurfaceResource> CXDGSurfaceResource::fromResource(wl_resource* res) {
auto data = (CXDGSurfaceResource*)(((CXdgSurface*)wl_resource_get_user_data(res))->data());
auto data = sc<CXDGSurfaceResource*>(sc<CXdgSurface*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
static void onConfigure(void* data) {
((CXDGSurfaceResource*)data)->configure();
sc<CXDGSurfaceResource*>(data)->configure();
}
uint32_t CXDGSurfaceResource::scheduleConfigure() {
@ -547,14 +547,14 @@ CXDGPositionerResource::CXDGPositionerResource(SP<CXdgPositioner> resource_, SP<
m_resource->setSetGravity([this](CXdgPositioner* r, xdgPositionerGravity g) { m_state.setGravity(g); });
m_resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { m_state.constraintAdjustment = (uint32_t)a; });
m_resource->setSetConstraintAdjustment([this](CXdgPositioner* r, xdgPositionerConstraintAdjustment a) { m_state.constraintAdjustment = sc<uint32_t>(a); });
// TODO: support this shit better. The current impl _works_, but is lacking and could be wrong in a few cases.
// doesn't matter _that_ much for now, though.
}
SP<CXDGPositionerResource> CXDGPositionerResource::fromResource(wl_resource* res) {
auto data = (CXDGPositionerResource*)(((CXdgPositioner*)wl_resource_get_user_data(res))->data());
auto data = sc<CXDGPositionerResource*>(sc<CXdgPositioner*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}

View file

@ -18,7 +18,7 @@ CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resour
m_client = m_resource->client();
m_resource->setSetSerial([this](CXwaylandSurfaceV1* r, uint32_t lo, uint32_t hi) {
m_serial = (((uint64_t)hi) << 32) + lo;
m_serial = (sc<uint64_t>(hi) << 32) + lo;
PROTO::xwaylandShell->m_events.newSurface.emit(m_self.lock());
});
}

View file

@ -28,7 +28,7 @@ static wpColorManagerV1TransferFunction getWPTransferFunction(xxColorManagerV4Tr
}
static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primaries) {
return (wpColorManagerV1Primaries)(primaries + 1);
return sc<wpColorManagerV1Primaries>(primaries + 1);
}
CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) {
@ -235,7 +235,7 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
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);
const auto PO = sc<CXxImageDescriptionV4*>(wl_resource_get_user_data(image_description));
if (!PO) { // FIXME check validity
r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description creation failed");
return;
@ -425,7 +425,7 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return;
}
m_settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf));
m_settings.transferFunction = convertTransferFunction(getWPTransferFunction(sc<xxColorManagerV4TransferFunction>(tf)));
m_valuesSet |= PC_TF;
});
m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) {
@ -455,7 +455,7 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI
case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3:
case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB:
m_settings.primariesNameSet = true;
m_settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries));
m_settings.primariesNamed = convertPrimaries(getWPPrimaries(sc<xxColorManagerV4Primaries>(primaries)));
m_settings.primaries = getPrimaries(m_settings.primariesNamed);
m_valuesSet |= PC_PRIMARIES;
break;
@ -585,7 +585,7 @@ CXXColorManagementImageDescriptionInfo::CXXColorManagementImageDescriptionInfo(S
m_client = m_resource->client();
const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); };
const auto toProto = [](float value) { return sc<int32_t>(std::round(value * 10000)); };
if (m_settings.icc.fd >= 0)
m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);

View file

@ -57,7 +57,7 @@ bool CWLRegionResource::good() {
}
SP<CWLRegionResource> CWLRegionResource::fromResource(wl_resource* res) {
auto data = (CWLRegionResource*)(((CWlRegion*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLRegionResource*>(sc<CWlRegion*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -167,7 +167,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
whenReadable();
} else if (state->buffer->type() == Aquamarine::BUFFER_TYPE_DMABUF && state->buffer->dmabuf().success) {
// async buffer and is dmabuf, then we can wait on implicit fences
auto syncFd = dynamic_cast<CDMABuffer*>(state->buffer.m_buffer.get())->exportSyncFile();
auto syncFd = dc<CDMABuffer*>(state->buffer.m_buffer.get())->exportSyncFile();
if (syncFd.isValid())
g_pEventLoopManager->doOnReadable(std::move(syncFd), whenReadable);
@ -211,7 +211,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP<CWlSurface> resource_) : m_resource(re
m_pending.updated.bits.transform = true;
m_pending.updated.bits.damage = true;
m_pending.transform = (wl_output_transform)tr;
m_pending.transform = sc<wl_output_transform>(tr);
m_pending.bufferDamage = CBox{{}, m_pending.bufferSize};
});
@ -270,7 +270,7 @@ void CWLSurfaceResource::dropCurrentBuffer() {
}
SP<CWLSurfaceResource> CWLSurfaceResource::fromResource(wl_resource* res) {
auto data = (CWLSurfaceResource*)(((CWlSurface*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLSurfaceResource*>(sc<CWlSurface*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -379,7 +379,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> const& nod
for (auto const& n : nodes) {
Vector2D offset = {};
if (n->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)n->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(n->m_role.get())->m_subsurface.lock();
offset = subsurface->posRelativeToParent();
}
@ -491,7 +491,7 @@ CBox CWLSurfaceResource::extends() {
if (surf->m_role->role() != SURFACE_ROLE_SUBSURFACE)
return;
((CRegion*)d)->add(CBox{offset, surf->m_current.size});
sc<CRegion*>(d)->add(CBox{offset, surf->m_current.size});
},
&full);
return full.getExtents();
@ -515,7 +515,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
m_current.texture->m_transform = wlTransformToHyprutils(m_current.transform);
if (m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(m_role.get())->m_subsurface.lock();
if (subsurface->m_sync)
return;
@ -525,7 +525,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
breadthfirst(
[](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) {
if (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)surf->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(surf->m_role.get())->m_subsurface.lock();
if (!subsurface->m_sync)
return;
}
@ -543,7 +543,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
auto parent = m_self;
if (parent->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)parent->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(parent->m_role.get())->m_subsurface.lock();
parent = subsurface->t1Parent();
}
WP<CMonitor> monitor;
@ -611,7 +611,7 @@ void CWLSurfaceResource::updateCursorShm(CRegion damage) {
// bpp is 32 INSALLAH
auto begin = 4 * box.y1 * (box.x2 - box.x1) + box.x1;
auto len = 4 * (box.x2 - box.x1);
memcpy((uint8_t*)shmData.data() + begin, (uint8_t*)pixelData + begin, len);
memcpy(shmData.data() + begin, pixelData + begin, len);
}
});
}

View file

@ -157,7 +157,7 @@ CWLDataSourceResource::~CWLDataSourceResource() {
}
SP<CWLDataSourceResource> CWLDataSourceResource::fromResource(wl_resource* res) {
auto data = (CWLDataSourceResource*)(((CWlDataSource*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLDataSourceResource*>(sc<CWlDataSource*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}

View file

@ -51,7 +51,7 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito
}
SP<CWLOutputResource> CWLOutputResource::fromResource(wl_resource* res) {
auto data = (CWLOutputResource*)(((CWlOutput*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLOutputResource*>(sc<CWlOutput*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}
@ -74,10 +74,10 @@ void CWLOutputResource::updateState() {
if (m_resource->version() >= 2)
m_resource->sendScale(std::ceil(m_monitor->m_scale));
m_resource->sendMode((wl_output_mode)(WL_OUTPUT_MODE_CURRENT), m_monitor->m_pixelSize.x, m_monitor->m_pixelSize.y, m_monitor->m_refreshRate * 1000.0);
m_resource->sendMode(WL_OUTPUT_MODE_CURRENT, m_monitor->m_pixelSize.x, m_monitor->m_pixelSize.y, m_monitor->m_refreshRate * 1000.0);
m_resource->sendGeometry(0, 0, m_monitor->m_output->physicalSize.x, m_monitor->m_output->physicalSize.y, (wl_output_subpixel)m_monitor->m_output->subpixel,
m_monitor->m_output->make.c_str(), m_monitor->m_output->model.c_str(), m_monitor->m_transform);
m_resource->sendGeometry(0, 0, m_monitor->m_output->physicalSize.x, m_monitor->m_output->physicalSize.y, m_monitor->m_output->subpixel, m_monitor->m_output->make.c_str(),
m_monitor->m_output->model.c_str(), m_monitor->m_transform);
if (m_resource->version() >= 2)
m_resource->sendDone();

View file

@ -473,7 +473,7 @@ void CWLSeatResource::sendCapabilities(uint32_t caps) {
if (caps & eHIDCapabilityType::HID_INPUT_CAPABILITY_TOUCH)
wlCaps |= WL_SEAT_CAPABILITY_TOUCH;
m_resource->sendCapabilities((wl_seat_capability)wlCaps);
m_resource->sendCapabilities(sc<wl_seat_capability>(wlCaps));
}
bool CWLSeatResource::good() {
@ -561,6 +561,6 @@ SP<CWLSeatResource> CWLSeatProtocol::seatResourceForClient(wl_client* client) {
std::vector<uint8_t>& CCursorSurfaceRole::cursorPixelData(SP<CWLSurfaceResource> surface) {
RASSERT(surface->m_role->role() == SURFACE_ROLE_CURSOR, "cursorPixelData called on a non-cursor surface");
auto role = (CCursorSurfaceRole*)surface->m_role.get();
auto role = sc<CCursorSurfaceRole*>(surface->m_role.get());
return role->m_cursorShmPixelData;
}

View file

@ -59,7 +59,7 @@ Aquamarine::SSHMAttrs CWLSHMBuffer::shm() {
}
std::tuple<uint8_t*, uint32_t, size_t> CWLSHMBuffer::beginDataPtr(uint32_t flags) {
return {(uint8_t*)m_pool->m_data + m_offset, m_fmt, m_stride * size.y};
return {sc<uint8_t*>(m_pool->m_data) + m_offset, m_fmt, m_stride * size.y};
}
void CWLSHMBuffer::endDataPtr() {
@ -101,7 +101,7 @@ static int shmIsSizeValid(CFileDescriptor& fd, size_t size) {
return 0;
}
return (size_t)st.st_size >= size;
return sc<size_t>(st.st_size) >= size;
}
CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor fd_, size_t size_) : m_resource(resource_) {
@ -119,7 +119,7 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
m_resource->setOnDestroy([this](CWlShmPool* r) { PROTO::shm->destroyResource(this); });
m_resource->setResize([this](CWlShmPool* r, int32_t size_) {
if UNLIKELY (size_ < (int32_t)m_pool->m_size) {
if UNLIKELY (size_ < sc<int32_t>(m_pool->m_size)) {
r->error(-1, "Shrinking a shm pool is illegal");
return;
}
@ -188,7 +188,7 @@ CWLSHMResource::CWLSHMResource(SP<CWlShm> resource_) : m_resource(resource_) {
// send a few supported formats. No need for any other I think?
for (auto const& s : PROTO::shm->m_shmFormats) {
m_resource->sendFormat((wl_shm_format)s);
m_resource->sendFormat(sc<wl_shm_format>(s));
}
}

View file

@ -116,7 +116,7 @@ Vector2D CWLSubsurfaceResource::posRelativeToParent() {
while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(m_parent->m_role.get())->m_subsurface.lock();
pos += subsurface->m_position;
surf = subsurface->m_parent.lock();
}
@ -133,7 +133,7 @@ SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(m_parent->m_role.get())->m_subsurface.lock();
surf = subsurface->m_parent.lock();
}
return surf;
@ -163,7 +163,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
SP<CWLSurfaceResource> t1Parent = nullptr;
if (PARENT->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)PARENT->m_role.get())->m_subsurface.lock();
auto subsurface = sc<CSubsurfaceRole*>(PARENT->m_role.get())->m_subsurface.lock();
t1Parent = subsurface->t1Parent();
} else
t1Parent = PARENT;

View file

@ -2,6 +2,7 @@
#include "color-management-v1.hpp"
#include <hyprgraphics/color/Color.hpp>
#include "../../helpers/memory/Memory.hpp"
#define SDR_MIN_LUMINANCE 0.2
#define SDR_MAX_LUMINANCE 80.0
@ -42,16 +43,16 @@ namespace NColorManagement {
// NOTE should be ok this way. unsupported primaries/tfs must be rejected earlier. supported enum values should be in sync with proto.
// might need a proper switch-case and additional INVALID enum value.
inline wpColorManagerV1Primaries convertPrimaries(ePrimaries primaries) {
return (wpColorManagerV1Primaries)primaries;
return sc<wpColorManagerV1Primaries>(primaries);
}
inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) {
return (ePrimaries)primaries;
return sc<ePrimaries>(primaries);
}
inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) {
return (wpColorManagerV1TransferFunction)tf;
return sc<wpColorManagerV1TransferFunction>(tf);
}
inline eTransferFunction convertTransferFunction(wpColorManagerV1TransferFunction tf) {
return (eTransferFunction)tf;
return sc<eTransferFunction>(tf);
}
using SPCPRimaries = Hyprgraphics::SPCPRimaries;

View file

@ -36,7 +36,7 @@ wl_resource* CWLBufferResource::getResource() {
}
SP<CWLBufferResource> CWLBufferResource::fromResource(wl_resource* res) {
auto data = (CWLBufferResource*)(((CWlBuffer*)wl_resource_get_user_data(res))->data());
auto data = sc<CWLBufferResource*>(sc<CWlBuffer*>(wl_resource_get_user_data(res))->data());
return data ? data->m_self.lock() : nullptr;
}