2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "effects.h"
|
|
|
|
|
2022-02-23 13:27:05 +00:00
|
|
|
#include <config-kwin.h>
|
|
|
|
|
2014-03-25 12:43:56 +00:00
|
|
|
#include "effectloader.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "effectsadaptor.h"
|
2022-04-14 12:33:28 +00:00
|
|
|
#include "output.h"
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2013-04-04 14:14:12 +00:00
|
|
|
#include "activities.h"
|
|
|
|
#endif
|
2013-02-19 10:25:46 +00:00
|
|
|
#include "cursor.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "deleted.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "group.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "input_event.h"
|
2022-04-22 17:45:19 +00:00
|
|
|
#include "internalwindow.h"
|
2016-12-23 16:39:12 +00:00
|
|
|
#include "osd.h"
|
2016-02-23 11:29:05 +00:00
|
|
|
#include "pointer_input.h"
|
2021-11-10 10:34:18 +00:00
|
|
|
#include "renderbackend.h"
|
2008-01-02 15:37:46 +00:00
|
|
|
#include "unmanaged.h"
|
2022-04-22 17:54:31 +00:00
|
|
|
#include "x11window.h"
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2011-03-06 11:15:16 +00:00
|
|
|
#include "tabbox.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2013-01-21 08:04:06 +00:00
|
|
|
#include "screenedge.h"
|
2013-04-03 10:19:27 +00:00
|
|
|
#include "screens.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "scripting/scriptedeffect.h"
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2016-08-15 06:16:33 +00:00
|
|
|
#include "screenlockerwatcher.h"
|
2022-02-23 13:27:05 +00:00
|
|
|
#endif
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "composite.h"
|
|
|
|
#include "decorations/decorationbridge.h"
|
2022-02-09 13:53:59 +00:00
|
|
|
#include "inputmethod.h"
|
2022-04-22 17:42:35 +00:00
|
|
|
#include "inputpanelv1window.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "kwinglutils.h"
|
|
|
|
#include "kwinoffscreenquickview.h"
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2022-01-13 13:54:03 +00:00
|
|
|
#include "utils/xcbutils.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "virtualdesktops.h"
|
2015-03-20 13:41:03 +00:00
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:51:07 +00:00
|
|
|
#include "waylandwindow.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "window_property_notify_x11_filter.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <Plasma/Theme>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-02-09 21:00:07 +00:00
|
|
|
#include <KDecoration2/Decoration>
|
2014-07-22 14:08:08 +00:00
|
|
|
#include <KDecoration2/DecorationSettings>
|
2014-07-22 12:47:08 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QWheelEvent>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2010-02-01 07:44:27 +00:00
|
|
|
//---------------------
|
|
|
|
// Static
|
|
|
|
|
2013-09-11 06:38:10 +00:00
|
|
|
static QByteArray readWindowProperty(xcb_window_t win, xcb_atom_t atom, xcb_atom_t type, int format)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-05-02 15:47:39 +00:00
|
|
|
if (win == XCB_WINDOW_NONE) {
|
|
|
|
return QByteArray();
|
|
|
|
}
|
2013-09-11 06:38:10 +00:00
|
|
|
uint32_t len = 32768;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (;;) {
|
2014-04-15 08:09:25 +00:00
|
|
|
Xcb::Property prop(false, win, atom, XCB_ATOM_ANY, 0, len);
|
2013-09-11 06:38:10 +00:00
|
|
|
if (prop.isNull()) {
|
|
|
|
// get property failed
|
2010-02-01 07:44:27 +00:00
|
|
|
return QByteArray();
|
2013-09-11 06:38:10 +00:00
|
|
|
}
|
|
|
|
if (prop->bytes_after > 0) {
|
|
|
|
len *= 2;
|
|
|
|
continue;
|
|
|
|
}
|
2014-04-15 08:09:25 +00:00
|
|
|
return prop.toByteArray(format, type);
|
2010-02-01 07:44:27 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2020-12-10 08:54:14 +00:00
|
|
|
static void deleteWindowProperty(xcb_window_t win, long int atom)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-05-02 15:47:39 +00:00
|
|
|
if (win == XCB_WINDOW_NONE) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-02 08:04:15 +00:00
|
|
|
xcb_delete_property(kwinApp()->x11Connection(), win, atom);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2017-08-23 09:41:26 +00:00
|
|
|
static xcb_atom_t registerSupportProperty(const QByteArray &propertyName)
|
|
|
|
{
|
|
|
|
auto c = kwinApp()->x11Connection();
|
|
|
|
if (!c) {
|
|
|
|
return XCB_ATOM_NONE;
|
|
|
|
}
|
|
|
|
// get the atom for the propertyName
|
|
|
|
ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(c,
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()),
|
|
|
|
nullptr));
|
2017-08-23 09:41:26 +00:00
|
|
|
if (atomReply.isNull()) {
|
|
|
|
return XCB_ATOM_NONE;
|
|
|
|
}
|
|
|
|
// announce property on root window
|
|
|
|
unsigned char dummy = 0;
|
|
|
|
xcb_change_property(c, XCB_PROP_MODE_REPLACE, kwinApp()->x11RootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy);
|
|
|
|
// TODO: add to _NET_SUPPORTED
|
|
|
|
return atomReply->atom;
|
|
|
|
}
|
|
|
|
|
2010-02-01 07:44:27 +00:00
|
|
|
//---------------------
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-08-23 16:04:36 +00:00
|
|
|
EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
|
2021-11-10 10:34:18 +00:00
|
|
|
: EffectsHandler(Compositor::self()->backend()->compositingType())
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
, keyboard_grab_effect(nullptr)
|
|
|
|
, fullscreen_effect(nullptr)
|
2012-08-23 16:04:36 +00:00
|
|
|
, m_compositor(compositor)
|
2012-08-16 19:19:54 +00:00
|
|
|
, m_scene(scene)
|
2012-03-29 18:12:34 +00:00
|
|
|
, m_desktopRendering(false)
|
|
|
|
, m_currentRenderedDesktop(0)
|
2014-01-24 14:42:40 +00:00
|
|
|
, m_effectLoader(new EffectLoader(this))
|
2015-02-07 16:12:53 +00:00
|
|
|
, m_trackingCursorChanges(0)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
qRegisterMetaType<QVector<KWin::EffectWindow *>>();
|
|
|
|
connect(m_effectLoader, &AbstractEffectLoader::effectLoaded, this, [this](Effect *effect, const QString &name) {
|
|
|
|
effect_order.insert(effect->requestedEffectChainPosition(), EffectPair(name, effect));
|
|
|
|
loaded_effects << EffectPair(name, effect);
|
|
|
|
effectsChanged();
|
|
|
|
});
|
2016-01-29 10:24:18 +00:00
|
|
|
m_effectLoader->setConfig(kwinApp()->config());
|
2012-08-30 06:20:26 +00:00
|
|
|
new EffectsAdaptor(this);
|
|
|
|
QDBusConnection dbus = QDBusConnection::sessionBus();
|
2013-07-23 05:02:52 +00:00
|
|
|
dbus.registerObject(QStringLiteral("/Effects"), this);
|
2011-11-27 17:36:59 +00:00
|
|
|
|
2011-02-25 19:41:10 +00:00
|
|
|
Workspace *ws = Workspace::self();
|
2012-11-16 07:23:47 +00:00
|
|
|
VirtualDesktopManager *vds = VirtualDesktopManager::self();
|
2022-04-14 10:58:03 +00:00
|
|
|
connect(ws, &Workspace::showingDesktopChanged, this, [this](bool showing, bool animated) {
|
|
|
|
if (animated) {
|
|
|
|
Q_EMIT showingDesktopChanged(showing);
|
|
|
|
}
|
2022-02-04 14:13:47 +00:00
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(ws, &Workspace::currentDesktopChanged, this, [this](int old, Window *c) {
|
2022-04-15 12:23:44 +00:00
|
|
|
const int newDesktop = VirtualDesktopManager::self()->current();
|
|
|
|
if (old != 0 && newDesktop != old) {
|
|
|
|
Q_EMIT desktopChanged(old, newDesktop, c ? c->effectWindow() : nullptr);
|
|
|
|
// TODO: remove in 4.10
|
|
|
|
Q_EMIT desktopChanged(old, newDesktop);
|
2014-03-26 08:13:35 +00:00
|
|
|
}
|
2022-04-15 12:23:44 +00:00
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(ws, &Workspace::currentDesktopChanging, this, [this](uint currentDesktop, QPointF offset, KWin::Window *c) {
|
2022-04-15 12:23:44 +00:00
|
|
|
Q_EMIT desktopChanging(currentDesktop, offset, c ? c->effectWindow() : nullptr);
|
|
|
|
});
|
|
|
|
connect(ws, &Workspace::currentDesktopChangingCancelled, this, [this]() {
|
|
|
|
Q_EMIT desktopChangingCancelled();
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(ws, &Workspace::desktopPresenceChanged, this, [this](Window *c, int old) {
|
2022-03-23 10:13:38 +00:00
|
|
|
if (!c->effectWindow()) {
|
|
|
|
return;
|
2014-03-26 08:13:35 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT desktopPresenceChanged(c->effectWindow(), old, c->desktop());
|
|
|
|
});
|
2022-04-23 08:33:23 +00:00
|
|
|
connect(ws, &Workspace::windowAdded, this, [this](Window *c) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->readyForPainting()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
slotClientShown(c);
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::windowShown, this, &EffectsHandlerImpl::slotClientShown);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
|
|
|
connect(ws, &Workspace::unmanagedAdded, this, [this](Unmanaged *u) {
|
|
|
|
// it's never initially ready but has synthetic 50ms delay
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(u, &Window::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown);
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2022-04-23 08:33:23 +00:00
|
|
|
connect(ws, &Workspace::internalWindowAdded, this, [this](InternalWindow *client) {
|
2022-03-23 10:13:38 +00:00
|
|
|
setupClientConnections(client);
|
|
|
|
Q_EMIT windowAdded(client->effectWindow());
|
|
|
|
});
|
2022-04-23 08:33:23 +00:00
|
|
|
connect(ws, &Workspace::windowActivated, this, [this](KWin::Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowActivated(c ? c->effectWindow() : nullptr);
|
|
|
|
});
|
|
|
|
connect(ws, &Workspace::deletedRemoved, this, [this](KWin::Deleted *d) {
|
|
|
|
Q_EMIT windowDeleted(d->effectWindow());
|
|
|
|
elevated_windows.removeAll(d->effectWindow());
|
|
|
|
});
|
|
|
|
connect(ws->sessionManager(), &SessionManager::stateChanged, this, &KWin::EffectsHandler::sessionStateChanged);
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(vds, &VirtualDesktopManager::countChanged, this, &EffectsHandler::numberDesktopsChanged);
|
2020-04-02 16:18:01 +00:00
|
|
|
connect(Cursors::self()->mouse(), &Cursor::mouseChanged, this, &EffectsHandler::mouseChanged);
|
2021-03-01 09:45:52 +00:00
|
|
|
connect(Screens::self(), &Screens::sizeChanged, this, &EffectsHandler::virtualScreenSizeChanged);
|
|
|
|
connect(Screens::self(), &Screens::geometryChanged, this, &EffectsHandler::virtualScreenGeometryChanged);
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2015-07-07 09:48:42 +00:00
|
|
|
if (Activities *activities = Activities::self()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(activities, &Activities::added, this, &EffectsHandler::activityAdded);
|
|
|
|
connect(activities, &Activities::removed, this, &EffectsHandler::activityRemoved);
|
2015-07-07 09:48:42 +00:00
|
|
|
connect(activities, &Activities::currentChanged, this, &EffectsHandler::currentActivityChanged);
|
|
|
|
}
|
2013-04-04 14:14:12 +00:00
|
|
|
#endif
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(ws, &Workspace::stackingOrderChanged, this, &EffectsHandler::stackingOrderChanged);
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded);
|
|
|
|
connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated);
|
|
|
|
connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed);
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent);
|
2013-01-26 10:50:14 +00:00
|
|
|
#endif
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching);
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2016-08-15 06:37:24 +00:00
|
|
|
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged);
|
2019-06-23 15:59:44 +00:00
|
|
|
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &EffectsHandler::screenAboutToLock);
|
2022-02-23 13:27:05 +00:00
|
|
|
#endif
|
2017-08-23 09:41:26 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(kwinApp(), &Application::x11ConnectionChanged, this, [this]() {
|
|
|
|
registered_atoms.clear();
|
|
|
|
for (auto it = m_propertiesForEffects.keyBegin(); it != m_propertiesForEffects.keyEnd(); it++) {
|
|
|
|
const auto atom = registerSupportProperty(*it);
|
|
|
|
if (atom == XCB_ATOM_NONE) {
|
|
|
|
continue;
|
2017-09-16 17:25:33 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
m_compositor->keepSupportProperty(atom);
|
|
|
|
m_managedProperties.insert(*it, atom);
|
|
|
|
registerPropertyType(atom, true);
|
2017-08-23 09:41:26 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
if (kwinApp()->x11Connection()) {
|
|
|
|
m_x11WindowPropertyNotify = std::make_unique<WindowPropertyNotifyX11Filter>(this);
|
|
|
|
} else {
|
|
|
|
m_x11WindowPropertyNotify.reset();
|
|
|
|
}
|
|
|
|
Q_EMIT xcbConnectionChanged();
|
|
|
|
});
|
2017-08-23 09:41:26 +00:00
|
|
|
|
2017-09-16 17:25:33 +00:00
|
|
|
if (kwinApp()->x11Connection()) {
|
|
|
|
m_x11WindowPropertyNotify = std::make_unique<WindowPropertyNotifyX11Filter>(this);
|
|
|
|
}
|
|
|
|
|
2011-02-27 08:25:45 +00:00
|
|
|
// connect all clients
|
2022-04-22 17:39:12 +00:00
|
|
|
for (Window *client : ws->allClientList()) {
|
2020-10-01 11:33:31 +00:00
|
|
|
if (client->readyForPainting()) {
|
|
|
|
setupClientConnections(client);
|
|
|
|
} else {
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(client, &Window::windowShown, this, &EffectsHandlerImpl::slotClientShown);
|
2020-10-01 11:33:31 +00:00
|
|
|
}
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
2013-09-24 12:31:35 +00:00
|
|
|
for (Unmanaged *u : ws->unmanagedList()) {
|
2011-03-06 10:13:11 +00:00
|
|
|
setupUnmanagedConnections(u);
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
2022-04-23 08:33:23 +00:00
|
|
|
for (InternalWindow *client : ws->internalWindows()) {
|
2020-05-08 07:07:20 +00:00
|
|
|
setupClientConnections(client);
|
2019-08-26 07:44:04 +00:00
|
|
|
}
|
2020-10-01 11:33:31 +00:00
|
|
|
|
2021-03-01 09:45:52 +00:00
|
|
|
connect(kwinApp()->platform(), &Platform::outputEnabled, this, &EffectsHandlerImpl::slotOutputEnabled);
|
|
|
|
connect(kwinApp()->platform(), &Platform::outputDisabled, this, &EffectsHandlerImpl::slotOutputDisabled);
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
const QVector<Output *> outputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
for (Output *output : outputs) {
|
2021-03-01 09:45:52 +00:00
|
|
|
slotOutputEnabled(output);
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:53:59 +00:00
|
|
|
connect(InputMethod::self(), &InputMethod::panelChanged, this, &EffectsHandlerImpl::inputPanelChanged);
|
|
|
|
|
2007-05-28 11:23:00 +00:00
|
|
|
reconfigure();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectsHandlerImpl::~EffectsHandlerImpl()
|
2015-11-12 10:29:56 +00:00
|
|
|
{
|
|
|
|
unloadAllEffects();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::unloadAllEffects()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-05-13 16:41:39 +00:00
|
|
|
for (const EffectPair &pair : qAsConst(loaded_effects)) {
|
2018-12-19 14:44:06 +00:00
|
|
|
destroyEffect(pair.second);
|
2013-11-13 09:03:58 +00:00
|
|
|
}
|
2018-12-01 16:33:52 +00:00
|
|
|
|
|
|
|
effect_order.clear();
|
2015-11-16 13:06:23 +00:00
|
|
|
m_effectLoader->clear();
|
2018-12-01 16:33:52 +00:00
|
|
|
|
|
|
|
effectsChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::setupClientConnections(Window *c)
|
2011-03-06 10:13:11 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
|
|
|
|
connect(c, static_cast<void (Window::*)(KWin::Window *, MaximizeMode)>(&Window::clientMaximizedStateChanged),
|
2014-03-26 08:13:35 +00:00
|
|
|
this, &EffectsHandlerImpl::slotClientMaximized);
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::clientStartUserMovedResized, this, [this](Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowStartUserMovedResized(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::clientStepUserMovedResized, this, [this](Window *c, const QRect &geometry) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowStepUserMovedResized(c->effectWindow(), geometry);
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::clientFinishUserMovedResized, this, [this](Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowFinishUserMovedResized(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
|
|
|
|
connect(c, &Window::clientMinimized, this, [this](Window *c, bool animate) {
|
2022-03-23 10:13:38 +00:00
|
|
|
// TODO: notify effects even if it should not animate?
|
|
|
|
if (animate) {
|
|
|
|
Q_EMIT windowMinimized(c->effectWindow());
|
2014-03-26 08:13:35 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::clientUnminimized, this, [this](Window *c, bool animate) {
|
2022-03-23 10:13:38 +00:00
|
|
|
// TODO: notify effects even if it should not animate?
|
|
|
|
if (animate) {
|
|
|
|
Q_EMIT windowUnminimized(c->effectWindow());
|
2014-03-26 08:13:35 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::modalChanged, this, &EffectsHandlerImpl::slotClientModalityChanged);
|
|
|
|
connect(c, &Window::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
|
|
|
|
connect(c, &Window::frameGeometryChanged, this, &EffectsHandlerImpl::slotFrameGeometryChanged);
|
|
|
|
connect(c, &Window::damaged, this, &EffectsHandlerImpl::slotWindowDamaged);
|
|
|
|
connect(c, &Window::unresponsiveChanged, this, [this, c](bool unresponsive) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowUnresponsiveChanged(c->effectWindow(), unresponsive);
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::windowShown, this, [this](Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowShown(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::windowHidden, this, [this](Window *c) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowHidden(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::keepAboveChanged, this, [this, c](bool above) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_UNUSED(above)
|
|
|
|
Q_EMIT windowKeepAboveChanged(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::keepBelowChanged, this, [this, c](bool below) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_UNUSED(below)
|
|
|
|
Q_EMIT windowKeepBelowChanged(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::fullScreenChanged, this, [this, c]() {
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_EMIT windowFullScreenChanged(c->effectWindow());
|
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::visibleGeometryChanged, this, [this, c]() {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowExpandedGeometryChanged(c->effectWindow());
|
2021-02-05 13:05:13 +00:00
|
|
|
});
|
2022-04-22 17:39:12 +00:00
|
|
|
connect(c, &Window::decorationChanged, this, [this, c]() {
|
2022-02-09 21:00:07 +00:00
|
|
|
Q_EMIT windowDecorationChanged(c->effectWindow());
|
|
|
|
});
|
2015-10-26 09:43:36 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged *u)
|
2011-03-06 10:13:11 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(u, &Unmanaged::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
|
|
|
|
connect(u, &Unmanaged::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(u, &Unmanaged::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
|
2020-02-11 17:03:23 +00:00
|
|
|
connect(u, &Unmanaged::frameGeometryChanged, this, &EffectsHandlerImpl::slotFrameGeometryChanged);
|
2022-03-23 10:13:38 +00:00
|
|
|
connect(u, &Unmanaged::damaged, this, &EffectsHandlerImpl::slotWindowDamaged);
|
2021-02-05 13:05:13 +00:00
|
|
|
connect(u, &Unmanaged::visibleGeometryChanged, this, [this, u]() {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowExpandedGeometryChanged(u->effectWindow());
|
2021-02-05 13:05:13 +00:00
|
|
|
});
|
2011-03-06 10:13:11 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 11:23:00 +00:00
|
|
|
void EffectsHandlerImpl::reconfigure()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-03-25 12:43:56 +00:00
|
|
|
m_effectLoader->queryAndLoadAll();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-28 11:23:00 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// the idea is that effects call this function again which calls the next one
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
(*m_currentPaintScreenIterator++)->prePaintScreen(data, presentTime);
|
2011-08-27 09:21:31 +00:00
|
|
|
--m_currentPaintScreenIterator;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintScreenIterator++)->paintScreen(mask, region, data);
|
|
|
|
--m_currentPaintScreenIterator;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2012-08-16 19:19:54 +00:00
|
|
|
m_scene->finalPaintScreen(mask, region, data);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-03-29 18:12:34 +00:00
|
|
|
void EffectsHandlerImpl::paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData &data)
|
|
|
|
{
|
|
|
|
if (desktop < 1 || desktop > numberOfDesktops()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_currentRenderedDesktop = desktop;
|
|
|
|
m_desktopRendering = true;
|
|
|
|
// save the paint screen iterator
|
2013-07-19 09:34:01 +00:00
|
|
|
EffectsIterator savedIterator = m_currentPaintScreenIterator;
|
|
|
|
m_currentPaintScreenIterator = m_activeEffects.constBegin();
|
2012-03-29 18:12:34 +00:00
|
|
|
effects->paintScreen(mask, region, data);
|
|
|
|
// restore the saved iterator
|
|
|
|
m_currentPaintScreenIterator = savedIterator;
|
|
|
|
m_desktopRendering = false;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintScreenIterator++)->postPaintScreen();
|
|
|
|
--m_currentPaintScreenIterator;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
(*m_currentPaintWindowIterator++)->prePaintWindow(w, data, presentTime);
|
2011-08-27 09:21:31 +00:00
|
|
|
--m_currentPaintWindowIterator;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data);
|
|
|
|
--m_currentPaintWindowIterator;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2022-03-23 10:13:38 +00:00
|
|
|
m_scene->finalPaintWindow(static_cast<EffectWindowImpl *>(w), mask, region, data);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintEffectFrameIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity);
|
|
|
|
--m_currentPaintEffectFrameIterator;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2022-03-23 10:13:38 +00:00
|
|
|
const EffectFrameImpl *frameImpl = static_cast<const EffectFrameImpl *>(frame);
|
2011-01-30 14:34:42 +00:00
|
|
|
frameImpl->finalRender(region, opacity, frameOpacity);
|
2010-07-24 16:29:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-24 16:29:16 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::postPaintWindow(EffectWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintWindowIterator++)->postPaintWindow(w);
|
|
|
|
--m_currentPaintWindowIterator;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// no special final code
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-03-23 01:06:46 +00:00
|
|
|
Effect *EffectsHandlerImpl::provides(Effect::Feature ef)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
for (int i = 0; i < loaded_effects.size(); ++i) {
|
|
|
|
if (loaded_effects.at(i).second->provides(ef)) {
|
2012-03-23 01:06:46 +00:00
|
|
|
return loaded_effects.at(i).second;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
}
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-04-25 18:40:04 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data);
|
|
|
|
--m_currentDrawWindowIterator;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2022-03-23 10:13:38 +00:00
|
|
|
m_scene->finalDrawWindow(static_cast<EffectWindowImpl *>(w), mask, region, data);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-10-17 10:30:43 +00:00
|
|
|
bool EffectsHandlerImpl::hasDecorationShadows() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-07-22 11:11:19 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2010-03-05 18:21:14 +00:00
|
|
|
bool EffectsHandlerImpl::decorationsHaveAlpha() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-07-22 11:11:19 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-05 18:21:14 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// start another painting pass
|
|
|
|
void EffectsHandlerImpl::startPaint()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-08-27 09:21:31 +00:00
|
|
|
m_activeEffects.clear();
|
2013-07-19 09:46:42 +00:00
|
|
|
m_activeEffects.reserve(loaded_effects.count());
|
2022-03-23 10:13:38 +00:00
|
|
|
for (QVector<KWin::EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
2011-08-27 09:21:31 +00:00
|
|
|
if (it->second->isActive()) {
|
|
|
|
m_activeEffects << it->second;
|
|
|
|
}
|
|
|
|
}
|
2013-07-19 09:34:01 +00:00
|
|
|
m_currentDrawWindowIterator = m_activeEffects.constBegin();
|
|
|
|
m_currentPaintWindowIterator = m_activeEffects.constBegin();
|
|
|
|
m_currentPaintScreenIterator = m_activeEffects.constBegin();
|
|
|
|
m_currentPaintEffectFrameIterator = m_activeEffects.constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotClientMaximized(KWin::Window *c, MaximizeMode maxMode)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-03-13 08:48:51 +00:00
|
|
|
bool horizontal = false;
|
|
|
|
bool vertical = false;
|
|
|
|
switch (maxMode) {
|
2014-12-02 12:49:08 +00:00
|
|
|
case MaximizeHorizontal:
|
2011-03-13 08:48:51 +00:00
|
|
|
horizontal = true;
|
|
|
|
break;
|
2014-12-02 12:49:08 +00:00
|
|
|
case MaximizeVertical:
|
2011-03-13 08:48:51 +00:00
|
|
|
vertical = true;
|
|
|
|
break;
|
2014-12-02 12:49:08 +00:00
|
|
|
case MaximizeFull:
|
2011-03-13 08:48:51 +00:00
|
|
|
horizontal = true;
|
|
|
|
vertical = true;
|
|
|
|
break;
|
2014-12-02 12:49:08 +00:00
|
|
|
case MaximizeRestore: // fall through
|
2011-03-13 08:48:51 +00:00
|
|
|
default:
|
|
|
|
// default - nothing to do
|
|
|
|
break;
|
|
|
|
}
|
2013-05-07 07:46:40 +00:00
|
|
|
if (EffectWindowImpl *w = c->effectWindow()) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowMaximizedStateChanged(w, horizontal, vertical);
|
2013-05-07 07:46:40 +00:00
|
|
|
}
|
2011-02-28 20:03:13 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotOpacityChanged(Window *t, qreal oldOpacity)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-15 17:34:12 +00:00
|
|
|
if (t->opacity() == oldOpacity || !t->effectWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-03-06 09:30:23 +00:00
|
|
|
}
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowOpacityChanged(t->effectWindow(), oldOpacity, (qreal)t->opacity());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotClientShown(KWin::Window *t)
|
2012-01-24 16:00:40 +00:00
|
|
|
{
|
2022-04-14 13:50:12 +00:00
|
|
|
Q_ASSERT(t->isClient());
|
2022-04-22 17:39:12 +00:00
|
|
|
disconnect(t, &Window::windowShown, this, &EffectsHandlerImpl::slotClientShown);
|
2022-04-18 08:10:29 +00:00
|
|
|
setupClientConnections(t);
|
|
|
|
Q_EMIT windowAdded(t->effectWindow());
|
2012-01-24 16:00:40 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotUnmanagedShown(KWin::Window *t)
|
2022-03-23 10:13:38 +00:00
|
|
|
{ // regardless, unmanaged windows are -yet?- not synced anyway
|
2018-12-08 12:04:20 +00:00
|
|
|
Q_ASSERT(qobject_cast<Unmanaged *>(t));
|
2022-03-23 10:13:38 +00:00
|
|
|
Unmanaged *u = static_cast<Unmanaged *>(t);
|
2013-06-28 12:23:22 +00:00
|
|
|
setupUnmanagedConnections(u);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowAdded(u->effectWindow());
|
2013-06-28 12:23:22 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotWindowClosed(KWin::Window *c, KWin::Deleted *d)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-12-29 16:02:09 +00:00
|
|
|
c->disconnect(this);
|
2015-11-09 15:27:15 +00:00
|
|
|
if (d) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowClosed(c->effectWindow());
|
2015-11-09 15:27:15 +00:00
|
|
|
}
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 14:26:55 +00:00
|
|
|
void EffectsHandlerImpl::slotClientModalityChanged()
|
|
|
|
{
|
2022-04-22 17:54:31 +00:00
|
|
|
Q_EMIT windowModalityChanged(static_cast<X11Window *>(sender())->effectWindow());
|
2013-06-19 14:26:55 +00:00
|
|
|
}
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void EffectsHandlerImpl::slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT currentTabAboutToChange(from, to);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::slotTabAdded(EffectWindow *w, EffectWindow *to)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT tabAdded(w, to);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow *leaderOfFormerGroup)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT tabRemoved(w, leaderOfFormerGroup);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotWindowDamaged(Window *t, const QRegion &r)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-05-19 15:28:15 +00:00
|
|
|
if (!t->effectWindow()) {
|
|
|
|
// can happen during tear down of window
|
|
|
|
return;
|
|
|
|
}
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowDamaged(t->effectWindow(), r);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotGeometryShapeChanged(Window *t, const QRect &old)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-03-12 11:34:59 +00:00
|
|
|
// during late cleanup effectWindow() may be already NULL
|
|
|
|
// in some functions that may still call this
|
2022-03-25 12:20:32 +00:00
|
|
|
if (t == nullptr || t->effectWindow() == nullptr) {
|
2011-03-12 11:34:59 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowGeometryShapeChanged(t->effectWindow(), old);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectsHandlerImpl::slotFrameGeometryChanged(Window *toplevel, const QRect &oldGeometry)
|
2020-02-11 17:03:23 +00:00
|
|
|
{
|
|
|
|
// effectWindow() might be nullptr during tear down of the client.
|
|
|
|
if (toplevel->effectWindow()) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowFrameGeometryChanged(toplevel->effectWindow(), oldGeometry);
|
2020-02-11 17:03:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::setActiveFullScreenEffect(Effect *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-06-23 19:41:26 +00:00
|
|
|
if (fullscreen_effect == e) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-03 00:11:59 +00:00
|
|
|
const bool activeChanged = (e == nullptr || fullscreen_effect == nullptr);
|
2007-11-01 17:47:41 +00:00
|
|
|
fullscreen_effect = e;
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT activeFullScreenEffectChanged();
|
2018-10-03 00:11:59 +00:00
|
|
|
if (activeChanged) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT hasActiveFullScreenEffectChanged();
|
2018-10-03 00:11:59 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-01 17:47:41 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Effect *EffectsHandlerImpl::activeFullScreenEffect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-11-01 17:47:41 +00:00
|
|
|
return fullscreen_effect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-01 17:47:41 +00:00
|
|
|
|
2018-10-03 00:11:59 +00:00
|
|
|
bool EffectsHandlerImpl::hasActiveFullScreenEffect() const
|
|
|
|
{
|
|
|
|
return fullscreen_effect;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool EffectsHandlerImpl::grabKeyboard(Effect *effect)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (keyboard_grab_effect != nullptr) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2017-09-23 18:21:26 +00:00
|
|
|
if (!doGrabKeyboard()) {
|
|
|
|
return false;
|
2013-07-02 09:44:18 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
keyboard_grab_effect = effect;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
bool EffectsHandlerImpl::doGrabKeyboard()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::ungrabKeyboard()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
Q_ASSERT(keyboard_grab_effect != nullptr);
|
2017-09-23 18:21:26 +00:00
|
|
|
doUngrabKeyboard();
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
keyboard_grab_effect = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
void EffectsHandlerImpl::doUngrabKeyboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (keyboard_grab_effect != nullptr) {
|
2011-01-30 14:34:42 +00:00
|
|
|
keyboard_grab_effect->grabbedKeyboardEvent(e);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-04-24 14:51:04 +00:00
|
|
|
void EffectsHandlerImpl::startMouseInterception(Effect *effect, Qt::CursorShape shape)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.contains(effect)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_grabbedMouseEffects.append(effect);
|
|
|
|
if (m_grabbedMouseEffects.size() != 1) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-23 18:21:26 +00:00
|
|
|
doStartMouseInterception(shape);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::doStartMouseInterception(Qt::CursorShape shape)
|
|
|
|
{
|
|
|
|
input()->pointer()->setEffectsOverrideCursor(shape);
|
2013-04-24 14:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::stopMouseInterception(Effect *effect)
|
|
|
|
{
|
|
|
|
if (!m_grabbedMouseEffects.contains(effect)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_grabbedMouseEffects.removeAll(effect);
|
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
2017-09-23 18:21:26 +00:00
|
|
|
doStopMouseInterception();
|
2013-04-24 14:51:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
void EffectsHandlerImpl::doStopMouseInterception()
|
|
|
|
{
|
|
|
|
input()->pointer()->removeEffectsOverrideCursor();
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
bool EffectsHandlerImpl::isMouseInterception() const
|
|
|
|
{
|
|
|
|
return m_grabbedMouseEffects.count() > 0;
|
|
|
|
}
|
|
|
|
|
2019-08-11 19:57:45 +00:00
|
|
|
bool EffectsHandlerImpl::touchDown(qint32 id, const QPointF &pos, quint32 time)
|
2016-08-15 13:44:10 +00:00
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->touchDown(id, pos, time)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-11 19:57:45 +00:00
|
|
|
bool EffectsHandlerImpl::touchMotion(qint32 id, const QPointF &pos, quint32 time)
|
2016-08-15 13:44:10 +00:00
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->touchMotion(id, pos, time)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-11 19:57:45 +00:00
|
|
|
bool EffectsHandlerImpl::touchUp(qint32 id, quint32 time)
|
2016-08-15 13:44:10 +00:00
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->touchUp(id, time)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-01-19 18:15:31 +00:00
|
|
|
bool EffectsHandlerImpl::tabletToolEvent(TabletEvent *event)
|
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->tabletToolEvent(event)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId)
|
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->tabletToolButtonEvent(button, pressed, tabletToolId.m_uniqueId)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId)
|
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->tabletPadButtonEvent(button, pressed, tabletPadId.data)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId)
|
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->tabletPadStripEvent(number, position, isFinger, tabletPadId.data)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId)
|
|
|
|
{
|
|
|
|
// TODO: reverse call order?
|
|
|
|
for (auto it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if (it->second->tabletPadRingEvent(number, position, isFinger, tabletPadId.data)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-10 10:26:50 +00:00
|
|
|
void EffectsHandlerImpl::registerGlobalShortcut(const QKeySequence &shortcut, QAction *action)
|
|
|
|
{
|
|
|
|
input()->registerShortcut(shortcut, action);
|
|
|
|
}
|
|
|
|
|
2013-07-14 20:58:30 +00:00
|
|
|
void EffectsHandlerImpl::registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action)
|
|
|
|
{
|
|
|
|
input()->registerPointerShortcut(modifiers, pointerButtons, action);
|
|
|
|
}
|
|
|
|
|
2013-07-15 10:04:13 +00:00
|
|
|
void EffectsHandlerImpl::registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action)
|
|
|
|
{
|
|
|
|
input()->registerAxisShortcut(modifiers, axis, action);
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback)
|
2021-04-19 04:42:46 +00:00
|
|
|
{
|
2022-02-02 21:51:39 +00:00
|
|
|
input()->registerRealtimeTouchpadSwipeShortcut(dir, fingerCount, onUp, progressCallback);
|
2021-04-19 04:42:46 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 21:51:39 +00:00
|
|
|
void EffectsHandlerImpl::registerTouchpadSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action)
|
2017-03-18 10:00:30 +00:00
|
|
|
{
|
2022-02-02 21:51:39 +00:00
|
|
|
input()->registerTouchpadSwipeShortcut(direction, fingerCount, action);
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback)
|
2022-02-02 21:51:39 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
input()->registerRealtimeTouchpadPinchShortcut(dir, fingerCount, onUp, progressCallback);
|
2022-02-02 21:51:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *action)
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
input()->registerTouchpadPinchShortcut(direction, fingerCount, action);
|
2017-03-18 10:00:30 +00:00
|
|
|
}
|
|
|
|
|
2022-03-16 18:00:24 +00:00
|
|
|
void EffectsHandlerImpl::registerTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action)
|
|
|
|
{
|
|
|
|
input()->registerTouchscreenSwipeShortcut(direction, fingerCount, action);
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void *EffectsHandlerImpl::getProxy(QString name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if ((*it).first == name) {
|
2009-02-06 10:15:06 +00:00
|
|
|
return (*it).second->proxy();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-06 10:15:06 +00:00
|
|
|
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-06 10:15:06 +00:00
|
|
|
|
2009-02-01 15:16:52 +00:00
|
|
|
void EffectsHandlerImpl::startMousePolling()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (Cursors::self()->mouse()) {
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->startMousePolling();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-01 15:16:52 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::stopMousePolling()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (Cursors::self()->mouse()) {
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->stopMousePolling();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-01 15:16:52 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectsHandlerImpl::hasKeyboardGrab() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return keyboard_grab_effect != nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::registerPropertyType(long atom, bool reg)
|
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (reg) {
|
2022-03-23 10:13:38 +00:00
|
|
|
++registered_atoms[atom]; // initialized to 0 if not present yet
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
|
|
|
if (--registered_atoms[atom] == 0) {
|
2011-01-30 14:34:42 +00:00
|
|
|
registered_atoms.remove(atom);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
|
2012-12-13 23:09:47 +00:00
|
|
|
xcb_atom_t EffectsHandlerImpl::announceSupportProperty(const QByteArray &propertyName, Effect *effect)
|
|
|
|
{
|
|
|
|
PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName);
|
|
|
|
if (it != m_propertiesForEffects.end()) {
|
|
|
|
// property has already been registered for an effect
|
|
|
|
// just append Effect and return the atom stored in m_managedProperties
|
|
|
|
if (!it.value().contains(effect)) {
|
|
|
|
it.value().append(effect);
|
|
|
|
}
|
2017-08-23 09:41:26 +00:00
|
|
|
return m_managedProperties.value(propertyName, XCB_ATOM_NONE);
|
2012-12-13 23:09:47 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
m_propertiesForEffects.insert(propertyName, QList<Effect *>() << effect);
|
2017-08-23 09:41:26 +00:00
|
|
|
const auto atom = registerSupportProperty(propertyName);
|
|
|
|
if (atom == XCB_ATOM_NONE) {
|
|
|
|
return atom;
|
|
|
|
}
|
|
|
|
m_compositor->keepSupportProperty(atom);
|
|
|
|
m_managedProperties.insert(propertyName, atom);
|
|
|
|
registerPropertyType(atom, true);
|
|
|
|
return atom;
|
2012-12-13 23:09:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::removeSupportProperty(const QByteArray &propertyName, Effect *effect)
|
|
|
|
{
|
|
|
|
PropertyEffectMap::iterator it = m_propertiesForEffects.find(propertyName);
|
|
|
|
if (it == m_propertiesForEffects.end()) {
|
|
|
|
// property is not registered - nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!it.value().contains(effect)) {
|
|
|
|
// property is not registered for given effect - nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
it.value().removeAll(effect);
|
|
|
|
if (!it.value().isEmpty()) {
|
|
|
|
// property still registered for another effect - nothing further to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const xcb_atom_t atom = m_managedProperties.take(propertyName);
|
|
|
|
registerPropertyType(atom, false);
|
|
|
|
m_propertiesForEffects.remove(propertyName);
|
2013-04-26 22:00:23 +00:00
|
|
|
m_compositor->removeSupportProperty(atom); // delayed removal
|
2012-12-13 23:09:47 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray EffectsHandlerImpl::readRootProperty(long atom, long type, int format) const
|
|
|
|
{
|
2017-09-02 08:04:15 +00:00
|
|
|
if (!kwinApp()->x11Connection()) {
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
return readWindowProperty(kwinApp()->x11RootWindow(), atom, type, format);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::activateWindow(EffectWindow *c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(c)->window();
|
|
|
|
if (window->isClient()) {
|
2022-04-23 08:33:23 +00:00
|
|
|
Workspace::self()->activateWindow(window, true);
|
2018-12-08 12:04:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::activeWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-23 08:33:23 +00:00
|
|
|
return Workspace::self()->activeWindow() ? Workspace::self()->activeWindow()->effectWindow() : nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::moveWindow(EffectWindow *w, const QPoint &pos, bool snap, double snapAdjust)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
|
|
|
if (!window->isClient() || !window->isMovable()) {
|
2009-10-05 04:06:20 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2009-10-05 04:06:20 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if (snap) {
|
2022-04-23 08:33:23 +00:00
|
|
|
window->move(Workspace::self()->adjustWindowPosition(window, pos, true, snapAdjust));
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2022-04-18 08:10:29 +00:00
|
|
|
window->move(pos);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::windowToDesktop(EffectWindow *w, int desktop)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
|
|
|
if (window->isClient() && !window->isDesktop() && !window->isDock()) {
|
2022-04-23 08:33:23 +00:00
|
|
|
Workspace::self()->sendWindowToDesktop(window, desktop, true);
|
[wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)
Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)
Test Plan: used a bit a plasma session together with D12820, D13748 and D13746
Reviewers: #plasma, #kwin, graesslin, davidedmundson
Reviewed By: #plasma, #kwin, davidedmundson
Subscribers: hein, zzag, davidedmundson, kwin
Tags: #kwin
Maniphest Tasks: T4457
Differential Revision: https://phabricator.kde.org/D13887
2018-10-29 22:29:15 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2018-11-13 16:18:46 +00:00
|
|
|
void EffectsHandlerImpl::windowToDesktops(EffectWindow *w, const QVector<uint> &desktopIds)
|
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
|
|
|
if (!window->isClient() || window->isDesktop() || window->isDock()) {
|
2018-11-13 16:18:46 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QVector<VirtualDesktop *> desktops;
|
2018-11-13 16:18:46 +00:00
|
|
|
desktops.reserve(desktopIds.count());
|
2022-03-23 10:13:38 +00:00
|
|
|
for (uint x11Id : desktopIds) {
|
2018-11-13 16:18:46 +00:00
|
|
|
if (x11Id > VirtualDesktopManager::self()->count()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
VirtualDesktop *d = VirtualDesktopManager::self()->desktopForX11Id(x11Id);
|
|
|
|
Q_ASSERT(d);
|
|
|
|
if (desktops.contains(d)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
desktops << d;
|
|
|
|
}
|
2022-04-18 08:10:29 +00:00
|
|
|
window->setDesktops(desktops);
|
2018-11-13 16:18:46 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::windowToScreen(EffectWindow *w, EffectScreen *screen)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
|
|
|
if (window->isClient() && !window->isDesktop() && !window->isDock()) {
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreenImpl *screenImpl = static_cast<EffectScreenImpl *>(screen);
|
2022-04-23 08:33:23 +00:00
|
|
|
Workspace::self()->sendWindowToOutput(window, screenImpl->platformOutput());
|
2021-08-28 14:51:00 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-19 08:34:28 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setShowingDesktop(bool showing)
|
|
|
|
{
|
|
|
|
Workspace::self()->setShowingDesktop(showing);
|
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
2011-04-24 12:20:47 +00:00
|
|
|
QString EffectsHandlerImpl::currentActivity() const
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_ACTIVITIES
|
2015-07-07 09:48:42 +00:00
|
|
|
if (!Activities::self()) {
|
|
|
|
return QString();
|
|
|
|
}
|
2013-04-04 14:14:12 +00:00
|
|
|
return Activities::self()->current();
|
|
|
|
#else
|
|
|
|
return QString();
|
|
|
|
#endif
|
2011-04-24 12:20:47 +00:00
|
|
|
}
|
2009-06-28 17:17:29 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int EffectsHandlerImpl::currentDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->current();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::numberOfDesktops() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->count();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setCurrentDesktop(int desktop)
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
VirtualDesktopManager::self()->setCurrent(desktop);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setNumberOfDesktops(int desktops)
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
VirtualDesktopManager::self()->setCount(desktops);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-28 09:04:14 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
QSize EffectsHandlerImpl::desktopGridSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->grid().size();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::desktopGridWidth() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return desktopGridSize().width();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::desktopGridHeight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return desktopGridSize().height();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-14 14:49:46 +00:00
|
|
|
int EffectsHandlerImpl::workspaceWidth() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-03-01 09:45:52 +00:00
|
|
|
return desktopGridWidth() * Screens::self()->size().width();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::workspaceHeight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-03-01 09:45:52 +00:00
|
|
|
return desktopGridHeight() * Screens::self()->size().height();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopAtCoords(QPoint coords) const
|
|
|
|
{
|
2016-11-10 13:02:14 +00:00
|
|
|
if (auto vd = VirtualDesktopManager::self()->grid().at(coords)) {
|
|
|
|
return vd->x11DesktopNumber();
|
|
|
|
}
|
|
|
|
return 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint EffectsHandlerImpl::desktopGridCoords(int id) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->grid().gridCoords(id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint EffectsHandlerImpl::desktopCoords(int id) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
QPoint coords = VirtualDesktopManager::self()->grid().gridCoords(id);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (coords.x() == -1) {
|
2012-11-16 07:23:47 +00:00
|
|
|
return QPoint(-1, -1);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2021-03-01 09:45:52 +00:00
|
|
|
const QSize displaySize = Screens::self()->size();
|
2016-06-08 10:46:02 +00:00
|
|
|
return QPoint(coords.x() * displaySize.width(), coords.y() * displaySize.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopAbove(int desktop, bool wrap) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return getDesktop<DesktopAbove>(desktop, wrap);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopToRight(int desktop, bool wrap) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return getDesktop<DesktopRight>(desktop, wrap);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopBelow(int desktop, bool wrap) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return getDesktop<DesktopBelow>(desktop, wrap);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::desktopToLeft(int desktop, bool wrap) const
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return getDesktop<DesktopLeft>(desktop, wrap);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QString EffectsHandlerImpl::desktopName(int desktop) const
|
|
|
|
{
|
2021-08-25 17:09:33 +00:00
|
|
|
const VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForX11Id(desktop);
|
|
|
|
return vd ? vd->name() : QString();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-14 14:49:46 +00:00
|
|
|
|
|
|
|
bool EffectsHandlerImpl::optionRollOverDesktops() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-02-20 09:25:13 +00:00
|
|
|
return options->isRollOverDesktops();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:17:08 +00:00
|
|
|
|
2008-08-30 07:25:54 +00:00
|
|
|
double EffectsHandlerImpl::animationTimeFactor() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-08-30 07:25:54 +00:00
|
|
|
return options->animationTimeFactor();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-30 07:25:54 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::findWindow(WId id) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-22 17:54:31 +00:00
|
|
|
if (X11Window *w = Workspace::self()->findClient(Predicate::WindowMatch, id)) {
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (Unmanaged *w = Workspace::self()->findUnmanaged(id)) {
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-02 15:37:46 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::findWindow(KWaylandServer::SurfaceInterface *surf) const
|
2015-09-14 14:39:39 +00:00
|
|
|
{
|
|
|
|
if (waylandServer()) {
|
2022-04-23 08:33:23 +00:00
|
|
|
if (Window *w = waylandServer()->findWindow(surf)) {
|
2015-09-14 14:39:39 +00:00
|
|
|
return w->effectWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::findWindow(QWindow *w) const
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
if (Window *toplevel = workspace()->findInternal(w)) {
|
2019-08-26 07:44:04 +00:00
|
|
|
return toplevel->effectWindow();
|
2019-01-13 16:50:32 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-20 13:04:13 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::findWindow(const QUuid &id) const
|
|
|
|
{
|
2022-04-25 12:59:39 +00:00
|
|
|
if (Window *window = workspace()->findToplevel(id)) {
|
|
|
|
return window->effectWindow();
|
2019-01-20 13:04:13 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-09-14 14:39:39 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
QList<Window *> list = Workspace::self()->xStackingOrder();
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2022-04-22 17:39:12 +00:00
|
|
|
for (Window *t : list) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (EffectWindow *w = effectWindow(t)) {
|
2013-07-02 10:45:01 +00:00
|
|
|
ret.append(w);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2013-07-02 10:45:01 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::setElevatedWindow(KWin::EffectWindow *w, bool set)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
elevated_windows.removeAll(w);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (set) {
|
2011-01-30 14:34:42 +00:00
|
|
|
elevated_windows.append(w);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2022-04-18 08:10:29 +00:00
|
|
|
auto window = static_cast<EffectWindowImpl *>(w)->window();
|
|
|
|
if (window->isClient()) {
|
|
|
|
TabBox::TabBox::self()->setCurrentClient(window);
|
2011-06-30 11:02:30 +00:00
|
|
|
}
|
2011-07-07 16:31:18 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(w)
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox::self()->setCurrentDesktop(desktop);
|
2011-07-07 16:31:18 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(desktop)
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2015-03-05 12:59:18 +00:00
|
|
|
const auto clients = TabBox::TabBox::self()->currentClientList();
|
2018-07-01 07:45:39 +00:00
|
|
|
EffectWindowList ret;
|
|
|
|
ret.reserve(clients.size());
|
|
|
|
std::transform(std::cbegin(clients), std::cend(clients),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(ret),
|
|
|
|
[](auto client) {
|
|
|
|
return client->effectWindow();
|
|
|
|
});
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-06-30 11:02:30 +00:00
|
|
|
#else
|
2011-07-06 15:42:07 +00:00
|
|
|
return EffectWindowList();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::refTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox::self()->reference();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::unrefTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox::self()->unreference();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::closeTabBox()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox::self()->close();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<int> EffectsHandlerImpl::currentTabBoxDesktopList() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
return TabBox::TabBox::self()->currentDesktopList();
|
2019-08-10 10:27:19 +00:00
|
|
|
#else
|
2022-03-23 10:13:38 +00:00
|
|
|
return QList<int>();
|
2019-08-10 10:27:19 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int EffectsHandlerImpl::currentTabBoxDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
return TabBox::TabBox::self()->currentDesktop();
|
2019-08-10 10:27:19 +00:00
|
|
|
#else
|
2011-06-25 16:05:07 +00:00
|
|
|
return -1;
|
2019-08-10 10:27:19 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectsHandlerImpl::currentTabBoxWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2022-03-25 12:20:32 +00:00
|
|
|
if (auto c = TabBox::TabBox::self()->currentClient()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->effectWindow();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectsHandlerImpl::addRepaintFull()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(const QRect &r)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaint(r);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(const QRegion &r)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaint(r);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-19 14:16:21 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::addRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaint(x, y, w, h);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreen *EffectsHandlerImpl::activeScreen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
return EffectScreenImpl::get(workspace()->activeOutput());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2022-03-29 09:59:02 +00:00
|
|
|
static VirtualDesktop *resolveVirtualDesktop(int desktopId)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-29 09:59:02 +00:00
|
|
|
if (desktopId == 0 || desktopId == -1) {
|
|
|
|
return VirtualDesktopManager::self()->currentDesktop();
|
2021-10-01 07:23:30 +00:00
|
|
|
} else {
|
2022-03-29 09:59:02 +00:00
|
|
|
return VirtualDesktopManager::self()->desktopForX11Id(desktopId);
|
2021-10-01 07:23:30 +00:00
|
|
|
}
|
2022-03-29 09:59:02 +00:00
|
|
|
}
|
2008-06-19 14:16:21 +00:00
|
|
|
|
2022-03-29 09:59:02 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *screen, int desktop) const
|
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
const EffectScreenImpl *screenImpl = static_cast<const EffectScreenImpl *>(screen);
|
2022-03-29 09:59:02 +00:00
|
|
|
return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), resolveVirtualDesktop(desktop));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *c) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
const Window *t = static_cast<const EffectWindowImpl *>(c)->window();
|
2021-08-26 10:42:52 +00:00
|
|
|
return Workspace::self()->clientArea(opt, t);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-14 12:33:28 +00:00
|
|
|
const Output *output = kwinApp()->platform()->outputAt(p);
|
2022-03-29 09:59:02 +00:00
|
|
|
const VirtualDesktop *virtualDesktop = resolveVirtualDesktop(desktop);
|
|
|
|
return Workspace::self()->clientArea(opt, output, virtualDesktop);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-02-27 08:55:45 +00:00
|
|
|
QRect EffectsHandlerImpl::virtualScreenGeometry() const
|
|
|
|
{
|
2021-03-01 09:45:52 +00:00
|
|
|
return Screens::self()->geometry();
|
2014-02-27 08:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize EffectsHandlerImpl::virtualScreenSize() const
|
|
|
|
{
|
2021-03-01 09:45:52 +00:00
|
|
|
return Screens::self()->size();
|
2014-02-27 08:55:45 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 14:51:04 +00:00
|
|
|
void EffectsHandlerImpl::defineCursor(Qt::CursorShape shape)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2017-09-23 18:21:26 +00:00
|
|
|
input()->pointer()->setEffectsOverrideCursor(shape);
|
2013-02-19 17:35:23 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 09:40:30 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(QMouseEvent *e)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-11-03 11:55:31 +00:00
|
|
|
for (Effect *effect : qAsConst(m_grabbedMouseEffects)) {
|
2013-06-26 09:40:30 +00:00
|
|
|
effect->windowInputMouseEvent(e);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-04 13:14:44 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(QWheelEvent *e)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-11-03 11:55:31 +00:00
|
|
|
for (Effect *effect : qAsConst(m_grabbedMouseEffects)) {
|
2016-03-04 13:14:44 +00:00
|
|
|
effect->windowInputMouseEvent(e);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-07 16:12:53 +00:00
|
|
|
void EffectsHandlerImpl::connectNotify(const QMetaMethod &signal)
|
|
|
|
{
|
|
|
|
if (signal == QMetaMethod::fromSignal(&EffectsHandler::cursorShapeChanged)) {
|
|
|
|
if (!m_trackingCursorChanges) {
|
2020-04-02 16:18:01 +00:00
|
|
|
connect(Cursors::self()->mouse(), &Cursor::cursorChanged, this, &EffectsHandler::cursorShapeChanged);
|
|
|
|
Cursors::self()->mouse()->startCursorTracking();
|
2015-02-07 16:12:53 +00:00
|
|
|
}
|
|
|
|
++m_trackingCursorChanges;
|
|
|
|
}
|
|
|
|
EffectsHandler::connectNotify(signal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::disconnectNotify(const QMetaMethod &signal)
|
|
|
|
{
|
|
|
|
if (signal == QMetaMethod::fromSignal(&EffectsHandler::cursorShapeChanged)) {
|
|
|
|
Q_ASSERT(m_trackingCursorChanges > 0);
|
|
|
|
if (!--m_trackingCursorChanges) {
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->stopCursorTracking();
|
|
|
|
disconnect(Cursors::self()->mouse(), &Cursor::cursorChanged, this, &EffectsHandler::cursorShapeChanged);
|
2015-02-07 16:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EffectsHandler::disconnectNotify(signal);
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::checkInputWindowStacking()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-24 14:51:04 +00:00
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2012-07-16 19:57:11 +00:00
|
|
|
}
|
2017-09-23 18:21:26 +00:00
|
|
|
doCheckInputWindowStacking();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::doCheckInputWindowStacking()
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QPoint EffectsHandlerImpl::cursorPos() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-04-02 16:18:01 +00:00
|
|
|
return Cursors::self()->mouse()->pos();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-01-22 11:47:06 +00:00
|
|
|
void EffectsHandlerImpl::reserveElectricBorder(ElectricBorder border, Effect *effect)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-25 09:15:00 +00:00
|
|
|
ScreenEdges::self()->reserve(border, effect, "borderActivated");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-01-22 11:47:06 +00:00
|
|
|
void EffectsHandlerImpl::unreserveElectricBorder(ElectricBorder border, Effect *effect)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-25 09:15:00 +00:00
|
|
|
ScreenEdges::self()->unreserve(border, effect);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2017-03-31 05:41:21 +00:00
|
|
|
void EffectsHandlerImpl::registerTouchBorder(ElectricBorder border, QAction *action)
|
|
|
|
{
|
|
|
|
ScreenEdges::self()->reserveTouch(border, action);
|
|
|
|
}
|
|
|
|
|
2022-03-09 16:17:37 +00:00
|
|
|
void EffectsHandlerImpl::registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback)
|
|
|
|
{
|
2022-04-14 12:33:28 +00:00
|
|
|
ScreenEdges::self()->reserveTouch(border, action, [progressCallback](ElectricBorder border, const QSizeF &deltaProgress, Output *output) {
|
2022-03-09 16:17:37 +00:00
|
|
|
progressCallback(border, deltaProgress, EffectScreenImpl::get(output));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-31 05:41:21 +00:00
|
|
|
void EffectsHandlerImpl::unregisterTouchBorder(ElectricBorder border, QAction *action)
|
|
|
|
{
|
|
|
|
ScreenEdges::self()->unreserveTouch(border, action);
|
|
|
|
}
|
|
|
|
|
2013-06-21 12:14:48 +00:00
|
|
|
QPainter *EffectsHandlerImpl::scenePainter()
|
|
|
|
{
|
2017-08-09 04:56:23 +00:00
|
|
|
return m_scene->scenePainter();
|
2013-06-21 12:14:48 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::toggleEffect(const QString &name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (isEffectLoaded(name)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
unloadEffect(name);
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
loadEffect(name);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList EffectsHandlerImpl::loadedEffects() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList listModules;
|
2018-07-09 10:53:39 +00:00
|
|
|
listModules.reserve(loaded_effects.count());
|
|
|
|
std::transform(loaded_effects.constBegin(), loaded_effects.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(listModules),
|
|
|
|
[](const EffectPair &pair) {
|
|
|
|
return pair.first;
|
|
|
|
});
|
2011-01-30 14:34:42 +00:00
|
|
|
return listModules;
|
|
|
|
}
|
2008-06-02 19:52:02 +00:00
|
|
|
|
2008-06-10 09:32:46 +00:00
|
|
|
QStringList EffectsHandlerImpl::listOfEffects() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-03-25 12:43:56 +00:00
|
|
|
return m_effectLoader->listOfKnownEffects();
|
2014-03-09 08:12:09 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool EffectsHandlerImpl::loadEffect(const QString &name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
makeOpenGLContextCurrent();
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaintFull();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-03-25 12:43:56 +00:00
|
|
|
return m_effectLoader->loadEffect(name);
|
2012-01-29 16:32:56 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::unloadEffect(const QString &name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-12-19 14:44:06 +00:00
|
|
|
auto it = std::find_if(effect_order.begin(), effect_order.end(),
|
2022-03-23 10:13:38 +00:00
|
|
|
[name](EffectPair &pair) {
|
|
|
|
return pair.first == name;
|
|
|
|
});
|
2018-12-19 14:44:06 +00:00
|
|
|
if (it == effect_order.end()) {
|
|
|
|
qCDebug(KWIN_CORE) << "EffectsHandler::unloadEffect : Effect not loaded :" << name;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qCDebug(KWIN_CORE) << "EffectsHandler::unloadEffect : Unloading Effect :" << name;
|
|
|
|
destroyEffect((*it).second);
|
|
|
|
effect_order.erase(it);
|
|
|
|
effectsChanged();
|
|
|
|
|
2021-11-09 10:36:24 +00:00
|
|
|
m_compositor->scene()->addRepaintFull();
|
2018-12-19 14:44:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2018-12-19 14:44:06 +00:00
|
|
|
void EffectsHandlerImpl::destroyEffect(Effect *effect)
|
|
|
|
{
|
|
|
|
makeOpenGLContextCurrent();
|
|
|
|
|
|
|
|
if (fullscreen_effect == effect) {
|
|
|
|
setActiveFullScreenEffect(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keyboard_grab_effect == effect) {
|
|
|
|
ungrabKeyboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
stopMouseInterception(effect);
|
|
|
|
|
|
|
|
const QList<QByteArray> properties = m_propertiesForEffects.keys();
|
|
|
|
for (const QByteArray &property : properties) {
|
|
|
|
removeSupportProperty(property, effect);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-19 14:44:06 +00:00
|
|
|
delete effect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::reconfigureEffect(const QString &name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it).first == name) {
|
2016-01-29 10:24:18 +00:00
|
|
|
kwinApp()->config()->reparseConfiguration();
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
makeOpenGLContextCurrent();
|
2011-01-30 14:34:42 +00:00
|
|
|
(*it).second->reconfigure(Effect::ReconfigureAll);
|
2008-10-02 09:27:32 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-29 11:42:47 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool EffectsHandlerImpl::isEffectLoaded(const QString &name) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-07-02 07:26:58 +00:00
|
|
|
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
[&name](const EffectPair &pair) {
|
|
|
|
return pair.first == name;
|
|
|
|
});
|
2018-07-02 07:26:58 +00:00
|
|
|
return it != loaded_effects.constEnd();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-29 11:42:47 +00:00
|
|
|
|
2014-03-09 08:12:09 +00:00
|
|
|
bool EffectsHandlerImpl::isEffectSupported(const QString &name)
|
|
|
|
{
|
2018-07-02 07:26:58 +00:00
|
|
|
// If the effect is loaded, it is obviously supported.
|
|
|
|
if (isEffectLoaded(name)) {
|
2014-03-09 08:12:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// next checks might require a context
|
|
|
|
makeOpenGLContextCurrent();
|
|
|
|
|
2014-03-25 12:43:56 +00:00
|
|
|
return m_effectLoader->isEffectSupported(name);
|
2014-03-09 08:12:09 +00:00
|
|
|
}
|
|
|
|
|
2018-07-09 10:53:39 +00:00
|
|
|
QList<bool> EffectsHandlerImpl::areEffectsSupported(const QStringList &names)
|
2014-03-09 08:12:09 +00:00
|
|
|
{
|
2018-07-09 10:53:39 +00:00
|
|
|
QList<bool> retList;
|
|
|
|
retList.reserve(names.count());
|
|
|
|
std::transform(names.constBegin(), names.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(retList),
|
|
|
|
[this](const QString &name) {
|
|
|
|
return isEffectSupported(name);
|
|
|
|
});
|
2014-03-09 08:12:09 +00:00
|
|
|
return retList;
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:15:46 +00:00
|
|
|
void EffectsHandlerImpl::reloadEffect(Effect *effect)
|
|
|
|
{
|
|
|
|
QString effectName;
|
2022-03-23 10:13:38 +00:00
|
|
|
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
2011-11-26 15:15:46 +00:00
|
|
|
if ((*it).second == effect) {
|
|
|
|
effectName = (*it).first;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!effectName.isNull()) {
|
|
|
|
unloadEffect(effectName);
|
2014-03-25 12:43:56 +00:00
|
|
|
m_effectLoader->loadEffect(effectName);
|
2011-11-26 15:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-06 12:38:41 +00:00
|
|
|
void EffectsHandlerImpl::effectsChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-07-06 12:38:41 +00:00
|
|
|
loaded_effects.clear();
|
2013-05-03 21:12:53 +00:00
|
|
|
m_activeEffects.clear(); // it's possible to have a reconfigure and a quad rebuild between two paint cycles - bug #308201
|
2018-07-09 12:36:27 +00:00
|
|
|
|
|
|
|
loaded_effects.reserve(effect_order.count());
|
|
|
|
std::copy(effect_order.constBegin(), effect_order.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(loaded_effects));
|
2018-07-09 12:36:27 +00:00
|
|
|
|
2013-07-19 09:46:42 +00:00
|
|
|
m_activeEffects.reserve(loaded_effects.count());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-07-06 12:38:41 +00:00
|
|
|
|
2011-12-29 22:33:45 +00:00
|
|
|
QStringList EffectsHandlerImpl::activeEffects() const
|
|
|
|
{
|
|
|
|
QStringList ret;
|
2022-03-23 10:13:38 +00:00
|
|
|
for (QVector<KWin::EffectPair>::const_iterator it = loaded_effects.constBegin(),
|
|
|
|
end = loaded_effects.constEnd();
|
|
|
|
it != end; ++it) {
|
|
|
|
if (it->second->isActive()) {
|
|
|
|
ret << it->first;
|
2011-12-29 22:33:45 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
}
|
2011-12-29 22:33:45 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-02-02 13:26:43 +00:00
|
|
|
bool EffectsHandlerImpl::blocksDirectScanout() const
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
for (QVector<KWin::EffectPair>::const_iterator it = loaded_effects.constBegin(),
|
|
|
|
end = loaded_effects.constEnd();
|
|
|
|
it != end; ++it) {
|
2021-02-02 13:26:43 +00:00
|
|
|
if (it->second->isActive() && it->second->blocksDirectScanout()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
KWaylandServer::Display *EffectsHandlerImpl::waylandDisplay() const
|
2015-08-31 13:47:01 +00:00
|
|
|
{
|
|
|
|
if (waylandServer()) {
|
|
|
|
return waylandServer()->display();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectFrame *EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return new EffectFrameImpl(style, staticSize, position, alignment);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-04-25 15:04:04 +00:00
|
|
|
QVariant EffectsHandlerImpl::kwinOption(KWinOption kwopt)
|
|
|
|
{
|
2011-08-09 21:53:46 +00:00
|
|
|
switch (kwopt) {
|
2021-10-16 00:01:49 +00:00
|
|
|
case CloseButtonCorner: {
|
2014-07-22 14:08:08 +00:00
|
|
|
// TODO: this could become per window and be derived from the actual position in the deco
|
2021-10-16 00:01:49 +00:00
|
|
|
const auto settings = Decoration::DecorationBridge::self()->settings();
|
|
|
|
return settings && settings->decorationButtonsLeft().contains(KDecoration2::DecorationButtonType::Close) ? Qt::TopLeftCorner : Qt::TopRightCorner;
|
|
|
|
}
|
2013-01-30 12:36:37 +00:00
|
|
|
case SwitchDesktopOnScreenEdge:
|
|
|
|
return ScreenEdges::self()->isDesktopSwitching();
|
|
|
|
case SwitchDesktopOnScreenEdgeMovingWindows:
|
|
|
|
return ScreenEdges::self()->isDesktopSwitchingMovingClients();
|
2013-02-22 11:37:12 +00:00
|
|
|
default:
|
|
|
|
return QVariant(); // an invalid one
|
2011-04-25 15:04:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-11 09:24:37 +00:00
|
|
|
QString EffectsHandlerImpl::supportInformation(const QString &name) const
|
|
|
|
{
|
2018-07-02 08:10:04 +00:00
|
|
|
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(),
|
2022-03-23 10:13:38 +00:00
|
|
|
[name](const EffectPair &pair) {
|
|
|
|
return pair.first == name;
|
|
|
|
});
|
2018-07-02 08:10:04 +00:00
|
|
|
if (it == loaded_effects.constEnd()) {
|
2012-08-11 09:24:37 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2018-07-02 08:10:04 +00:00
|
|
|
|
|
|
|
QString support((*it).first + QLatin1String(":\n"));
|
|
|
|
const QMetaObject *metaOptions = (*it).second->metaObject();
|
2022-03-23 10:13:38 +00:00
|
|
|
for (int i = 0; i < metaOptions->propertyCount(); ++i) {
|
2018-07-02 08:10:04 +00:00
|
|
|
const QMetaProperty property = metaOptions->property(i);
|
|
|
|
if (qstrcmp(property.name(), "objectName") == 0) {
|
|
|
|
continue;
|
2012-08-11 09:24:37 +00:00
|
|
|
}
|
2018-07-02 08:10:04 +00:00
|
|
|
support += QString::fromUtf8(property.name()) + QLatin1String(": ") + (*it).second->property(property.name()).toString() + QLatin1Char('\n');
|
2012-08-11 09:24:37 +00:00
|
|
|
}
|
2018-07-02 08:10:04 +00:00
|
|
|
|
|
|
|
return support;
|
2012-08-11 09:24:37 +00:00
|
|
|
}
|
|
|
|
|
2013-01-30 12:07:59 +00:00
|
|
|
bool EffectsHandlerImpl::isScreenLocked() const
|
|
|
|
{
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_SCREENLOCKER
|
2016-08-15 06:37:24 +00:00
|
|
|
return ScreenLockerWatcher::self()->isLocked();
|
2022-02-23 13:27:05 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2013-01-30 12:07:59 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QString EffectsHandlerImpl::debug(const QString &name, const QString ¶meter) const
|
2012-10-27 21:35:19 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
QString internalName = name.toLower();
|
|
|
|
for (QVector<EffectPair>::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
2012-10-27 21:35:19 +00:00
|
|
|
if ((*it).first == internalName) {
|
|
|
|
return it->second->debug(parameter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
bool EffectsHandlerImpl::makeOpenGLContextCurrent()
|
|
|
|
{
|
|
|
|
return m_scene->makeOpenGLContextCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::doneOpenGLContextCurrent()
|
|
|
|
{
|
|
|
|
m_scene->doneOpenGLContextCurrent();
|
|
|
|
}
|
|
|
|
|
2016-08-10 07:24:53 +00:00
|
|
|
bool EffectsHandlerImpl::animationsSupported() const
|
|
|
|
{
|
|
|
|
static const QByteArray forceEnvVar = qgetenv("KWIN_EFFECTS_FORCE_ANIMATIONS");
|
|
|
|
if (!forceEnvVar.isEmpty()) {
|
|
|
|
static const int forceValue = forceEnvVar.toInt();
|
|
|
|
return forceValue == 1;
|
|
|
|
}
|
|
|
|
return m_scene->animationsSupported();
|
|
|
|
}
|
|
|
|
|
2016-08-30 13:50:31 +00:00
|
|
|
void EffectsHandlerImpl::highlightWindows(const QVector<EffectWindow *> &windows)
|
|
|
|
{
|
|
|
|
Effect *e = provides(Effect::HighlightWindows);
|
|
|
|
if (!e) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e->perform(Effect::HighlightWindows, QVariantList{QVariant::fromValue(windows)});
|
|
|
|
}
|
|
|
|
|
2016-10-17 14:12:21 +00:00
|
|
|
PlatformCursorImage EffectsHandlerImpl::cursorImage() const
|
|
|
|
{
|
|
|
|
return kwinApp()->platform()->cursorImage();
|
|
|
|
}
|
|
|
|
|
2016-10-20 08:25:37 +00:00
|
|
|
void EffectsHandlerImpl::hideCursor()
|
|
|
|
{
|
2021-12-25 17:12:12 +00:00
|
|
|
Cursors::self()->hideCursor();
|
2016-10-20 08:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::showCursor()
|
|
|
|
{
|
2021-12-25 17:12:12 +00:00
|
|
|
Cursors::self()->showCursor();
|
2016-10-20 08:25:37 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback)
|
2016-11-15 14:40:30 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
kwinApp()->platform()->startInteractiveWindowSelection([callback](KWin::Window *t) {
|
2022-03-23 10:13:38 +00:00
|
|
|
if (t && t->effectWindow()) {
|
|
|
|
callback(t->effectWindow());
|
|
|
|
} else {
|
|
|
|
callback(nullptr);
|
2016-11-15 14:40:30 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2016-11-15 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectsHandlerImpl::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
2016-11-23 14:53:17 +00:00
|
|
|
{
|
|
|
|
kwinApp()->platform()->startInteractivePositionSelection(callback);
|
|
|
|
}
|
|
|
|
|
2016-12-23 16:39:12 +00:00
|
|
|
void EffectsHandlerImpl::showOnScreenMessage(const QString &message, const QString &iconName)
|
|
|
|
{
|
|
|
|
OSD::show(message, iconName);
|
|
|
|
}
|
|
|
|
|
2017-01-11 19:14:36 +00:00
|
|
|
void EffectsHandlerImpl::hideOnScreenMessage(OnScreenMessageHideFlags flags)
|
2016-12-23 16:39:12 +00:00
|
|
|
{
|
2017-01-11 19:14:36 +00:00
|
|
|
OSD::HideFlags osdFlags;
|
|
|
|
if (flags.testFlag(OnScreenMessageHideFlag::SkipsCloseAnimation)) {
|
|
|
|
osdFlags |= OSD::HideFlag::SkipCloseAnimation;
|
|
|
|
}
|
|
|
|
OSD::hide(osdFlags);
|
2016-12-23 16:39:12 +00:00
|
|
|
}
|
|
|
|
|
2016-12-02 19:27:43 +00:00
|
|
|
KSharedConfigPtr EffectsHandlerImpl::config() const
|
|
|
|
{
|
|
|
|
return kwinApp()->config();
|
|
|
|
}
|
|
|
|
|
2017-04-19 15:00:02 +00:00
|
|
|
KSharedConfigPtr EffectsHandlerImpl::inputConfig() const
|
|
|
|
{
|
2020-07-13 01:56:45 +00:00
|
|
|
return InputConfig::self()->inputConfig();
|
2017-04-19 15:00:02 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 16:23:37 +00:00
|
|
|
Effect *EffectsHandlerImpl::findEffect(const QString &name) const
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), [name](const EffectPair &pair) {
|
|
|
|
return pair.first == name;
|
|
|
|
});
|
2018-12-01 16:23:37 +00:00
|
|
|
if (it == loaded_effects.constEnd()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return (*it).second;
|
|
|
|
}
|
|
|
|
|
2021-11-19 09:19:59 +00:00
|
|
|
void EffectsHandlerImpl::renderOffscreenQuickView(OffscreenQuickView *w) const
|
[libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.
Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.
The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.
QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.
* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.
* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.
* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.
* When using software rendering for both an image gets passed directly.
Mouse and keyboard events can be forwarded, only if the effect
intercepts them.
The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.
The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.
The close button in present windows will also be ported to this,
simplifiying that code base.
Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.
Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?
I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.
Test Plan: Used in an effect
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 15:06:37 +00:00
|
|
|
{
|
|
|
|
if (!w->isVisible()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-11-19 09:19:59 +00:00
|
|
|
scene()->paintOffscreenQuickView(w);
|
[libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.
Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.
The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.
QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.
* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.
* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.
* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.
* When using software rendering for both an image gets passed directly.
Mouse and keyboard events can be forwarded, only if the effect
intercepts them.
The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.
The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.
The close button in present windows will also be ported to this,
simplifiying that code base.
Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.
Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?
I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.
Test Plan: Used in an effect
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 15:06:37 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 17:14:55 +00:00
|
|
|
SessionState EffectsHandlerImpl::sessionState() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->sessionManager()->state();
|
|
|
|
}
|
|
|
|
|
2021-03-01 09:45:52 +00:00
|
|
|
QList<EffectScreen *> EffectsHandlerImpl::screens() const
|
|
|
|
{
|
|
|
|
return m_effectScreens;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectScreen *EffectsHandlerImpl::screenAt(const QPoint &point) const
|
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
return EffectScreenImpl::get(kwinApp()->platform()->outputAt(point));
|
2021-03-01 09:45:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EffectScreen *EffectsHandlerImpl::findScreen(const QString &name) const
|
|
|
|
{
|
|
|
|
for (EffectScreen *screen : qAsConst(m_effectScreens)) {
|
|
|
|
if (screen->name() == name) {
|
|
|
|
return screen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectScreen *EffectsHandlerImpl::findScreen(int screenId) const
|
|
|
|
{
|
|
|
|
return m_effectScreens.value(screenId);
|
|
|
|
}
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
void EffectsHandlerImpl::slotOutputEnabled(Output *output)
|
2021-03-01 09:45:52 +00:00
|
|
|
{
|
|
|
|
EffectScreen *screen = new EffectScreenImpl(output, this);
|
|
|
|
m_effectScreens.append(screen);
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT screenAdded(screen);
|
2021-03-01 09:45:52 +00:00
|
|
|
}
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
void EffectsHandlerImpl::slotOutputDisabled(Output *output)
|
2021-03-01 09:45:52 +00:00
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreen *screen = EffectScreenImpl::get(output);
|
|
|
|
m_effectScreens.removeOne(screen);
|
|
|
|
Q_EMIT screenRemoved(screen);
|
|
|
|
delete screen;
|
2021-03-01 09:45:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 15:14:25 +00:00
|
|
|
void EffectsHandlerImpl::renderScreen(EffectScreen *screen)
|
|
|
|
{
|
2022-04-12 08:16:27 +00:00
|
|
|
RenderTarget renderTarget(GLFramebuffer::currentFramebuffer());
|
|
|
|
renderTarget.setDevicePixelRatio(screen->devicePixelRatio());
|
|
|
|
|
2021-07-28 15:14:25 +00:00
|
|
|
auto output = static_cast<EffectScreenImpl *>(screen)->platformOutput();
|
2022-02-04 18:38:37 +00:00
|
|
|
m_scene->prePaint(output);
|
2022-04-12 08:16:27 +00:00
|
|
|
m_scene->paint(&renderTarget, output->geometry());
|
2022-02-04 18:38:37 +00:00
|
|
|
m_scene->postPaint();
|
2021-07-28 15:14:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 12:15:03 +00:00
|
|
|
bool EffectsHandlerImpl::isCursorHidden() const
|
|
|
|
{
|
|
|
|
return Cursors::self()->isCursorHidden();
|
|
|
|
}
|
|
|
|
|
2022-02-06 12:07:48 +00:00
|
|
|
QRect EffectsHandlerImpl::renderTargetRect() const
|
|
|
|
{
|
|
|
|
return m_scene->renderTargetRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal EffectsHandlerImpl::renderTargetScale() const
|
|
|
|
{
|
|
|
|
return m_scene->renderTargetScale();
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:53:59 +00:00
|
|
|
KWin::EffectWindow *EffectsHandlerImpl::inputPanel() const
|
|
|
|
{
|
2022-03-11 09:16:30 +00:00
|
|
|
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:53:59 +00:00
|
|
|
auto panel = InputMethod::self()->panel();
|
|
|
|
if (panel) {
|
|
|
|
return panel->effectWindow();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::isInputPanelOverlay() const
|
|
|
|
{
|
2022-03-11 09:16:30 +00:00
|
|
|
if (!InputMethod::self() || !InputMethod::self()->isEnabled()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-02-09 13:53:59 +00:00
|
|
|
auto panel = InputMethod::self()->panel();
|
|
|
|
if (panel) {
|
2022-04-22 17:42:35 +00:00
|
|
|
return panel->mode() == InputPanelV1Window::Overlay;
|
2022-02-09 13:53:59 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-01 09:45:52 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectScreenImpl
|
|
|
|
//****************************************
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
EffectScreenImpl::EffectScreenImpl(Output *output, QObject *parent)
|
2021-03-01 09:45:52 +00:00
|
|
|
: EffectScreen(parent)
|
|
|
|
, m_platformOutput(output)
|
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
m_platformOutput->m_effectScreen = this;
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
connect(output, &Output::aboutToChange, this, &EffectScreen::aboutToChange);
|
|
|
|
connect(output, &Output::changed, this, &EffectScreen::changed);
|
|
|
|
connect(output, &Output::wakeUp, this, &EffectScreen::wakeUp);
|
|
|
|
connect(output, &Output::aboutToTurnOff, this, &EffectScreen::aboutToTurnOff);
|
|
|
|
connect(output, &Output::scaleChanged, this, &EffectScreen::devicePixelRatioChanged);
|
|
|
|
connect(output, &Output::geometryChanged, this, &EffectScreen::geometryChanged);
|
2021-03-01 09:45:52 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreenImpl::~EffectScreenImpl()
|
|
|
|
{
|
|
|
|
if (m_platformOutput) {
|
|
|
|
m_platformOutput->m_effectScreen = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
EffectScreenImpl *EffectScreenImpl::get(Output *output)
|
2021-10-01 07:23:30 +00:00
|
|
|
{
|
|
|
|
return output->m_effectScreen;
|
|
|
|
}
|
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *EffectScreenImpl::platformOutput() const
|
2021-03-01 09:45:52 +00:00
|
|
|
{
|
|
|
|
return m_platformOutput;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EffectScreenImpl::name() const
|
|
|
|
{
|
|
|
|
return m_platformOutput->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal EffectScreenImpl::devicePixelRatio() const
|
|
|
|
{
|
|
|
|
return m_platformOutput->scale();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectScreenImpl::geometry() const
|
|
|
|
{
|
|
|
|
return m_platformOutput->geometry();
|
|
|
|
}
|
|
|
|
|
2022-04-04 16:05:56 +00:00
|
|
|
int EffectScreenImpl::refreshRate() const
|
|
|
|
{
|
|
|
|
return m_platformOutput->refreshRate();
|
|
|
|
}
|
|
|
|
|
2021-07-29 02:07:13 +00:00
|
|
|
EffectScreen::Transform EffectScreenImpl::transform() const
|
|
|
|
{
|
|
|
|
return EffectScreen::Transform(m_platformOutput->transform());
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectWindowImpl
|
|
|
|
//****************************************
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
EffectWindowImpl::EffectWindowImpl(Window *toplevel)
|
2011-12-29 09:31:37 +00:00
|
|
|
: EffectWindow(toplevel)
|
|
|
|
, toplevel(toplevel)
|
2018-11-30 09:58:45 +00:00
|
|
|
, sw(nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
// Deleted windows are not managed. So, when windowClosed signal is
|
|
|
|
// emitted, effects can't distinguish managed windows from unmanaged
|
|
|
|
// windows(e.g. combo box popups, popup menus, etc). Save value of the
|
|
|
|
// managed property during construction of EffectWindow. At that time,
|
2019-08-30 21:36:58 +00:00
|
|
|
// parent can be Client, XdgShellClient, or Unmanaged. So, later on, when
|
2018-11-30 09:58:45 +00:00
|
|
|
// an instance of Deleted becomes parent of the EffectWindow, effects
|
|
|
|
// can still figure out whether it is/was a managed window.
|
|
|
|
managed = toplevel->isClient();
|
|
|
|
|
2022-04-22 17:51:07 +00:00
|
|
|
waylandClient = qobject_cast<KWin::WaylandWindow *>(toplevel) != nullptr;
|
2022-04-22 17:54:31 +00:00
|
|
|
x11Client = qobject_cast<KWin::X11Window *>(toplevel) != nullptr || qobject_cast<KWin::Unmanaged *>(toplevel) != nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindowImpl::~EffectWindowImpl()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
QVariant cachedTextureVariant = data(LanczosCacheRole);
|
|
|
|
if (cachedTextureVariant.isValid()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
GLTexture *cachedTexture = static_cast<GLTexture *>(cachedTextureVariant.value<void *>());
|
2010-11-01 10:46:11 +00:00
|
|
|
delete cachedTexture;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool EffectWindowImpl::isPaintingEnabled()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return sceneWindow()->isPaintingEnabled();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::enablePainting(int reason)
|
|
|
|
{
|
|
|
|
sceneWindow()->enablePainting(reason);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::disablePainting(int reason)
|
|
|
|
{
|
|
|
|
sceneWindow()->disablePainting(reason);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void EffectWindowImpl::addRepaint(const QRect &r)
|
|
|
|
{
|
|
|
|
toplevel->addRepaint(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
toplevel->addRepaint(x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaintFull()
|
|
|
|
{
|
|
|
|
toplevel->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addLayerRepaint(const QRect &r)
|
|
|
|
{
|
|
|
|
toplevel->addLayerRepaint(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addLayerRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
toplevel->addLayerRepaint(x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const EffectWindowGroup *EffectWindowImpl::group() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-22 17:54:31 +00:00
|
|
|
if (auto c = qobject_cast<X11Window *>(toplevel)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->group()->effectGroup();
|
2018-12-08 12:04:20 +00:00
|
|
|
}
|
2018-11-30 09:58:45 +00:00
|
|
|
return nullptr; // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::refWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-14 19:36:34 +00:00
|
|
|
if (auto d = static_cast<Deleted *>(toplevel->isDeleted() ? toplevel : nullptr)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->refWindow();
|
2018-12-08 12:04:20 +00:00
|
|
|
}
|
2022-01-04 08:28:42 +00:00
|
|
|
Q_UNREACHABLE(); // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void EffectWindowImpl::unrefWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-14 19:36:34 +00:00
|
|
|
if (auto d = static_cast<Deleted *>(toplevel->isDeleted() ? toplevel : nullptr)) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return d->unrefWindow(); // delays deletion in case
|
2018-12-08 12:04:20 +00:00
|
|
|
}
|
2022-01-04 08:28:42 +00:00
|
|
|
Q_UNREACHABLE(); // TODO
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreen *EffectWindowImpl::screen() const
|
|
|
|
{
|
|
|
|
return EffectScreenImpl::get(toplevel->output());
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
#define TOPLEVEL_HELPER(rettype, prototype, toplevelPrototype) \
|
|
|
|
rettype EffectWindowImpl::prototype() const \
|
|
|
|
{ \
|
|
|
|
return toplevel->toplevelPrototype(); \
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TOPLEVEL_HELPER(double, opacity, opacity)
|
|
|
|
TOPLEVEL_HELPER(bool, hasAlpha, hasAlpha)
|
|
|
|
TOPLEVEL_HELPER(int, x, x)
|
|
|
|
TOPLEVEL_HELPER(int, y, y)
|
|
|
|
TOPLEVEL_HELPER(int, width, width)
|
|
|
|
TOPLEVEL_HELPER(int, height, height)
|
|
|
|
TOPLEVEL_HELPER(QPoint, pos, pos)
|
|
|
|
TOPLEVEL_HELPER(QSize, size, size)
|
2019-09-27 10:01:10 +00:00
|
|
|
TOPLEVEL_HELPER(QRect, geometry, frameGeometry)
|
2019-09-28 15:09:12 +00:00
|
|
|
TOPLEVEL_HELPER(QRect, frameGeometry, frameGeometry)
|
|
|
|
TOPLEVEL_HELPER(QRect, bufferGeometry, bufferGeometry)
|
2021-05-28 08:05:28 +00:00
|
|
|
TOPLEVEL_HELPER(QRect, clientGeometry, clientGeometry)
|
2021-02-05 12:46:22 +00:00
|
|
|
TOPLEVEL_HELPER(QRect, expandedGeometry, visibleGeometry)
|
2018-11-30 09:58:45 +00:00
|
|
|
TOPLEVEL_HELPER(QRect, rect, rect)
|
|
|
|
TOPLEVEL_HELPER(int, desktop, desktop)
|
|
|
|
TOPLEVEL_HELPER(bool, isDesktop, isDesktop)
|
|
|
|
TOPLEVEL_HELPER(bool, isDock, isDock)
|
|
|
|
TOPLEVEL_HELPER(bool, isToolbar, isToolbar)
|
|
|
|
TOPLEVEL_HELPER(bool, isMenu, isMenu)
|
|
|
|
TOPLEVEL_HELPER(bool, isNormalWindow, isNormalWindow)
|
|
|
|
TOPLEVEL_HELPER(bool, isDialog, isDialog)
|
|
|
|
TOPLEVEL_HELPER(bool, isSplash, isSplash)
|
|
|
|
TOPLEVEL_HELPER(bool, isUtility, isUtility)
|
|
|
|
TOPLEVEL_HELPER(bool, isDropdownMenu, isDropdownMenu)
|
|
|
|
TOPLEVEL_HELPER(bool, isPopupMenu, isPopupMenu)
|
|
|
|
TOPLEVEL_HELPER(bool, isTooltip, isTooltip)
|
|
|
|
TOPLEVEL_HELPER(bool, isNotification, isNotification)
|
2019-05-02 08:29:38 +00:00
|
|
|
TOPLEVEL_HELPER(bool, isCriticalNotification, isCriticalNotification)
|
2018-11-30 09:58:45 +00:00
|
|
|
TOPLEVEL_HELPER(bool, isOnScreenDisplay, isOnScreenDisplay)
|
|
|
|
TOPLEVEL_HELPER(bool, isComboBox, isComboBox)
|
|
|
|
TOPLEVEL_HELPER(bool, isDNDIcon, isDNDIcon)
|
|
|
|
TOPLEVEL_HELPER(bool, isDeleted, isDeleted)
|
|
|
|
TOPLEVEL_HELPER(QString, windowRole, windowRole)
|
|
|
|
TOPLEVEL_HELPER(QStringList, activities, activities)
|
|
|
|
TOPLEVEL_HELPER(bool, skipsCloseAnimation, skipsCloseAnimation)
|
2020-04-29 15:18:41 +00:00
|
|
|
TOPLEVEL_HELPER(KWaylandServer::SurfaceInterface *, surface, surface)
|
2018-11-30 09:58:45 +00:00
|
|
|
TOPLEVEL_HELPER(bool, isPopupWindow, isPopupWindow)
|
2019-03-19 14:01:29 +00:00
|
|
|
TOPLEVEL_HELPER(bool, isOutline, isOutline)
|
2021-05-12 18:56:16 +00:00
|
|
|
TOPLEVEL_HELPER(bool, isLockScreen, isLockScreen)
|
2019-09-26 12:54:33 +00:00
|
|
|
TOPLEVEL_HELPER(pid_t, pid, pid)
|
2020-11-01 14:25:15 +00:00
|
|
|
TOPLEVEL_HELPER(qlonglong, windowId, window)
|
2021-11-22 15:58:04 +00:00
|
|
|
TOPLEVEL_HELPER(QUuid, internalId, internalId)
|
2018-11-30 09:58:45 +00:00
|
|
|
|
|
|
|
#undef TOPLEVEL_HELPER
|
|
|
|
|
2022-04-15 07:15:59 +00:00
|
|
|
#define CLIENT_HELPER(rettype, prototype, propertyname, defaultValue) \
|
2022-04-14 13:50:12 +00:00
|
|
|
rettype EffectWindowImpl::prototype() const \
|
|
|
|
{ \
|
2022-04-22 17:39:12 +00:00
|
|
|
auto client = static_cast<Window *>(toplevel->isClient() ? toplevel : nullptr); \
|
2022-04-14 13:50:12 +00:00
|
|
|
if (client) { \
|
|
|
|
return client->propertyname(); \
|
|
|
|
} \
|
2022-04-14 19:36:34 +00:00
|
|
|
auto deleted = static_cast<Deleted *>(toplevel->isDeleted() ? toplevel : nullptr); \
|
2022-04-14 13:50:12 +00:00
|
|
|
if (deleted) { \
|
|
|
|
return deleted->propertyname(); \
|
|
|
|
} \
|
|
|
|
return defaultValue; \
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 07:15:59 +00:00
|
|
|
CLIENT_HELPER(bool, isMinimized, isMinimized, false)
|
|
|
|
CLIENT_HELPER(bool, isModal, isModal, false)
|
|
|
|
CLIENT_HELPER(bool, isFullScreen, isFullScreen, false)
|
|
|
|
CLIENT_HELPER(bool, keepAbove, keepAbove, false)
|
|
|
|
CLIENT_HELPER(bool, keepBelow, keepBelow, false)
|
|
|
|
CLIENT_HELPER(QString, caption, caption, QString());
|
|
|
|
CLIENT_HELPER(QVector<uint>, desktops, x11DesktopIds, QVector<uint>());
|
|
|
|
CLIENT_HELPER(bool, isMovable, isMovable, false)
|
|
|
|
CLIENT_HELPER(bool, isMovableAcrossScreens, isMovableAcrossScreens, false)
|
|
|
|
CLIENT_HELPER(bool, isUserMove, isInteractiveMove, false)
|
|
|
|
CLIENT_HELPER(bool, isUserResize, isInteractiveResize, false)
|
|
|
|
CLIENT_HELPER(QRect, iconGeometry, iconGeometry, QRect())
|
|
|
|
CLIENT_HELPER(bool, isSpecialWindow, isSpecialWindow, true)
|
|
|
|
CLIENT_HELPER(bool, acceptsFocus, wantsInput, true) // We don't actually know...
|
|
|
|
CLIENT_HELPER(QIcon, icon, icon, QIcon())
|
|
|
|
CLIENT_HELPER(bool, isSkipSwitcher, skipSwitcher, false)
|
|
|
|
CLIENT_HELPER(bool, decorationHasAlpha, decorationHasAlpha, false)
|
|
|
|
CLIENT_HELPER(bool, isUnresponsive, unresponsive, false)
|
2018-11-30 09:58:45 +00:00
|
|
|
|
2022-04-15 07:15:59 +00:00
|
|
|
#undef CLIENT_HELPER
|
2018-11-30 09:58:45 +00:00
|
|
|
|
2019-09-14 08:58:12 +00:00
|
|
|
// legacy from tab groups, can be removed when no effects use this any more.
|
|
|
|
bool EffectWindowImpl::isCurrentTab() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-30 09:58:45 +00:00
|
|
|
QString EffectWindowImpl::windowClass() const
|
|
|
|
{
|
|
|
|
return toplevel->resourceName() + QLatin1Char(' ') + toplevel->resourceClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectWindowImpl::contentsRect() const
|
|
|
|
{
|
|
|
|
return QRect(toplevel->clientPos(), toplevel->clientSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
NET::WindowType EffectWindowImpl::windowType() const
|
|
|
|
{
|
|
|
|
return toplevel->windowType();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize EffectWindowImpl::basicUnit() const
|
|
|
|
{
|
2022-04-22 17:54:31 +00:00
|
|
|
if (auto client = qobject_cast<X11Window *>(toplevel)) {
|
2018-11-30 09:58:45 +00:00
|
|
|
return client->basicUnit();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
return QSize(1, 1);
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectWindowImpl::setWindow(Window *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
toplevel = w;
|
2011-12-29 09:31:37 +00:00
|
|
|
setParent(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void EffectWindowImpl::setSceneWindow(SceneWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
sw = w;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-03-12 16:33:01 +00:00
|
|
|
QRect EffectWindowImpl::decorationInnerRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2021-08-12 11:56:39 +00:00
|
|
|
return toplevel->rect() - toplevel->frameMargins();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-12 16:33:01 +00:00
|
|
|
|
2022-02-09 21:00:07 +00:00
|
|
|
KDecoration2::Decoration *EffectWindowImpl::decoration() const
|
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
return toplevel->decoration();
|
2022-02-09 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray EffectWindowImpl::readProperty(long atom, long type, int format) const
|
|
|
|
{
|
2017-09-02 08:04:15 +00:00
|
|
|
if (!kwinApp()->x11Connection()) {
|
|
|
|
return QByteArray();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return readWindowProperty(window()->window(), atom, type, format);
|
|
|
|
}
|
2008-01-02 15:21:33 +00:00
|
|
|
|
2009-06-27 10:21:49 +00:00
|
|
|
void EffectWindowImpl::deleteProperty(long int atom) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2017-09-02 08:04:15 +00:00
|
|
|
if (kwinApp()->x11Connection()) {
|
|
|
|
deleteWindowProperty(window()->window(), atom);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-27 10:21:49 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectWindowImpl::findModal()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *modal = toplevel->findModal();
|
2018-12-08 12:04:20 +00:00
|
|
|
if (modal) {
|
|
|
|
return modal->effectWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *EffectWindowImpl::transientFor()
|
2020-08-02 10:25:28 +00:00
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
Window *transientFor = toplevel->transientFor();
|
2020-08-02 10:25:28 +00:00
|
|
|
if (transientFor) {
|
|
|
|
return transientFor->effectWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
QWindow *EffectWindowImpl::internalWindow() const
|
|
|
|
{
|
2022-04-22 17:45:19 +00:00
|
|
|
auto client = qobject_cast<InternalWindow *>(toplevel);
|
2019-01-13 16:50:32 +00:00
|
|
|
if (!client) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return client->internalWindow();
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
template<typename T>
|
2018-12-08 11:47:22 +00:00
|
|
|
EffectWindowList getMainWindows(T *c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-23 08:33:23 +00:00
|
|
|
const auto mainwindows = c->mainWindows();
|
2018-07-01 07:45:39 +00:00
|
|
|
EffectWindowList ret;
|
2022-04-23 08:33:23 +00:00
|
|
|
ret.reserve(mainwindows.size());
|
|
|
|
std::transform(std::cbegin(mainwindows), std::cend(mainwindows),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(ret),
|
2022-04-23 08:33:23 +00:00
|
|
|
[](auto window) {
|
|
|
|
return window->effectWindow();
|
2022-03-23 10:13:38 +00:00
|
|
|
});
|
2013-06-03 13:08:05 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowList EffectWindowImpl::mainWindows() const
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
if (auto client = static_cast<Window *>(toplevel->isClient() ? toplevel : nullptr)) {
|
2018-12-08 11:47:22 +00:00
|
|
|
return getMainWindows(client);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2022-04-15 07:15:59 +00:00
|
|
|
|
2022-04-14 19:36:34 +00:00
|
|
|
if (auto deleted = static_cast<Deleted *>(toplevel->isDeleted() ? toplevel : nullptr)) {
|
2018-12-08 11:47:22 +00:00
|
|
|
return getMainWindows(deleted);
|
|
|
|
}
|
2022-04-15 07:15:59 +00:00
|
|
|
|
2018-12-08 11:47:22 +00:00
|
|
|
return {};
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setData(int role, const QVariant &data)
|
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (!data.isNull()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
dataMap[role] = data;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
dataMap.remove(role);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT effects->windowDataChanged(this, role);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-03 17:50:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QVariant EffectWindowImpl::data(int role) const
|
|
|
|
{
|
2018-07-01 07:30:30 +00:00
|
|
|
return dataMap.value(role);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-01-03 17:50:38 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
EffectWindow *effectWindow(Window *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindowImpl *ret = w->effectWindow();
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
EffectWindow *effectWindow(SceneWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindowImpl *ret = w->window()->effectWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
ret->setSceneWindow(w);
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-04-24 08:46:34 +00:00
|
|
|
void EffectWindowImpl::elevate(bool elevate)
|
|
|
|
{
|
|
|
|
effects->setElevatedWindow(this, elevate);
|
|
|
|
}
|
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void EffectWindowImpl::minimize()
|
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
if (toplevel->isClient()) {
|
|
|
|
toplevel->minimize();
|
2019-01-07 16:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::unminimize()
|
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
if (toplevel->isClient()) {
|
|
|
|
toplevel->unminimize();
|
2019-01-07 16:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::closeWindow()
|
|
|
|
{
|
2022-04-18 08:10:29 +00:00
|
|
|
if (toplevel->isClient()) {
|
|
|
|
toplevel->closeWindow();
|
2019-01-07 16:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-13 06:17:28 +00:00
|
|
|
void EffectWindowImpl::referencePreviousWindowPixmap()
|
|
|
|
{
|
|
|
|
if (sw) {
|
|
|
|
sw->referencePreviousPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::unreferencePreviousWindowPixmap()
|
|
|
|
{
|
|
|
|
if (sw) {
|
|
|
|
sw->unreferencePreviousPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-30 09:58:45 +00:00
|
|
|
bool EffectWindowImpl::isManaged() const
|
|
|
|
{
|
|
|
|
return managed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isWaylandClient() const
|
|
|
|
{
|
|
|
|
return waylandClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isX11Client() const
|
|
|
|
{
|
|
|
|
return x11Client;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectWindowGroupImpl
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
EffectWindowList EffectWindowGroupImpl::members() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-07-01 07:45:39 +00:00
|
|
|
const auto memberList = group->members();
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2018-07-01 07:45:39 +00:00
|
|
|
ret.reserve(memberList.size());
|
|
|
|
std::transform(std::cbegin(memberList), std::cend(memberList),
|
2022-03-23 10:13:38 +00:00
|
|
|
std::back_inserter(ret),
|
|
|
|
[](auto toplevel) {
|
|
|
|
return toplevel->effectWindow();
|
|
|
|
});
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectFrameImpl
|
|
|
|
//****************************************
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrameImpl::EffectFrameImpl(EffectFrameStyle style, bool staticSize, QPoint position, Qt::Alignment alignment)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
: QObject(nullptr)
|
2010-07-18 16:32:37 +00:00
|
|
|
, EffectFrame()
|
2011-01-30 14:34:42 +00:00
|
|
|
, m_style(style)
|
|
|
|
, m_static(staticSize)
|
|
|
|
, m_point(position)
|
|
|
|
, m_alignment(alignment)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
, m_shader(nullptr)
|
2013-07-22 14:10:47 +00:00
|
|
|
, m_theme(new Plasma::Theme(this))
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_style == EffectFrameStyled) {
|
2013-07-23 05:02:52 +00:00
|
|
|
m_frame.setImagePath(QStringLiteral("widgets/background"));
|
2011-01-30 14:34:42 +00:00
|
|
|
m_frame.setCacheAllRenderedFrames(true);
|
2020-09-23 18:39:59 +00:00
|
|
|
connect(m_theme, &Plasma::Theme::themeChanged, this, &EffectFrameImpl::plasmaThemeChanged);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-07-23 05:02:52 +00:00
|
|
|
m_selection.setImagePath(QStringLiteral("widgets/viewitem"));
|
|
|
|
m_selection.setElementPrefix(QStringLiteral("hover"));
|
2011-04-28 11:41:11 +00:00
|
|
|
m_selection.setCacheAllRenderedFrames(true);
|
|
|
|
m_selection.setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2013-06-24 06:49:24 +00:00
|
|
|
m_sceneFrame = Compositor::self()->scene()->createEffectFrame(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
EffectFrameImpl::~EffectFrameImpl()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
delete m_sceneFrame;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QFont &EffectFrameImpl::font() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_font;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setFont(const QFont &font)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_font == font) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_font = font;
|
|
|
|
QRect oldGeom = m_geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!m_text.isEmpty()) {
|
2010-07-18 16:32:37 +00:00
|
|
|
autoResize();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (oldGeom == m_geometry) {
|
|
|
|
// Wasn't updated in autoResize()
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->freeTextFrame();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
void EffectFrameImpl::free()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QRect &EffectFrameImpl::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setGeometry(const QRect &geometry, bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
QRect oldGeom = m_geometry;
|
|
|
|
m_geometry = geometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_geometry == oldGeom && !force) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
effects->addRepaint(oldGeom);
|
|
|
|
effects->addRepaint(m_geometry);
|
|
|
|
if (m_geometry.size() == oldGeom.size() && !force) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_style == EffectFrameStyled) {
|
2010-07-18 16:32:37 +00:00
|
|
|
qreal left, top, right, bottom;
|
2022-03-23 10:13:38 +00:00
|
|
|
m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry
|
2011-01-30 14:34:42 +00:00
|
|
|
m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size());
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QIcon &EffectFrameImpl::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_icon;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setIcon(const QIcon &icon)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_icon = icon;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isCrossFade()) {
|
2010-08-07 14:08:34 +00:00
|
|
|
m_sceneFrame->crossFadeIcon();
|
2010-07-18 16:32:37 +00:00
|
|
|
}
|
2013-12-06 13:41:23 +00:00
|
|
|
if (m_iconSize.isEmpty() && !m_icon.availableSizes().isEmpty()) { // Set a size if we don't already have one
|
2021-05-13 16:38:42 +00:00
|
|
|
setIconSize(m_icon.availableSizes().constFirst());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
m_sceneFrame->freeIconFrame();
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QSize &EffectFrameImpl::iconSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_iconSize;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setIconSize(const QSize &size)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_iconSize == size) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_iconSize = size;
|
|
|
|
autoResize();
|
2010-07-20 21:11:03 +00:00
|
|
|
m_sceneFrame->freeIconFrame();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
void EffectFrameImpl::plasmaThemeChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
free();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2019-10-29 22:04:15 +00:00
|
|
|
void EffectFrameImpl::render(const QRegion ®ion, double opacity, double frameOpacity)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_geometry.isEmpty()) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Nothing to display
|
2010-07-24 16:29:16 +00:00
|
|
|
}
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
m_shader = nullptr;
|
2022-03-23 10:13:38 +00:00
|
|
|
setScreenProjectionMatrix(static_cast<EffectsHandlerImpl *>(effects)->scene()->screenProjectionMatrix());
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintEffectFrame(this, region, opacity, frameOpacity);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::finalRender(QRegion region, double opacity, double frameOpacity) const
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
m_sceneFrame->render(region, opacity, frameOpacity);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
Qt::Alignment EffectFrameImpl::alignment() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_alignment;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::align(QRect &geometry)
|
2010-12-04 10:01:57 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (m_alignment & Qt::AlignLeft) {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveLeft(m_point.x());
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (m_alignment & Qt::AlignRight) {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveLeft(m_point.x() - geometry.width());
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveLeft(m_point.x() - geometry.width() / 2);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (m_alignment & Qt::AlignTop) {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveTop(m_point.y());
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (m_alignment & Qt::AlignBottom) {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveTop(m_point.y() - geometry.height());
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveTop(m_point.y() - geometry.height() / 2);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2010-12-04 10:01:57 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setAlignment(Qt::Alignment alignment)
|
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_alignment = alignment;
|
2011-01-30 14:34:42 +00:00
|
|
|
align(m_geometry);
|
|
|
|
setGeometry(m_geometry);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setPosition(const QPoint &point)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
m_point = point;
|
2010-12-04 10:01:57 +00:00
|
|
|
QRect geometry = m_geometry; // this is important, setGeometry need call repaint for old & new geometry
|
2011-01-30 14:34:42 +00:00
|
|
|
align(geometry);
|
|
|
|
setGeometry(geometry);
|
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const QString &EffectFrameImpl::text() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
return m_text;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setText(const QString &text)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (m_text == text) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (isCrossFade()) {
|
2010-08-07 14:08:34 +00:00
|
|
|
m_sceneFrame->crossFadeText();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
m_text = text;
|
|
|
|
QRect oldGeom = m_geometry;
|
|
|
|
autoResize();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (oldGeom == m_geometry) {
|
|
|
|
// Wasn't updated in autoResize()
|
2010-07-18 16:32:37 +00:00
|
|
|
m_sceneFrame->freeTextFrame();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void EffectFrameImpl::setSelection(const QRect &selection)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (selection == m_selectionGeometry) {
|
2010-07-26 20:00:04 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
m_selectionGeometry = selection;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_selectionGeometry.size() != m_selection.frameSize().toSize()) {
|
|
|
|
m_selection.resizeFrame(m_selectionGeometry.size());
|
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
// TODO; optimize to only recreate when resizing
|
|
|
|
m_sceneFrame->freeSelection();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-26 20:00:04 +00:00
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
void EffectFrameImpl::autoResize()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (m_static) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Not automatically resizing
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
QRect geometry;
|
|
|
|
// Set size
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!m_text.isEmpty()) {
|
|
|
|
QFontMetrics metrics(m_font);
|
|
|
|
geometry.setSize(metrics.size(0, m_text));
|
|
|
|
}
|
|
|
|
if (!m_icon.isNull() && !m_iconSize.isEmpty()) {
|
|
|
|
geometry.setLeft(-m_iconSize.width());
|
2022-03-25 12:20:32 +00:00
|
|
|
if (m_iconSize.height() > geometry.height()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.setHeight(m_iconSize.height());
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2010-07-18 16:32:37 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
align(geometry);
|
|
|
|
setGeometry(geometry);
|
|
|
|
}
|
|
|
|
|
2011-02-17 18:35:08 +00:00
|
|
|
QColor EffectFrameImpl::styledTextColor()
|
|
|
|
{
|
2013-07-22 14:10:47 +00:00
|
|
|
return m_theme->color(Plasma::Theme::TextColor);
|
2011-02-17 18:35:08 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|