File indexing completed on 2024-12-01 13:37:26
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org> 0006 SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include "kwineffects.h" 0014 0015 #include "kwinoffscreenquickview.h" 0016 #include "scene/workspacescene.h" 0017 0018 #include <QFont> 0019 #include <QHash> 0020 0021 #include <memory> 0022 0023 class QMouseEvent; 0024 class QWheelEvent; 0025 0026 namespace KWaylandServer 0027 { 0028 class Display; 0029 } 0030 0031 class QDBusPendingCallWatcher; 0032 class QDBusServiceWatcher; 0033 0034 namespace KWin 0035 { 0036 class Window; 0037 class Compositor; 0038 class Deleted; 0039 class EffectLoader; 0040 class Group; 0041 class Unmanaged; 0042 class WindowPropertyNotifyX11Filter; 0043 class TabletEvent; 0044 class TabletPadId; 0045 class TabletToolId; 0046 0047 class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler 0048 { 0049 Q_OBJECT 0050 Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects") 0051 Q_PROPERTY(QStringList activeEffects READ activeEffects) 0052 Q_PROPERTY(QStringList loadedEffects READ loadedEffects) 0053 Q_PROPERTY(QStringList listOfEffects READ listOfEffects) 0054 public: 0055 EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *scene); 0056 ~EffectsHandlerImpl() override; 0057 void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; 0058 void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; 0059 void postPaintScreen() override; 0060 void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; 0061 void paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; 0062 void postPaintWindow(EffectWindow *w) override; 0063 0064 Effect *provides(Effect::Feature ef); 0065 0066 void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; 0067 void renderWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; 0068 0069 void activateWindow(EffectWindow *c) override; 0070 EffectWindow *activeWindow() const override; 0071 void moveWindow(EffectWindow *w, const QPoint &pos, bool snap = false, double snapAdjust = 1.0) override; 0072 void windowToDesktop(EffectWindow *w, int desktop) override; 0073 void windowToScreen(EffectWindow *w, EffectScreen *screen) override; 0074 void setShowingDesktop(bool showing) override; 0075 0076 QString currentActivity() const override; 0077 int currentDesktop() const override; 0078 int numberOfDesktops() const override; 0079 void setCurrentDesktop(int desktop) override; 0080 void setNumberOfDesktops(int desktops) override; 0081 QSize desktopGridSize() const override; 0082 int desktopGridWidth() const override; 0083 int desktopGridHeight() const override; 0084 int workspaceWidth() const override; 0085 int workspaceHeight() const override; 0086 int desktopAtCoords(QPoint coords) const override; 0087 QPoint desktopGridCoords(int id) const override; 0088 QPoint desktopCoords(int id) const override; 0089 int desktopAbove(int desktop = 0, bool wrap = true) const override; 0090 int desktopToRight(int desktop = 0, bool wrap = true) const override; 0091 int desktopBelow(int desktop = 0, bool wrap = true) const override; 0092 int desktopToLeft(int desktop = 0, bool wrap = true) const override; 0093 QString desktopName(int desktop) const override; 0094 bool optionRollOverDesktops() const override; 0095 0096 QPoint cursorPos() const override; 0097 bool grabKeyboard(Effect *effect) override; 0098 void ungrabKeyboard() override; 0099 // not performing XGrabPointer 0100 void startMouseInterception(Effect *effect, Qt::CursorShape shape) override; 0101 void stopMouseInterception(Effect *effect) override; 0102 bool isMouseInterception() const; 0103 void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override; 0104 void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) override; 0105 void registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback) override; 0106 void registerTouchpadSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action) override; 0107 void registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback) override; 0108 void registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *action) override; 0109 void registerTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function<void(qreal)> progressCallback) override; 0110 void *getProxy(QString name) override; 0111 void startMousePolling() override; 0112 void stopMousePolling() override; 0113 EffectWindow *findWindow(WId id) const override; 0114 EffectWindow *findWindow(KWaylandServer::SurfaceInterface *surf) const override; 0115 EffectWindow *findWindow(QWindow *w) const override; 0116 EffectWindow *findWindow(const QUuid &id) const override; 0117 EffectWindowList stackingOrder() const override; 0118 void setElevatedWindow(KWin::EffectWindow *w, bool set) override; 0119 0120 void setTabBoxWindow(EffectWindow *) override; 0121 void setTabBoxDesktop(int) override; 0122 EffectWindowList currentTabBoxWindowList() const override; 0123 void refTabBox() override; 0124 void unrefTabBox() override; 0125 void closeTabBox() override; 0126 QList<int> currentTabBoxDesktopList() const override; 0127 int currentTabBoxDesktop() const override; 0128 EffectWindow *currentTabBoxWindow() const override; 0129 0130 void setActiveFullScreenEffect(Effect *e) override; 0131 Effect *activeFullScreenEffect() const override; 0132 bool hasActiveFullScreenEffect() const override; 0133 0134 void addRepaintFull() override; 0135 void addRepaint(const QRect &r) override; 0136 void addRepaint(const QRectF &r) override; 0137 0138 void addRepaint(const QRegion &r) override; 0139 void addRepaint(int x, int y, int w, int h) override; 0140 EffectScreen *activeScreen() const override; 0141 QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override; 0142 QRectF clientArea(clientAreaOption, const EffectWindow *c) const override; 0143 QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const override; 0144 QSize virtualScreenSize() const override; 0145 QRect virtualScreenGeometry() const override; 0146 double animationTimeFactor() const override; 0147 0148 void defineCursor(Qt::CursorShape shape) override; 0149 bool checkInputWindowEvent(QMouseEvent *e); 0150 bool checkInputWindowEvent(QWheelEvent *e); 0151 void checkInputWindowStacking(); 0152 0153 void reserveElectricBorder(ElectricBorder border, Effect *effect) override; 0154 void unreserveElectricBorder(ElectricBorder border, Effect *effect) override; 0155 0156 void registerTouchBorder(ElectricBorder border, QAction *action) override; 0157 void registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback) override; 0158 void unregisterTouchBorder(ElectricBorder border, QAction *action) override; 0159 0160 QPainter *scenePainter() override; 0161 void reconfigure() override; 0162 QByteArray readRootProperty(long atom, long type, int format) const override; 0163 xcb_atom_t announceSupportProperty(const QByteArray &propertyName, Effect *effect) override; 0164 void removeSupportProperty(const QByteArray &propertyName, Effect *effect) override; 0165 0166 bool hasDecorationShadows() const override; 0167 0168 bool decorationsHaveAlpha() const override; 0169 0170 std::unique_ptr<EffectFrame> effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const override; 0171 0172 QVariant kwinOption(KWinOption kwopt) override; 0173 bool isScreenLocked() const override; 0174 0175 bool makeOpenGLContextCurrent() override; 0176 void doneOpenGLContextCurrent() override; 0177 0178 xcb_connection_t *xcbConnection() const override; 0179 xcb_window_t x11RootWindow() const override; 0180 0181 // internal (used by kwin core or compositing code) 0182 void startPaint(); 0183 void grabbedKeyboardEvent(QKeyEvent *e); 0184 bool hasKeyboardGrab() const; 0185 0186 void reloadEffect(Effect *effect) override; 0187 QStringList loadedEffects() const; 0188 QStringList listOfEffects() const; 0189 void unloadAllEffects(); 0190 0191 QList<EffectWindow *> elevatedWindows() const; 0192 QStringList activeEffects() const; 0193 0194 /** 0195 * @returns whether or not any effect is currently active where KWin should not use direct scanout 0196 */ 0197 bool blocksDirectScanout() const; 0198 0199 KWaylandServer::Display *waylandDisplay() const override; 0200 0201 bool animationsSupported() const override; 0202 0203 PlatformCursorImage cursorImage() const override; 0204 0205 void hideCursor() override; 0206 void showCursor() override; 0207 0208 void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback) override; 0209 void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override; 0210 0211 void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override; 0212 void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override; 0213 0214 KSharedConfigPtr config() const override; 0215 KSharedConfigPtr inputConfig() const override; 0216 0217 WorkspaceScene *scene() const 0218 { 0219 return m_scene; 0220 } 0221 0222 bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time); 0223 bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time); 0224 bool touchUp(qint32 id, std::chrono::microseconds time); 0225 0226 bool tabletToolEvent(KWin::TabletEvent *event); 0227 bool tabletToolButtonEvent(uint button, bool pressed, const KWin::TabletToolId &tabletToolId, std::chrono::microseconds time); 0228 bool tabletPadButtonEvent(uint button, bool pressed, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time); 0229 bool tabletPadStripEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time); 0230 bool tabletPadRingEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time); 0231 0232 void highlightWindows(const QVector<EffectWindow *> &windows); 0233 0234 bool isPropertyTypeRegistered(xcb_atom_t atom) const 0235 { 0236 return registered_atoms.contains(atom); 0237 } 0238 0239 void windowToDesktops(EffectWindow *w, const QVector<uint> &desktops) override; 0240 0241 /** 0242 * Finds an effect with the given name. 0243 * 0244 * @param name The name of the effect. 0245 * @returns The effect with the given name @p name, or nullptr if there 0246 * is no such effect loaded. 0247 */ 0248 Effect *findEffect(const QString &name) const; 0249 0250 void renderOffscreenQuickView(OffscreenQuickView *effectQuickView) const override; 0251 0252 SessionState sessionState() const override; 0253 QList<EffectScreen *> screens() const override; 0254 EffectScreen *screenAt(const QPoint &point) const override; 0255 EffectScreen *findScreen(const QString &name) const override; 0256 EffectScreen *findScreen(int screenId) const override; 0257 void renderScreen(EffectScreen *screen) override; 0258 bool isCursorHidden() const override; 0259 QRect renderTargetRect() const override; 0260 qreal renderTargetScale() const override; 0261 0262 KWin::EffectWindow *inputPanel() const override; 0263 bool isInputPanelOverlay() const override; 0264 0265 public Q_SLOTS: 0266 void slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to); 0267 void slotTabAdded(EffectWindow *from, EffectWindow *to); 0268 void slotTabRemoved(EffectWindow *c, EffectWindow *newActiveWindow); 0269 0270 // slots for D-Bus interface 0271 Q_SCRIPTABLE void reconfigureEffect(const QString &name); 0272 Q_SCRIPTABLE bool loadEffect(const QString &name); 0273 Q_SCRIPTABLE void toggleEffect(const QString &name); 0274 Q_SCRIPTABLE void unloadEffect(const QString &name); 0275 Q_SCRIPTABLE bool isEffectLoaded(const QString &name) const; 0276 Q_SCRIPTABLE bool isEffectSupported(const QString &name); 0277 Q_SCRIPTABLE QList<bool> areEffectsSupported(const QStringList &names); 0278 Q_SCRIPTABLE QString supportInformation(const QString &name) const; 0279 Q_SCRIPTABLE QString debug(const QString &name, const QString ¶meter = QString()) const; 0280 0281 protected Q_SLOTS: 0282 void slotWindowShown(KWin::Window *); 0283 void slotUnmanagedShown(KWin::Window *); 0284 void slotWindowClosed(KWin::Window *original, KWin::Deleted *d); 0285 void slotClientMaximized(KWin::Window *window, MaximizeMode maxMode); 0286 void slotOpacityChanged(KWin::Window *window, qreal oldOpacity); 0287 void slotClientModalityChanged(); 0288 void slotGeometryShapeChanged(KWin::Window *window, const QRectF &old); 0289 void slotFrameGeometryChanged(Window *window, const QRectF &oldGeometry); 0290 void slotWindowDamaged(KWin::Window *window); 0291 void slotOutputAdded(Output *output); 0292 void slotOutputRemoved(Output *output); 0293 0294 protected: 0295 void connectNotify(const QMetaMethod &signal) override; 0296 void disconnectNotify(const QMetaMethod &signal) override; 0297 void effectsChanged(); 0298 void setupWindowConnections(KWin::Window *window); 0299 void setupUnmanagedConnections(KWin::Unmanaged *u); 0300 0301 /** 0302 * Default implementation does nothing and returns @c true. 0303 */ 0304 virtual bool doGrabKeyboard(); 0305 /** 0306 * Default implementation does nothing. 0307 */ 0308 virtual void doUngrabKeyboard(); 0309 0310 /** 0311 * Default implementation sets Effects override cursor on the PointerInputRedirection. 0312 */ 0313 virtual void doStartMouseInterception(Qt::CursorShape shape); 0314 0315 /** 0316 * Default implementation removes the Effects override cursor on the PointerInputRedirection. 0317 */ 0318 virtual void doStopMouseInterception(); 0319 0320 /** 0321 * Default implementation does nothing 0322 */ 0323 virtual void doCheckInputWindowStacking(); 0324 0325 Effect *keyboard_grab_effect; 0326 Effect *fullscreen_effect; 0327 QList<EffectWindow *> elevated_windows; 0328 QMultiMap<int, EffectPair> effect_order; 0329 QHash<long, int> registered_atoms; 0330 0331 private: 0332 void registerPropertyType(long atom, bool reg); 0333 void destroyEffect(Effect *effect); 0334 0335 typedef QVector<Effect *> EffectsList; 0336 typedef EffectsList::const_iterator EffectsIterator; 0337 EffectsList m_activeEffects; 0338 EffectsIterator m_currentDrawWindowIterator; 0339 EffectsIterator m_currentPaintWindowIterator; 0340 EffectsIterator m_currentPaintScreenIterator; 0341 typedef QHash<QByteArray, QList<Effect *>> PropertyEffectMap; 0342 PropertyEffectMap m_propertiesForEffects; 0343 QHash<QByteArray, qulonglong> m_managedProperties; 0344 Compositor *m_compositor; 0345 WorkspaceScene *m_scene; 0346 QList<Effect *> m_grabbedMouseEffects; 0347 EffectLoader *m_effectLoader; 0348 int m_trackingCursorChanges; 0349 std::unique_ptr<WindowPropertyNotifyX11Filter> m_x11WindowPropertyNotify; 0350 QList<EffectScreen *> m_effectScreens; 0351 }; 0352 0353 class EffectScreenImpl : public EffectScreen 0354 { 0355 Q_OBJECT 0356 0357 public: 0358 explicit EffectScreenImpl(Output *output, QObject *parent = nullptr); 0359 ~EffectScreenImpl() override; 0360 0361 Output *platformOutput() const; 0362 0363 QString name() const override; 0364 QString manufacturer() const override; 0365 QString model() const override; 0366 QString serialNumber() const override; 0367 qreal devicePixelRatio() const override; 0368 QRect geometry() const override; 0369 int refreshRate() const override; 0370 Transform transform() const override; 0371 0372 static EffectScreenImpl *get(Output *output); 0373 0374 private: 0375 QPointer<Output> m_platformOutput; 0376 }; 0377 0378 class EffectWindowImpl : public EffectWindow 0379 { 0380 Q_OBJECT 0381 public: 0382 explicit EffectWindowImpl(Window *window); 0383 ~EffectWindowImpl() override; 0384 0385 void addRepaint(const QRect &r) override; 0386 void addRepaintFull() override; 0387 void addLayerRepaint(const QRect &r) override; 0388 0389 void refWindow() override; 0390 void unrefWindow() override; 0391 0392 const EffectWindowGroup *group() const override; 0393 0394 bool isDeleted() const override; 0395 bool isMinimized() const override; 0396 bool isHidden() const override; 0397 double opacity() const override; 0398 0399 QStringList activities() const override; 0400 int desktop() const override; 0401 QVector<uint> desktops() const override; 0402 qreal x() const override; 0403 qreal y() const override; 0404 qreal width() const override; 0405 qreal height() const override; 0406 0407 QSizeF basicUnit() const override; 0408 QRectF geometry() const override; 0409 QRectF frameGeometry() const override; 0410 QRectF bufferGeometry() const override; 0411 QRectF clientGeometry() const override; 0412 0413 QString caption() const override; 0414 0415 QRectF expandedGeometry() const override; 0416 EffectScreen *screen() const override; 0417 QPointF pos() const override; 0418 QSizeF size() const override; 0419 QRectF rect() const override; 0420 0421 bool isMovable() const override; 0422 bool isMovableAcrossScreens() const override; 0423 bool isUserMove() const override; 0424 bool isUserResize() const override; 0425 QRectF iconGeometry() const override; 0426 0427 bool isDesktop() const override; 0428 bool isDock() const override; 0429 bool isToolbar() const override; 0430 bool isMenu() const override; 0431 bool isNormalWindow() const override; 0432 bool isSpecialWindow() const override; 0433 bool isDialog() const override; 0434 bool isSplash() const override; 0435 bool isUtility() const override; 0436 bool isDropdownMenu() const override; 0437 bool isPopupMenu() const override; 0438 bool isTooltip() const override; 0439 bool isNotification() const override; 0440 bool isCriticalNotification() const override; 0441 bool isAppletPopup() const override; 0442 bool isOnScreenDisplay() const override; 0443 bool isComboBox() const override; 0444 bool isDNDIcon() const override; 0445 bool skipsCloseAnimation() const override; 0446 0447 bool acceptsFocus() const override; 0448 bool keepAbove() const override; 0449 bool keepBelow() const override; 0450 bool isModal() const override; 0451 bool isPopupWindow() const override; 0452 bool isOutline() const override; 0453 bool isLockScreen() const override; 0454 0455 KWaylandServer::SurfaceInterface *surface() const override; 0456 bool isFullScreen() const override; 0457 bool isUnresponsive() const override; 0458 0459 QRectF contentsRect() const override; 0460 bool decorationHasAlpha() const override; 0461 QIcon icon() const override; 0462 QString windowClass() const override; 0463 NET::WindowType windowType() const override; 0464 bool isSkipSwitcher() const override; 0465 bool isCurrentTab() const override; 0466 QString windowRole() const override; 0467 0468 bool isManaged() const override; 0469 bool isWaylandClient() const override; 0470 bool isX11Client() const override; 0471 0472 pid_t pid() const override; 0473 qlonglong windowId() const override; 0474 QUuid internalId() const override; 0475 0476 QRectF decorationInnerRect() const override; 0477 KDecoration2::Decoration *decoration() const override; 0478 QByteArray readProperty(long atom, long type, int format) const override; 0479 void deleteProperty(long atom) const override; 0480 0481 EffectWindow *findModal() override; 0482 EffectWindow *transientFor() override; 0483 EffectWindowList mainWindows() const override; 0484 0485 void minimize() override; 0486 void unminimize() override; 0487 void closeWindow() override; 0488 0489 void referencePreviousWindowPixmap() override; 0490 void unreferencePreviousWindowPixmap() override; 0491 0492 QWindow *internalWindow() const override; 0493 0494 const Window *window() const; 0495 Window *window(); 0496 0497 void setWindow(Window *w); // internal 0498 void setWindowItem(WindowItem *item); // internal 0499 WindowItem *windowItem() const; // internal 0500 0501 void elevate(bool elevate); 0502 0503 void setData(int role, const QVariant &data) override; 0504 QVariant data(int role) const override; 0505 0506 private: 0507 void refVisible(const EffectWindowVisibleRef *holder) override; 0508 void unrefVisible(const EffectWindowVisibleRef *holder) override; 0509 0510 Window *m_window; 0511 WindowItem *m_windowItem; // This one is used only during paint pass. 0512 QHash<int, QVariant> dataMap; 0513 bool managed = false; 0514 bool m_waylandWindow; 0515 bool m_x11Window; 0516 }; 0517 0518 class EffectWindowGroupImpl 0519 : public EffectWindowGroup 0520 { 0521 public: 0522 explicit EffectWindowGroupImpl(Group *g); 0523 EffectWindowList members() const override; 0524 0525 private: 0526 Group *group; 0527 }; 0528 0529 class EffectFrameQuickScene : public OffscreenQuickScene 0530 { 0531 Q_OBJECT 0532 0533 Q_PROPERTY(QFont font READ font NOTIFY fontChanged) 0534 Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) 0535 Q_PROPERTY(QSize iconSize READ iconSize NOTIFY iconSizeChanged) 0536 Q_PROPERTY(QString text READ text NOTIFY textChanged) 0537 Q_PROPERTY(qreal frameOpacity READ frameOpacity NOTIFY frameOpacityChanged) 0538 Q_PROPERTY(bool crossFadeEnabled READ crossFadeEnabled NOTIFY crossFadeEnabledChanged) 0539 Q_PROPERTY(qreal crossFadeProgress READ crossFadeProgress NOTIFY crossFadeProgressChanged) 0540 0541 public: 0542 EffectFrameQuickScene(EffectFrameStyle style, bool staticSize, QPoint position, 0543 Qt::Alignment alignment, QObject *parent = nullptr); 0544 ~EffectFrameQuickScene() override; 0545 0546 EffectFrameStyle style() const; 0547 bool isStatic() const; 0548 0549 // has to be const-ref to match EffectFrameImpl... 0550 const QFont &font() const; 0551 void setFont(const QFont &font); 0552 Q_SIGNAL void fontChanged(const QFont &font); 0553 0554 const QIcon &icon() const; 0555 void setIcon(const QIcon &icon); 0556 Q_SIGNAL void iconChanged(const QIcon &icon); 0557 0558 const QSize &iconSize() const; 0559 void setIconSize(const QSize &iconSize); 0560 Q_SIGNAL void iconSizeChanged(const QSize &iconSize); 0561 0562 const QString &text() const; 0563 void setText(const QString &text); 0564 Q_SIGNAL void textChanged(const QString &text); 0565 0566 qreal frameOpacity() const; 0567 void setFrameOpacity(qreal frameOpacity); 0568 Q_SIGNAL void frameOpacityChanged(qreal frameOpacity); 0569 0570 bool crossFadeEnabled() const; 0571 void setCrossFadeEnabled(bool enabled); 0572 Q_SIGNAL void crossFadeEnabledChanged(bool enabled); 0573 0574 qreal crossFadeProgress() const; 0575 void setCrossFadeProgress(qreal progress); 0576 Q_SIGNAL void crossFadeProgressChanged(qreal progress); 0577 0578 Qt::Alignment alignment() const; 0579 void setAlignment(Qt::Alignment alignment); 0580 0581 QPoint position() const; 0582 void setPosition(const QPoint &point); 0583 0584 private: 0585 void reposition(); 0586 0587 EffectFrameStyle m_style; 0588 0589 // Position 0590 bool m_static; 0591 QPoint m_point; 0592 Qt::Alignment m_alignment; 0593 0594 // Contents 0595 QFont m_font; 0596 QIcon m_icon; 0597 QSize m_iconSize; 0598 QString m_text; 0599 qreal m_frameOpacity = 0.0; 0600 bool m_crossFadeEnabled = false; 0601 qreal m_crossFadeProgress = 0.0; 0602 }; 0603 0604 class KWIN_EXPORT EffectFrameImpl 0605 : public QObject, 0606 public EffectFrame 0607 { 0608 Q_OBJECT 0609 public: 0610 explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1), 0611 Qt::Alignment alignment = Qt::AlignCenter); 0612 ~EffectFrameImpl() override; 0613 0614 void free() override; 0615 void render(const QRegion ®ion = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override; 0616 Qt::Alignment alignment() const override; 0617 void setAlignment(Qt::Alignment alignment) override; 0618 const QFont &font() const override; 0619 void setFont(const QFont &font) override; 0620 const QRect &geometry() const override; 0621 void setGeometry(const QRect &geometry, bool force = false) override; 0622 const QIcon &icon() const override; 0623 void setIcon(const QIcon &icon) override; 0624 const QSize &iconSize() const override; 0625 void setIconSize(const QSize &size) override; 0626 void setPosition(const QPoint &point) override; 0627 const QString &text() const override; 0628 void setText(const QString &text) override; 0629 EffectFrameStyle style() const override; 0630 bool isCrossFade() const override; 0631 void enableCrossFade(bool enable) override; 0632 qreal crossFadeProgress() const override; 0633 void setCrossFadeProgress(qreal progress) override; 0634 0635 private: 0636 Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class 0637 0638 EffectFrameQuickScene *m_view; 0639 QRect m_geometry; 0640 }; 0641 0642 inline QList<EffectWindow *> EffectsHandlerImpl::elevatedWindows() const 0643 { 0644 if (isScreenLocked()) { 0645 return QList<EffectWindow *>(); 0646 } 0647 return elevated_windows; 0648 } 0649 0650 inline xcb_window_t EffectsHandlerImpl::x11RootWindow() const 0651 { 0652 return kwinApp()->x11RootWindow(); 0653 } 0654 0655 inline xcb_connection_t *EffectsHandlerImpl::xcbConnection() const 0656 { 0657 return kwinApp()->x11Connection(); 0658 } 0659 0660 inline EffectWindowGroupImpl::EffectWindowGroupImpl(Group *g) 0661 : group(g) 0662 { 0663 } 0664 0665 inline WindowItem *EffectWindowImpl::windowItem() const 0666 { 0667 return m_windowItem; 0668 } 0669 0670 inline const Window *EffectWindowImpl::window() const 0671 { 0672 return m_window; 0673 } 0674 0675 inline Window *EffectWindowImpl::window() 0676 { 0677 return m_window; 0678 } 0679 0680 } // namespace