Add kwin full source tree, greeter login, zsh, pcid service, and build system improvements
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#######################################
|
||||
# Effect
|
||||
|
||||
set(mousemark_SOURCES
|
||||
main.cpp
|
||||
mousemark.cpp
|
||||
)
|
||||
|
||||
kconfig_add_kcfg_files(mousemark_SOURCES
|
||||
mousemarkconfig.kcfgc
|
||||
)
|
||||
|
||||
kwin_add_builtin_effect(mousemark ${mousemark_SOURCES})
|
||||
target_link_libraries(mousemark PRIVATE
|
||||
kwin
|
||||
|
||||
KF6::ConfigGui
|
||||
KF6::GlobalAccel
|
||||
KF6::I18n
|
||||
)
|
||||
|
||||
ecm_qt_declare_logging_category(mousemark
|
||||
HEADER mousemarklogging.h
|
||||
IDENTIFIER KWIN_MOUSEMARK
|
||||
CATEGORY_NAME kwin_effect_mousemark
|
||||
DEFAULT_SEVERITY Warning
|
||||
)
|
||||
|
||||
#######################################
|
||||
# Config
|
||||
if (KWIN_BUILD_KCMS)
|
||||
set(kwin_mousemark_config_SRCS mousemark_config.cpp)
|
||||
ki18n_wrap_ui(kwin_mousemark_config_SRCS mousemark_config.ui)
|
||||
kconfig_add_kcfg_files(kwin_mousemark_config_SRCS mousemarkconfig.kcfgc)
|
||||
|
||||
kwin_add_effect_config(kwin_mousemark_config ${kwin_mousemark_config_SRCS})
|
||||
|
||||
target_link_libraries(kwin_mousemark_config
|
||||
KF6::KCMUtils
|
||||
KF6::CoreAddons
|
||||
KF6::GlobalAccel
|
||||
KF6::I18n
|
||||
KF6::XmlGui
|
||||
KWinEffectsInterface
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
||||
SPDX-FileCopyrightText: 2023 Andrew Shark <ashark at linuxcomp.ru>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "mousemark.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT_FACTORY(MouseMarkEffect,
|
||||
"metadata.json.stripped")
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#include "main.moc"
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"KPlugin": {
|
||||
"Category": "Appearance",
|
||||
"Description": "Allows you to draw lines on the desktop; activated with a keyboard shortcut",
|
||||
"Description[ar]": "يسمح لك برسم خطوط على سطح المكتب، تفعّل باختصار لوحة المفاتيح",
|
||||
"Description[bg]": "Позволява ви да чертаете линии на работния плот, активирано с клавишна комбинация",
|
||||
"Description[ca@valencia]": "Permet dibuixar línies en l'escriptori; activat amb una drecera de teclat",
|
||||
"Description[ca]": "Permet dibuixar línies a l'escriptori; activat amb una drecera de teclat",
|
||||
"Description[da]": "Tillader dig at tegne linjer på skrivebordet; aktiveret med en tastaturgenvej",
|
||||
"Description[de]": "Lässt Sie mit der Maus Linien auf die Arbeitsfläche zeichnen; mit einem Tastatur-Kurzbefehl ausgelöst",
|
||||
"Description[en_GB]": "Allows you to draw lines on the desktop; activated with a keyboard shortcut",
|
||||
"Description[eo]": "Permesas al vi desegni liniojn sur la labortablo; aktivigita per klavara ŝparvojo",
|
||||
"Description[es]": "Le permite dibujar líneas en el escritorio; se activa con un atajo de teclado",
|
||||
"Description[eu]": "Mahaigainean marrak marrazteko aukera ematen dizu; ; teklatuko lasterbide batekin aktibatua",
|
||||
"Description[fi]": "Antaa piirtää viivoja työpöydälle; käynnistyy pikanäppäimellä",
|
||||
"Description[fr]": "Vous permet de tracer des lignes sur le bureau. Activé grâce à un raccourci clavier.",
|
||||
"Description[gl]": "Permítelle debuxar riscos no escritorio; actívase cun atallo de teclado.",
|
||||
"Description[he]": "מאפשר לך לצייר קווים על גבי שולחן העבודה, מופעל דרך צירוף מקשי מקלדת",
|
||||
"Description[hu]": "Lehetővé teszi vonalak rajzolását az asztalon; gyorsbillentyűvel aktiválható",
|
||||
"Description[ia]": "Permitte te designar lineas super le scriptorio; activate con un via breve de claviero",
|
||||
"Description[is]": "Gerir þér kleift að teikna línur á skjáborðið; virkjað með flýtilykli",
|
||||
"Description[it]": "Consente di tracciare linee sul desktop; attivato con una scorciatoia da tastiera",
|
||||
"Description[ka]": "სამუშაო მაგიდაზე ხაზების დახატვის უფლება. აქტიურდება კლავიატურის მალსახმობით",
|
||||
"Description[ko]": "바탕 화면에 선 그리기, 키보드 단축키로 활성화",
|
||||
"Description[lt]": "Leidžia piešti linijas ant darbalaukio; aktyvinama naudojant sparčiuosius klavišus",
|
||||
"Description[lv]": "Ļauj darbvirsmā zīmēt līnijas; ieslēdz ar tastatūras saīsni",
|
||||
"Description[nb]": "lar deg tegne linjer på skjermen – slått av/på med hurtigtast",
|
||||
"Description[nl]": "Laat u lijnen tekenen op het bureaublad; geactiveerd met een sneltoets",
|
||||
"Description[nn]": "La deg teikna linjer på skjermen – slått på/av med snøggtast",
|
||||
"Description[pl]": "Umożliwia rysowanie linii na pulpicie; uruchamiane skrótem klawiszowym",
|
||||
"Description[pt_BR]": "Permite-lhe desenhar linhas na sua área de trabalho; ativado com um atalho de teclado",
|
||||
"Description[sa]": "डेस्कटॉप् मध्ये रेखाः आकर्षितुं शक्नोति; कीबोर्ड-शॉर्टकट्-सहितं सक्रियम्",
|
||||
"Description[sl]": "Omogoča risanje črt na namizju; aktivirano z bližnjico tipkovnice",
|
||||
"Description[sv]": "Låter dig rita linjer på skrivbordet, aktiveras med en snabbtangent",
|
||||
"Description[tr]": "Masaüstünde çizgiler çizmenize izin verir; klavye kısayoluyla etkinleştirilir",
|
||||
"Description[uk]": "Можливість малювання ліній на стільниці; активується клавіатурним скороченням",
|
||||
"Description[x-test]": "xxAllows you to draw lines on the desktop; activated with a keyboard shortcutxx",
|
||||
"Description[zh_CN]": "用于在桌面上绘制线条;使用键盘快捷键激活",
|
||||
"Description[zh_TW]": "讓您能在桌面上畫線——需要用鍵盤快捷鍵觸發",
|
||||
"EnabledByDefault": false,
|
||||
"License": "GPL",
|
||||
"Name": "Mouse Mark",
|
||||
"Name[ar]": "علامة الفأرة",
|
||||
"Name[ast]": "Marca del mur",
|
||||
"Name[az]": "Siçanla rəsmçəkmə",
|
||||
"Name[be]": "Пазначэнне мышшу",
|
||||
"Name[bg]": "Маркиране с мишката",
|
||||
"Name[ca@valencia]": "Marca amb el ratolí",
|
||||
"Name[ca]": "Marca amb el ratolí",
|
||||
"Name[cs]": "Značkovač",
|
||||
"Name[da]": "Musemærke",
|
||||
"Name[de]": "Mausspur",
|
||||
"Name[en_GB]": "Mouse Mark",
|
||||
"Name[eo]": "Muso Marko",
|
||||
"Name[es]": "Marcar con el ratón",
|
||||
"Name[et]": "Hiirejälg",
|
||||
"Name[eu]": "Saguaren arrastoa",
|
||||
"Name[fi]": "Hiiren jäljet",
|
||||
"Name[fr]": "Tracé à la souris",
|
||||
"Name[gl]": "Marca do rato",
|
||||
"Name[he]": "סימון עכבר",
|
||||
"Name[hu]": "Egérnyom",
|
||||
"Name[ia]": "Marca de mus",
|
||||
"Name[id]": "Coretan Mouse",
|
||||
"Name[is]": "Músarmerki",
|
||||
"Name[it]": "Pennarello",
|
||||
"Name[ja]": "マウスマーク",
|
||||
"Name[ka]": "თაგუნას ნიშანი",
|
||||
"Name[ko]": "마우스 자취",
|
||||
"Name[lt]": "Žymėjimas pele",
|
||||
"Name[lv]": "Atzīmēšana ar peli",
|
||||
"Name[nb]": "Muselinjer",
|
||||
"Name[nl]": "Muismarkering",
|
||||
"Name[nn]": "Muselinjer",
|
||||
"Name[pl]": "Znacznik myszy",
|
||||
"Name[pt]": "Marcação com o Rato",
|
||||
"Name[pt_BR]": "Anotar com o mouse",
|
||||
"Name[ro]": "Urme de maus",
|
||||
"Name[ru]": "Рисование мышью",
|
||||
"Name[sa]": "मूषकचिह्न",
|
||||
"Name[sk]": "Stopa myši",
|
||||
"Name[sl]": "Oznaka miške",
|
||||
"Name[sv]": "Markera med musen",
|
||||
"Name[ta]": "சுட்டியை குறி",
|
||||
"Name[tr]": "Fare İmi",
|
||||
"Name[uk]": "Позначки мишкою",
|
||||
"Name[vi]": "Vết chuột",
|
||||
"Name[x-test]": "xxMouse Markxx",
|
||||
"Name[zh_CN]": "鼠标屏幕画线",
|
||||
"Name[zh_TW]": "滑鼠標記"
|
||||
},
|
||||
"X-KDE-ConfigModule": "kwin_mousemark_config"
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
||||
SPDX-FileCopyrightText: 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
|
||||
SPDX-FileCopyrightText: 2023 Andrew Shark <ashark at linuxcomp.ru>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "mousemark.h"
|
||||
#include "mousemarklogging.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "mousemarkconfig.h"
|
||||
|
||||
#include "core/rendertarget.h"
|
||||
#include "core/renderviewport.h"
|
||||
#include "effect/effecthandler.h"
|
||||
#include "opengl/glplatform.h"
|
||||
#include <KGlobalAccel>
|
||||
#include <KLocalizedString>
|
||||
#include <QAction>
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
static consteval QPoint nullPoint()
|
||||
{
|
||||
return QPoint(-1, -1);
|
||||
}
|
||||
|
||||
MouseMarkEffect::MouseMarkEffect()
|
||||
{
|
||||
MouseMarkConfig::instance(effects->config());
|
||||
QAction *a = new QAction(this);
|
||||
a->setObjectName(QStringLiteral("ClearMouseMarks"));
|
||||
a->setText(i18n("Clear All Mouse Marks"));
|
||||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F11));
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F11));
|
||||
connect(a, &QAction::triggered, this, &MouseMarkEffect::clear);
|
||||
a = new QAction(this);
|
||||
a->setObjectName(QStringLiteral("ClearLastMouseMark"));
|
||||
a->setText(i18n("Clear Last Mouse Mark"));
|
||||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F12));
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F12));
|
||||
connect(a, &QAction::triggered, this, &MouseMarkEffect::clearLast);
|
||||
|
||||
connect(effects, &EffectsHandler::mouseChanged, this, &MouseMarkEffect::slotMouseChanged);
|
||||
connect(effects, &EffectsHandler::screenLockingChanged, this, &MouseMarkEffect::screenLockingChanged);
|
||||
reconfigure(ReconfigureAll);
|
||||
arrow_tail = nullPoint();
|
||||
}
|
||||
|
||||
MouseMarkEffect::~MouseMarkEffect()
|
||||
{
|
||||
}
|
||||
|
||||
static int width_2 = 1;
|
||||
void MouseMarkEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
m_freedraw_modifiers = Qt::KeyboardModifiers();
|
||||
m_arrowdraw_modifiers = Qt::KeyboardModifiers();
|
||||
MouseMarkConfig::self()->read();
|
||||
width = MouseMarkConfig::lineWidth();
|
||||
width_2 = width / 2;
|
||||
color = MouseMarkConfig::color();
|
||||
color.setAlphaF(1.0);
|
||||
if (MouseMarkConfig::freedrawshift()) {
|
||||
m_freedraw_modifiers |= Qt::ShiftModifier;
|
||||
}
|
||||
if (MouseMarkConfig::freedrawalt()) {
|
||||
m_freedraw_modifiers |= Qt::AltModifier;
|
||||
}
|
||||
if (MouseMarkConfig::freedrawcontrol()) {
|
||||
m_freedraw_modifiers |= Qt::ControlModifier;
|
||||
}
|
||||
if (MouseMarkConfig::freedrawmeta()) {
|
||||
m_freedraw_modifiers |= Qt::MetaModifier;
|
||||
}
|
||||
|
||||
if (MouseMarkConfig::arrowdrawshift()) {
|
||||
m_arrowdraw_modifiers |= Qt::ShiftModifier;
|
||||
}
|
||||
if (MouseMarkConfig::arrowdrawalt()) {
|
||||
m_arrowdraw_modifiers |= Qt::AltModifier;
|
||||
}
|
||||
if (MouseMarkConfig::arrowdrawcontrol()) {
|
||||
m_arrowdraw_modifiers |= Qt::ControlModifier;
|
||||
}
|
||||
if (MouseMarkConfig::arrowdrawmeta()) {
|
||||
m_arrowdraw_modifiers |= Qt::MetaModifier;
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen)
|
||||
{
|
||||
effects->paintScreen(renderTarget, viewport, mask, region, screen); // paint normal screen
|
||||
if (marks.isEmpty() && drawing.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (const auto context = effects->openglContext()) {
|
||||
if (!context->isOpenGLES()) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
}
|
||||
glLineWidth(width);
|
||||
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
||||
vbo->reset();
|
||||
const auto scale = viewport.scale();
|
||||
ShaderBinder binder(ShaderTrait::UniformColor | ShaderTrait::TransformColorspace);
|
||||
binder.shader()->setUniform(GLShader::Mat4Uniform::ModelViewProjectionMatrix, viewport.projectionMatrix());
|
||||
binder.shader()->setColorspaceUniforms(ColorDescription::sRGB, renderTarget.colorDescription(), RenderingIntent::Perceptual);
|
||||
binder.shader()->setUniform(GLShader::ColorUniform::Color, color);
|
||||
QList<QVector2D> verts;
|
||||
for (const Mark &mark : std::as_const(marks)) {
|
||||
verts.clear();
|
||||
verts.reserve(mark.size());
|
||||
for (const QPointF &p : std::as_const(mark)) {
|
||||
verts.push_back(QVector2D(p.x() * scale, p.y() * scale));
|
||||
}
|
||||
vbo->setVertices(verts);
|
||||
vbo->render(GL_LINE_STRIP);
|
||||
}
|
||||
if (!drawing.isEmpty()) {
|
||||
verts.clear();
|
||||
verts.reserve(drawing.size());
|
||||
for (const QPointF &p : std::as_const(drawing)) {
|
||||
verts.push_back(QVector2D(p.x() * scale, p.y() * scale));
|
||||
}
|
||||
vbo->setVertices(verts);
|
||||
vbo->render(GL_LINE_STRIP);
|
||||
}
|
||||
glLineWidth(1.0);
|
||||
if (!context->isOpenGLES()) {
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
} else if (effects->compositingType() == QPainterCompositing) {
|
||||
QPainter *painter = effects->scenePainter();
|
||||
painter->save();
|
||||
QPen pen(color);
|
||||
pen.setWidth(width);
|
||||
painter->setPen(pen);
|
||||
for (const Mark &mark : std::as_const(marks)) {
|
||||
drawMark(painter, mark);
|
||||
}
|
||||
drawMark(painter, drawing);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::drawMark(QPainter *painter, const Mark &mark)
|
||||
{
|
||||
if (mark.count() <= 1) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < mark.count() - 1; ++i) {
|
||||
painter->drawLine(mark[i], mark[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::slotMouseChanged(const QPointF &pos, const QPointF &,
|
||||
Qt::MouseButtons, Qt::MouseButtons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
if (effects->isScreenLocked()) {
|
||||
return;
|
||||
}
|
||||
qCDebug(KWIN_MOUSEMARK) << "MouseChanged" << pos;
|
||||
if (modifiers == m_arrowdraw_modifiers && m_arrowdraw_modifiers != Qt::NoModifier) { // start/finish arrow
|
||||
if (arrow_tail != nullPoint()) {
|
||||
if (drawing.length() != 0) {
|
||||
clearLast(); // clear our arrow with tail at previous position
|
||||
}
|
||||
drawing = createArrow(pos, arrow_tail);
|
||||
effects->addRepaintFull();
|
||||
return;
|
||||
} else {
|
||||
if (drawing.length() > 0) { // has unfinished freedraw right before arrowdraw
|
||||
marks.append(drawing);
|
||||
drawing.clear();
|
||||
}
|
||||
arrow_tail = pos;
|
||||
}
|
||||
} else if (modifiers == m_freedraw_modifiers && m_freedraw_modifiers != Qt::NoModifier ) { // activated
|
||||
if (arrow_tail != nullPoint()) {
|
||||
arrow_tail = nullPoint(); // for the case when user started freedraw right after arrowdraw
|
||||
marks.append(drawing);
|
||||
drawing.clear();
|
||||
}
|
||||
if (drawing.isEmpty()) {
|
||||
drawing.append(pos);
|
||||
}
|
||||
if (drawing.last() == pos) {
|
||||
return;
|
||||
}
|
||||
QPointF pos2 = drawing.last();
|
||||
drawing.append(pos);
|
||||
QRect repaint = QRect(std::min(pos.x(), pos2.x()), std::min(pos.y(), pos2.y()),
|
||||
std::max(pos.x(), pos2.x()), std::max(pos.y(), pos2.y()));
|
||||
repaint.adjust(-width, -width, width, width);
|
||||
effects->addRepaint(repaint);
|
||||
} else { // neither freedraw, nor arrowdraw modifiers pressed, but mouse moved
|
||||
if (drawing.length() > 1) {
|
||||
marks.append(drawing);
|
||||
}
|
||||
drawing.clear();
|
||||
arrow_tail = nullPoint();
|
||||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::clear()
|
||||
{
|
||||
arrow_tail = nullPoint();
|
||||
drawing.clear();
|
||||
marks.clear();
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
void MouseMarkEffect::clearLast()
|
||||
{
|
||||
if (drawing.length() > 1) { // just pressing a modifiers already create a drawing with 1 point (so not visible), treat it as non-existent
|
||||
drawing.clear();
|
||||
effects->addRepaintFull();
|
||||
} else if (!marks.isEmpty()) {
|
||||
marks.pop_back();
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPointF arrow_head, QPointF arrow_tail)
|
||||
{
|
||||
Mark ret;
|
||||
double angle = atan2((double)(arrow_tail.y() - arrow_head.y()), (double)(arrow_tail.x() - arrow_head.x()));
|
||||
// Arrow is made of connected lines. We make it's last point at tail, so freedraw can begin from the tail
|
||||
ret += arrow_head;
|
||||
ret += arrow_head + QPoint(50 * cos(angle + M_PI / 6),
|
||||
50 * sin(angle + M_PI / 6)); // right one
|
||||
ret += arrow_head;
|
||||
ret += arrow_head + QPoint(50 * cos(angle - M_PI / 6),
|
||||
50 * sin(angle - M_PI / 6)); // left one
|
||||
ret += arrow_head;
|
||||
ret += arrow_tail;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MouseMarkEffect::screenLockingChanged(bool locked)
|
||||
{
|
||||
if (!marks.isEmpty() || !drawing.isEmpty()) {
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
bool MouseMarkEffect::isActive() const
|
||||
{
|
||||
return (!marks.isEmpty() || !drawing.isEmpty()) && !effects->isScreenLocked();
|
||||
}
|
||||
|
||||
int MouseMarkEffect::requestedEffectChainPosition() const
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "moc_mousemark.cpp"
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org>
|
||||
SPDX-FileCopyrightText: 2023 Andrew Shark <ashark at linuxcomp.ru>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "effect/effect.h"
|
||||
#include "opengl/glutils.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class MouseMarkEffect
|
||||
: public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int width READ configuredWidth)
|
||||
Q_PROPERTY(QColor color READ configuredColor)
|
||||
Q_PROPERTY(Qt::KeyboardModifiers modifiers READ freedraw_modifiers)
|
||||
Q_PROPERTY(Qt::KeyboardModifiers modifiers READ arrowdraw_modifiers)
|
||||
public:
|
||||
MouseMarkEffect();
|
||||
~MouseMarkEffect() override;
|
||||
void reconfigure(ReconfigureFlags) override;
|
||||
void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion ®ion, Output *screen) override;
|
||||
bool isActive() const override;
|
||||
int requestedEffectChainPosition() const override;
|
||||
|
||||
// for properties
|
||||
int configuredWidth() const
|
||||
{
|
||||
return width;
|
||||
}
|
||||
QColor configuredColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
Qt::KeyboardModifiers freedraw_modifiers() const
|
||||
{
|
||||
return m_freedraw_modifiers;
|
||||
}
|
||||
Qt::KeyboardModifiers arrowdraw_modifiers() const
|
||||
{
|
||||
return m_freedraw_modifiers;
|
||||
}
|
||||
private Q_SLOTS:
|
||||
void clear();
|
||||
void clearLast();
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void screenLockingChanged(bool locked);
|
||||
|
||||
private:
|
||||
typedef QList<QPointF> Mark;
|
||||
void drawMark(QPainter *painter, const Mark &mark);
|
||||
static Mark createArrow(QPointF arrow_head, QPointF arrow_tail);
|
||||
QList<Mark> marks;
|
||||
Mark drawing;
|
||||
QPointF arrow_tail;
|
||||
int width;
|
||||
QColor color;
|
||||
Qt::KeyboardModifiers m_freedraw_modifiers;
|
||||
Qt::KeyboardModifiers m_arrowdraw_modifiers;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile arg="true"/>
|
||||
<group name="Effect-mousemark">
|
||||
<entry name="LineWidth" type="UInt">
|
||||
<default>3</default>
|
||||
</entry>
|
||||
<entry name="Color" type="Color">
|
||||
<default>255,0,0</default>
|
||||
</entry>
|
||||
<entry name="Freedrawmeta" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Freedrawcontrol" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="Freedrawalt" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="Freedrawshift" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="Arrowdrawmeta" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Arrowdrawcontrol" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Arrowdrawalt" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="Arrowdrawshift" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
|
||||
SPDX-FileCopyrightText: 2023 Andrew Shark <ashark at linuxcomp.ru>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#include "mousemark_config.h"
|
||||
|
||||
#include "config-kwin.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "mousemarkconfig.h"
|
||||
#include <kwineffects_interface.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KGlobalAccel>
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QWidget>
|
||||
|
||||
K_PLUGIN_CLASS(KWin::MouseMarkEffectConfig)
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
MouseMarkEffectConfig::MouseMarkEffectConfig(QObject *parent, const KPluginMetaData &data)
|
||||
: KCModule(parent, data)
|
||||
{
|
||||
m_ui.setupUi(widget());
|
||||
|
||||
MouseMarkConfig::instance(KWIN_CONFIG);
|
||||
addConfig(MouseMarkConfig::self(), widget());
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
||||
m_actionCollection->setComponentDisplayName(i18n("KWin"));
|
||||
|
||||
QAction *a = m_actionCollection->addAction(QStringLiteral("ClearMouseMarks"));
|
||||
a->setText(i18n("Clear Mouse Marks"));
|
||||
a->setProperty("isConfigurationAction", true);
|
||||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F11));
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F11));
|
||||
|
||||
a = m_actionCollection->addAction(QStringLiteral("ClearLastMouseMark"));
|
||||
a->setText(i18n("Clear Last Mouse Mark"));
|
||||
a->setProperty("isConfigurationAction", true);
|
||||
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F12));
|
||||
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::SHIFT | Qt::META | Qt::Key_F12));
|
||||
|
||||
m_ui.editor->addCollection(m_actionCollection);
|
||||
|
||||
connect(m_ui.kcfg_LineWidth, qOverload<int>(&QSpinBox::valueChanged), this, [this]() {
|
||||
updateSpinBoxSuffix();
|
||||
});
|
||||
}
|
||||
|
||||
void MouseMarkEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
updateSpinBoxSuffix();
|
||||
}
|
||||
|
||||
void MouseMarkEffectConfig::save()
|
||||
{
|
||||
qDebug() << "Saving config of MouseMark";
|
||||
KCModule::save();
|
||||
|
||||
m_actionCollection->writeSettings();
|
||||
m_ui.editor->save(); // undo() will restore to this state from now on
|
||||
|
||||
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Effects"),
|
||||
QDBusConnection::sessionBus());
|
||||
interface.reconfigureEffect(QStringLiteral("mousemark"));
|
||||
}
|
||||
|
||||
void MouseMarkEffectConfig::updateSpinBoxSuffix()
|
||||
{
|
||||
m_ui.kcfg_LineWidth->setSuffix(i18ncp("Suffix", " pixel", " pixels", m_ui.kcfg_LineWidth->value()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "mousemark_config.moc"
|
||||
|
||||
#include "moc_mousemark_config.cpp"
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
|
||||
SPDX-FileCopyrightText: 2023 Andrew Shark <ashark at linuxcomp.ru>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <kcmodule.h>
|
||||
|
||||
#include "ui_mousemark_config.h"
|
||||
|
||||
class KActionCollection;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class MouseMarkEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MouseMarkEffectConfig(QObject *parent, const KPluginMetaData &data);
|
||||
|
||||
void load() override;
|
||||
void save() override;
|
||||
|
||||
private:
|
||||
void updateSpinBoxSuffix();
|
||||
|
||||
Ui::MouseMarkEffectConfigForm m_ui;
|
||||
KActionCollection *m_actionCollection;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>KWin::MouseMarkEffectConfigForm</class>
|
||||
<widget class="QWidget" name="KWin::MouseMarkEffectConfigForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>279</width>
|
||||
<height>178</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Appearance</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Wid&th:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_LineWidth</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>&Color:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_Color</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="KColorCombo" name="kcfg_Color">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_LineWidth">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KShortcutsEditor" name="editor">
|
||||
<property name="actionTypes">
|
||||
<enum>KShortcutsEditor::GlobalAction</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox2">
|
||||
<property name="title">
|
||||
<string>Draw with the mouse by holding modifier keys and moving the mouse</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hlayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_FreedrawModifierKeys">
|
||||
<property name="text">
|
||||
<string>Free draw modifier keys:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="widgetf" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutf">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Freedrawalt">
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Freedrawcontrol">
|
||||
<property name="text">
|
||||
<string>Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Freedrawshift">
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Freedrawmeta">
|
||||
<property name="text">
|
||||
<string>Meta</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_ArrowdrawModifierKeys">
|
||||
<property name="text">
|
||||
<string>Arrow draw modifier keys:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="widgeta" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayouta">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Arrowdrawalt">
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Arrowdrawcontrol">
|
||||
<property name="text">
|
||||
<string>Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Arrowdrawshift">
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_Arrowdrawmeta">
|
||||
<property name="text">
|
||||
<string>Meta</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KShortcutsEditor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>kshortcutseditor.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,5 @@
|
||||
File=mousemark.kcfg
|
||||
ClassName=MouseMarkConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
||||
Reference in New Issue
Block a user