2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
2011-03-16 18:39:10 +00:00
|
|
|
Copyright (C) 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "effects.h"
|
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
#include "effectsadaptor.h"
|
2014-03-25 12:43:56 +00:00
|
|
|
#include "effectloader.h"
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
#include "activities.h"
|
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "deleted.h"
|
|
|
|
#include "client.h"
|
2013-02-19 10:25:46 +00:00
|
|
|
#include "cursor.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "group.h"
|
2016-02-23 11:29:05 +00:00
|
|
|
#include "pointer_input.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "scene_xrender.h"
|
2013-06-21 12:14:48 +00:00
|
|
|
#include "scene_qpainter.h"
|
2008-01-02 15:37:46 +00:00
|
|
|
#include "unmanaged.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef 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"
|
2012-01-29 16:32:56 +00:00
|
|
|
#include "scripting/scriptedeffect.h"
|
2013-04-03 10:19:27 +00:00
|
|
|
#include "screens.h"
|
2016-08-15 06:16:33 +00:00
|
|
|
#include "screenlockerwatcher.h"
|
2011-11-10 13:28:06 +00:00
|
|
|
#include "thumbnailitem.h"
|
2012-11-16 07:23:47 +00:00
|
|
|
#include "virtualdesktops.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2014-03-25 12:43:56 +00:00
|
|
|
|
2011-02-17 18:35:08 +00:00
|
|
|
#include <Plasma/Theme>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
2011-08-21 19:50:23 +00:00
|
|
|
#include "composite.h"
|
2012-12-20 13:03:02 +00:00
|
|
|
#include "xcbutils.h"
|
2016-04-07 07:24:17 +00:00
|
|
|
#include "platform.h"
|
2015-03-04 08:21:10 +00:00
|
|
|
#include "shell_client.h"
|
2015-03-20 13:41:03 +00:00
|
|
|
#include "wayland_server.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-07-22 12:47:08 +00:00
|
|
|
#include "decorations/decorationbridge.h"
|
2014-07-22 14:08:08 +00:00
|
|
|
#include <KDecoration2/DecorationSettings>
|
2014-07-22 12:47:08 +00:00
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
static void deleteWindowProperty(Window win, long int atom)
|
|
|
|
{
|
2016-05-02 15:47:39 +00:00
|
|
|
if (win == XCB_WINDOW_NONE) {
|
|
|
|
return;
|
|
|
|
}
|
2013-09-10 07:33:07 +00:00
|
|
|
xcb_delete_property(connection(), win, atom);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
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)
|
2012-08-16 19:19:54 +00:00
|
|
|
: EffectsHandler(scene->compositingType())
|
2011-01-30 14:34:42 +00:00
|
|
|
, keyboard_grab_effect(NULL)
|
|
|
|
, fullscreen_effect(0)
|
|
|
|
, next_window_quad_type(EFFECT_QUAD_TYPE_START)
|
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
|
|
|
{
|
2016-08-30 13:50:31 +00:00
|
|
|
qRegisterMetaType<QVector<KWin::EffectWindow*>>();
|
2014-03-25 12:43:56 +00:00
|
|
|
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
|
|
|
// init is important, otherwise causes crashes when quads are build before the first painting pass start
|
2013-07-19 09:34:01 +00:00
|
|
|
m_currentBuildQuadsIterator = m_activeEffects.constEnd();
|
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();
|
2015-03-28 23:12:21 +00:00
|
|
|
connect(ws, &Workspace::showingDesktopChanged,
|
|
|
|
this, &EffectsHandlerImpl::showingDesktopChanged);
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(ws, &Workspace::currentDesktopChanged, this,
|
2015-03-06 11:38:07 +00:00
|
|
|
[this](int old, AbstractClient *c) {
|
2014-03-26 08:13:35 +00:00
|
|
|
const int newDesktop = VirtualDesktopManager::self()->current();
|
|
|
|
if (old != 0 && newDesktop != old) {
|
|
|
|
emit desktopChanged(old, newDesktop, c ? c->effectWindow() : 0);
|
|
|
|
// TODO: remove in 4.10
|
|
|
|
emit desktopChanged(old, newDesktop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(ws, &Workspace::desktopPresenceChanged, this,
|
2015-03-13 10:48:08 +00:00
|
|
|
[this](AbstractClient *c, int old) {
|
2014-03-26 08:13:35 +00:00
|
|
|
if (!c->effectWindow()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-05-12 09:33:03 +00:00
|
|
|
// the visibility update hasn't happed yet, thus the signal is delayed to prevent glitches, see also BUG 347490
|
|
|
|
QMetaObject::invokeMethod(this, "desktopPresenceChanged", Qt::QueuedConnection,
|
|
|
|
Q_ARG(KWin::EffectWindow*, c->effectWindow()),
|
|
|
|
Q_ARG(int, old),
|
|
|
|
Q_ARG(int, c->desktop()));
|
2014-03-26 08:13:35 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(ws, &Workspace::clientAdded, this,
|
|
|
|
[this](Client *c) {
|
|
|
|
if (c->readyForPainting())
|
|
|
|
slotClientShown(c);
|
|
|
|
else
|
|
|
|
connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(ws, &Workspace::unmanagedAdded, this,
|
|
|
|
[this](Unmanaged *u) {
|
|
|
|
// it's never initially ready but has synthetic 50ms delay
|
|
|
|
connect(u, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(ws, &Workspace::clientActivated, this,
|
2015-03-06 12:58:24 +00:00
|
|
|
[this](KWin::AbstractClient *c) {
|
2014-03-26 08:13:35 +00:00
|
|
|
emit windowActivated(c ? c->effectWindow() : nullptr);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(ws, &Workspace::deletedRemoved, this,
|
|
|
|
[this](KWin::Deleted *d) {
|
|
|
|
emit windowDeleted(d->effectWindow());
|
|
|
|
elevated_windows.removeAll(d->effectWindow());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(vds, &VirtualDesktopManager::countChanged, this, &EffectsHandler::numberDesktopsChanged);
|
|
|
|
connect(Cursor::self(), &Cursor::mouseChanged, this, &EffectsHandler::mouseChanged);
|
|
|
|
connect(ws, &Workspace::propertyNotify, this,
|
|
|
|
[this](long int atom) {
|
|
|
|
if (!registered_atoms.contains(atom))
|
|
|
|
return;
|
|
|
|
emit propertyNotify(nullptr, atom);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(screens(), &Screens::countChanged, this, &EffectsHandler::numberScreensChanged);
|
|
|
|
connect(screens(), &Screens::sizeChanged, this, &EffectsHandler::virtualScreenSizeChanged);
|
2014-02-27 08:55:45 +00:00
|
|
|
connect(screens(), &Screens::geometryChanged, this, &EffectsHandler::virtualScreenGeometryChanged);
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2015-07-07 09:48:42 +00:00
|
|
|
if (Activities *activities = Activities::self()) {
|
|
|
|
connect(activities, &Activities::added, this, &EffectsHandler::activityAdded);
|
|
|
|
connect(activities, &Activities::removed, this, &EffectsHandler::activityRemoved);
|
|
|
|
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);
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox *tabBox = TabBox::TabBox::self();
|
2014-03-26 08:13:35 +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);
|
|
|
|
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);
|
2016-08-15 06:37:24 +00:00
|
|
|
connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged);
|
2011-02-27 08:25:45 +00:00
|
|
|
// connect all clients
|
2013-09-24 12:31:35 +00:00
|
|
|
for (Client *c : ws->clientList()) {
|
2011-03-06 10:13:11 +00:00
|
|
|
setupClientConnections(c);
|
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
|
|
|
}
|
2015-03-04 08:21:10 +00:00
|
|
|
if (auto w = waylandServer()) {
|
|
|
|
connect(w, &WaylandServer::shellClientAdded, this,
|
|
|
|
[this](ShellClient *c) {
|
|
|
|
if (c->readyForPainting())
|
|
|
|
slotShellClientShown(c);
|
|
|
|
else
|
|
|
|
connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotShellClientShown);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
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
|
|
|
{
|
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
|
|
|
if (keyboard_grab_effect != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
ungrabKeyboard();
|
2013-11-13 09:03:58 +00:00
|
|
|
setActiveFullScreenEffect(nullptr);
|
|
|
|
for (auto it = loaded_effects.begin(); it != loaded_effects.end(); ++it) {
|
|
|
|
Effect *effect = (*it).second;
|
|
|
|
stopMouseInterception(effect);
|
|
|
|
// remove support properties for the effect
|
|
|
|
const QList<QByteArray> properties = m_propertiesForEffects.keys();
|
|
|
|
for (const QByteArray &property : properties) {
|
|
|
|
removeSupportProperty(property, effect);
|
|
|
|
}
|
|
|
|
delete effect;
|
|
|
|
}
|
2014-01-12 22:03:42 +00:00
|
|
|
loaded_effects.clear();
|
2015-11-16 13:06:23 +00:00
|
|
|
m_effectLoader->clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-10-26 09:43:36 +00:00
|
|
|
void EffectsHandlerImpl::setupAbstractClientConnections(AbstractClient* c)
|
2011-03-06 10:13:11 +00:00
|
|
|
{
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
|
|
|
|
connect(c, static_cast<void (AbstractClient::*)(KWin::AbstractClient*, MaximizeMode)>(&AbstractClient::clientMaximizedStateChanged),
|
2014-03-26 08:13:35 +00:00
|
|
|
this, &EffectsHandlerImpl::slotClientMaximized);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::clientStartUserMovedResized, this,
|
2015-10-22 13:47:02 +00:00
|
|
|
[this](AbstractClient *c) {
|
2014-03-26 08:13:35 +00:00
|
|
|
emit windowStartUserMovedResized(c->effectWindow());
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::clientStepUserMovedResized, this,
|
2015-10-22 13:47:02 +00:00
|
|
|
[this](AbstractClient *c, const QRect &geometry) {
|
2014-03-26 08:13:35 +00:00
|
|
|
emit windowStepUserMovedResized(c->effectWindow(), geometry);
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::clientFinishUserMovedResized, this,
|
2015-10-22 13:47:02 +00:00
|
|
|
[this](AbstractClient *c) {
|
2014-03-26 08:13:35 +00:00
|
|
|
emit windowFinishUserMovedResized(c->effectWindow());
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
|
|
|
|
connect(c, &AbstractClient::clientMinimized, this,
|
2015-03-13 13:45:21 +00:00
|
|
|
[this](AbstractClient *c, bool animate) {
|
2014-03-26 08:13:35 +00:00
|
|
|
// TODO: notify effects even if it should not animate?
|
|
|
|
if (animate) {
|
|
|
|
emit windowMinimized(c->effectWindow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::clientUnminimized, this,
|
2015-03-13 13:45:21 +00:00
|
|
|
[this](AbstractClient* c, bool animate) {
|
2014-03-26 08:13:35 +00:00
|
|
|
// TODO: notify effects even if it should not animate?
|
|
|
|
if (animate) {
|
|
|
|
emit windowUnminimized(c->effectWindow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
connect(c, &AbstractClient::modalChanged, this, &EffectsHandlerImpl::slotClientModalityChanged);
|
|
|
|
connect(c, &AbstractClient::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
|
|
|
|
connect(c, &AbstractClient::damaged, this, &EffectsHandlerImpl::slotWindowDamaged);
|
2016-07-04 13:37:30 +00:00
|
|
|
connect(c, &AbstractClient::windowShown, this,
|
|
|
|
[this](Toplevel *c) {
|
|
|
|
emit windowShown(c->effectWindow());
|
|
|
|
}
|
|
|
|
);
|
|
|
|
connect(c, &AbstractClient::windowHidden, this,
|
|
|
|
[this](Toplevel *c) {
|
|
|
|
emit windowHidden(c->effectWindow());
|
|
|
|
}
|
|
|
|
);
|
2015-10-26 09:43:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::setupClientConnections(Client* c)
|
|
|
|
{
|
|
|
|
setupAbstractClientConnections(c);
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(c, &Client::paddingChanged, this, &EffectsHandlerImpl::slotPaddingChanged);
|
|
|
|
connect(c, &Client::propertyNotify, this, &EffectsHandlerImpl::slotPropertyNotify);
|
2011-03-06 10:13:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u)
|
|
|
|
{
|
2014-03-26 08:13:35 +00:00
|
|
|
connect(u, &Unmanaged::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
|
|
|
|
connect(u, &Unmanaged::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
|
|
|
|
connect(u, &Unmanaged::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
|
|
|
|
connect(u, &Unmanaged::paddingChanged, this, &EffectsHandlerImpl::slotPaddingChanged);
|
|
|
|
connect(u, &Unmanaged::damaged, this, &EffectsHandlerImpl::slotWindowDamaged);
|
|
|
|
connect(u, &Unmanaged::propertyNotify, this, &EffectsHandlerImpl::slotPropertyNotify);
|
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
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintScreenIterator++)->prePaintScreen(data, time);
|
|
|
|
--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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
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;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2012-08-16 19:19:54 +00:00
|
|
|
m_scene->finalPaintScreen(mask, region, data);
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
|
|
|
{
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentPaintWindowIterator++)->prePaintWindow(w, data, time);
|
|
|
|
--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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
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;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2012-08-16 19:19:54 +00:00
|
|
|
m_scene->finalPaintWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
|
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::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
|
|
|
|
{
|
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 {
|
|
|
|
const EffectFrameImpl* frameImpl = static_cast<const EffectFrameImpl*>(frame);
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::postPaintWindow(EffectWindow* w)
|
|
|
|
{
|
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
|
|
|
{
|
|
|
|
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;
|
|
|
|
return NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-04-25 18:40:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
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;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2012-08-16 19:19:54 +00:00
|
|
|
m_scene->finalDrawWindow(static_cast<EffectWindowImpl*>(w), mask, region, data);
|
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::buildQuads(EffectWindow* w, WindowQuadList& quadList)
|
|
|
|
{
|
2012-05-07 20:29:54 +00:00
|
|
|
static bool initIterator = true;
|
|
|
|
if (initIterator) {
|
2013-07-19 09:34:01 +00:00
|
|
|
m_currentBuildQuadsIterator = m_activeEffects.constBegin();
|
2012-05-07 20:29:54 +00:00
|
|
|
initIterator = false;
|
|
|
|
}
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentBuildQuadsIterator != m_activeEffects.constEnd()) {
|
2011-08-27 09:21:31 +00:00
|
|
|
(*m_currentBuildQuadsIterator++)->buildQuads(w, quadList);
|
|
|
|
--m_currentBuildQuadsIterator;
|
2008-10-17 10:30:43 +00:00
|
|
|
}
|
2013-07-19 09:34:01 +00:00
|
|
|
if (m_currentBuildQuadsIterator == m_activeEffects.constBegin())
|
2012-05-07 20:29:54 +00:00
|
|
|
initIterator = true;
|
2011-01-30 14:34:42 +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
|
|
|
|
2010-11-10 18:33:07 +00:00
|
|
|
bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-07-22 12:47:08 +00:00
|
|
|
return Decoration::DecorationBridge::self()->needsBlur();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-10 18:33:07 +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());
|
2013-07-19 09:34:01 +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
|
|
|
|
2015-06-07 01:17:34 +00:00
|
|
|
void EffectsHandlerImpl::slotClientMaximized(KWin::AbstractClient *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()) {
|
|
|
|
emit windowMaximizedStateChanged(w, horizontal, vertical);
|
|
|
|
}
|
2011-02-28 20:03:13 +00:00
|
|
|
}
|
|
|
|
|
2011-03-06 09:30:23 +00:00
|
|
|
void EffectsHandlerImpl::slotOpacityChanged(Toplevel *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
|
|
|
}
|
|
|
|
emit windowOpacityChanged(t->effectWindow(), oldOpacity, (qreal)t->opacity());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t)
|
2012-01-24 16:00:40 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
Q_ASSERT(dynamic_cast<Client*>(t));
|
|
|
|
Client *c = static_cast<Client*>(t);
|
2016-08-03 14:12:23 +00:00
|
|
|
disconnect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown);
|
2012-01-12 06:42:55 +00:00
|
|
|
setupClientConnections(c);
|
|
|
|
if (!c->tabGroup()) // the "window" has already been there
|
|
|
|
emit windowAdded(c->effectWindow());
|
2012-01-24 16:00:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-04 08:21:10 +00:00
|
|
|
void EffectsHandlerImpl::slotShellClientShown(Toplevel *t)
|
|
|
|
{
|
|
|
|
ShellClient *c = static_cast<ShellClient*>(t);
|
2015-10-26 09:43:36 +00:00
|
|
|
setupAbstractClientConnections(c);
|
2015-03-04 08:21:10 +00:00
|
|
|
emit windowAdded(t->effectWindow());
|
|
|
|
}
|
|
|
|
|
2013-06-28 12:23:22 +00:00
|
|
|
void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t)
|
|
|
|
{ // regardless, unmanaged windows are -yet?- not synced anyway
|
|
|
|
Q_ASSERT(dynamic_cast<Unmanaged*>(t));
|
|
|
|
Unmanaged *u = static_cast<Unmanaged*>(t);
|
|
|
|
setupUnmanagedConnections(u);
|
|
|
|
emit windowAdded(u->effectWindow());
|
|
|
|
}
|
|
|
|
|
2015-11-09 15:27:15 +00:00
|
|
|
void EffectsHandlerImpl::slotWindowClosed(KWin::Toplevel *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) {
|
|
|
|
emit windowClosed(c->effectWindow());
|
|
|
|
}
|
2011-02-27 08:25:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 14:26:55 +00:00
|
|
|
void EffectsHandlerImpl::slotClientModalityChanged()
|
|
|
|
{
|
|
|
|
emit windowModalityChanged(static_cast<Client*>(sender())->effectWindow());
|
|
|
|
}
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void EffectsHandlerImpl::slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
emit currentTabAboutToChange(from, to);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void EffectsHandlerImpl::slotTabAdded(EffectWindow* w, EffectWindow* to)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
emit tabAdded(w, to);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow* leaderOfFormerGroup)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
emit tabRemoved(w, leaderOfFormerGroup);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-03-12 14:04:22 +00:00
|
|
|
void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRect& 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;
|
|
|
|
}
|
2011-03-12 14:04:22 +00:00
|
|
|
emit windowDamaged(t->effectWindow(), r);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-06-19 20:07:19 +00:00
|
|
|
void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel* 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
|
2011-06-19 20:07:19 +00:00
|
|
|
if (t == NULL || t->effectWindow() == NULL)
|
2011-03-12 11:34:59 +00:00
|
|
|
return;
|
2011-06-19 20:07:19 +00:00
|
|
|
emit windowGeometryShapeChanged(t->effectWindow(), old);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-03-24 21:42:29 +00:00
|
|
|
void EffectsHandlerImpl::slotPaddingChanged(Toplevel* t, const QRect& old)
|
|
|
|
{
|
|
|
|
// during late cleanup effectWindow() may be already NULL
|
|
|
|
// in some functions that may still call this
|
|
|
|
if (t == NULL || t->effectWindow() == NULL)
|
|
|
|
return;
|
|
|
|
emit windowPaddingChanged(t->effectWindow(), old);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e)
|
|
|
|
{
|
2007-11-01 17:47:41 +00:00
|
|
|
fullscreen_effect = e;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-01 17:47:41 +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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool EffectsHandlerImpl::grabKeyboard(Effect* effect)
|
|
|
|
{
|
|
|
|
if (keyboard_grab_effect != NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2013-07-02 09:44:18 +00:00
|
|
|
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
|
|
|
bool ret = grabXKeyboard();
|
|
|
|
if (!ret)
|
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
void EffectsHandlerImpl::ungrabKeyboard()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(keyboard_grab_effect != NULL);
|
2013-07-02 09:44:18 +00:00
|
|
|
if (kwinApp()->operationMode() == Application::OperationModeX11) {
|
|
|
|
ungrabXKeyboard();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
keyboard_grab_effect = NULL;
|
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::grabbedKeyboardEvent(QKeyEvent* e)
|
|
|
|
{
|
|
|
|
if (keyboard_grab_effect != NULL)
|
|
|
|
keyboard_grab_effect->grabbedKeyboardEvent(e);
|
|
|
|
}
|
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;
|
|
|
|
}
|
2013-06-26 09:40:30 +00:00
|
|
|
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
2016-02-23 11:29:05 +00:00
|
|
|
input()->pointer()->setEffectsOverrideCursor(shape);
|
2013-06-26 09:40:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-04-24 14:51:04 +00:00
|
|
|
// NOTE: it is intended to not perform an XPointerGrab on X11. See documentation in kwineffects.h
|
|
|
|
// The mouse grab is implemented by using a full screen input only window
|
|
|
|
if (!m_mouseInterceptionWindow.isValid()) {
|
2014-11-25 07:40:23 +00:00
|
|
|
const QSize &s = screens()->size();
|
|
|
|
const QRect geo(0, 0, s.width(), s.height());
|
2015-03-18 06:47:49 +00:00
|
|
|
const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
|
2013-04-24 14:51:04 +00:00
|
|
|
const uint32_t values[] = {
|
|
|
|
true,
|
2015-03-18 06:47:49 +00:00
|
|
|
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION
|
2013-04-24 14:51:04 +00:00
|
|
|
};
|
|
|
|
m_mouseInterceptionWindow.reset(Xcb::createInputWindow(geo, mask, values));
|
2015-03-18 06:47:49 +00:00
|
|
|
defineCursor(shape);
|
2015-01-30 08:28:31 +00:00
|
|
|
} else {
|
|
|
|
defineCursor(shape);
|
2013-04-24 14:51:04 +00:00
|
|
|
}
|
|
|
|
m_mouseInterceptionWindow.map();
|
|
|
|
m_mouseInterceptionWindow.raise();
|
|
|
|
// Raise electric border windows above the input windows
|
|
|
|
// so they can still be triggered.
|
|
|
|
ScreenEdges::self()->ensureOnTop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::stopMouseInterception(Effect *effect)
|
|
|
|
{
|
|
|
|
if (!m_grabbedMouseEffects.contains(effect)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_grabbedMouseEffects.removeAll(effect);
|
2013-06-26 09:40:30 +00:00
|
|
|
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
2016-02-23 11:29:05 +00:00
|
|
|
input()->pointer()->removeEffectsOverrideCursor();
|
2013-06-26 09:40:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-04-24 14:51:04 +00:00
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
|
|
|
m_mouseInterceptionWindow.unmap();
|
|
|
|
Workspace::self()->stackScreenEdgesUnderOverrideRedirect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
bool EffectsHandlerImpl::isMouseInterception() const
|
|
|
|
{
|
|
|
|
return m_grabbedMouseEffects.count() > 0;
|
|
|
|
}
|
|
|
|
|
2016-08-15 13:44:10 +00:00
|
|
|
|
|
|
|
bool EffectsHandlerImpl::touchDown(quint32 id, const QPointF &pos, quint32 time)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::touchMotion(quint32 id, const QPointF &pos, quint32 time)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::touchUp(quint32 id, quint32 time)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void* EffectsHandlerImpl::getProxy(QString name)
|
|
|
|
{
|
2013-07-19 09:34:01 +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)
|
2009-02-06 10:15:06 +00:00
|
|
|
return (*it).second->proxy();
|
|
|
|
|
|
|
|
return NULL;
|
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
|
|
|
{
|
2015-11-09 15:24:13 +00:00
|
|
|
if (Cursor::self())
|
|
|
|
Cursor::self()->startMousePolling();
|
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
|
|
|
{
|
2015-11-09 15:24:13 +00:00
|
|
|
if (Cursor::self())
|
|
|
|
Cursor::self()->stopMousePolling();
|
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
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return keyboard_grab_effect != NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-11-26 15:15:46 +00:00
|
|
|
void EffectsHandlerImpl::desktopResized(const QSize &size)
|
|
|
|
{
|
2012-08-16 19:19:54 +00:00
|
|
|
m_scene->screenGeometryChanged(size);
|
2013-04-24 14:51:04 +00:00
|
|
|
if (m_mouseInterceptionWindow.isValid()) {
|
|
|
|
m_mouseInterceptionWindow.setGeometry(QRect(0, 0, size.width(), size.height()));
|
|
|
|
}
|
2011-11-26 15:15:46 +00:00
|
|
|
emit screenGeometryChanged(size);
|
|
|
|
}
|
|
|
|
|
2011-03-12 18:18:19 +00:00
|
|
|
void EffectsHandlerImpl::slotPropertyNotify(Toplevel* t, long int atom)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!registered_atoms.contains(atom))
|
2008-01-02 15:21:33 +00:00
|
|
|
return;
|
2011-03-12 18:18:19 +00:00
|
|
|
emit propertyNotify(t->effectWindow(), atom);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::registerPropertyType(long atom, bool reg)
|
|
|
|
{
|
|
|
|
if (reg)
|
2008-01-02 15:21:33 +00:00
|
|
|
++registered_atoms[ atom ]; // initialized to 0 if not present yet
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
|
|
|
if (--registered_atoms[ atom ] == 0)
|
|
|
|
registered_atoms.remove(atom);
|
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);
|
|
|
|
}
|
|
|
|
return m_managedProperties.value(propertyName);
|
|
|
|
}
|
|
|
|
// get the atom for the propertyName
|
2013-06-21 16:45:19 +00:00
|
|
|
ScopedCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(connection(),
|
2012-12-13 23:09:47 +00:00
|
|
|
xcb_intern_atom_unchecked(connection(), false, propertyName.size(), propertyName.constData()),
|
|
|
|
NULL));
|
|
|
|
if (atomReply.isNull()) {
|
|
|
|
return XCB_ATOM_NONE;
|
|
|
|
}
|
2013-04-26 22:00:23 +00:00
|
|
|
m_compositor->keepSupportProperty(atomReply->atom);
|
2012-12-13 23:09:47 +00:00
|
|
|
// announce property on root window
|
|
|
|
unsigned char dummy = 0;
|
|
|
|
xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, rootWindow(), atomReply->atom, atomReply->atom, 8, 1, &dummy);
|
|
|
|
// TODO: add to _NET_SUPPORTED
|
|
|
|
m_managedProperties.insert(propertyName, atomReply->atom);
|
|
|
|
m_propertiesForEffects.insert(propertyName, QList<Effect*>() << effect);
|
|
|
|
registerPropertyType(atomReply->atom, true);
|
|
|
|
return atomReply->atom;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return readWindowProperty(rootWindow(), atom, type, format);
|
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::deleteRootProperty(long atom) const
|
|
|
|
{
|
|
|
|
deleteWindowProperty(rootWindow(), atom);
|
|
|
|
}
|
2010-02-01 07:44:27 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::activateWindow(EffectWindow* c)
|
|
|
|
{
|
2015-07-07 14:11:35 +00:00
|
|
|
if (AbstractClient* cl = dynamic_cast< AbstractClient* >(static_cast<EffectWindowImpl*>(c)->window()))
|
2011-01-30 14:34:42 +00:00
|
|
|
Workspace::self()->activateClient(cl, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::activeWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : NULL;
|
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::moveWindow(EffectWindow* w, const QPoint& pos, bool snap, double snapAdjust)
|
|
|
|
{
|
2015-10-14 15:35:10 +00:00
|
|
|
AbstractClient* cl = dynamic_cast< AbstractClient* >(static_cast<EffectWindowImpl*>(w)->window());
|
2009-10-05 04:06:20 +00:00
|
|
|
if (!cl || !cl->isMovable())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (snap)
|
|
|
|
cl->move(Workspace::self()->adjustClientPosition(cl, pos, true, snapAdjust));
|
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
cl->move(pos);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowToDesktop(EffectWindow* w, int desktop)
|
|
|
|
{
|
2015-10-14 15:35:10 +00:00
|
|
|
AbstractClient* cl = dynamic_cast< AbstractClient* >(static_cast<EffectWindowImpl*>(w)->window());
|
2011-06-24 10:19:47 +00:00
|
|
|
if (cl && !cl->isDesktop() && !cl->isDock())
|
2011-01-30 14:34:42 +00:00
|
|
|
Workspace::self()->sendClientToDesktop(cl, desktop, true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::windowToScreen(EffectWindow* w, int screen)
|
|
|
|
{
|
2015-10-14 15:35:10 +00:00
|
|
|
AbstractClient* cl = dynamic_cast< AbstractClient* >(static_cast<EffectWindowImpl*>(w)->window());
|
2011-06-24 10:19:47 +00:00
|
|
|
if (cl && !cl->isDesktop() && !cl->isDock())
|
2011-01-30 14:34:42 +00:00
|
|
|
Workspace::self()->sendClientToScreen(cl, screen);
|
|
|
|
}
|
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
|
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
#ifdef 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
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return desktopGridWidth() * displayWidth();
|
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
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return desktopGridHeight() * displayHeight();
|
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
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->grid().at(coords);
|
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);
|
|
|
|
if (coords.x() == -1)
|
|
|
|
return QPoint(-1, -1);
|
|
|
|
return QPoint(coords.x() * displayWidth(), coords.y() * displayHeight());
|
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
|
|
|
|
{
|
2012-11-16 07:23:47 +00:00
|
|
|
return VirtualDesktopManager::self()->name(desktop);
|
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
|
|
|
|
2008-10-17 10:30:43 +00:00
|
|
|
WindowQuadType EffectsHandlerImpl::newWindowQuadType()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return WindowQuadType(next_window_quad_type++);
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* EffectsHandlerImpl::findWindow(WId id) const
|
|
|
|
{
|
2014-03-20 08:19:53 +00:00
|
|
|
if (Client* w = Workspace::self()->findClient(Predicate::WindowMatch, id))
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
2014-03-20 06:52:18 +00:00
|
|
|
if (Unmanaged* w = Workspace::self()->findUnmanaged(id))
|
2008-01-02 15:37:46 +00:00
|
|
|
return w->effectWindow();
|
2015-05-18 12:51:40 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
if (ShellClient *w = waylandServer()->findClient(id)) {
|
|
|
|
return w->effectWindow();
|
|
|
|
}
|
|
|
|
}
|
2008-01-02 15:37:46 +00:00
|
|
|
return NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-02 15:37:46 +00:00
|
|
|
|
2015-09-14 14:39:39 +00:00
|
|
|
EffectWindow* EffectsHandlerImpl::findWindow(KWayland::Server::SurfaceInterface *surf) const
|
|
|
|
{
|
|
|
|
if (waylandServer()) {
|
|
|
|
if (ShellClient *w = waylandServer()->findClient(surf)) {
|
|
|
|
return w->effectWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-05-01 20:56:37 +00:00
|
|
|
ToplevelList list = Workspace::self()->xStackingOrder();
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2013-09-24 12:31:35 +00:00
|
|
|
for (Toplevel *t : list) {
|
2013-07-02 10:45:01 +00:00
|
|
|
if (EffectWindow *w = effectWindow(t))
|
|
|
|
ret.append(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
|
|
|
|
2015-03-28 23:13:41 +00:00
|
|
|
void EffectsHandlerImpl::setElevatedWindow(KWin::EffectWindow* w, bool set)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
elevated_windows.removeAll(w);
|
|
|
|
if (set)
|
|
|
|
elevated_windows.append(w);
|
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2015-10-14 15:35:10 +00:00
|
|
|
if (AbstractClient* c = dynamic_cast< AbstractClient* >(static_cast< EffectWindowImpl* >(w)->window())) {
|
2013-04-04 07:41:18 +00:00
|
|
|
TabBox::TabBox::self()->setCurrentClient(c);
|
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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef 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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2015-03-05 12:59:18 +00:00
|
|
|
const auto clients = TabBox::TabBox::self()->currentClientList();
|
|
|
|
for (auto c : clients)
|
2011-01-30 14:34:42 +00:00
|
|
|
ret.append(c->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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef 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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef 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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef 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
|
|
|
|
|
|
|
QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
return TabBox::TabBox::self()->currentDesktopList();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-06-25 16:05:07 +00:00
|
|
|
return QList< int >();
|
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
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
return TabBox::TabBox::self()->currentDesktop();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-06-25 16:05:07 +00:00
|
|
|
return -1;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2015-03-05 12:59:18 +00:00
|
|
|
if (auto c = TabBox::TabBox::self()->currentClient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->effectWindow();
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
return NULL;
|
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
|
|
|
{
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->addRepaintFull();
|
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::addRepaint(const QRect& r)
|
|
|
|
{
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->addRepaint(r);
|
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::addRepaint(const QRegion& r)
|
|
|
|
{
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->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)
|
|
|
|
{
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->addRepaint(x, y, w, h);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-11-20 18:58:30 +00:00
|
|
|
int EffectsHandlerImpl::activeScreen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-03 10:19:27 +00:00
|
|
|
return screens()->current();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2008-06-09 16:09:56 +00:00
|
|
|
int EffectsHandlerImpl::numScreens() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-03 10:19:27 +00:00
|
|
|
return screens()->count();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
int EffectsHandlerImpl::screenNumber(const QPoint& pos) const
|
|
|
|
{
|
2013-04-03 10:19:27 +00:00
|
|
|
return screens()->number(pos);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-06-19 14:16:21 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, int screen, int desktop) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea(opt, screen, desktop);
|
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow* c) const
|
|
|
|
{
|
2007-11-20 18:58:30 +00:00
|
|
|
const Toplevel* t = static_cast< const EffectWindowImpl* >(c)->window();
|
2015-10-14 15:35:10 +00:00
|
|
|
if (const AbstractClient* cl = dynamic_cast< const AbstractClient* >(t))
|
2011-01-30 14:34:42 +00:00
|
|
|
return Workspace::self()->clientArea(opt, cl);
|
2007-11-20 18:58:30 +00:00
|
|
|
else
|
2012-11-16 07:23:47 +00:00
|
|
|
return Workspace::self()->clientArea(opt, t->geometry().center(), VirtualDesktopManager::self()->current());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 18:58:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint& p, int desktop) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea(opt, p, desktop);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-02-27 08:55:45 +00:00
|
|
|
QRect EffectsHandlerImpl::virtualScreenGeometry() const
|
|
|
|
{
|
|
|
|
return screens()->geometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize EffectsHandlerImpl::virtualScreenSize() const
|
|
|
|
{
|
|
|
|
return screens()->size();
|
|
|
|
}
|
|
|
|
|
2013-04-24 14:51:04 +00:00
|
|
|
void EffectsHandlerImpl::defineCursor(Qt::CursorShape shape)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-04-24 14:51:04 +00:00
|
|
|
if (!m_mouseInterceptionWindow.isValid()) {
|
2016-02-23 11:29:05 +00:00
|
|
|
input()->pointer()->setEffectsOverrideCursor(shape);
|
2013-04-24 14:51:04 +00:00
|
|
|
return;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2015-03-18 06:47:49 +00:00
|
|
|
const xcb_cursor_t c = Cursor::x11Cursor(shape);
|
|
|
|
if (c != XCB_CURSOR_NONE) {
|
|
|
|
m_mouseInterceptionWindow.defineCursor(c);
|
|
|
|
}
|
2013-02-19 17:35:23 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 06:46:31 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(xcb_button_press_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 06:46:31 +00:00
|
|
|
if (m_grabbedMouseEffects.isEmpty() || m_mouseInterceptionWindow != e->event) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2013-07-26 06:46:31 +00:00
|
|
|
}
|
|
|
|
for (Effect *effect : m_grabbedMouseEffects) {
|
|
|
|
Qt::MouseButton button = x11ToQtMouseButton(e->detail);
|
2013-08-06 10:19:20 +00:00
|
|
|
Qt::MouseButtons buttons = x11ToQtMouseButtons(e->state);
|
|
|
|
const QEvent::Type type = ((e->response_type & ~0x80) == XCB_BUTTON_PRESS) ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
|
|
|
|
if (type == QEvent::MouseButtonPress) {
|
|
|
|
buttons |= button;
|
|
|
|
} else {
|
|
|
|
buttons &= ~button;
|
|
|
|
}
|
|
|
|
QMouseEvent ev(type,
|
2013-07-26 06:46:31 +00:00
|
|
|
QPoint(e->event_x, e->event_y), QPoint(e->root_x, e->root_y),
|
|
|
|
button, buttons, x11ToQtKeyboardModifiers(e->state));
|
|
|
|
effect->windowInputMouseEvent(&ev);
|
|
|
|
}
|
|
|
|
return true; // eat event
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(xcb_motion_notify_event_t *e)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.isEmpty() || m_mouseInterceptionWindow != e->event) {
|
2013-04-24 14:51:04 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-26 06:46:31 +00:00
|
|
|
for (Effect *effect : m_grabbedMouseEffects) {
|
|
|
|
QMouseEvent ev(QEvent::MouseMove, QPoint(e->event_x, e->event_y), QPoint(e->root_x, e->root_y),
|
|
|
|
Qt::NoButton, x11ToQtMouseButtons(e->state), x11ToQtKeyboardModifiers(e->state));
|
|
|
|
effect->windowInputMouseEvent(&ev);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-04-24 14:51:04 +00:00
|
|
|
return true; // eat event
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-06-26 09:40:30 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(QMouseEvent *e)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
foreach (Effect *effect, m_grabbedMouseEffects) {
|
|
|
|
effect->windowInputMouseEvent(e);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-04 13:14:44 +00:00
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent(QWheelEvent *e)
|
|
|
|
{
|
|
|
|
if (m_grabbedMouseEffects.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
foreach (Effect *effect, m_grabbedMouseEffects) {
|
|
|
|
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) {
|
|
|
|
connect(Cursor::self(), &Cursor::cursorChanged, this, &EffectsHandler::cursorShapeChanged);
|
|
|
|
Cursor::self()->startCursorTracking();
|
|
|
|
}
|
|
|
|
++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) {
|
|
|
|
Cursor::self()->stopCursorTracking();
|
|
|
|
disconnect(Cursor::self(), &Cursor::cursorChanged, this, &EffectsHandler::cursorShapeChanged);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2013-06-26 09:40:30 +00:00
|
|
|
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-24 14:51:04 +00:00
|
|
|
m_mouseInterceptionWindow.raise();
|
2009-02-06 14:21:20 +00:00
|
|
|
// Raise electric border windows above the input windows
|
|
|
|
// so they can still be triggered. TODO: Do both at once.
|
2013-04-24 14:51:04 +00:00
|
|
|
ScreenEdges::self()->ensureOnTop();
|
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
|
|
|
{
|
2013-02-19 10:25:46 +00:00
|
|
|
return Cursor::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
|
|
|
|
|
|
|
unsigned long EffectsHandlerImpl::xrenderBufferPicture()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2012-08-16 19:19:54 +00:00
|
|
|
if (SceneXrender* s = dynamic_cast< SceneXrender* >(m_scene))
|
2007-04-29 17:35:43 +00:00
|
|
|
return s->bufferPicture();
|
|
|
|
#endif
|
|
|
|
return None;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-06-21 12:14:48 +00:00
|
|
|
QPainter *EffectsHandlerImpl::scenePainter()
|
|
|
|
{
|
|
|
|
if (SceneQPainter *s = dynamic_cast<SceneQPainter*>(m_scene)) {
|
|
|
|
return s->painter();
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::toggleEffect(const QString& name)
|
|
|
|
{
|
|
|
|
if (isEffectLoaded(name))
|
|
|
|
unloadEffect(name);
|
2007-05-29 11:42:47 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
loadEffect(name);
|
|
|
|
}
|
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;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
listModules << (*it).first;
|
2008-06-02 19:52:02 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2014-03-25 12:43:56 +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();
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->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
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectsHandlerImpl::unloadEffect(const QString& name)
|
|
|
|
{
|
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();
|
2012-08-23 16:04:36 +00:00
|
|
|
m_compositor->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) {
|
|
|
|
if (it.value().first == name) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "EffectsHandler::unloadEffect : Unloading Effect : " << name;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (activeFullScreenEffect() == it.value().second) {
|
|
|
|
setActiveFullScreenEffect(0);
|
|
|
|
}
|
2013-04-24 14:51:04 +00:00
|
|
|
stopMouseInterception(it.value().second);
|
2012-12-13 23:09:47 +00:00
|
|
|
// remove support properties for the effect
|
|
|
|
const QList<QByteArray> properties = m_propertiesForEffects.keys();
|
2013-09-24 12:31:35 +00:00
|
|
|
for (const QByteArray &property : properties) {
|
2012-12-13 23:09:47 +00:00
|
|
|
removeSupportProperty(property, it.value().second);
|
|
|
|
}
|
2007-07-06 12:38:41 +00:00
|
|
|
delete it.value().second;
|
|
|
|
effect_order.erase(it);
|
|
|
|
effectsChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "EffectsHandler::unloadEffect : Effect not loaded : " << name;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::reconfigureEffect(const QString& name)
|
|
|
|
{
|
2013-07-19 09:34:01 +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
|
|
|
}
|
|
|
|
}
|
2007-05-29 11:42:47 +00:00
|
|
|
|
2012-08-11 09:24:37 +00:00
|
|
|
bool EffectsHandlerImpl::isEffectLoaded(const QString& name) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-08-11 09:24:37 +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)
|
2007-05-29 11:42:47 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
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)
|
|
|
|
{
|
|
|
|
// if the effect is loaded, it is obviously supported
|
|
|
|
auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), [name](const EffectPair &pair) {
|
|
|
|
return pair.first == name;
|
|
|
|
});
|
|
|
|
if (it != loaded_effects.constEnd()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// next checks might require a context
|
|
|
|
makeOpenGLContextCurrent();
|
|
|
|
m_compositor->addRepaintFull();
|
|
|
|
|
2014-03-25 12:43:56 +00:00
|
|
|
return m_effectLoader->isEffectSupported(name);
|
2014-03-09 08:12:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QList< bool > EffectsHandlerImpl::areEffectsSupported(const QStringList &names)
|
|
|
|
{
|
|
|
|
QList< bool > retList;
|
|
|
|
for (const QString &name : names) {
|
|
|
|
retList << isEffectSupported(name);
|
|
|
|
}
|
|
|
|
return retList;
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:15:46 +00:00
|
|
|
void EffectsHandlerImpl::reloadEffect(Effect *effect)
|
|
|
|
{
|
|
|
|
QString effectName;
|
2013-07-19 09:34:01 +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
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "Recreating effects' list:";
|
2013-09-24 12:31:35 +00:00
|
|
|
for (const EffectPair & effect : effect_order) {
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << effect.first;
|
2011-01-30 14:34:42 +00:00
|
|
|
loaded_effects.append(effect);
|
2007-07-06 12:38:41 +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;
|
|
|
|
for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(),
|
|
|
|
end = loaded_effects.constEnd(); it != end; ++it) {
|
|
|
|
if (it->second->isActive()) {
|
|
|
|
ret << it->first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-08-31 13:47:01 +00:00
|
|
|
KWayland::Server::Display *EffectsHandlerImpl::waylandDisplay() const
|
|
|
|
{
|
|
|
|
if (waylandServer()) {
|
|
|
|
return waylandServer()->display();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrame* EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const
|
|
|
|
{
|
|
|
|
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) {
|
|
|
|
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
|
2014-10-29 15:11:20 +00:00
|
|
|
return Decoration::DecorationBridge::self()->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
|
|
|
|
{
|
|
|
|
if (!isEffectLoaded(name)) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
if ((*it).first == name) {
|
2015-11-05 14:14:06 +00:00
|
|
|
QString support((*it).first + QLatin1String(":\n"));
|
2012-08-11 09:24:37 +00:00
|
|
|
const QMetaObject *metaOptions = (*it).second->metaObject();
|
|
|
|
for (int i=0; i<metaOptions->propertyCount(); ++i) {
|
|
|
|
const QMetaProperty property = metaOptions->property(i);
|
2015-11-05 14:14:06 +00:00
|
|
|
if (qstrcmp(property.name(), "objectName") == 0) {
|
2012-08-11 09:24:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2015-11-05 14:14:06 +00:00
|
|
|
support += QString::fromUtf8(property.name()) + QLatin1String(": ") + (*it).second->property(property.name()).toString() + QLatin1Char('\n');
|
2012-08-11 09:24:37 +00:00
|
|
|
}
|
|
|
|
return support;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2012-10-27 21:35:19 +00:00
|
|
|
|
2013-01-30 12:07:59 +00:00
|
|
|
bool EffectsHandlerImpl::isScreenLocked() const
|
|
|
|
{
|
2016-08-15 06:37:24 +00:00
|
|
|
return ScreenLockerWatcher::self()->isLocked();
|
2013-01-30 12:07:59 +00:00
|
|
|
}
|
|
|
|
|
2012-10-27 21:35:19 +00:00
|
|
|
QString EffectsHandlerImpl::debug(const QString& name, const QString& parameter) const
|
|
|
|
{
|
2014-04-04 09:49:31 +00:00
|
|
|
QString internalName = name.toLower();;
|
2012-10-27 21:35:19 +00:00
|
|
|
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
|
|
|
|
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)});
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectWindowImpl
|
|
|
|
//****************************************
|
|
|
|
|
2011-12-29 09:31:37 +00:00
|
|
|
EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel)
|
|
|
|
: EffectWindow(toplevel)
|
|
|
|
, toplevel(toplevel)
|
2011-01-30 14:34:42 +00:00
|
|
|
, sw(NULL)
|
|
|
|
{
|
|
|
|
}
|
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()) {
|
2010-11-01 10:46:11 +00:00
|
|
|
GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>());
|
|
|
|
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
|
|
|
|
|
|
|
const EffectWindowGroup* EffectWindowImpl::group() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (Client* c = dynamic_cast< Client* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c->group()->effectGroup();
|
|
|
|
return NULL; // 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
|
|
|
{
|
|
|
|
if (Deleted* d = dynamic_cast< Deleted* >(toplevel))
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->refWindow();
|
|
|
|
abort(); // 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
|
|
|
{
|
|
|
|
if (Deleted* d = dynamic_cast< Deleted* >(toplevel))
|
2013-05-31 17:15:51 +00:00
|
|
|
return d->unrefWindow(); // delays deletion in case
|
2007-04-29 17:35:43 +00:00
|
|
|
abort(); // TODO
|
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::setWindow(Toplevel* w)
|
|
|
|
{
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setSceneWindow(Scene::Window* w)
|
|
|
|
{
|
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
|
|
|
|
2007-12-07 18:03:24 +00:00
|
|
|
QRegion EffectWindowImpl::shape() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-12-07 18:03:24 +00:00
|
|
|
return sw ? sw->shape() : geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-12-07 18:03:24 +00:00
|
|
|
|
2010-03-12 16:33:01 +00:00
|
|
|
QRect EffectWindowImpl::decorationInnerRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-03-12 16:33:01 +00:00
|
|
|
Client *client = dynamic_cast<Client*>(toplevel);
|
|
|
|
return client ? client->transparentRect() : contentsRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-03-12 16:33:01 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray EffectWindowImpl::readProperty(long atom, long type, int format) const
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
deleteWindowProperty(window()->window(), atom);
|
|
|
|
}
|
2009-06-27 10:21:49 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindow* EffectWindowImpl::findModal()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-03-05 12:59:18 +00:00
|
|
|
if (AbstractClient* c = dynamic_cast< AbstractClient* >(toplevel)) {
|
|
|
|
if (AbstractClient* c2 = c->findModal())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c2->effectWindow();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-06-03 13:08:05 +00:00
|
|
|
template <typename T>
|
|
|
|
EffectWindowList getMainWindows(Toplevel *toplevel)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-06-03 13:08:05 +00:00
|
|
|
T *c = static_cast<T*>(toplevel);
|
|
|
|
EffectWindowList ret;
|
2015-09-11 13:55:23 +00:00
|
|
|
const auto mainclients = c->mainClients();
|
|
|
|
for (auto tmp : mainclients)
|
2011-01-30 14:34:42 +00:00
|
|
|
ret.append(tmp->effectWindow());
|
2013-06-03 13:08:05 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowList EffectWindowImpl::mainWindows() const
|
|
|
|
{
|
2015-09-14 12:35:01 +00:00
|
|
|
if (dynamic_cast<AbstractClient*>(toplevel)) {
|
|
|
|
return getMainWindows<AbstractClient>(toplevel);
|
2013-06-03 13:08:05 +00:00
|
|
|
} else if (toplevel->isDeleted()) {
|
|
|
|
return getMainWindows<Deleted>(toplevel);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return EffectWindowList();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
WindowQuadList EffectWindowImpl::buildQuads(bool force) const
|
|
|
|
{
|
|
|
|
return sceneWindow()->buildQuads(force);
|
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectWindowImpl::setData(int role, const QVariant &data)
|
|
|
|
{
|
|
|
|
if (!data.isNull())
|
2010-01-03 17:50:38 +00:00
|
|
|
dataMap[ role ] = data;
|
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
dataMap.remove(role);
|
2016-10-31 10:22:24 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
if (!dataMap.contains(role))
|
2010-01-03 17:50:38 +00:00
|
|
|
return QVariant();
|
|
|
|
return dataMap[ 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
|
|
|
EffectWindow* effectWindow(Toplevel* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowImpl* ret = w->effectWindow();
|
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* effectWindow(Scene::Window* w)
|
|
|
|
{
|
2007-04-29 17:35:43 +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);
|
|
|
|
}
|
|
|
|
|
2012-03-29 13:32:41 +00:00
|
|
|
void EffectWindowImpl::registerThumbnail(AbstractThumbnailItem *item)
|
2011-11-10 13:28:06 +00:00
|
|
|
{
|
2012-03-29 13:46:53 +00:00
|
|
|
if (WindowThumbnailItem *thumb = qobject_cast<WindowThumbnailItem*>(item)) {
|
2012-03-29 13:32:41 +00:00
|
|
|
insertThumbnail(thumb);
|
|
|
|
connect(thumb, SIGNAL(destroyed(QObject*)), SLOT(thumbnailDestroyed(QObject*)));
|
|
|
|
connect(thumb, SIGNAL(wIdChanged(qulonglong)), SLOT(thumbnailTargetChanged()));
|
2012-03-29 18:17:57 +00:00
|
|
|
} else if (DesktopThumbnailItem *desktopThumb = qobject_cast<DesktopThumbnailItem*>(item)) {
|
|
|
|
m_desktopThumbnails.append(desktopThumb);
|
|
|
|
connect(desktopThumb, SIGNAL(destroyed(QObject*)), SLOT(desktopThumbnailDestroyed(QObject*)));
|
2012-03-29 13:32:41 +00:00
|
|
|
}
|
2011-11-10 13:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::thumbnailDestroyed(QObject *object)
|
|
|
|
{
|
|
|
|
// we know it is a ThumbnailItem
|
2012-03-29 13:46:53 +00:00
|
|
|
m_thumbnails.remove(static_cast<WindowThumbnailItem*>(object));
|
2011-11-10 13:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::thumbnailTargetChanged()
|
|
|
|
{
|
2012-03-29 13:46:53 +00:00
|
|
|
if (WindowThumbnailItem *item = qobject_cast<WindowThumbnailItem*>(sender())) {
|
2011-11-10 13:28:06 +00:00
|
|
|
insertThumbnail(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-29 13:46:53 +00:00
|
|
|
void EffectWindowImpl::insertThumbnail(WindowThumbnailItem *item)
|
2011-11-10 13:28:06 +00:00
|
|
|
{
|
|
|
|
EffectWindow *w = effects->findWindow(item->wId());
|
|
|
|
if (w) {
|
|
|
|
m_thumbnails.insert(item, QWeakPointer<EffectWindowImpl>(static_cast<EffectWindowImpl*>(w)));
|
|
|
|
} else {
|
|
|
|
m_thumbnails.insert(item, QWeakPointer<EffectWindowImpl>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
void EffectWindowImpl::desktopThumbnailDestroyed(QObject *object)
|
|
|
|
{
|
|
|
|
// we know it is a DesktopThumbnailItem
|
|
|
|
m_desktopThumbnails.removeAll(static_cast<DesktopThumbnailItem*>(object));
|
|
|
|
}
|
|
|
|
|
2013-05-13 06:17:28 +00:00
|
|
|
void EffectWindowImpl::referencePreviousWindowPixmap()
|
|
|
|
{
|
|
|
|
if (sw) {
|
|
|
|
sw->referencePreviousPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::unreferencePreviousWindowPixmap()
|
|
|
|
{
|
|
|
|
if (sw) {
|
|
|
|
sw->unreferencePreviousPixmap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//****************************************
|
|
|
|
// EffectWindowGroupImpl
|
|
|
|
//****************************************
|
|
|
|
|
2008-06-02 19:52:02 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectWindowGroupImpl::members() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList ret;
|
2013-09-24 12:31:35 +00:00
|
|
|
for (Toplevel * c : group->members())
|
2011-01-30 14:34:42 +00:00
|
|
|
ret.append(c->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)
|
|
|
|
: QObject(0)
|
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)
|
|
|
|
, m_shader(NULL)
|
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);
|
2013-07-22 14:10:47 +00:00
|
|
|
connect(m_theme, SIGNAL(themeChanged()), this, SLOT(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
|
|
|
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setFont(const QFont& font)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setGeometry(const QRect& geometry, bool force)
|
|
|
|
{
|
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;
|
2011-01-30 14:34:42 +00:00
|
|
|
m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry
|
|
|
|
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
|
|
|
|
2013-12-06 13:41:23 +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
|
|
|
|
2013-12-06 13:41:23 +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
|
|
|
|
setIconSize(m_icon.availableSizes().first());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
m_sceneFrame->freeIconFrame();
|
|
|
|
}
|
2010-07-18 16:32:37 +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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setIconSize(const QSize& size)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::render(QRegion region, double opacity, double frameOpacity)
|
|
|
|
{
|
|
|
|
if (m_geometry.isEmpty()) {
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Nothing to display
|
2010-07-24 16:29:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
m_shader = NULL;
|
2015-12-03 08:50:40 +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
|
|
|
|
2010-12-04 10:01:57 +00:00
|
|
|
|
|
|
|
void
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectFrameImpl::align(QRect &geometry)
|
2010-12-04 10:01:57 +00:00
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_alignment & Qt::AlignLeft)
|
|
|
|
geometry.moveLeft(m_point.x());
|
|
|
|
else if (m_alignment & Qt::AlignRight)
|
|
|
|
geometry.moveLeft(m_point.x() - geometry.width());
|
2010-12-04 10:01:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveLeft(m_point.x() - geometry.width() / 2);
|
|
|
|
if (m_alignment & Qt::AlignTop)
|
|
|
|
geometry.moveTop(m_point.y());
|
|
|
|
else if (m_alignment & Qt::AlignBottom)
|
|
|
|
geometry.moveTop(m_point.y() - geometry.height());
|
2010-12-04 10:01:57 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
geometry.moveTop(m_point.y() - geometry.height() / 2);
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setPosition(const QPoint& point)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setText(const QString& text)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void EffectFrameImpl::setSelection(const QRect& selection)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
if (m_static)
|
2010-07-18 16:32:37 +00:00
|
|
|
return; // Not automatically resizing
|
|
|
|
|
|
|
|
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());
|
|
|
|
if (m_iconSize.height() > geometry.height())
|
|
|
|
geometry.setHeight(m_iconSize.height());
|
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
|