Skip to content

Commit

Permalink
Moving it back to github
Browse files Browse the repository at this point in the history
  • Loading branch information
jinliu committed Feb 27, 2024
1 parent 9e9b1d0 commit c6cb720
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# kwin-effect-spotlight
"Find My Mouse" effect "Spotlight"

## Requirements

KDE Plasma 6.0

## Installation

Extract the following package into `/usr/lib/qt6/plugins/`:
Expand Down
4 changes: 2 additions & 2 deletions src/shakedetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::optional<qreal> ShakeDetector::update(QMouseEvent *event)
m_history.erase(m_history.begin(), it);
}

m_history.append(HistoryItem{
m_history.emplace_back(HistoryItem{
.position = event->localPos(),
.timestamp = event->timestamp(),
});
Expand All @@ -56,7 +56,7 @@ std::optional<qreal> ShakeDetector::update(QMouseEvent *event)
qreal bottom = m_history[0].position.y();
qreal distance = 0;

for (int i = 1; i < m_history.size(); ++i) {
for (size_t i = 1; i < m_history.size(); ++i) {
// Compute the length of the mouse path.
const qreal deltaX = m_history.at(i).position.x() - m_history.at(i - 1).position.x();
const qreal deltaY = m_history.at(i).position.y() - m_history.at(i - 1).position.y();
Expand Down
3 changes: 2 additions & 1 deletion src/shakedetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <QMouseEvent>

#include <deque>
#include <optional>

/**
Expand Down Expand Up @@ -37,7 +38,7 @@ class ShakeDetector
quint64 timestamp;
};

QList<HistoryItem> m_history;
std::deque<HistoryItem> m_history;
quint64 m_interval = 1000;
qreal m_sensitivity = 4;
};
10 changes: 6 additions & 4 deletions src/spotlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ void SpotlightEffect::pointerEvent(MouseEvent *event)
}
}

if (m_isActive)
if (m_isActive) {
effects->addRepaintFull();
}
}

void SpotlightEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen)
Expand All @@ -148,12 +149,13 @@ void SpotlightEffect::paintScreen(const RenderTarget &renderTarget, const Render

QPointF center = cursorPos();

if (screen != effects->screenAt(center.toPoint()))
if (screen != effects->screenAt(center.toPoint())) {
return;
}

QRectF screenGeometry = screen->geometry();

//qDebug() << "SpotlightEffect::paintScreen() cursorPos" << center << "screenGeometry" << screenGeometry;
// qDebug() << "SpotlightEffect::paintScreen() cursorPos" << center << "screenGeometry" << screenGeometry;

center -= screenGeometry.topLeft();

Expand All @@ -168,7 +170,7 @@ void SpotlightEffect::paintScreen(const RenderTarget &renderTarget, const Render
shader->setColorspaceUniformsFromSRGB(renderTarget.colorDescription());
QMatrix4x4 mvp = viewport.projectionMatrix();
mvp.translate(fullscreen.x(), fullscreen.y());
shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
shader->setUniform(GLShader::Mat4Uniform::ModelViewProjectionMatrix, mvp);

const bool clipping = region != infiniteRegion();
const QRegion clipRegion = clipping ? viewport.mapToRenderTarget(region) : infiniteRegion();
Expand Down
4 changes: 2 additions & 2 deletions src/spotlightconfig.kcfgc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <[email protected]>
# SPDX-FileCopyrightText: 2024 Jin Liu <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0
# SPDX-License-Identifier: GPL-2.0-or-later

File=spotlightconfig.kcfg
ClassName=SpotlightConfig
Expand Down

0 comments on commit c6cb720

Please sign in to comment.