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
|
|
|
|
|
|
|
#ifndef KWIN_EFFECTSIMPL_H
|
|
|
|
#define KWIN_EFFECTSIMPL_H
|
|
|
|
|
|
|
|
#include "kwineffects.h"
|
|
|
|
|
2014-12-02 10:31:07 +00:00
|
|
|
#include "client.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "scene.h"
|
2013-04-24 14:51:04 +00:00
|
|
|
#include "xcbutils.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-05-25 16:56:23 +00:00
|
|
|
#include <QHash>
|
2011-02-17 18:35:08 +00:00
|
|
|
#include <Plasma/FrameSvg>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-22 14:10:47 +00:00
|
|
|
namespace Plasma {
|
|
|
|
class Theme;
|
|
|
|
}
|
|
|
|
|
2015-08-31 13:47:01 +00:00
|
|
|
namespace KWayland
|
|
|
|
{
|
|
|
|
namespace Server
|
|
|
|
{
|
|
|
|
class Display;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-30 12:07:59 +00:00
|
|
|
class QDBusPendingCallWatcher;
|
|
|
|
class QDBusServiceWatcher;
|
2007-07-06 12:38:41 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2012-03-29 13:32:41 +00:00
|
|
|
class AbstractThumbnailItem;
|
2012-03-29 18:17:57 +00:00
|
|
|
class DesktopThumbnailItem;
|
2012-03-29 13:46:53 +00:00
|
|
|
class WindowThumbnailItem;
|
2011-11-10 13:28:06 +00:00
|
|
|
|
2011-02-25 21:06:02 +00:00
|
|
|
class Client;
|
2012-08-23 16:04:36 +00:00
|
|
|
class Compositor;
|
2011-02-27 09:47:42 +00:00
|
|
|
class Deleted;
|
2014-01-24 14:42:40 +00:00
|
|
|
class EffectLoader;
|
2011-02-25 21:06:02 +00:00
|
|
|
class Unmanaged;
|
|
|
|
|
2015-11-12 10:29:56 +00:00
|
|
|
class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-02-25 19:41:10 +00:00
|
|
|
Q_OBJECT
|
2012-08-30 06:20:26 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects")
|
|
|
|
Q_PROPERTY(QStringList activeEffects READ activeEffects)
|
|
|
|
Q_PROPERTY(QStringList loadedEffects READ loadedEffects)
|
|
|
|
Q_PROPERTY(QStringList listOfEffects READ listOfEffects)
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2012-08-23 16:04:36 +00:00
|
|
|
EffectsHandlerImpl(Compositor *compositor, Scene *scene);
|
2011-01-30 14:34:42 +00:00
|
|
|
virtual ~EffectsHandlerImpl();
|
2014-02-27 10:57:59 +00:00
|
|
|
void prePaintScreen(ScreenPrePaintData& data, int time) override;
|
|
|
|
void paintScreen(int mask, QRegion region, ScreenPaintData& data) override;
|
2012-03-29 18:12:34 +00:00
|
|
|
/**
|
|
|
|
* Special hook to perform a paintScreen but just with the windows on @p desktop.
|
|
|
|
**/
|
|
|
|
void paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData& data);
|
2014-02-27 10:57:59 +00:00
|
|
|
void postPaintScreen() override;
|
|
|
|
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override;
|
|
|
|
void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
|
|
|
|
void postPaintWindow(EffectWindow* w) override;
|
|
|
|
void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-03-23 01:06:46 +00:00
|
|
|
Effect *provides(Effect::Feature ef);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override;
|
|
|
|
|
|
|
|
void buildQuads(EffectWindow* w, WindowQuadList& quadList) override;
|
|
|
|
|
|
|
|
void activateWindow(EffectWindow* c) override;
|
|
|
|
EffectWindow* activeWindow() const override;
|
|
|
|
void moveWindow(EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0) override;
|
|
|
|
void windowToDesktop(EffectWindow* w, int desktop) override;
|
|
|
|
void windowToScreen(EffectWindow* w, int screen) override;
|
|
|
|
void setShowingDesktop(bool showing) override;
|
|
|
|
|
|
|
|
QString currentActivity() const override;
|
|
|
|
int currentDesktop() const override;
|
|
|
|
int numberOfDesktops() const override;
|
|
|
|
void setCurrentDesktop(int desktop) override;
|
|
|
|
void setNumberOfDesktops(int desktops) override;
|
|
|
|
QSize desktopGridSize() const override;
|
|
|
|
int desktopGridWidth() const override;
|
|
|
|
int desktopGridHeight() const override;
|
|
|
|
int workspaceWidth() const override;
|
|
|
|
int workspaceHeight() const override;
|
|
|
|
int desktopAtCoords(QPoint coords) const override;
|
|
|
|
QPoint desktopGridCoords(int id) const override;
|
|
|
|
QPoint desktopCoords(int id) const override;
|
|
|
|
int desktopAbove(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopToRight(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopBelow(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopToLeft(int desktop = 0, bool wrap = true) const override;
|
|
|
|
QString desktopName(int desktop) const override;
|
|
|
|
bool optionRollOverDesktops() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
QPoint cursorPos() const override;
|
|
|
|
bool grabKeyboard(Effect* effect) override;
|
|
|
|
void ungrabKeyboard() override;
|
2013-04-24 14:51:04 +00:00
|
|
|
// not performing XGrabPointer
|
2014-02-27 10:57:59 +00:00
|
|
|
void startMouseInterception(Effect *effect, Qt::CursorShape shape) override;
|
|
|
|
void stopMouseInterception(Effect *effect) override;
|
2016-02-23 11:29:05 +00:00
|
|
|
bool isMouseInterception() const;
|
2013-07-10 10:26:50 +00:00
|
|
|
void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) override;
|
2013-07-14 20:58:30 +00:00
|
|
|
void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override;
|
2013-07-15 10:04:13 +00:00
|
|
|
void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void* getProxy(QString name) override;
|
|
|
|
void startMousePolling() override;
|
|
|
|
void stopMousePolling() override;
|
|
|
|
EffectWindow* findWindow(WId id) const override;
|
2015-09-14 14:39:39 +00:00
|
|
|
EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
EffectWindowList stackingOrder() const override;
|
2015-03-28 23:13:41 +00:00
|
|
|
void setElevatedWindow(KWin::EffectWindow* w, bool set) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
|
|
|
|
void setTabBoxWindow(EffectWindow*) override;
|
|
|
|
void setTabBoxDesktop(int) override;
|
|
|
|
EffectWindowList currentTabBoxWindowList() const override;
|
|
|
|
void refTabBox() override;
|
|
|
|
void unrefTabBox() override;
|
|
|
|
void closeTabBox() override;
|
|
|
|
QList< int > currentTabBoxDesktopList() const override;
|
|
|
|
int currentTabBoxDesktop() const override;
|
|
|
|
EffectWindow* currentTabBoxWindow() const override;
|
|
|
|
|
|
|
|
void setActiveFullScreenEffect(Effect* e) override;
|
|
|
|
Effect* activeFullScreenEffect() const override;
|
|
|
|
|
|
|
|
void addRepaintFull() override;
|
|
|
|
void addRepaint(const QRect& r) override;
|
|
|
|
void addRepaint(const QRegion& r) override;
|
|
|
|
void addRepaint(int x, int y, int w, int h) override;
|
|
|
|
int activeScreen() const override;
|
|
|
|
int numScreens() const override;
|
|
|
|
int screenNumber(const QPoint& pos) const override;
|
|
|
|
QRect clientArea(clientAreaOption, int screen, int desktop) const override;
|
|
|
|
QRect clientArea(clientAreaOption, const EffectWindow* c) const override;
|
|
|
|
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const override;
|
2014-02-27 08:55:45 +00:00
|
|
|
QSize virtualScreenSize() const override;
|
|
|
|
QRect virtualScreenGeometry() const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
double animationTimeFactor() const override;
|
|
|
|
WindowQuadType newWindowQuadType() override;
|
|
|
|
|
|
|
|
void defineCursor(Qt::CursorShape shape) override;
|
2013-07-26 06:46:31 +00:00
|
|
|
bool checkInputWindowEvent(xcb_button_press_event_t *e);
|
|
|
|
bool checkInputWindowEvent(xcb_motion_notify_event_t *e);
|
2013-06-26 09:40:30 +00:00
|
|
|
bool checkInputWindowEvent(QMouseEvent *e);
|
2016-03-04 13:14:44 +00:00
|
|
|
bool checkInputWindowEvent(QWheelEvent *e);
|
2014-02-27 11:04:15 +00:00
|
|
|
void checkInputWindowStacking();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
void reserveElectricBorder(ElectricBorder border, Effect *effect) override;
|
|
|
|
void unreserveElectricBorder(ElectricBorder border, Effect *effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
unsigned long xrenderBufferPicture() override;
|
|
|
|
QPainter* scenePainter() override;
|
|
|
|
void reconfigure() override;
|
|
|
|
void registerPropertyType(long atom, bool reg) override;
|
|
|
|
QByteArray readRootProperty(long atom, long type, int format) const override;
|
|
|
|
void deleteRootProperty(long atom) const override;
|
|
|
|
xcb_atom_t announceSupportProperty(const QByteArray& propertyName, Effect* effect) override;
|
|
|
|
void removeSupportProperty(const QByteArray& propertyName, Effect* effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool hasDecorationShadows() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool decorationsHaveAlpha() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool decorationSupportsBlurBehind() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
QVariant kwinOption(KWinOption kwopt) override;
|
|
|
|
bool isScreenLocked() const override;
|
2011-04-25 15:04:04 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool makeOpenGLContextCurrent() override;
|
|
|
|
void doneOpenGLContextCurrent() override;
|
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
|
|
|
|
2014-04-16 13:58:06 +00:00
|
|
|
xcb_connection_t *xcbConnection() const override;
|
|
|
|
xcb_window_t x11RootWindow() const override;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
// internal (used by kwin core or compositing code)
|
|
|
|
void startPaint();
|
|
|
|
void grabbedKeyboardEvent(QKeyEvent* e);
|
|
|
|
bool hasKeyboardGrab() const;
|
2011-11-26 15:15:46 +00:00
|
|
|
void desktopResized(const QSize &size);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
void reloadEffect(Effect *effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
QStringList loadedEffects() const;
|
|
|
|
QStringList listOfEffects() const;
|
2015-11-12 10:29:56 +00:00
|
|
|
void unloadAllEffects();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
QList<EffectWindow*> elevatedWindows() const;
|
2011-12-29 22:33:45 +00:00
|
|
|
QStringList activeEffects() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-03-29 18:12:34 +00:00
|
|
|
/**
|
|
|
|
* @returns Whether we are currently in a desktop rendering process triggered by paintDesktop hook
|
|
|
|
**/
|
|
|
|
bool isDesktopRendering() const {
|
|
|
|
return m_desktopRendering;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @returns the desktop currently being rendered in the paintDesktop hook.
|
|
|
|
**/
|
|
|
|
int currentRenderedDesktop() const {
|
|
|
|
return m_currentRenderedDesktop;
|
|
|
|
}
|
|
|
|
|
2015-08-31 13:47:01 +00:00
|
|
|
KWayland::Server::Display *waylandDisplay() const override;
|
|
|
|
|
2016-08-10 07:24:53 +00:00
|
|
|
bool animationsSupported() const override;
|
|
|
|
|
2015-12-03 08:50:40 +00:00
|
|
|
Scene *scene() const {
|
|
|
|
return m_scene;
|
|
|
|
}
|
|
|
|
|
2016-08-15 13:44:10 +00:00
|
|
|
bool touchDown(quint32 id, const QPointF &pos, quint32 time);
|
|
|
|
bool touchMotion(quint32 id, const QPointF &pos, quint32 time);
|
|
|
|
bool touchUp(quint32 id, quint32 time);
|
|
|
|
|
2016-08-30 13:50:31 +00:00
|
|
|
void highlightWindows(const QVector<EffectWindow *> &windows);
|
|
|
|
|
2011-02-28 20:03:13 +00:00
|
|
|
public Q_SLOTS:
|
2012-01-12 06:42:55 +00:00
|
|
|
void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to);
|
|
|
|
void slotTabAdded(EffectWindow* from, EffectWindow* to);
|
|
|
|
void slotTabRemoved(EffectWindow* c, EffectWindow* newActiveWindow);
|
2011-02-28 20:03:13 +00:00
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
// slots for D-Bus interface
|
|
|
|
Q_SCRIPTABLE void reconfigureEffect(const QString& name);
|
2014-03-25 12:43:56 +00:00
|
|
|
Q_SCRIPTABLE bool loadEffect(const QString& name);
|
2012-08-30 06:20:26 +00:00
|
|
|
Q_SCRIPTABLE void toggleEffect(const QString& name);
|
|
|
|
Q_SCRIPTABLE void unloadEffect(const QString& name);
|
|
|
|
Q_SCRIPTABLE bool isEffectLoaded(const QString& name) const;
|
2014-03-09 08:12:09 +00:00
|
|
|
Q_SCRIPTABLE bool isEffectSupported(const QString& name);
|
|
|
|
Q_SCRIPTABLE QList<bool> areEffectsSupported(const QStringList &names);
|
2012-08-30 06:20:26 +00:00
|
|
|
Q_SCRIPTABLE QString supportInformation(const QString& name) const;
|
2012-10-27 21:35:19 +00:00
|
|
|
Q_SCRIPTABLE QString debug(const QString& name, const QString& parameter = QString()) const;
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2011-02-25 19:41:10 +00:00
|
|
|
protected Q_SLOTS:
|
2012-01-24 16:00:40 +00:00
|
|
|
void slotClientShown(KWin::Toplevel*);
|
2015-03-04 08:21:10 +00:00
|
|
|
void slotShellClientShown(KWin::Toplevel*);
|
2013-06-28 12:23:22 +00:00
|
|
|
void slotUnmanagedShown(KWin::Toplevel*);
|
2015-11-09 15:27:15 +00:00
|
|
|
void slotWindowClosed(KWin::Toplevel *c, KWin::Deleted *d);
|
2015-06-07 01:17:34 +00:00
|
|
|
void slotClientMaximized(KWin::AbstractClient *c, MaximizeMode maxMode);
|
2011-03-06 09:30:23 +00:00
|
|
|
void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity);
|
2013-06-19 14:26:55 +00:00
|
|
|
void slotClientModalityChanged();
|
2011-06-19 20:07:19 +00:00
|
|
|
void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old);
|
2012-03-24 21:42:29 +00:00
|
|
|
void slotPaddingChanged(KWin::Toplevel *t, const QRect &old);
|
2011-03-12 14:04:22 +00:00
|
|
|
void slotWindowDamaged(KWin::Toplevel *t, const QRect& r);
|
2011-03-12 18:18:19 +00:00
|
|
|
void slotPropertyNotify(KWin::Toplevel *t, long atom);
|
2011-02-25 19:41:10 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
protected:
|
2015-02-07 16:12:53 +00:00
|
|
|
void connectNotify(const QMetaMethod &signal) override;
|
|
|
|
void disconnectNotify(const QMetaMethod &signal) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
void effectsChanged();
|
2015-10-26 09:43:36 +00:00
|
|
|
void setupAbstractClientConnections(KWin::AbstractClient *c);
|
2011-03-06 10:13:11 +00:00
|
|
|
void setupClientConnections(KWin::Client *c);
|
|
|
|
void setupUnmanagedConnections(KWin::Unmanaged *u);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
Effect* keyboard_grab_effect;
|
|
|
|
Effect* fullscreen_effect;
|
|
|
|
QList<EffectWindow*> elevated_windows;
|
|
|
|
QMultiMap< int, EffectPair > effect_order;
|
|
|
|
QHash< long, int > registered_atoms;
|
|
|
|
int next_window_quad_type;
|
2011-08-27 09:21:31 +00:00
|
|
|
|
|
|
|
private:
|
2013-07-19 09:46:42 +00:00
|
|
|
typedef QVector< Effect*> EffectsList;
|
2013-07-19 09:34:01 +00:00
|
|
|
typedef EffectsList::const_iterator EffectsIterator;
|
2013-07-19 09:46:42 +00:00
|
|
|
EffectsList m_activeEffects;
|
2013-07-19 09:34:01 +00:00
|
|
|
EffectsIterator m_currentDrawWindowIterator;
|
|
|
|
EffectsIterator m_currentPaintWindowIterator;
|
|
|
|
EffectsIterator m_currentPaintEffectFrameIterator;
|
|
|
|
EffectsIterator m_currentPaintScreenIterator;
|
|
|
|
EffectsIterator m_currentBuildQuadsIterator;
|
2012-12-13 23:09:47 +00:00
|
|
|
typedef QHash< QByteArray, QList< Effect*> > PropertyEffectMap;
|
|
|
|
PropertyEffectMap m_propertiesForEffects;
|
|
|
|
QHash<QByteArray, qulonglong> m_managedProperties;
|
2012-08-23 16:04:36 +00:00
|
|
|
Compositor *m_compositor;
|
2012-08-16 19:19:54 +00:00
|
|
|
Scene *m_scene;
|
2012-03-29 18:12:34 +00:00
|
|
|
bool m_desktopRendering;
|
|
|
|
int m_currentRenderedDesktop;
|
2013-04-24 14:51:04 +00:00
|
|
|
Xcb::Window m_mouseInterceptionWindow;
|
|
|
|
QList<Effect*> m_grabbedMouseEffects;
|
2014-01-24 14:42:40 +00:00
|
|
|
EffectLoader *m_effectLoader;
|
2015-02-07 16:12:53 +00:00
|
|
|
int m_trackingCursorChanges;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
2011-12-29 09:31:37 +00:00
|
|
|
class EffectWindowImpl : public EffectWindow
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-11-10 13:28:06 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit EffectWindowImpl(Toplevel *toplevel);
|
2011-01-30 14:34:42 +00:00
|
|
|
virtual ~EffectWindowImpl();
|
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
void enablePainting(int reason) override;
|
|
|
|
void disablePainting(int reason) override;
|
|
|
|
bool isPaintingEnabled() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
void refWindow() override;
|
|
|
|
void unrefWindow() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
const EffectWindowGroup* group() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
QRegion shape() const override;
|
|
|
|
QRect decorationInnerRect() const override;
|
|
|
|
QByteArray readProperty(long atom, long type, int format) const override;
|
|
|
|
void deleteProperty(long atom) const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
EffectWindow* findModal() override;
|
|
|
|
EffectWindowList mainWindows() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
WindowQuadList buildQuads(bool force = false) const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
void referencePreviousWindowPixmap() override;
|
|
|
|
void unreferencePreviousWindowPixmap() override;
|
2013-05-13 06:17:28 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
const Toplevel* window() const;
|
|
|
|
Toplevel* window();
|
|
|
|
|
|
|
|
void setWindow(Toplevel* w); // internal
|
|
|
|
void setSceneWindow(Scene::Window* w); // internal
|
|
|
|
const Scene::Window* sceneWindow() const; // internal
|
|
|
|
Scene::Window* sceneWindow(); // internal
|
|
|
|
|
2013-04-24 08:46:34 +00:00
|
|
|
void elevate(bool elevate);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void setData(int role, const QVariant &data);
|
|
|
|
QVariant data(int role) const;
|
2011-11-10 13:28:06 +00:00
|
|
|
|
2012-03-29 13:32:41 +00:00
|
|
|
void registerThumbnail(AbstractThumbnailItem *item);
|
2012-03-29 13:46:53 +00:00
|
|
|
QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> > const &thumbnails() const {
|
2011-11-10 13:28:06 +00:00
|
|
|
return m_thumbnails;
|
|
|
|
}
|
2012-03-29 18:17:57 +00:00
|
|
|
QList<DesktopThumbnailItem*> const &desktopThumbnails() const {
|
|
|
|
return m_desktopThumbnails;
|
|
|
|
}
|
2011-11-10 13:28:06 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void thumbnailDestroyed(QObject *object);
|
|
|
|
void thumbnailTargetChanged();
|
2012-03-29 18:17:57 +00:00
|
|
|
void desktopThumbnailDestroyed(QObject *object);
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2012-03-29 13:46:53 +00:00
|
|
|
void insertThumbnail(WindowThumbnailItem *item);
|
2011-01-30 14:34:42 +00:00
|
|
|
Toplevel* toplevel;
|
|
|
|
Scene::Window* sw; // This one is used only during paint pass.
|
|
|
|
QHash<int, QVariant> dataMap;
|
2012-03-29 13:46:53 +00:00
|
|
|
QHash<WindowThumbnailItem*, QWeakPointer<EffectWindowImpl> > m_thumbnails;
|
2012-03-29 18:17:57 +00:00
|
|
|
QList<DesktopThumbnailItem*> m_desktopThumbnails;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EffectWindowGroupImpl
|
|
|
|
: public EffectWindowGroup
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit EffectWindowGroupImpl(Group* g);
|
2014-02-27 11:07:41 +00:00
|
|
|
EffectWindowList members() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
Group* group;
|
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
class EffectFrameImpl
|
|
|
|
: public QObject, public EffectFrame
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1),
|
|
|
|
Qt::Alignment alignment = Qt::AlignCenter);
|
|
|
|
virtual ~EffectFrameImpl();
|
|
|
|
|
2014-02-27 11:10:18 +00:00
|
|
|
void free() override;
|
|
|
|
void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override;
|
|
|
|
Qt::Alignment alignment() const override;
|
|
|
|
void setAlignment(Qt::Alignment alignment) override;
|
|
|
|
const QFont& font() const override;
|
|
|
|
void setFont(const QFont& font) override;
|
|
|
|
const QRect& geometry() const override;
|
|
|
|
void setGeometry(const QRect& geometry, bool force = false) override;
|
|
|
|
const QIcon& icon() const override;
|
|
|
|
void setIcon(const QIcon& icon) override;
|
|
|
|
const QSize& iconSize() const override;
|
|
|
|
void setIconSize(const QSize& size) override;
|
|
|
|
void setPosition(const QPoint& point) override;
|
|
|
|
const QString& text() const override;
|
|
|
|
void setText(const QString& text) override;
|
|
|
|
EffectFrameStyle style() const override {
|
2011-01-30 14:34:42 +00:00
|
|
|
return m_style;
|
|
|
|
};
|
|
|
|
Plasma::FrameSvg& frame() {
|
|
|
|
return m_frame;
|
|
|
|
}
|
|
|
|
bool isStatic() const {
|
|
|
|
return m_static;
|
2010-07-18 16:32:37 +00:00
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
void finalRender(QRegion region, double opacity, double frameOpacity) const;
|
2014-02-27 11:10:18 +00:00
|
|
|
void setShader(GLShader* shader) override {
|
2011-01-30 14:34:42 +00:00
|
|
|
m_shader = shader;
|
|
|
|
}
|
2014-02-27 11:10:18 +00:00
|
|
|
GLShader* shader() const override {
|
2011-01-30 14:34:42 +00:00
|
|
|
return m_shader;
|
|
|
|
}
|
2014-02-27 11:10:18 +00:00
|
|
|
void setSelection(const QRect& selection) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
const QRect& selection() const {
|
|
|
|
return m_selectionGeometry;
|
|
|
|
}
|
|
|
|
Plasma::FrameSvg& selectionFrame() {
|
|
|
|
return m_selection;
|
|
|
|
}
|
2011-02-17 18:35:08 +00:00
|
|
|
/**
|
|
|
|
* The foreground text color as specified by the default Plasma theme.
|
|
|
|
*/
|
2013-07-22 14:10:47 +00:00
|
|
|
QColor styledTextColor();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void plasmaThemeChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class
|
|
|
|
void align(QRect &geometry); // positions geometry around m_point respecting m_alignment
|
|
|
|
void autoResize(); // Auto-resize if not a static size
|
|
|
|
|
|
|
|
EffectFrameStyle m_style;
|
|
|
|
Plasma::FrameSvg m_frame; // TODO: share between all EffectFrames
|
|
|
|
Plasma::FrameSvg m_selection;
|
|
|
|
|
|
|
|
// Position
|
|
|
|
bool m_static;
|
|
|
|
QPoint m_point;
|
|
|
|
Qt::Alignment m_alignment;
|
|
|
|
QRect m_geometry;
|
|
|
|
|
|
|
|
// Contents
|
|
|
|
QString m_text;
|
|
|
|
QFont m_font;
|
2013-12-06 13:41:23 +00:00
|
|
|
QIcon m_icon;
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize m_iconSize;
|
|
|
|
QRect m_selectionGeometry;
|
|
|
|
|
|
|
|
Scene::EffectFrame* m_sceneFrame;
|
|
|
|
GLShader* m_shader;
|
2013-07-22 14:10:47 +00:00
|
|
|
|
|
|
|
Plasma::Theme *m_theme;
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2007-05-24 14:41:56 +00:00
|
|
|
|
|
|
|
inline
|
2008-01-13 13:00:15 +00:00
|
|
|
QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-05-10 09:15:16 +00:00
|
|
|
if (isScreenLocked())
|
|
|
|
return QList<EffectWindow*>();
|
2007-05-24 14:41:56 +00:00
|
|
|
return elevated_windows;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2014-04-16 13:58:06 +00:00
|
|
|
inline
|
|
|
|
xcb_window_t EffectsHandlerImpl::x11RootWindow() const
|
|
|
|
{
|
|
|
|
return rootWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
xcb_connection_t *EffectsHandlerImpl::xcbConnection() const
|
|
|
|
{
|
|
|
|
return connection();
|
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
inline
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g)
|
|
|
|
: group(g)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindow* effectWindow(Toplevel* w);
|
|
|
|
EffectWindow* effectWindow(Scene::Window* w);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-08-08 14:42:06 +00:00
|
|
|
inline
|
|
|
|
const Scene::Window* EffectWindowImpl::sceneWindow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-08 14:42:06 +00:00
|
|
|
return sw;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
Scene::Window* EffectWindowImpl::sceneWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-08 14:42:06 +00:00
|
|
|
return sw;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
const Toplevel* EffectWindowImpl::window() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-08 14:42:06 +00:00
|
|
|
return toplevel;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
Toplevel* EffectWindowImpl::window()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-08-08 14:42:06 +00:00
|
|
|
return toplevel;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|