effects: Declare logging category per effect

This allows us to decouple effects more and reduce the number of random
odd build failures on freebsd. Besides that, it provides more fine
grained control over logging, for example, one could select log output
from some concrete effect, etc.
This commit is contained in:
Vlad Zahorodnii 2021-12-17 23:49:53 +02:00
parent 0b1565c54c
commit defca98a1e
13 changed files with 66 additions and 53 deletions

View file

@ -163,7 +163,6 @@ add_subdirectory(wobblywindows)
# Add the builtins plugin
set(kwin4_effect_builtins_sources
logging.cpp
../service_utils.cpp
)

View file

@ -13,6 +13,8 @@
#include <cmath>
Q_LOGGING_CATEGORY(KWIN_FALLAPART, "kwin_effect_fallapart", QtWarningMsg)
namespace KWin
{
@ -132,15 +134,15 @@ bool FallApartEffect::isRealWindow(EffectWindow* w)
{
// TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately?
/*
qCDebug(KWINEFFECTS) << "--" << w->caption() << "--------------------------------";
qCDebug(KWINEFFECTS) << "Tooltip:" << w->isTooltip();
qCDebug(KWINEFFECTS) << "Toolbar:" << w->isToolbar();
qCDebug(KWINEFFECTS) << "Desktop:" << w->isDesktop();
qCDebug(KWINEFFECTS) << "Special:" << w->isSpecialWindow();
qCDebug(KWINEFFECTS) << "TopMenu:" << w->isTopMenu();
qCDebug(KWINEFFECTS) << "Notific:" << w->isNotification();
qCDebug(KWINEFFECTS) << "Splash:" << w->isSplash();
qCDebug(KWINEFFECTS) << "Normal:" << w->isNormalWindow();
qCDebug(KWIN_FALLAPART) << "--" << w->caption() << "--------------------------------";
qCDebug(KWIN_FALLAPART) << "Tooltip:" << w->isTooltip();
qCDebug(KWIN_FALLAPART) << "Toolbar:" << w->isToolbar();
qCDebug(KWIN_FALLAPART) << "Desktop:" << w->isDesktop();
qCDebug(KWIN_FALLAPART) << "Special:" << w->isSpecialWindow();
qCDebug(KWIN_FALLAPART) << "TopMenu:" << w->isTopMenu();
qCDebug(KWIN_FALLAPART) << "Notific:" << w->isNotification();
qCDebug(KWIN_FALLAPART) << "Splash:" << w->isSplash();
qCDebug(KWIN_FALLAPART) << "Normal:" << w->isNormalWindow();
*/
if (w->isPopupWindow()) {
return false;

View file

@ -12,6 +12,8 @@
#include <QDBusConnection>
Q_LOGGING_CATEGORY(KWIN_HIGHLIGHTWINDOW, "kwin_effect_highlightwindow", QtWarningMsg)
namespace KWin
{
@ -138,7 +140,7 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWi
m_highlightedIds << data[i];
EffectWindow* foundWin = effects->findWindow(data[i]);
if (!foundWin) {
qCDebug(KWINEFFECTS) << "Invalid window targetted for highlight. Requested:" << data[i];
qCDebug(KWIN_HIGHLIGHTWINDOW) << "Invalid window targetted for highlight. Requested:" << data[i];
continue; // might come in later.
}
m_highlightedWindows.append(foundWin);

View file

@ -20,6 +20,8 @@
#include <QMatrix4x4>
Q_LOGGING_CATEGORY(KWIN_INVERT, "kwin_effect_invert", QtWarningMsg)
namespace KWin
{
@ -64,7 +66,7 @@ bool InvertEffect::loadData()
m_shader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("invert.frag"));
if (!m_shader->isValid()) {
qCCritical(KWINEFFECTS) << "The shader failed to load!";
qCCritical(KWIN_INVERT) << "The shader failed to load!";
return false;
}

View file

@ -37,6 +37,8 @@
* 3: fading in
*/
Q_LOGGING_CATEGORY(KWIN_KSCREEN, "kwin_effect_kscreen", QtWarningMsg)
namespace KWin
{
@ -189,7 +191,7 @@ void KscreenEffect::propertyNotify(EffectWindow *window, long int atom)
const uint32_t *data = byteData.isEmpty() ? nullptr : reinterpret_cast<const uint32_t *>(byteData.data());
if (!data || data[0] >= LastState) { // Property was deleted
if (data) {
qCDebug(KWINEFFECTS) << "Incorrect Property state, immediate stop: " << data[0];
qCDebug(KWIN_KSCREEN) << "Incorrect Property state, immediate stop: " << data[0];
}
setState(m_xcbState, StateNormal);
return;

View file

@ -1,10 +0,0 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <kwineffects.h>
Q_LOGGING_CATEGORY(KWINEFFECTS, "kwineffects", QtWarningMsg)

View file

@ -27,6 +27,8 @@
#include <cmath>
Q_LOGGING_CATEGORY(KWIN_LOOKINGGLASS, "kwin_effect_lookingglass", QtWarningMsg)
namespace KWin
{
@ -83,7 +85,7 @@ void LookingGlassEffect::reconfigure(ReconfigureFlags)
LookingGlassConfig::self()->read();
initialradius = LookingGlassConfig::radius();
radius = initialradius;
qCDebug(KWINEFFECTS) << "Radius from config:" << radius;
qCDebug(KWIN_LOOKINGGLASS) << "Radius from config:" << radius;
m_valid = loadData();
}
@ -109,7 +111,7 @@ bool LookingGlassEffect::loadData()
ShaderBinder binder(m_shader);
m_shader->setUniform("u_textureSize", QVector2D(screenSize.width(), screenSize.height()));
} else {
qCCritical(KWINEFFECTS) << "The shader failed to load!";
qCCritical(KWIN_LOOKINGGLASS) << "The shader failed to load!";
return false;
}
@ -195,7 +197,7 @@ void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::m
zoom = qMin(zoom * qMax(1.0 + diff, 1.2), target_zoom);
else
zoom = qMax(zoom * qMin(1.0 - diff, 0.8), target_zoom);
qCDebug(KWINEFFECTS) << "zoom is now " << zoom;
qCDebug(KWIN_LOOKINGGLASS) << "zoom is now " << zoom;
radius = qBound((double)initialradius, initialradius * zoom, 3.5 * initialradius);
if (zoom <= 1.0f) {

View file

@ -34,6 +34,8 @@
#include <climits>
#include <cmath>
Q_LOGGING_CATEGORY(KWIN_PRESENTWINDOWS, "kwin_effect_presentwindows", QtWarningMsg)
namespace KWin
{
@ -927,7 +929,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a)
for (int i = 0; i < length; i++) {
EffectWindow* foundWin = effects->findWindow(data[i]);
if (!foundWin) {
qCDebug(KWINEFFECTS) << "Invalid window targetted for present windows. Requested:" << data[i];
qCDebug(KWIN_PRESENTWINDOWS) << "Invalid window targetted for present windows. Requested:" << data[i];
continue;
}
m_selectedWindows.append(foundWin);
@ -1195,7 +1197,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
rows = (int)ceil(sqrt((double)windowlist.count()));
columns = (int)ceil((double)windowlist.count() / (double)rows);
}
//qCDebug(KWINEFFECTS) << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients";
//qCDebug(KWIN_PRESENTWINDOWS) << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients";
// Calculate width & height
int w = (availRect.width() - (columns + 1) * spacing) / columns;
@ -1298,7 +1300,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis
// winData->slot = pos;
motionManager.moveWindow(window, target);
//qCDebug(KWINEFFECTS) << "Window '" << window->caption() << "' gets moved to (" <<
//qCDebug(KWIN_PRESENTWINDOWS) << "Window '" << window->caption() << "' gets moved to (" <<
// mWindowData[window].area.left() << "; " << mWindowData[window].area.right() <<
// "), scale: " << mWindowData[window].scale << endl;
}

View file

@ -9,6 +9,13 @@ set(screenshot_SOURCES
screenshotdbusinterface2.cpp
)
ecm_qt_declare_logging_category(screenshot_SOURCES
HEADER screenshotlogging.h
IDENTIFIER KWIN_SCREENSHOT
CATEGORY_NAME kwin_effect_screenshot
DEFAULT_SEVERITY Warning
)
qt_add_dbus_adaptor(screenshot_SOURCES org.kde.KWin.ScreenShot2.xml screenshotdbusinterface2.h KWin::ScreenShotDBusInterface2)
kwin4_add_effect_module(kwin4_effect_screenshot ${screenshot_SOURCES})

View file

@ -6,6 +6,7 @@
*/
#include "screenshotdbusinterface1.h"
#include "screenshotlogging.h"
#include "../service_utils.h"
#include <KLocalizedString>
@ -19,7 +20,6 @@
#include <QtConcurrent>
#include <unistd.h>
Q_LOGGING_CATEGORY(KWINEFFECTS, "kwineffects", QtWarningMsg)
namespace KWin
{
@ -295,13 +295,13 @@ ScreenShotSink1::ScreenShotSink1(ScreenShotDBusInterface1 *interface, QDBusMessa
void ScreenShotSink1::flush(const QImage &image)
{
Q_UNUSED(image)
qCWarning(KWINEFFECTS) << metaObject()->className() << "does not implement" << Q_FUNC_INFO;
qCWarning(KWIN_SCREENSHOT) << metaObject()->className() << "does not implement" << Q_FUNC_INFO;
}
void ScreenShotSink1::flushMulti(const QList<QImage> &images)
{
Q_UNUSED(images)
qCWarning(KWINEFFECTS) << metaObject()->className() << "does not implement" << Q_FUNC_INFO;
qCWarning(KWIN_SCREENSHOT) << metaObject()->className() << "does not implement" << Q_FUNC_INFO;
}
void ScreenShotSink1::cancel()
@ -506,7 +506,7 @@ bool ScreenShotDBusInterface1::checkCall() const
const auto interfaces = KWin::fetchRestrictedDBusInterfacesFromPid(pid);
if (!interfaces.contains(s_dbusInterfaceName)) {
sendErrorReply(s_errorNotAuthorized, s_errorNotAuthorizedMsg);
qCWarning(KWINEFFECTS) << "Process" << pid << "tried to take a screenshot without being granted to DBus interface" << s_dbusInterfaceName;
qCWarning(KWIN_SCREENSHOT) << "Process" << pid << "tried to take a screenshot without being granted to DBus interface" << s_dbusInterfaceName;
return false;
}
} else {

View file

@ -9,6 +9,7 @@
#include "screenshotdbusinterface2.h"
#include "../service_utils.h"
#include "screenshot2adaptor.h"
#include "screenshotlogging.h"
#include <KLocalizedString>
@ -51,7 +52,7 @@ static void writeBufferToPipe(int fileDescriptor, const QByteArray &buffer)
QFile file;
if (!file.open(fileDescriptor, QIODevice::WriteOnly, QFileDevice::AutoCloseHandle)) {
close(fileDescriptor);
qCWarning(KWINEFFECTS) << Q_FUNC_INFO << "failed to open pipe:" << file.errorString();
qCWarning(KWIN_SCREENSHOT) << Q_FUNC_INFO << "failed to open pipe:" << file.errorString();
return;
}
@ -65,21 +66,21 @@ static void writeBufferToPipe(int fileDescriptor, const QByteArray &buffer)
const int ready = poll(pfds, 1, 60000);
if (ready < 0) {
if (errno != EINTR) {
qCWarning(KWINEFFECTS) << Q_FUNC_INFO << "poll() failed:" << strerror(errno);
qCWarning(KWIN_SCREENSHOT) << Q_FUNC_INFO << "poll() failed:" << strerror(errno);
return;
}
} else if (ready == 0) {
qCWarning(KWINEFFECTS) << Q_FUNC_INFO << "timed out writing to pipe";
qCWarning(KWIN_SCREENSHOT) << Q_FUNC_INFO << "timed out writing to pipe";
return;
} else if (!(pfds[0].revents & POLLOUT)) {
qCWarning(KWINEFFECTS) << Q_FUNC_INFO << "pipe is broken";
qCWarning(KWIN_SCREENSHOT) << Q_FUNC_INFO << "pipe is broken";
return;
} else {
const char *chunk = buffer.constData() + (buffer.size() - remainingSize);
const qint64 writtenCount = file.write(chunk, remainingSize);
if (writtenCount < 0) {
qCWarning(KWINEFFECTS) << Q_FUNC_INFO << "write() failed:" << file.errorString();
qCWarning(KWIN_SCREENSHOT) << Q_FUNC_INFO << "write() failed:" << file.errorString();
return;
}
@ -340,7 +341,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureWindow(const QString &handle,
if (ok) {
window = effects->findWindow(winId);
} else {
qCWarning(KWINEFFECTS) << "Invalid handle:" << handle;
qCWarning(KWIN_SCREENSHOT) << "Invalid handle:" << handle;
}
}
if (!window) {

View file

@ -28,6 +28,8 @@
// based on StartupId in KRunner by Lubos Lunak
// SPDX-FileCopyrightText: 2001 Lubos Lunak <l.lunak@kde.org>
Q_LOGGING_CATEGORY(KWIN_STARTUPFEEDBACK, "kwin_effect_startupfeedback", QtWarningMsg)
namespace KWin
{
@ -145,9 +147,9 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags)
if (effects->compositingType() == OpenGLCompositing) {
m_blinkingShader.reset(ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("blinking-startup-fragment.glsl")));
if (m_blinkingShader->isValid()) {
qCDebug(KWINEFFECTS) << "Blinking Shader is valid";
qCDebug(KWIN_STARTUPFEEDBACK) << "Blinking Shader is valid";
} else {
qCDebug(KWINEFFECTS) << "Blinking Shader is not valid";
qCDebug(KWIN_STARTUPFEEDBACK) << "Blinking Shader is not valid";
}
}
} else

View file

@ -26,6 +26,8 @@
# endif
#endif
Q_LOGGING_CATEGORY(KWIN_WOBBLYWINDOWS, "kwin_effect_wobblywindows", QtWarningMsg)
namespace KWin
{
@ -132,7 +134,7 @@ WobblyWindowsEffect::~WobblyWindowsEffect()
if (!windows.empty()) {
// we should be empty at this point...
// emit a warning and clean the list.
qCDebug(KWINEFFECTS) << "Windows list not empty. Left items : " << windows.count();
qCDebug(KWIN_WOBBLYWINDOWS) << "Windows list not empty. Left items : " << windows.count();
QHash< const EffectWindow*, WindowWobblyInfos >::iterator i;
for (i = windows.begin(); i != windows.end(); ++i) {
freeWobblyInfo(i.value());
@ -148,7 +150,7 @@ void WobblyWindowsEffect::reconfigure(ReconfigureFlags)
if (settingsMode != QStringLiteral("Custom")) {
unsigned int wobblynessLevel = WobblyWindowsConfig::wobblynessLevel();
if (wobblynessLevel > 4) {
qCDebug(KWINEFFECTS) << "Wrong value for \"WobblynessLevel\" : " << wobblynessLevel;
qCDebug(KWIN_WOBBLYWINDOWS) << "Wrong value for \"WobblynessLevel\" : " << wobblynessLevel;
wobblynessLevel = 4;
}
setParameterSet(pset[wobblynessLevel]);
@ -178,7 +180,7 @@ void WobblyWindowsEffect::reconfigure(ReconfigureFlags)
m_resizeWobble = WobblyWindowsConfig::resizeWobble();
#if defined VERBOSE_MODE
qCDebug(KWINEFFECTS) << "Parameters :\n" <<
qCDebug(KWIN_WOBBLYWINDOWS) << "Parameters :\n" <<
"grid(" << m_stiffness << ", " << m_drag << ", " << m_move_factor << ")\n" <<
"velocity(" << m_minVelocity << ", " << m_maxVelocity << ", " << m_stopVelocity << ")\n" <<
"acceleration(" << m_minAcceleration << ", " << m_maxAcceleration << ", " << m_stopAcceleration << ")\n" <<
@ -392,14 +394,14 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w)
int indy = (picked.y - rect.y()) / y_increment + 0.5;
int pickedPointIndex = indy * wwi.width + indx;
if (pickedPointIndex < 0) {
qCDebug(KWINEFFECTS) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
qCDebug(KWIN_WOBBLYWINDOWS) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
pickedPointIndex = 0;
} else if (static_cast<unsigned int>(pickedPointIndex) > wwi.count - 1) {
qCDebug(KWINEFFECTS) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
qCDebug(KWIN_WOBBLYWINDOWS) << "Picked index == " << pickedPointIndex << " with (" << cursorPos().x() << "," << cursorPos().y() << ")";
pickedPointIndex = wwi.count - 1;
}
#if defined VERBOSE_MODE
qCDebug(KWINEFFECTS) << "Original Picked point -- x : " << picked.x << " - y : " << picked.y;
qCDebug(KWIN_WOBBLYWINDOWS) << "Original Picked point -- x : " << picked.x << " - y : " << picked.y;
#endif
wwi.constraint[pickedPointIndex] = true;
@ -598,8 +600,8 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
qreal y_length = rect.height() / (wwi.height - 1.0);
#if defined VERBOSE_MODE
qCDebug(KWINEFFECTS) << "time " << time;
qCDebug(KWINEFFECTS) << "increment x " << x_length << " // y" << y_length;
qCDebug(KWIN_WOBBLYWINDOWS) << "time " << time;
qCDebug(KWIN_WOBBLYWINDOWS) << "increment x " << x_length << " // y" << y_length;
#endif
Pair origine = {rect.x(), rect.y()};
@ -895,7 +897,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
#if defined VERBOSE_MODE
if (wwi.constraint[i]) {
qCDebug(KWINEFFECTS) << "Constraint point ** vel : " << vel.x << "," << vel.y << " ** move : " << vel.x*time << "," << vel.y*time;
qCDebug(KWIN_WOBBLYWINDOWS) << "Constraint point ** vel : " << vel.x << "," << vel.y << " ** move : " << vel.x*time << "," << vel.y*time;
}
#endif
}
@ -923,10 +925,10 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time)
#if defined VERBOSE_MODE
# if defined COMPUTE_STATS
qCDebug(KWINEFFECTS) << "Acceleration bounds (" << accBound.x << ", " << accBound.y << ")";
qCDebug(KWINEFFECTS) << "Velocity bounds (" << velBound.x << ", " << velBound.y << ")";
qCDebug(KWIN_WOBBLYWINDOWS) << "Acceleration bounds (" << accBound.x << ", " << accBound.y << ")";
qCDebug(KWIN_WOBBLYWINDOWS) << "Velocity bounds (" << velBound.x << ", " << velBound.y << ")";
# endif
qCDebug(KWINEFFECTS) << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum;
qCDebug(KWIN_WOBBLYWINDOWS) << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum;
#endif
if (wwi.status != Moving && acc_sum < m_stopAcceleration && vel_sum < m_stopVelocity) {