File indexing completed on 2024-04-28 16:48:57

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
0006     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0007     SPDX-FileCopyrightText: 2012 Martin Gräßlin <m.graesslin@kde.org>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #pragma once
0013 
0014 #include "main.h"
0015 
0016 #include <KConfigWatcher>
0017 
0018 namespace KWin
0019 {
0020 
0021 // Whether to keep all windows mapped when compositing (i.e. whether to have
0022 // actively updated window pixmaps).
0023 enum HiddenPreviews {
0024     // The normal mode with regard to mapped windows. Hidden (minimized, etc.)
0025     // and windows on inactive virtual desktops are not mapped, their pixmaps
0026     // are only their icons.
0027     HiddenPreviewsNever,
0028     // Like normal mode, but shown windows (i.e. on inactive virtual desktops)
0029     // are kept mapped, only hidden windows are unmapped.
0030     HiddenPreviewsShown,
0031     // All windows are kept mapped regardless of their state.
0032     HiddenPreviewsAlways
0033 };
0034 
0035 enum XwaylandEavesdropsMode {
0036     None,
0037     Modifiers,
0038     Combinations,
0039     All
0040 };
0041 
0042 /**
0043  * This enum type specifies whether the Xwayland server must be restarted after a crash.
0044  */
0045 enum XwaylandCrashPolicy {
0046     Stop,
0047     Restart,
0048 };
0049 
0050 /**
0051  * This enum type specifies the latency level configured by the user.
0052  */
0053 enum LatencyPolicy {
0054     LatencyExtremelyLow,
0055     LatencyLow,
0056     LatencyMedium,
0057     LatencyHigh,
0058     LatencyExtremelyHigh,
0059 };
0060 
0061 /**
0062  * This enum type specifies the method for estimating the expected render time.
0063  */
0064 enum RenderTimeEstimator {
0065     RenderTimeEstimatorMinimum,
0066     RenderTimeEstimatorMaximum,
0067     RenderTimeEstimatorAverage,
0068 };
0069 
0070 /**
0071  * Placement policies. How workspace decides the way windows get positioned
0072  * on the screen. The better the policy, the heavier the resource use.
0073  * Normally you don't have to worry. What the WM adds to the startup time
0074  * is nil compared to the creation of the window itself in the memory
0075  */
0076 enum PlacementPolicy {
0077     PlacementNone, // not really a placement
0078     PlacementDefault, // special, means to use the global default
0079     PlacementUnknown, // special, means the function should use its default
0080     PlacementRandom,
0081     PlacementSmart,
0082     PlacementCentered,
0083     PlacementZeroCornered,
0084     PlacementUnderMouse, // special
0085     PlacementOnMainWindow, // special
0086     PlacementMaximizing,
0087 };
0088 
0089 class Settings;
0090 
0091 class KWIN_EXPORT Options : public QObject
0092 {
0093     Q_OBJECT
0094     Q_ENUM(XwaylandCrashPolicy)
0095     Q_ENUM(LatencyPolicy)
0096     Q_ENUM(RenderTimeEstimator)
0097     Q_ENUM(PlacementPolicy)
0098     Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged)
0099     Q_PROPERTY(XwaylandCrashPolicy xwaylandCrashPolicy READ xwaylandCrashPolicy WRITE setXwaylandCrashPolicy NOTIFY xwaylandCrashPolicyChanged)
0100     Q_PROPERTY(int xwaylandMaxCrashCount READ xwaylandMaxCrashCount WRITE setXwaylandMaxCrashCount NOTIFY xwaylandMaxCrashCountChanged)
0101     Q_PROPERTY(bool nextFocusPrefersMouse READ isNextFocusPrefersMouse WRITE setNextFocusPrefersMouse NOTIFY nextFocusPrefersMouseChanged)
0102     /**
0103      * Whether clicking on a window raises it in FocusFollowsMouse
0104      * mode or not.
0105      */
0106     Q_PROPERTY(bool clickRaise READ isClickRaise WRITE setClickRaise NOTIFY clickRaiseChanged)
0107     /**
0108      * Whether autoraise is enabled FocusFollowsMouse mode or not.
0109      */
0110     Q_PROPERTY(bool autoRaise READ isAutoRaise WRITE setAutoRaise NOTIFY autoRaiseChanged)
0111     /**
0112      * Autoraise interval.
0113      */
0114     Q_PROPERTY(int autoRaiseInterval READ autoRaiseInterval WRITE setAutoRaiseInterval NOTIFY autoRaiseIntervalChanged)
0115     /**
0116      * Delayed focus interval.
0117      */
0118     Q_PROPERTY(int delayFocusInterval READ delayFocusInterval WRITE setDelayFocusInterval NOTIFY delayFocusIntervalChanged)
0119     /**
0120      * Whether shade hover is enabled or not.
0121      */
0122     Q_PROPERTY(bool shadeHover READ isShadeHover WRITE setShadeHover NOTIFY shadeHoverChanged)
0123     /**
0124      * Shade hover interval.
0125      */
0126     Q_PROPERTY(int shadeHoverInterval READ shadeHoverInterval WRITE setShadeHoverInterval NOTIFY shadeHoverIntervalChanged)
0127     /**
0128      * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client)
0129      */
0130     Q_PROPERTY(bool separateScreenFocus READ isSeparateScreenFocus WRITE setSeparateScreenFocus NOTIFY separateScreenFocusChanged)
0131     Q_PROPERTY(bool activeMouseScreen READ activeMouseScreen WRITE setActiveMouseScreen NOTIFY activeMouseScreenChanged)
0132     Q_PROPERTY(PlacementPolicy placement READ placement WRITE setPlacement NOTIFY placementChanged)
0133     Q_PROPERTY(ActivationDesktopPolicy activationDesktopPolicy READ activationDesktopPolicy WRITE setActivationDesktopPolicy NOTIFY activationDesktopPolicyChanged)
0134     Q_PROPERTY(bool focusPolicyIsReasonable READ focusPolicyIsReasonable NOTIFY focusPolicyIsResonableChanged)
0135     /**
0136      * The size of the zone that triggers snapping on desktop borders.
0137      */
0138     Q_PROPERTY(int borderSnapZone READ borderSnapZone WRITE setBorderSnapZone NOTIFY borderSnapZoneChanged)
0139     /**
0140      * The size of the zone that triggers snapping with other windows.
0141      */
0142     Q_PROPERTY(int windowSnapZone READ windowSnapZone WRITE setWindowSnapZone NOTIFY windowSnapZoneChanged)
0143     /**
0144      * The size of the zone that triggers snapping on the screen center.
0145      */
0146     Q_PROPERTY(int centerSnapZone READ centerSnapZone WRITE setCenterSnapZone NOTIFY centerSnapZoneChanged)
0147     /**
0148      * Snap only when windows will overlap.
0149      */
0150     Q_PROPERTY(bool snapOnlyWhenOverlapping READ isSnapOnlyWhenOverlapping WRITE setSnapOnlyWhenOverlapping NOTIFY snapOnlyWhenOverlappingChanged)
0151     /**
0152      * Whether or not we roll over to the other edge when switching desktops past the edge.
0153      */
0154     Q_PROPERTY(bool rollOverDesktops READ isRollOverDesktops WRITE setRollOverDesktops NOTIFY rollOverDesktopsChanged)
0155     /**
0156      * 0 - 4 , see Workspace::allowWindowActivation()
0157      */
0158     Q_PROPERTY(int focusStealingPreventionLevel READ focusStealingPreventionLevel WRITE setFocusStealingPreventionLevel NOTIFY focusStealingPreventionLevelChanged)
0159     Q_PROPERTY(KWin::Options::WindowOperation operationTitlebarDblClick READ operationTitlebarDblClick WRITE setOperationTitlebarDblClick NOTIFY operationTitlebarDblClickChanged)
0160     Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonLeftClick READ operationMaxButtonLeftClick WRITE setOperationMaxButtonLeftClick NOTIFY operationMaxButtonLeftClickChanged)
0161     Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonMiddleClick READ operationMaxButtonMiddleClick WRITE setOperationMaxButtonMiddleClick NOTIFY operationMaxButtonMiddleClickChanged)
0162     Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonRightClick READ operationMaxButtonRightClick WRITE setOperationMaxButtonRightClick NOTIFY operationMaxButtonRightClickChanged)
0163     Q_PROPERTY(MouseCommand commandActiveTitlebar1 READ commandActiveTitlebar1 WRITE setCommandActiveTitlebar1 NOTIFY commandActiveTitlebar1Changed)
0164     Q_PROPERTY(MouseCommand commandActiveTitlebar2 READ commandActiveTitlebar2 WRITE setCommandActiveTitlebar2 NOTIFY commandActiveTitlebar2Changed)
0165     Q_PROPERTY(MouseCommand commandActiveTitlebar3 READ commandActiveTitlebar3 WRITE setCommandActiveTitlebar3 NOTIFY commandActiveTitlebar3Changed)
0166     Q_PROPERTY(MouseCommand commandInactiveTitlebar1 READ commandInactiveTitlebar1 WRITE setCommandInactiveTitlebar1 NOTIFY commandInactiveTitlebar1Changed)
0167     Q_PROPERTY(MouseCommand commandInactiveTitlebar2 READ commandInactiveTitlebar2 WRITE setCommandInactiveTitlebar2 NOTIFY commandInactiveTitlebar2Changed)
0168     Q_PROPERTY(MouseCommand commandInactiveTitlebar3 READ commandInactiveTitlebar3 WRITE setCommandInactiveTitlebar3 NOTIFY commandInactiveTitlebar3Changed)
0169     Q_PROPERTY(MouseCommand commandWindow1 READ commandWindow1 WRITE setCommandWindow1 NOTIFY commandWindow1Changed)
0170     Q_PROPERTY(MouseCommand commandWindow2 READ commandWindow2 WRITE setCommandWindow2 NOTIFY commandWindow2Changed)
0171     Q_PROPERTY(MouseCommand commandWindow3 READ commandWindow3 WRITE setCommandWindow3 NOTIFY commandWindow3Changed)
0172     Q_PROPERTY(MouseCommand commandWindowWheel READ commandWindowWheel WRITE setCommandWindowWheel NOTIFY commandWindowWheelChanged)
0173     Q_PROPERTY(MouseCommand commandAll1 READ commandAll1 WRITE setCommandAll1 NOTIFY commandAll1Changed)
0174     Q_PROPERTY(MouseCommand commandAll2 READ commandAll2 WRITE setCommandAll2 NOTIFY commandAll2Changed)
0175     Q_PROPERTY(MouseCommand commandAll3 READ commandAll3 WRITE setCommandAll3 NOTIFY commandAll3Changed)
0176     Q_PROPERTY(uint keyCmdAllModKey READ keyCmdAllModKey WRITE setKeyCmdAllModKey NOTIFY keyCmdAllModKeyChanged)
0177     /**
0178      * Whether the visible name should be condensed.
0179      */
0180     Q_PROPERTY(bool condensedTitle READ condensedTitle WRITE setCondensedTitle NOTIFY condensedTitleChanged)
0181     /**
0182      * Whether a window gets maximized when it reaches top screen edge while being moved.
0183      */
0184     Q_PROPERTY(bool electricBorderMaximize READ electricBorderMaximize WRITE setElectricBorderMaximize NOTIFY electricBorderMaximizeChanged)
0185     /**
0186      * Whether a window is tiled to half screen when reaching left or right screen edge while been moved.
0187      */
0188     Q_PROPERTY(bool electricBorderTiling READ electricBorderTiling WRITE setElectricBorderTiling NOTIFY electricBorderTilingChanged)
0189     /**
0190      * Whether a window is tiled to half screen when reaching left or right screen edge while been moved.
0191      */
0192     Q_PROPERTY(float electricBorderCornerRatio READ electricBorderCornerRatio WRITE setElectricBorderCornerRatio NOTIFY electricBorderCornerRatioChanged)
0193     Q_PROPERTY(bool borderlessMaximizedWindows READ borderlessMaximizedWindows WRITE setBorderlessMaximizedWindows NOTIFY borderlessMaximizedWindowsChanged)
0194     /**
0195      * timeout before non-responding application will be killed after attempt to close.
0196      */
0197     Q_PROPERTY(int killPingTimeout READ killPingTimeout WRITE setKillPingTimeout NOTIFY killPingTimeoutChanged)
0198     /**
0199      * Whether to hide utility windows for inactive applications.
0200      */
0201     Q_PROPERTY(bool hideUtilityWindowsForInactive READ isHideUtilityWindowsForInactive WRITE setHideUtilityWindowsForInactive NOTIFY hideUtilityWindowsForInactiveChanged)
0202     Q_PROPERTY(int compositingMode READ compositingMode WRITE setCompositingMode NOTIFY compositingModeChanged)
0203     Q_PROPERTY(bool useCompositing READ isUseCompositing WRITE setUseCompositing NOTIFY useCompositingChanged)
0204     Q_PROPERTY(int hiddenPreviews READ hiddenPreviews WRITE setHiddenPreviews NOTIFY hiddenPreviewsChanged)
0205     /**
0206      * 0 = no, 1 = yes when transformed,
0207      * 2 = try trilinear when transformed; else 1,
0208      * -1 = auto
0209      */
0210     Q_PROPERTY(int glSmoothScale READ glSmoothScale WRITE setGlSmoothScale NOTIFY glSmoothScaleChanged)
0211     Q_PROPERTY(bool glStrictBinding READ isGlStrictBinding WRITE setGlStrictBinding NOTIFY glStrictBindingChanged)
0212     /**
0213      * Whether strict binding follows the driver or has been overwritten by a user defined config value.
0214      * If @c true glStrictBinding is set by the OpenGL Scene during initialization.
0215      * If @c false glStrictBinding is set from a config value and not updated during scene initialization.
0216      */
0217     Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged)
0218     Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged)
0219     Q_PROPERTY(KWin::OpenGLPlatformInterface glPlatformInterface READ glPlatformInterface WRITE setGlPlatformInterface NOTIFY glPlatformInterfaceChanged)
0220     Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged)
0221     Q_PROPERTY(LatencyPolicy latencyPolicy READ latencyPolicy WRITE setLatencyPolicy NOTIFY latencyPolicyChanged)
0222     Q_PROPERTY(RenderTimeEstimator renderTimeEstimator READ renderTimeEstimator WRITE setRenderTimeEstimator NOTIFY renderTimeEstimatorChanged)
0223     Q_PROPERTY(bool allowTearing READ allowTearing WRITE setAllowTearing NOTIFY allowTearingChanged)
0224 public:
0225     explicit Options(QObject *parent = nullptr);
0226     ~Options() override;
0227 
0228     void updateSettings();
0229 
0230     /**
0231      * This enum type is used to specify the focus policy.
0232      *
0233      * Note that FocusUnderMouse and FocusStrictlyUnderMouse are not
0234      * particulary useful. They are only provided for old-fashined
0235      * die-hard UNIX people ;-)
0236      */
0237     enum FocusPolicy {
0238         /**
0239          * Clicking into a window activates it. This is also the default.
0240          */
0241         ClickToFocus,
0242         /**
0243          * Moving the mouse pointer actively onto a normal window activates it.
0244          * For convenience, the desktop and windows on the dock are excluded.
0245          * They require clicking.
0246          */
0247         FocusFollowsMouse,
0248         /**
0249          * The window that happens to be under the mouse pointer becomes active.
0250          * The invariant is: no window can have focus that is not under the mouse.
0251          * This also means that Alt-Tab won't work properly and popup dialogs are
0252          * usually unsable with the keyboard. Note that the desktop and windows on
0253          * the dock are excluded for convenience. They get focus only when clicking
0254          * on it.
0255          */
0256         FocusUnderMouse,
0257         /**
0258          * This is even worse than FocusUnderMouse. Only the window under the mouse
0259          * pointer is active. If the mouse points nowhere, nothing has the focus. If
0260          * the mouse points onto the desktop, the desktop has focus. The same holds
0261          * for windows on the dock.
0262          */
0263         FocusStrictlyUnderMouse
0264     };
0265     Q_ENUM(FocusPolicy)
0266 
0267     FocusPolicy focusPolicy() const
0268     {
0269         return m_focusPolicy;
0270     }
0271     bool isNextFocusPrefersMouse() const
0272     {
0273         return m_nextFocusPrefersMouse;
0274     }
0275 
0276     XwaylandCrashPolicy xwaylandCrashPolicy() const
0277     {
0278         return m_xwaylandCrashPolicy;
0279     }
0280     int xwaylandMaxCrashCount() const
0281     {
0282         return m_xwaylandMaxCrashCount;
0283     }
0284     XwaylandEavesdropsMode xwaylandEavesdrops() const
0285     {
0286         return m_xwaylandEavesdrops;
0287     }
0288 
0289     /**
0290      * Whether clicking on a window raises it in FocusFollowsMouse
0291      * mode or not.
0292      */
0293     bool isClickRaise() const
0294     {
0295         return m_clickRaise;
0296     }
0297 
0298     /**
0299      * Whether autoraise is enabled FocusFollowsMouse mode or not.
0300      */
0301     bool isAutoRaise() const
0302     {
0303         return m_autoRaise;
0304     }
0305 
0306     /**
0307      * Autoraise interval
0308      */
0309     int autoRaiseInterval() const
0310     {
0311         return m_autoRaiseInterval;
0312     }
0313 
0314     /**
0315      * Delayed focus interval.
0316      */
0317     int delayFocusInterval() const
0318     {
0319         return m_delayFocusInterval;
0320     }
0321 
0322     /**
0323      * Whether shade hover is enabled or not.
0324      */
0325     bool isShadeHover() const
0326     {
0327         return m_shadeHover;
0328     }
0329 
0330     /**
0331      * Shade hover interval.
0332      */
0333     int shadeHoverInterval()
0334     {
0335         return m_shadeHoverInterval;
0336     }
0337 
0338     /**
0339      * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client)
0340      */
0341     bool isSeparateScreenFocus() const
0342     {
0343         return m_separateScreenFocus;
0344     }
0345 
0346     bool activeMouseScreen() const
0347     {
0348         return m_activeMouseScreen;
0349     }
0350 
0351     PlacementPolicy placement() const
0352     {
0353         return m_placement;
0354     }
0355 
0356     bool focusPolicyIsReasonable()
0357     {
0358         return m_focusPolicy == ClickToFocus || m_focusPolicy == FocusFollowsMouse;
0359     }
0360 
0361     enum ActivationDesktopPolicy {
0362         SwitchToOtherDesktop,
0363         BringToCurrentDesktop
0364     };
0365     Q_ENUM(ActivationDesktopPolicy)
0366 
0367     ActivationDesktopPolicy activationDesktopPolicy() const
0368     {
0369         return m_activationDesktopPolicy;
0370     }
0371 
0372     /**
0373      * The size of the zone that triggers snapping on desktop borders.
0374      */
0375     int borderSnapZone() const
0376     {
0377         return m_borderSnapZone;
0378     }
0379 
0380     /**
0381      * The size of the zone that triggers snapping with other windows.
0382      */
0383     int windowSnapZone() const
0384     {
0385         return m_windowSnapZone;
0386     }
0387 
0388     /**
0389      * The size of the zone that triggers snapping on the screen center.
0390      */
0391     int centerSnapZone() const
0392     {
0393         return m_centerSnapZone;
0394     }
0395 
0396     /**
0397      * Snap only when windows will overlap.
0398      */
0399     bool isSnapOnlyWhenOverlapping() const
0400     {
0401         return m_snapOnlyWhenOverlapping;
0402     }
0403 
0404     /**
0405      * Whether or not we roll over to the other edge when switching desktops past the edge.
0406      */
0407     bool isRollOverDesktops() const
0408     {
0409         return m_rollOverDesktops;
0410     }
0411 
0412     /**
0413      * Returns the focus stealing prevention level.
0414      *
0415      * @see allowWindowActivation
0416      */
0417     int focusStealingPreventionLevel() const
0418     {
0419         return m_focusStealingPreventionLevel;
0420     }
0421 
0422     enum WindowOperation {
0423         MaximizeOp = 5000,
0424         RestoreOp,
0425         MinimizeOp,
0426         MoveOp,
0427         UnrestrictedMoveOp,
0428         ResizeOp,
0429         UnrestrictedResizeOp,
0430         CloseOp,
0431         OnAllDesktopsOp,
0432         ShadeOp,
0433         KeepAboveOp,
0434         KeepBelowOp,
0435         OperationsOp,
0436         WindowRulesOp,
0437         ToggleStoreSettingsOp = WindowRulesOp, ///< @obsolete
0438         HMaximizeOp,
0439         VMaximizeOp,
0440         LowerOp,
0441         FullScreenOp,
0442         NoBorderOp,
0443         NoOp,
0444         SetupWindowShortcutOp,
0445         ApplicationRulesOp,
0446     };
0447     Q_ENUM(WindowOperation)
0448 
0449     WindowOperation operationTitlebarDblClick() const
0450     {
0451         return OpTitlebarDblClick;
0452     }
0453     WindowOperation operationMaxButtonLeftClick() const
0454     {
0455         return opMaxButtonLeftClick;
0456     }
0457     WindowOperation operationMaxButtonRightClick() const
0458     {
0459         return opMaxButtonRightClick;
0460     }
0461     WindowOperation operationMaxButtonMiddleClick() const
0462     {
0463         return opMaxButtonMiddleClick;
0464     }
0465     WindowOperation operationMaxButtonClick(Qt::MouseButtons button) const;
0466 
0467     enum MouseCommand {
0468         MouseRaise,
0469         MouseLower,
0470         MouseOperationsMenu,
0471         MouseToggleRaiseAndLower,
0472         MouseActivateAndRaise,
0473         MouseActivateAndLower,
0474         MouseActivate,
0475         MouseActivateRaiseAndPassClick,
0476         MouseActivateAndPassClick,
0477         MouseMove,
0478         MouseUnrestrictedMove,
0479         MouseActivateRaiseAndMove,
0480         MouseActivateRaiseAndUnrestrictedMove,
0481         MouseResize,
0482         MouseUnrestrictedResize,
0483         MouseShade,
0484         MouseSetShade,
0485         MouseUnsetShade,
0486         MouseMaximize,
0487         MouseRestore,
0488         MouseMinimize,
0489         MouseNextDesktop,
0490         MousePreviousDesktop,
0491         MouseAbove,
0492         MouseBelow,
0493         MouseOpacityMore,
0494         MouseOpacityLess,
0495         MouseClose,
0496         MouseNothing
0497     };
0498     Q_ENUM(MouseCommand)
0499 
0500     enum MouseWheelCommand {
0501         MouseWheelRaiseLower,
0502         MouseWheelShadeUnshade,
0503         MouseWheelMaximizeRestore,
0504         MouseWheelAboveBelow,
0505         MouseWheelPreviousNextDesktop,
0506         MouseWheelChangeOpacity,
0507         MouseWheelNothing
0508     };
0509     Q_ENUM(MouseWheelCommand)
0510 
0511     MouseCommand operationTitlebarMouseWheel(int delta) const
0512     {
0513         return wheelToMouseCommand(CmdTitlebarWheel, delta);
0514     }
0515     MouseCommand operationWindowMouseWheel(int delta) const
0516     {
0517         return wheelToMouseCommand(CmdAllWheel, delta);
0518     }
0519 
0520     MouseCommand commandActiveTitlebar1() const
0521     {
0522         return CmdActiveTitlebar1;
0523     }
0524     MouseCommand commandActiveTitlebar2() const
0525     {
0526         return CmdActiveTitlebar2;
0527     }
0528     MouseCommand commandActiveTitlebar3() const
0529     {
0530         return CmdActiveTitlebar3;
0531     }
0532     MouseCommand commandInactiveTitlebar1() const
0533     {
0534         return CmdInactiveTitlebar1;
0535     }
0536     MouseCommand commandInactiveTitlebar2() const
0537     {
0538         return CmdInactiveTitlebar2;
0539     }
0540     MouseCommand commandInactiveTitlebar3() const
0541     {
0542         return CmdInactiveTitlebar3;
0543     }
0544     MouseCommand commandWindow1() const
0545     {
0546         return CmdWindow1;
0547     }
0548     MouseCommand commandWindow2() const
0549     {
0550         return CmdWindow2;
0551     }
0552     MouseCommand commandWindow3() const
0553     {
0554         return CmdWindow3;
0555     }
0556     MouseCommand commandWindowWheel() const
0557     {
0558         return CmdWindowWheel;
0559     }
0560     MouseCommand commandAll1() const
0561     {
0562         return CmdAll1;
0563     }
0564     MouseCommand commandAll2() const
0565     {
0566         return CmdAll2;
0567     }
0568     MouseCommand commandAll3() const
0569     {
0570         return CmdAll3;
0571     }
0572     MouseWheelCommand commandAllWheel() const
0573     {
0574         return CmdAllWheel;
0575     }
0576     uint keyCmdAllModKey() const
0577     {
0578         return CmdAllModKey;
0579     }
0580     Qt::KeyboardModifier commandAllModifier() const
0581     {
0582         switch (CmdAllModKey) {
0583         case Qt::Key_Alt:
0584             return Qt::AltModifier;
0585         case Qt::Key_Meta:
0586             return Qt::MetaModifier;
0587         default:
0588             Q_UNREACHABLE();
0589         }
0590     }
0591 
0592     static WindowOperation windowOperation(const QString &name, bool restricted);
0593     static MouseCommand mouseCommand(const QString &name, bool restricted);
0594     static MouseWheelCommand mouseWheelCommand(const QString &name);
0595 
0596     /**
0597      * Returns whether the user prefers his caption clean.
0598      */
0599     bool condensedTitle() const;
0600 
0601     /**
0602      * @returns true if a window gets maximized when it reaches top screen edge
0603      * while being moved.
0604      */
0605     bool electricBorderMaximize() const
0606     {
0607         return electric_border_maximize;
0608     }
0609     /**
0610      * @returns true if window is tiled to half screen when reaching left or
0611      * right screen edge while been moved.
0612      */
0613     bool electricBorderTiling() const
0614     {
0615         return electric_border_tiling;
0616     }
0617     /**
0618      * @returns the factor that determines the corner part of the edge (ie. 0.1 means tiny corner)
0619      */
0620     float electricBorderCornerRatio() const
0621     {
0622         return electric_border_corner_ratio;
0623     }
0624 
0625     bool borderlessMaximizedWindows() const
0626     {
0627         return borderless_maximized_windows;
0628     }
0629 
0630     /**
0631      * Timeout before non-responding application will be killed after attempt to close.
0632      */
0633     int killPingTimeout() const
0634     {
0635         return m_killPingTimeout;
0636     }
0637 
0638     /**
0639      * Whether to hide utility windows for inactive applications.
0640      */
0641     bool isHideUtilityWindowsForInactive() const
0642     {
0643         return m_hideUtilityWindowsForInactive;
0644     }
0645 
0646     /**
0647      * Returns the animation time factor for desktop effects.
0648      */
0649     double animationTimeFactor() const;
0650 
0651     //----------------------
0652     // Compositing settings
0653     void reloadCompositingSettings(bool force = false);
0654     CompositingType compositingMode() const
0655     {
0656         return m_compositingMode;
0657     }
0658     void setCompositingMode(CompositingType mode)
0659     {
0660         m_compositingMode = mode;
0661     }
0662     // Separate to mode so the user can toggle
0663     bool isUseCompositing() const;
0664 
0665     // General preferences
0666     HiddenPreviews hiddenPreviews() const
0667     {
0668         return m_hiddenPreviews;
0669     }
0670     // OpenGL
0671     // 1 = yes,
0672     // 2 = try trilinear when transformed; else 1,
0673     // -1 = auto
0674     int glSmoothScale() const
0675     {
0676         return m_glSmoothScale;
0677     }
0678 
0679     // Settings that should be auto-detected
0680     bool isGlStrictBinding() const
0681     {
0682         return m_glStrictBinding;
0683     }
0684     bool isGlStrictBindingFollowsDriver() const
0685     {
0686         return m_glStrictBindingFollowsDriver;
0687     }
0688     OpenGLPlatformInterface glPlatformInterface() const
0689     {
0690         return m_glPlatformInterface;
0691     }
0692 
0693     enum GlSwapStrategy {
0694         CopyFrontBuffer = 'c',
0695         PaintFullScreen = 'p',
0696         ExtendDamage = 'e',
0697         AutoSwapStrategy = 'a',
0698     };
0699     Q_ENUM(GlSwapStrategy)
0700     GlSwapStrategy glPreferBufferSwap() const
0701     {
0702         return m_glPreferBufferSwap;
0703     }
0704 
0705     bool windowsBlockCompositing() const
0706     {
0707         return m_windowsBlockCompositing;
0708     }
0709 
0710     bool moveMinimizedWindowsToEndOfTabBoxFocusChain() const
0711     {
0712         return m_MoveMinimizedWindowsToEndOfTabBoxFocusChain;
0713     }
0714 
0715     QStringList modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const;
0716     LatencyPolicy latencyPolicy() const;
0717     RenderTimeEstimator renderTimeEstimator() const;
0718     bool allowTearing() const;
0719 
0720     // setters
0721     void setFocusPolicy(FocusPolicy focusPolicy);
0722     void setXwaylandCrashPolicy(XwaylandCrashPolicy crashPolicy);
0723     void setXwaylandMaxCrashCount(int maxCrashCount);
0724     void setXwaylandEavesdrops(XwaylandEavesdropsMode mode);
0725     void setNextFocusPrefersMouse(bool nextFocusPrefersMouse);
0726     void setClickRaise(bool clickRaise);
0727     void setAutoRaise(bool autoRaise);
0728     void setAutoRaiseInterval(int autoRaiseInterval);
0729     void setDelayFocusInterval(int delayFocusInterval);
0730     void setShadeHover(bool shadeHover);
0731     void setShadeHoverInterval(int shadeHoverInterval);
0732     void setSeparateScreenFocus(bool separateScreenFocus);
0733     void setActiveMouseScreen(bool activeMouseScreen);
0734     void setPlacement(PlacementPolicy placement);
0735     void setActivationDesktopPolicy(ActivationDesktopPolicy activationDesktopPolicy);
0736     void setBorderSnapZone(int borderSnapZone);
0737     void setWindowSnapZone(int windowSnapZone);
0738     void setCenterSnapZone(int centerSnapZone);
0739     void setSnapOnlyWhenOverlapping(bool snapOnlyWhenOverlapping);
0740     void setRollOverDesktops(bool rollOverDesktops);
0741     void setFocusStealingPreventionLevel(int focusStealingPreventionLevel);
0742     void setOperationTitlebarDblClick(WindowOperation operationTitlebarDblClick);
0743     void setOperationMaxButtonLeftClick(WindowOperation op);
0744     void setOperationMaxButtonRightClick(WindowOperation op);
0745     void setOperationMaxButtonMiddleClick(WindowOperation op);
0746     void setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1);
0747     void setCommandActiveTitlebar2(MouseCommand commandActiveTitlebar2);
0748     void setCommandActiveTitlebar3(MouseCommand commandActiveTitlebar3);
0749     void setCommandInactiveTitlebar1(MouseCommand commandInactiveTitlebar1);
0750     void setCommandInactiveTitlebar2(MouseCommand commandInactiveTitlebar2);
0751     void setCommandInactiveTitlebar3(MouseCommand commandInactiveTitlebar3);
0752     void setCommandWindow1(MouseCommand commandWindow1);
0753     void setCommandWindow2(MouseCommand commandWindow2);
0754     void setCommandWindow3(MouseCommand commandWindow3);
0755     void setCommandWindowWheel(MouseCommand commandWindowWheel);
0756     void setCommandAll1(MouseCommand commandAll1);
0757     void setCommandAll2(MouseCommand commandAll2);
0758     void setCommandAll3(MouseCommand commandAll3);
0759     void setKeyCmdAllModKey(uint keyCmdAllModKey);
0760     void setCondensedTitle(bool condensedTitle);
0761     void setElectricBorderMaximize(bool electricBorderMaximize);
0762     void setElectricBorderTiling(bool electricBorderTiling);
0763     void setElectricBorderCornerRatio(float electricBorderCornerRatio);
0764     void setBorderlessMaximizedWindows(bool borderlessMaximizedWindows);
0765     void setKillPingTimeout(int killPingTimeout);
0766     void setHideUtilityWindowsForInactive(bool hideUtilityWindowsForInactive);
0767     void setCompositingMode(int compositingMode);
0768     void setUseCompositing(bool useCompositing);
0769     void setHiddenPreviews(int hiddenPreviews);
0770     void setGlSmoothScale(int glSmoothScale);
0771     void setGlStrictBinding(bool glStrictBinding);
0772     void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver);
0773     void setGlPreferBufferSwap(char glPreferBufferSwap);
0774     void setGlPlatformInterface(OpenGLPlatformInterface interface);
0775     void setWindowsBlockCompositing(bool set);
0776     void setMoveMinimizedWindowsToEndOfTabBoxFocusChain(bool set);
0777     void setLatencyPolicy(LatencyPolicy policy);
0778     void setRenderTimeEstimator(RenderTimeEstimator estimator);
0779     void setAllowTearing(bool allow);
0780 
0781     // default values
0782     static WindowOperation defaultOperationTitlebarDblClick()
0783     {
0784         return MaximizeOp;
0785     }
0786     static WindowOperation defaultOperationMaxButtonLeftClick()
0787     {
0788         return MaximizeOp;
0789     }
0790     static WindowOperation defaultOperationMaxButtonRightClick()
0791     {
0792         return HMaximizeOp;
0793     }
0794     static WindowOperation defaultOperationMaxButtonMiddleClick()
0795     {
0796         return VMaximizeOp;
0797     }
0798     static MouseCommand defaultCommandActiveTitlebar1()
0799     {
0800         return MouseRaise;
0801     }
0802     static MouseCommand defaultCommandActiveTitlebar2()
0803     {
0804         return MouseNothing;
0805     }
0806     static MouseCommand defaultCommandActiveTitlebar3()
0807     {
0808         return MouseOperationsMenu;
0809     }
0810     static MouseCommand defaultCommandInactiveTitlebar1()
0811     {
0812         return MouseActivateAndRaise;
0813     }
0814     static MouseCommand defaultCommandInactiveTitlebar2()
0815     {
0816         return MouseNothing;
0817     }
0818     static MouseCommand defaultCommandInactiveTitlebar3()
0819     {
0820         return MouseOperationsMenu;
0821     }
0822     static MouseCommand defaultCommandWindow1()
0823     {
0824         return MouseActivateRaiseAndPassClick;
0825     }
0826     static MouseCommand defaultCommandWindow2()
0827     {
0828         return MouseActivateAndPassClick;
0829     }
0830     static MouseCommand defaultCommandWindow3()
0831     {
0832         return MouseActivateAndPassClick;
0833     }
0834     static MouseCommand defaultCommandWindowWheel()
0835     {
0836         return MouseNothing;
0837     }
0838     static MouseCommand defaultCommandAll1()
0839     {
0840         return MouseUnrestrictedMove;
0841     }
0842     static MouseCommand defaultCommandAll2()
0843     {
0844         return MouseToggleRaiseAndLower;
0845     }
0846     static MouseCommand defaultCommandAll3()
0847     {
0848         return MouseUnrestrictedResize;
0849     }
0850     static MouseWheelCommand defaultCommandTitlebarWheel()
0851     {
0852         return MouseWheelNothing;
0853     }
0854     static MouseWheelCommand defaultCommandAllWheel()
0855     {
0856         return MouseWheelNothing;
0857     }
0858     static uint defaultKeyCmdAllModKey()
0859     {
0860         return Qt::Key_Alt;
0861     }
0862     static CompositingType defaultCompositingMode()
0863     {
0864         return OpenGLCompositing;
0865     }
0866     static bool defaultUseCompositing()
0867     {
0868         return true;
0869     }
0870     static HiddenPreviews defaultHiddenPreviews()
0871     {
0872         return HiddenPreviewsShown;
0873     }
0874     static int defaultGlSmoothScale()
0875     {
0876         return 2;
0877     }
0878     static bool defaultGlStrictBinding()
0879     {
0880         return true;
0881     }
0882     static bool defaultGlStrictBindingFollowsDriver()
0883     {
0884         return true;
0885     }
0886     static GlSwapStrategy defaultGlPreferBufferSwap()
0887     {
0888         return AutoSwapStrategy;
0889     }
0890     static OpenGLPlatformInterface defaultGlPlatformInterface()
0891     {
0892         return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface;
0893     }
0894     static XwaylandCrashPolicy defaultXwaylandCrashPolicy()
0895     {
0896         return XwaylandCrashPolicy::Restart;
0897     }
0898     static int defaultXwaylandMaxCrashCount()
0899     {
0900         return 3;
0901     }
0902     static XwaylandEavesdropsMode defaultXwaylandEavesdrops()
0903     {
0904         return None;
0905     }
0906     static LatencyPolicy defaultLatencyPolicy()
0907     {
0908         return LatencyExtremelyHigh;
0909     }
0910     static RenderTimeEstimator defaultRenderTimeEstimator()
0911     {
0912         return RenderTimeEstimatorMaximum;
0913     }
0914     static ActivationDesktopPolicy defaultActivationDesktopPolicy()
0915     {
0916         return ActivationDesktopPolicy::SwitchToOtherDesktop;
0917     }
0918     /**
0919      * Performs loading all settings except compositing related.
0920      */
0921     void loadConfig();
0922     /**
0923      * Performs loading of compositing settings which do not depend on OpenGL.
0924      */
0925     bool loadCompositingConfig(bool force);
0926     void reparseConfiguration();
0927 
0928     //----------------------
0929 Q_SIGNALS:
0930     // for properties
0931     void focusPolicyChanged();
0932     void focusPolicyIsResonableChanged();
0933     void xwaylandCrashPolicyChanged();
0934     void xwaylandMaxCrashCountChanged();
0935     void xwaylandEavesdropsChanged();
0936     void nextFocusPrefersMouseChanged();
0937     void clickRaiseChanged();
0938     void autoRaiseChanged();
0939     void autoRaiseIntervalChanged();
0940     void delayFocusIntervalChanged();
0941     void shadeHoverChanged();
0942     void shadeHoverIntervalChanged();
0943     void separateScreenFocusChanged(bool);
0944     void activeMouseScreenChanged();
0945     void placementChanged();
0946     void activationDesktopPolicyChanged();
0947     void borderSnapZoneChanged();
0948     void windowSnapZoneChanged();
0949     void centerSnapZoneChanged();
0950     void snapOnlyWhenOverlappingChanged();
0951     void rollOverDesktopsChanged(bool enabled);
0952     void focusStealingPreventionLevelChanged();
0953     void operationTitlebarDblClickChanged();
0954     void operationMaxButtonLeftClickChanged();
0955     void operationMaxButtonRightClickChanged();
0956     void operationMaxButtonMiddleClickChanged();
0957     void commandActiveTitlebar1Changed();
0958     void commandActiveTitlebar2Changed();
0959     void commandActiveTitlebar3Changed();
0960     void commandInactiveTitlebar1Changed();
0961     void commandInactiveTitlebar2Changed();
0962     void commandInactiveTitlebar3Changed();
0963     void commandWindow1Changed();
0964     void commandWindow2Changed();
0965     void commandWindow3Changed();
0966     void commandWindowWheelChanged();
0967     void commandAll1Changed();
0968     void commandAll2Changed();
0969     void commandAll3Changed();
0970     void keyCmdAllModKeyChanged();
0971     void condensedTitleChanged();
0972     void electricBorderMaximizeChanged();
0973     void electricBorderTilingChanged();
0974     void electricBorderCornerRatioChanged();
0975     void borderlessMaximizedWindowsChanged();
0976     void killPingTimeoutChanged();
0977     void hideUtilityWindowsForInactiveChanged();
0978     void compositingModeChanged();
0979     void useCompositingChanged();
0980     void hiddenPreviewsChanged();
0981     void glSmoothScaleChanged();
0982     void glStrictBindingChanged();
0983     void glStrictBindingFollowsDriverChanged();
0984     void glPreferBufferSwapChanged();
0985     void glPlatformInterfaceChanged();
0986     void windowsBlockCompositingChanged();
0987     void animationSpeedChanged();
0988     void latencyPolicyChanged();
0989     void configChanged();
0990     void renderTimeEstimatorChanged();
0991     void allowTearingChanged();
0992 
0993 private:
0994     void setElectricBorders(int borders);
0995     void syncFromKcfgc();
0996     std::unique_ptr<Settings> m_settings;
0997     KConfigWatcher::Ptr m_configWatcher;
0998 
0999     FocusPolicy m_focusPolicy;
1000     bool m_nextFocusPrefersMouse;
1001     bool m_clickRaise;
1002     bool m_autoRaise;
1003     int m_autoRaiseInterval;
1004     int m_delayFocusInterval;
1005     bool m_shadeHover;
1006     int m_shadeHoverInterval;
1007     bool m_separateScreenFocus;
1008     bool m_activeMouseScreen;
1009     PlacementPolicy m_placement;
1010     ActivationDesktopPolicy m_activationDesktopPolicy;
1011     int m_borderSnapZone;
1012     int m_windowSnapZone;
1013     int m_centerSnapZone;
1014     bool m_snapOnlyWhenOverlapping;
1015     bool m_rollOverDesktops;
1016     int m_focusStealingPreventionLevel;
1017     int m_killPingTimeout;
1018     bool m_hideUtilityWindowsForInactive;
1019     XwaylandCrashPolicy m_xwaylandCrashPolicy;
1020     int m_xwaylandMaxCrashCount;
1021     XwaylandEavesdropsMode m_xwaylandEavesdrops;
1022     LatencyPolicy m_latencyPolicy;
1023     RenderTimeEstimator m_renderTimeEstimator;
1024 
1025     CompositingType m_compositingMode;
1026     bool m_useCompositing;
1027     HiddenPreviews m_hiddenPreviews;
1028     int m_glSmoothScale;
1029     // Settings that should be auto-detected
1030     bool m_glStrictBinding;
1031     bool m_glStrictBindingFollowsDriver;
1032     GlSwapStrategy m_glPreferBufferSwap;
1033     OpenGLPlatformInterface m_glPlatformInterface;
1034     bool m_windowsBlockCompositing;
1035     bool m_MoveMinimizedWindowsToEndOfTabBoxFocusChain;
1036 
1037     WindowOperation OpTitlebarDblClick;
1038     WindowOperation opMaxButtonRightClick = defaultOperationMaxButtonRightClick();
1039     WindowOperation opMaxButtonMiddleClick = defaultOperationMaxButtonMiddleClick();
1040     WindowOperation opMaxButtonLeftClick = defaultOperationMaxButtonRightClick();
1041 
1042     // mouse bindings
1043     MouseCommand CmdActiveTitlebar1;
1044     MouseCommand CmdActiveTitlebar2;
1045     MouseCommand CmdActiveTitlebar3;
1046     MouseCommand CmdInactiveTitlebar1;
1047     MouseCommand CmdInactiveTitlebar2;
1048     MouseCommand CmdInactiveTitlebar3;
1049     MouseWheelCommand CmdTitlebarWheel;
1050     MouseCommand CmdWindow1;
1051     MouseCommand CmdWindow2;
1052     MouseCommand CmdWindow3;
1053     MouseCommand CmdWindowWheel;
1054     MouseCommand CmdAll1;
1055     MouseCommand CmdAll2;
1056     MouseCommand CmdAll3;
1057     MouseWheelCommand CmdAllWheel;
1058     uint CmdAllModKey;
1059 
1060     bool electric_border_maximize;
1061     bool electric_border_tiling;
1062     float electric_border_corner_ratio;
1063     bool borderless_maximized_windows;
1064     bool condensed_title;
1065 
1066     bool m_allowTearing = true;
1067 
1068     QHash<Qt::KeyboardModifier, QStringList> m_modifierOnlyShortcuts;
1069 
1070     MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const;
1071 };
1072 
1073 extern KWIN_EXPORT Options *options;
1074 
1075 } // namespace
1076 
1077 Q_DECLARE_METATYPE(KWin::Options::WindowOperation)
1078 Q_DECLARE_METATYPE(KWin::OpenGLPlatformInterface)