diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..ddd9476 --- /dev/null +++ b/.clangd @@ -0,0 +1,5 @@ +CompileFlags: + Remove: + # GCC-only flags from the system's default spec that clang/clangd cannot + # parse. They appear in compile_commands.json but are not set by the project. + - -mno-direct-extern-access diff --git a/CMakeLists.txt b/CMakeLists.txt index fc9f50a..b091ec4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,10 +61,12 @@ set(CMAKE_INSTALL_MESSAGE NEVER) add_compile_options( -Wall -Wextra -Wpedantic -Wshadow -Wconversion - -Wold-style-cast -Wnull-dereference -Wdouble-promotion - -Wformat=2 -Wfloat-equal -Woverloaded-virtual + -Wnull-dereference -Wdouble-promotion + -Wformat=2 -Wfloat-equal -Wsign-conversion -Wredundant-decls -Wswitch -Wunreachable-code + $<$:-Wold-style-cast> + $<$:-Woverloaded-virtual> ) @@ -188,4 +190,11 @@ if("m3shapes" IN_LIST ENABLE_MODULES) if(TARGET m3shapesplugin) set_target_properties(m3shapesplugin PROPERTIES INSTALL_RPATH "$ORIGIN") endif() + + # Silence warnings that come from m3shapes files we do not manage. + foreach(m3shapes_target m3shapes_core m3shapes_morph m3shapes_shapes m3shapes m3shapesplugin) + if(TARGET ${m3shapes_target}) + target_compile_options(${m3shapes_target} PRIVATE -Wno-shadow -Wno-float-equal) + endif() + endforeach() endif() diff --git a/Plugins/ZShell/Blobs/blobrect.hpp b/Plugins/ZShell/Blobs/blobrect.hpp index 68df1c3..967e339 100644 --- a/Plugins/ZShell/Blobs/blobrect.hpp +++ b/Plugins/ZShell/Blobs/blobrect.hpp @@ -50,9 +50,9 @@ class BlobRect : public BlobShape { [[nodiscard]] qreal damping() const { return m_damping; } - void setDamping(qreal d) { - if (!qFuzzyCompare(m_damping, d)) { - m_damping = d; + void setDamping(qreal value) { + if (!qFuzzyCompare(m_damping, value)) { + m_damping = value; emit dampingChanged(); } } @@ -110,7 +110,6 @@ class BlobRect : public BlobShape { void checkAtRest(float speed); void beginRetire(); - // Physics state QPointF m_prevScenePos; QElapsedTimer m_elapsed; bool m_physicsActive = false; @@ -122,13 +121,10 @@ class BlobRect : public BlobShape { float m_retire01 = 0.0f; float m_retire11 = 1.0f; - // Symmetric 2x2 deformation matrix components (3 independent: m00, m01, - // m11) Rest state is identity: m00=1, m01=0, m11=1 float m_dm00 = 1.0f; float m_dm01 = 0.0f; float m_dm11 = 1.0f; - // Spring velocities for each component float m_dmVel00 = 0.0f; float m_dmVel01 = 0.0f; float m_dmVel11 = 0.0f; diff --git a/Plugins/ZShell/Blobs/blobshape.cpp b/Plugins/ZShell/Blobs/blobshape.cpp index e33b2f3..c73d02c 100644 --- a/Plugins/ZShell/Blobs/blobshape.cpp +++ b/Plugins/ZShell/Blobs/blobshape.cpp @@ -168,10 +168,6 @@ void BlobShape::updatePolish() { if (other->width() <= 0 || other->height() <= 0) continue; - // Excluded shapes stay in the rect data. Exclusion only gates the smooth - // blend (via excludeMask below); ownership must still see every shape, - // otherwise two nodes can both believe they own a pixel and the pixel is - // blended twice. const QPointF otherScene = other->mapToScene(QPointF(0, 0)); bool include = false; @@ -196,7 +192,7 @@ void BlobShape::updatePolish() { const QMatrix4x4& dm = other->m_deformMatrix; const float a = dm(0, 0), b = dm(1, 0); - const float c = dm(0, 1), d = dm(1, 1); + const float c = dm(0, 1), e = dm(1, 1); BlobRectData r; r.cx = static_cast(otherScene.x() + other->width() / 2.0); @@ -207,19 +203,19 @@ void BlobShape::updatePolish() { r.offsetX = dm(0, 3); r.offsetY = dm(1, 3); - const float det = a * d - c * b; + const float det = a * e - c * b; const float invDet = std::abs(det) > 1e-6f ? 1.0f / det : 1.0f; - r.invDeform[0] = d * invDet; + r.invDeform[0] = e * invDet; r.invDeform[1] = -b * invDet; r.invDeform[2] = -c * invDet; r.invDeform[3] = a * invDet; - const float halfTr = 0.5f * (a + d); - const float halfDiff = 0.5f * (a - d); + const float halfTr = 0.5f * (a + e); + const float halfDiff = 0.5f * (a - e); r.minEig = halfTr - std::sqrt(halfDiff * halfDiff + c * c); r.screenHalfX = std::abs(a) * r.hw + std::abs(c) * r.hh; - r.screenHalfY = std::abs(b) * r.hw + std::abs(d) * r.hh; + r.screenHalfY = std::abs(b) * r.hw + std::abs(e) * r.hh; m_cachedRects.append(r); rectShapes.append(other); diff --git a/Plugins/ZShell/Components/carouselview.cpp b/Plugins/ZShell/Components/carouselview.cpp index 0a5aa66..da2842a 100644 --- a/Plugins/ZShell/Components/carouselview.cpp +++ b/Plugins/ZShell/Components/carouselview.cpp @@ -187,7 +187,7 @@ void CarouselView::setModel(const QVariantList& m) { emit modelChanged(); - const int newCount = m_model.size(); + const int newCount = static_cast(m_model.size()); if (newCount == 0) { m_currentRealIndex = -1; @@ -647,7 +647,7 @@ qreal CarouselView::sampleSize(qreal childLoc) const { } int CarouselView::realIndexOf(int virtualIndex) const { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0) return -1; @@ -668,7 +668,7 @@ qreal CarouselView::snapTargetX(qreal x) const { } void CarouselView::wrapContentIfNeeded() { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0) return; @@ -707,7 +707,7 @@ void CarouselView::wrapContentIfNeeded() { } void CarouselView::updateCurrentIndexFromContentX(bool emitPreview) { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0) return; @@ -856,8 +856,8 @@ void CarouselView::positionSlot(const Slot& slot) const { return rightIndex == n ? m_arrangement.outerSpacing : m_itemSpacing; }; - const auto leftGap = [this, n](int leftIndex) { - return leftIndex == -n ? m_arrangement.outerSpacing : m_itemSpacing; + const auto leftGap = [this, n](int gapIndex) { + return gapIndex == -n ? m_arrangement.outerSpacing : m_itemSpacing; }; qreal center = 0; @@ -974,7 +974,7 @@ void CarouselView::releaseAllItems() { } void CarouselView::relayout() { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0 || width() <= 0 || m_focalWidth <= 0) { for (Slot& s : m_slots) { @@ -1038,7 +1038,7 @@ void CarouselView::relayout() { m_slots.append(Slot{}); slotUsedThisPass.append(false); - freeSlot = m_slots.size() - 1; + freeSlot = static_cast(m_slots.size()) - 1; } updateSlotContent(m_slots[freeSlot], v); @@ -1092,7 +1092,7 @@ void CarouselView::snapToNearest() { } void CarouselView::goToIndex(int realIndex) { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0) return; @@ -1126,7 +1126,7 @@ void CarouselView::decrementCurrentIndex() { } void CarouselView::centerInstantlyOnReal(int realIndex) { - const int count = m_model.size(); + const int count = static_cast(m_model.size()); if (count == 0) return; @@ -1220,7 +1220,7 @@ qreal CarouselView::sampledVelocity() const { const VelocitySample& oldest = m_velocitySamples.first(); const VelocitySample& newest = m_velocitySamples.last(); - const qreal dt = newest.t - oldest.t; + const qreal dt = static_cast(newest.t - oldest.t); if (dt < 8) return 0; diff --git a/Plugins/ZShell/Components/chatlistview.cpp b/Plugins/ZShell/Components/chatlistview.cpp index 56ff397..90e48bf 100644 --- a/Plugins/ZShell/Components/chatlistview.cpp +++ b/Plugins/ZShell/Components/chatlistview.cpp @@ -252,8 +252,6 @@ int ChatListView::count() const { } bool ChatListView::event(QEvent* e) { - // qDebug() << "ChatListView::event() runs"; - return QQuickItem::event(e); } @@ -366,7 +364,6 @@ void ChatListView::updatePolish() { m_animateY = false; const int layoutSize = static_cast(m_layout.size()); const qint64 now = m_clock.elapsed(); - bool wrote = false; for (auto& entry : m_delegates) { if (!entry.item || entry.pendingRemoval || entry.pendingInsert) continue; @@ -397,7 +394,6 @@ void ChatListView::updatePolish() { entry.item->setY(target); entry.hasPropY = false; } - wrote = true; } applyAnchor(); diff --git a/Plugins/ZShell/Components/sparklinecontent.cpp b/Plugins/ZShell/Components/sparklinecontent.cpp index 8d51704..97b4dd5 100644 --- a/Plugins/ZShell/Components/sparklinecontent.cpp +++ b/Plugins/ZShell/Components/sparklinecontent.cpp @@ -50,8 +50,6 @@ void SparklineContent::setLine2(internal::CircularBuffer* buffer) { void SparklineContent::connectBuffer(internal::CircularBuffer* buffer) { if (!buffer) return; - // New data, or the buffer's own smoothingRadius changed (it re-emits - // valuesChanged in that case too) -> geometry is stale. connect( buffer, &internal::CircularBuffer::valuesChanged, @@ -67,7 +65,7 @@ void SparklineContent::connectBuffer(internal::CircularBuffer* buffer) { void SparklineContent::setLine1Color(const QColor& color) { if (m_line1Color == color) return; m_line1Color = color; - update(); // visual-only, no geometry rebuild needed + update(); } void SparklineContent::setLine2Color(const QColor& color) { @@ -173,7 +171,7 @@ SparklineContent::LineGeometry SparklineContent::buildGeometry( if (m_curveSmoothing && points.size() > 2) { const qreal tension = 1.0; const qreal k = tension / 6.0; - const int n = points.size(); + const int n = static_cast(points.size()); for (int i = 0; i < n - 1; ++i) { const QPointF& p0 = points[qMax(i - 1, 0)]; diff --git a/Plugins/ZShell/Components/sparklinesceneitem.cpp b/Plugins/ZShell/Components/sparklinesceneitem.cpp index 42170e3..eedac27 100644 --- a/Plugins/ZShell/Components/sparklinesceneitem.cpp +++ b/Plugins/ZShell/Components/sparklinesceneitem.cpp @@ -84,7 +84,6 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample( points.reserve(len); for (int i = 0; i < len; ++i) { - // Already smoothed once, incrementally, by the buffer itself. const qreal value = qBound(0.0, buffer->smoothedAt(i), m_maxValue); @@ -99,7 +98,7 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample( if (m_curveSmoothing && points.size() > 2) { const qreal tension = 1.0; const qreal k = tension / 6.0; - const int n = points.size(); + const int n = static_cast(points.size()); for (int i = 0; i < n - 1; ++i) { const QPointF& p0 = points[qMax(i - 1, 0)]; const QPointF& p1 = points[i]; @@ -125,9 +124,6 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample( } } - // Flatten the curve to a polyline once, here, on data change only. - // This is CPU math only -- no QPainter draw calls, no image, no - // texture upload happen as a result of this. const auto subpaths = path.toSubpathPolygons(); if (subpaths.isEmpty()) return sample; @@ -139,7 +135,7 @@ SparklineSceneItem::LineSample SparklineSceneItem::buildSample( void SparklineSceneItem::writeFillGeometry( QSGGeometryNode* node, const LineSample& sample) { - const int n = sample.polyline.size(); + const int n = static_cast(sample.polyline.size()); auto* geometry = node->geometry(); geometry->allocate(n * 2); geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip); @@ -147,8 +143,10 @@ void SparklineSceneItem::writeFillGeometry( auto* vertices = geometry->vertexDataAsPoint2D(); for (int i = 0; i < n; ++i) { const QPointF& p = sample.polyline[i]; - vertices[i * 2].set(p.x(), p.y()); - vertices[i * 2 + 1].set(p.x(), sample.fillBottom); + vertices[i * 2].set( + static_cast(p.x()), static_cast(p.y())); + vertices[i * 2 + 1].set( + static_cast(p.x()), static_cast(sample.fillBottom)); } node->markDirty(QSGNode::DirtyGeometry); @@ -156,7 +154,7 @@ void SparklineSceneItem::writeFillGeometry( void SparklineSceneItem::writeStrokeGeometry( QSGGeometryNode* node, const LineSample& sample, qreal lineWidth) { - const int n = sample.polyline.size(); + const int n = static_cast(sample.polyline.size()); auto* geometry = node->geometry(); geometry->allocate(n * 2); geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip); @@ -179,8 +177,12 @@ void SparklineSceneItem::writeStrokeGeometry( const QPointF& p = sample.polyline[i]; const QPointF offset = normal * half; - vertices[i * 2].set(p.x() + offset.x(), p.y() + offset.y()); - vertices[i * 2 + 1].set(p.x() - offset.x(), p.y() - offset.y()); + vertices[i * 2].set( + static_cast(p.x() + offset.x()), + static_cast(p.y() + offset.y())); + vertices[i * 2 + 1].set( + static_cast(p.x() - offset.x()), + static_cast(p.y() - offset.y())); } node->markDirty(QSGNode::DirtyGeometry); @@ -243,7 +245,7 @@ QSGNode* SparklineSceneItem::updatePaintNode( } QMatrix4x4 matrix; - matrix.translate(-stepX() * m_slideProgress, 0); + matrix.translate(static_cast(-stepX() * m_slideProgress), 0.0f); transformNode->setMatrix(matrix); const bool needsGeometryWrite = samplesRebuilt || justCreated; diff --git a/Plugins/ZShell/Components/wavyline.hpp b/Plugins/ZShell/Components/wavyline.hpp index 5ce3b8e..4025664 100644 --- a/Plugins/ZShell/Components/wavyline.hpp +++ b/Plugins/ZShell/Components/wavyline.hpp @@ -85,7 +85,7 @@ class WavyLine : public QCanvasPainterItem { [[nodiscard]] qreal value() const; void setValue(qreal value); -signals: + signals: void lineWidthChanged(); void amplitudeMultiplierChanged(); void frequencyChanged(); diff --git a/Plugins/ZShell/HyprPlugins/main.cpp b/Plugins/ZShell/HyprPlugins/main.cpp index 39953e9..8e8f2e4 100644 --- a/Plugins/ZShell/HyprPlugins/main.cpp +++ b/Plugins/ZShell/HyprPlugins/main.cpp @@ -37,12 +37,10 @@ static std::filesystem::path g_runtimeDir{"/tmp"}; static std::filesystem::path g_cacheBase{"/tmp/.cache"}; static void initEnvPaths() { - if (const char* env = getenv("XDG_RUNTIME_DIR")) - g_runtimeDir = env; + if (const char* env = getenv("XDG_RUNTIME_DIR")) g_runtimeDir = env; if (const char* env = getenv("XDG_CACHE_HOME")) { - if (*env) - g_cacheBase = env; + if (*env) g_cacheBase = env; } else if (const char* home = getenv("HOME")) { g_cacheBase = std::filesystem::path(home) / ".cache"; } @@ -50,8 +48,7 @@ static void initEnvPaths() { static std::ofstream& debugLog() { static std::ofstream log( - g_runtimeDir / "zshell-nightlight-debug.log", - std::ios::app); + g_runtimeDir / "zshell-nightlight-debug.log", std::ios::app); return log; } @@ -173,15 +170,14 @@ static bool hkSaveBufferForMirror(CHyprOpenGLImpl* thisptr, const CBox& box) { static void installShader() { auto* gl = g_pHyprOpenGL.get(); - if (!gl) - return; + if (!gl) return; ensureShaderFile(shaderPath(), defaultShaderSource()); gl->applyScreenShader(shaderPath().string()); auto* shader = gl->m_finalScreenShader.get(); if (shader && shader->program() >= 1 && - shader->getUniformLocation(SHADER_TINT) != -1) { + shader->getUniformLocation(SHADER_TINT) != -1) { g_uniformMode = true; } else { g_uniformMode = false; @@ -196,8 +192,7 @@ static void installShader() { static void setUniformGain(const std::array& gain) { auto* gl = g_pHyprOpenGL.get(); auto* shader = gl ? gl->m_finalScreenShader.get() : nullptr; - if (!gl || !shader) - return; + if (!gl || !shader) return; gl->useShader(gl->m_finalScreenShader); shader->setUniformFloat3(SHADER_TINT, gain[0], gain[1], gain[2]); @@ -214,8 +209,7 @@ static void hkBegin( if (fb) { auto* renderer = g_pHyprRenderer.get(); - if (renderer) - renderer->m_renderData.blockScreenShader = true; + if (renderer) renderer->m_renderData.blockScreenShader = true; } if (!g_active) return; @@ -223,17 +217,15 @@ static void hkBegin( auto* gl = g_pHyprOpenGL.get(); if (!gl) return; - if (gl->m_finalScreenShader.get() && - gl->m_finalScreenShader->program() < 1) + if (gl->m_finalScreenShader.get() && gl->m_finalScreenShader->program() < 1) installShader(); if (!gl->m_finalScreenShader.get() || - gl->m_finalScreenShader->program() < 1) + gl->m_finalScreenShader->program() < 1) return; if (g_transition.active) { auto* monPtr = mon.get(); - if (!monPtr) - return; + if (!monPtr) return; const float elapsed = std::chrono::duration( std::chrono::steady_clock::now() - g_transition.start) @@ -255,9 +247,9 @@ static void hkBegin( ensureShaderFile( bakedShaderPath(g_currentGain), bakedShaderSource(g_currentGain)); - gl->applyScreenShader(bakedShaderPath(g_currentGain).string()); + gl->applyScreenShader(bakedShaderPath(g_currentGain).string()); + } } - } if (t >= 1.f) { g_transition.active = false; diff --git a/Plugins/ZShell/Internal/hyprextras.cpp b/Plugins/ZShell/Internal/hyprextras.cpp index fd28611..3baf4dc 100644 --- a/Plugins/ZShell/Internal/hyprextras.cpp +++ b/Plugins/ZShell/Internal/hyprextras.cpp @@ -182,10 +182,10 @@ static QString buildHlConfigCall(const QString& key, const QVariant& value) { } static QColor colorFromInt(quint32 value) { - const int a = (value >> 24) & 0xFF; - const int r = (value >> 16) & 0xFF; - const int g = (value >> 8) & 0xFF; - const int b = value & 0xFF; + const int a = static_cast(value >> 24) & 0xFF; + const int r = static_cast(value >> 16) & 0xFF; + const int g = static_cast(value >> 8) & 0xFF; + const int b = static_cast(value) & 0xFF; return QColor(r, g, b, a); } diff --git a/Plugins/ZShell/Internal/strokecanvasitem.cpp b/Plugins/ZShell/Internal/strokecanvasitem.cpp index dcb7e47..50bc676 100644 --- a/Plugins/ZShell/Internal/strokecanvasitem.cpp +++ b/Plugins/ZShell/Internal/strokecanvasitem.cpp @@ -72,7 +72,7 @@ static QCanvasPath buildStrokePath( void StrokeCanvasItem::undoLastGroup() { if (m_strokes.isEmpty()) return; const int lastGroup = m_strokes.last().groupId; - for (int i = m_strokes.size() - 1; + for (int i = static_cast(m_strokes.size()) - 1; i >= 0 && m_strokes[i].groupId == lastGroup; --i) m_strokes.remove(i); diff --git a/Plugins/ZShell/Internal/strokecanvasrenderer.cpp b/Plugins/ZShell/Internal/strokecanvasrenderer.cpp index c109728..11b2d08 100644 --- a/Plugins/ZShell/Internal/strokecanvasrenderer.cpp +++ b/Plugins/ZShell/Internal/strokecanvasrenderer.cpp @@ -154,7 +154,7 @@ void StrokeCanvasRenderer::synchronizeData(QCanvasPainterItem* item) { for (const auto& stroke : canvas->m_strokes) canvasGroupIds.insert(stroke.groupId); - for (int i = m_strokes.size() - 1; i >= 0; --i) { + for (int i = static_cast(m_strokes.size()) - 1; i >= 0; --i) { if (!canvasGroupIds.contains(m_strokes[i].groupId)) { if (m_strokes[i].groupId >= 0) m_pendingGroupRemovals.append(m_strokes[i].groupId); diff --git a/Plugins/ZShell/Llm/filetool.cpp b/Plugins/ZShell/Llm/filetool.cpp index c58ad82..2e368b9 100644 --- a/Plugins/ZShell/Llm/filetool.cpp +++ b/Plugins/ZShell/Llm/filetool.cpp @@ -119,7 +119,7 @@ void FileReadTool::execute( return; } const QString head = content.left(limit); - const int nextOffset = offset + head.toUtf8().size(); + const int nextOffset = offset + static_cast(head.toUtf8().size()); const QString output = head + QStringLiteral( diff --git a/Plugins/cmake/pch.cmake b/Plugins/cmake/pch.cmake index c5685fb..814d6b0 100644 --- a/Plugins/cmake/pch.cmake +++ b/Plugins/cmake/pch.cmake @@ -1,4 +1,5 @@ add_library(zshell-pch INTERFACE) +target_compile_options(zshell-pch INTERFACE $<$:-Wno-null-dereference>) target_precompile_headers(zshell-pch INTERFACE