From defca98a1e761acaa039cfa1d06836bff33cb63f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 17 Dec 2021 23:49:53 +0200 Subject: [PATCH] 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. --- src/effects/CMakeLists.txt | 1 - src/effects/fallapart/fallapart.cpp | 20 +++++++------- .../highlightwindow/highlightwindow.cpp | 4 ++- src/effects/invert/invert.cpp | 4 ++- src/effects/kscreen/kscreen.cpp | 4 ++- src/effects/logging.cpp | 10 ------- src/effects/lookingglass/lookingglass.cpp | 8 +++--- src/effects/presentwindows/presentwindows.cpp | 8 +++--- src/effects/screenshot/CMakeLists.txt | 7 +++++ .../screenshot/screenshotdbusinterface1.cpp | 8 +++--- .../screenshot/screenshotdbusinterface2.cpp | 13 +++++----- .../startupfeedback/startupfeedback.cpp | 6 +++-- src/effects/wobblywindows/wobblywindows.cpp | 26 ++++++++++--------- 13 files changed, 66 insertions(+), 53 deletions(-) delete mode 100644 src/effects/logging.cpp diff --git a/src/effects/CMakeLists.txt b/src/effects/CMakeLists.txt index 1f3614d0a2..4212547e89 100644 --- a/src/effects/CMakeLists.txt +++ b/src/effects/CMakeLists.txt @@ -163,7 +163,6 @@ add_subdirectory(wobblywindows) # Add the builtins plugin set(kwin4_effect_builtins_sources - logging.cpp ../service_utils.cpp ) diff --git a/src/effects/fallapart/fallapart.cpp b/src/effects/fallapart/fallapart.cpp index 2f7414c50f..e43506375b 100644 --- a/src/effects/fallapart/fallapart.cpp +++ b/src/effects/fallapart/fallapart.cpp @@ -13,6 +13,8 @@ #include +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; diff --git a/src/effects/highlightwindow/highlightwindow.cpp b/src/effects/highlightwindow/highlightwindow.cpp index 8cb82f27c8..709be8f373 100644 --- a/src/effects/highlightwindow/highlightwindow.cpp +++ b/src/effects/highlightwindow/highlightwindow.cpp @@ -12,6 +12,8 @@ #include +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); diff --git a/src/effects/invert/invert.cpp b/src/effects/invert/invert.cpp index d6d39453ea..42d24acc10 100644 --- a/src/effects/invert/invert.cpp +++ b/src/effects/invert/invert.cpp @@ -20,6 +20,8 @@ #include +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; } diff --git a/src/effects/kscreen/kscreen.cpp b/src/effects/kscreen/kscreen.cpp index 0624afacc0..9484399756 100644 --- a/src/effects/kscreen/kscreen.cpp +++ b/src/effects/kscreen/kscreen.cpp @@ -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(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; diff --git a/src/effects/logging.cpp b/src/effects/logging.cpp deleted file mode 100644 index 1a578ffa40..0000000000 --- a/src/effects/logging.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - KWin - the KDE window manager - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2013 Martin Gräßlin - - SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include -Q_LOGGING_CATEGORY(KWINEFFECTS, "kwineffects", QtWarningMsg) diff --git a/src/effects/lookingglass/lookingglass.cpp b/src/effects/lookingglass/lookingglass.cpp index ac7f717f08..2e3561991b 100644 --- a/src/effects/lookingglass/lookingglass.cpp +++ b/src/effects/lookingglass/lookingglass.cpp @@ -27,6 +27,8 @@ #include +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) { diff --git a/src/effects/presentwindows/presentwindows.cpp b/src/effects/presentwindows/presentwindows.cpp index dc10958642..fe5df93222 100644 --- a/src/effects/presentwindows/presentwindows.cpp +++ b/src/effects/presentwindows/presentwindows.cpp @@ -34,6 +34,8 @@ #include #include +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; } diff --git a/src/effects/screenshot/CMakeLists.txt b/src/effects/screenshot/CMakeLists.txt index 8458c6b450..2968726566 100644 --- a/src/effects/screenshot/CMakeLists.txt +++ b/src/effects/screenshot/CMakeLists.txt @@ -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}) diff --git a/src/effects/screenshot/screenshotdbusinterface1.cpp b/src/effects/screenshot/screenshotdbusinterface1.cpp index c3e4d28311..fd642bab90 100644 --- a/src/effects/screenshot/screenshotdbusinterface1.cpp +++ b/src/effects/screenshot/screenshotdbusinterface1.cpp @@ -6,6 +6,7 @@ */ #include "screenshotdbusinterface1.h" +#include "screenshotlogging.h" #include "../service_utils.h" #include @@ -19,7 +20,6 @@ #include #include -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 &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 { diff --git a/src/effects/screenshot/screenshotdbusinterface2.cpp b/src/effects/screenshot/screenshotdbusinterface2.cpp index 1d9c83a7fc..9a7abe7669 100644 --- a/src/effects/screenshot/screenshotdbusinterface2.cpp +++ b/src/effects/screenshot/screenshotdbusinterface2.cpp @@ -9,6 +9,7 @@ #include "screenshotdbusinterface2.h" #include "../service_utils.h" #include "screenshot2adaptor.h" +#include "screenshotlogging.h" #include @@ -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) { diff --git a/src/effects/startupfeedback/startupfeedback.cpp b/src/effects/startupfeedback/startupfeedback.cpp index f106526e23..9bf8779556 100644 --- a/src/effects/startupfeedback/startupfeedback.cpp +++ b/src/effects/startupfeedback/startupfeedback.cpp @@ -28,6 +28,8 @@ // based on StartupId in KRunner by Lubos Lunak // SPDX-FileCopyrightText: 2001 Lubos Lunak +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 diff --git a/src/effects/wobblywindows/wobblywindows.cpp b/src/effects/wobblywindows/wobblywindows.cpp index ad19ab37b3..759fdbdc02 100644 --- a/src/effects/wobblywindows/wobblywindows.cpp +++ b/src/effects/wobblywindows/wobblywindows.cpp @@ -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(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) {