1 /* 2 KWin - the KDE window manager 3 This file is part of the KDE project. 4 5 SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org> 6 SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org> 7 SPDX-FileCopyrightText: 2012 Martin Gräßlin <m.graesslin@kde.org> 8 9 SPDX-License-Identifier: GPL-2.0-or-later 10 */ 11 12 #ifndef KWIN_OPTIONS_H 13 #define KWIN_OPTIONS_H 14 15 #include "main.h" 16 #include "placement.h" 17 18 #include <KConfigWatcher> 19 20 namespace KWin 21 { 22 23 // Whether to keep all windows mapped when compositing (i.e. whether to have 24 // actively updated window pixmaps). 25 enum HiddenPreviews { 26 // The normal mode with regard to mapped windows. Hidden (minimized, etc.) 27 // and windows on inactive virtual desktops are not mapped, their pixmaps 28 // are only their icons. 29 HiddenPreviewsNever, 30 // Like normal mode, but shown windows (i.e. on inactive virtual desktops) 31 // are kept mapped, only hidden windows are unmapped. 32 HiddenPreviewsShown, 33 // All windows are kept mapped regardless of their state. 34 HiddenPreviewsAlways 35 }; 36 37 /** 38 * This enum type specifies whether the Xwayland server must be restarted after a crash. 39 */ 40 enum XwaylandCrashPolicy { 41 Stop, 42 Restart, 43 }; 44 45 /** 46 * This enum type specifies the latency level configured by the user. 47 */ 48 enum LatencyPolicy { 49 LatencyExteremelyLow, 50 LatencyLow, 51 LatencyMedium, 52 LatencyHigh, 53 LatencyExtremelyHigh, 54 }; 55 56 /** 57 * This enum type specifies the method for estimating the expected render time. 58 */ 59 enum RenderTimeEstimator { 60 RenderTimeEstimatorMinimum, 61 RenderTimeEstimatorMaximum, 62 RenderTimeEstimatorAverage, 63 }; 64 65 class Settings; 66 67 class KWIN_EXPORT Options : public QObject 68 { 69 Q_OBJECT 70 Q_ENUM(XwaylandCrashPolicy) 71 Q_ENUM(LatencyPolicy) 72 Q_ENUM(RenderTimeEstimator) 73 Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged) 74 Q_PROPERTY(XwaylandCrashPolicy xwaylandCrashPolicy READ xwaylandCrashPolicy WRITE setXwaylandCrashPolicy NOTIFY xwaylandCrashPolicyChanged) 75 Q_PROPERTY(int xwaylandMaxCrashCount READ xwaylandMaxCrashCount WRITE setXwaylandMaxCrashCount NOTIFY xwaylandMaxCrashCountChanged) 76 Q_PROPERTY(bool nextFocusPrefersMouse READ isNextFocusPrefersMouse WRITE setNextFocusPrefersMouse NOTIFY nextFocusPrefersMouseChanged) 77 /** 78 * Whether clicking on a window raises it in FocusFollowsMouse 79 * mode or not. 80 */ 81 Q_PROPERTY(bool clickRaise READ isClickRaise WRITE setClickRaise NOTIFY clickRaiseChanged) 82 /** 83 * Whether autoraise is enabled FocusFollowsMouse mode or not. 84 */ 85 Q_PROPERTY(bool autoRaise READ isAutoRaise WRITE setAutoRaise NOTIFY autoRaiseChanged) 86 /** 87 * Autoraise interval. 88 */ 89 Q_PROPERTY(int autoRaiseInterval READ autoRaiseInterval WRITE setAutoRaiseInterval NOTIFY autoRaiseIntervalChanged) 90 /** 91 * Delayed focus interval. 92 */ 93 Q_PROPERTY(int delayFocusInterval READ delayFocusInterval WRITE setDelayFocusInterval NOTIFY delayFocusIntervalChanged) 94 /** 95 * Whether shade hover is enabled or not. 96 */ 97 Q_PROPERTY(bool shadeHover READ isShadeHover WRITE setShadeHover NOTIFY shadeHoverChanged) 98 /** 99 * Shade hover interval. 100 */ 101 Q_PROPERTY(int shadeHoverInterval READ shadeHoverInterval WRITE setShadeHoverInterval NOTIFY shadeHoverIntervalChanged) 102 /** 103 * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client) 104 */ 105 Q_PROPERTY(bool separateScreenFocus READ isSeparateScreenFocus WRITE setSeparateScreenFocus NOTIFY separateScreenFocusChanged) 106 Q_PROPERTY(bool activeMouseScreen READ activeMouseScreen WRITE setActiveMouseScreen NOTIFY activeMouseScreenChanged) 107 Q_PROPERTY(int placement READ placement WRITE setPlacement NOTIFY placementChanged) 108 Q_PROPERTY(bool focusPolicyIsReasonable READ focusPolicyIsReasonable NOTIFY focusPolicyIsResonableChanged) 109 /** 110 * The size of the zone that triggers snapping on desktop borders. 111 */ 112 Q_PROPERTY(int borderSnapZone READ borderSnapZone WRITE setBorderSnapZone NOTIFY borderSnapZoneChanged) 113 /** 114 * The size of the zone that triggers snapping with other windows. 115 */ 116 Q_PROPERTY(int windowSnapZone READ windowSnapZone WRITE setWindowSnapZone NOTIFY windowSnapZoneChanged) 117 /** 118 * The size of the zone that triggers snapping on the screen center. 119 */ 120 Q_PROPERTY(int centerSnapZone READ centerSnapZone WRITE setCenterSnapZone NOTIFY centerSnapZoneChanged) 121 /** 122 * Snap only when windows will overlap. 123 */ 124 Q_PROPERTY(bool snapOnlyWhenOverlapping READ isSnapOnlyWhenOverlapping WRITE setSnapOnlyWhenOverlapping NOTIFY snapOnlyWhenOverlappingChanged) 125 /** 126 * Whether or not we roll over to the other edge when switching desktops past the edge. 127 */ 128 Q_PROPERTY(bool rollOverDesktops READ isRollOverDesktops WRITE setRollOverDesktops NOTIFY rollOverDesktopsChanged) 129 /** 130 * 0 - 4 , see Workspace::allowClientActivation() 131 */ 132 Q_PROPERTY(int focusStealingPreventionLevel READ focusStealingPreventionLevel WRITE setFocusStealingPreventionLevel NOTIFY focusStealingPreventionLevelChanged) 133 Q_PROPERTY(KWin::Options::WindowOperation operationTitlebarDblClick READ operationTitlebarDblClick WRITE setOperationTitlebarDblClick NOTIFY operationTitlebarDblClickChanged) 134 Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonLeftClick READ operationMaxButtonLeftClick WRITE setOperationMaxButtonLeftClick NOTIFY operationMaxButtonLeftClickChanged) 135 Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonMiddleClick READ operationMaxButtonMiddleClick WRITE setOperationMaxButtonMiddleClick NOTIFY operationMaxButtonMiddleClickChanged) 136 Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonRightClick READ operationMaxButtonRightClick WRITE setOperationMaxButtonRightClick NOTIFY operationMaxButtonRightClickChanged) 137 Q_PROPERTY(MouseCommand commandActiveTitlebar1 READ commandActiveTitlebar1 WRITE setCommandActiveTitlebar1 NOTIFY commandActiveTitlebar1Changed) 138 Q_PROPERTY(MouseCommand commandActiveTitlebar2 READ commandActiveTitlebar2 WRITE setCommandActiveTitlebar2 NOTIFY commandActiveTitlebar2Changed) 139 Q_PROPERTY(MouseCommand commandActiveTitlebar3 READ commandActiveTitlebar3 WRITE setCommandActiveTitlebar3 NOTIFY commandActiveTitlebar3Changed) 140 Q_PROPERTY(MouseCommand commandInactiveTitlebar1 READ commandInactiveTitlebar1 WRITE setCommandInactiveTitlebar1 NOTIFY commandInactiveTitlebar1Changed) 141 Q_PROPERTY(MouseCommand commandInactiveTitlebar2 READ commandInactiveTitlebar2 WRITE setCommandInactiveTitlebar2 NOTIFY commandInactiveTitlebar2Changed) 142 Q_PROPERTY(MouseCommand commandInactiveTitlebar3 READ commandInactiveTitlebar3 WRITE setCommandInactiveTitlebar3 NOTIFY commandInactiveTitlebar3Changed) 143 Q_PROPERTY(MouseCommand commandWindow1 READ commandWindow1 WRITE setCommandWindow1 NOTIFY commandWindow1Changed) 144 Q_PROPERTY(MouseCommand commandWindow2 READ commandWindow2 WRITE setCommandWindow2 NOTIFY commandWindow2Changed) 145 Q_PROPERTY(MouseCommand commandWindow3 READ commandWindow3 WRITE setCommandWindow3 NOTIFY commandWindow3Changed) 146 Q_PROPERTY(MouseCommand commandWindowWheel READ commandWindowWheel WRITE setCommandWindowWheel NOTIFY commandWindowWheelChanged) 147 Q_PROPERTY(MouseCommand commandAll1 READ commandAll1 WRITE setCommandAll1 NOTIFY commandAll1Changed) 148 Q_PROPERTY(MouseCommand commandAll2 READ commandAll2 WRITE setCommandAll2 NOTIFY commandAll2Changed) 149 Q_PROPERTY(MouseCommand commandAll3 READ commandAll3 WRITE setCommandAll3 NOTIFY commandAll3Changed) 150 Q_PROPERTY(uint keyCmdAllModKey READ keyCmdAllModKey WRITE setKeyCmdAllModKey NOTIFY keyCmdAllModKeyChanged) 151 /** 152 * Whether the Geometry Tip should be shown during a window move/resize. 153 */ 154 Q_PROPERTY(bool showGeometryTip READ showGeometryTip WRITE setShowGeometryTip NOTIFY showGeometryTipChanged) 155 /** 156 * Whether the visible name should be condensed. 157 */ 158 Q_PROPERTY(bool condensedTitle READ condensedTitle WRITE setCondensedTitle NOTIFY condensedTitleChanged) 159 /** 160 * Whether a window gets maximized when it reaches top screen edge while being moved. 161 */ 162 Q_PROPERTY(bool electricBorderMaximize READ electricBorderMaximize WRITE setElectricBorderMaximize NOTIFY electricBorderMaximizeChanged) 163 /** 164 * Whether a window is tiled to half screen when reaching left or right screen edge while been moved. 165 */ 166 Q_PROPERTY(bool electricBorderTiling READ electricBorderTiling WRITE setElectricBorderTiling NOTIFY electricBorderTilingChanged) 167 /** 168 * Whether a window is tiled to half screen when reaching left or right screen edge while been moved. 169 */ 170 Q_PROPERTY(float electricBorderCornerRatio READ electricBorderCornerRatio WRITE setElectricBorderCornerRatio NOTIFY electricBorderCornerRatioChanged) 171 Q_PROPERTY(bool borderlessMaximizedWindows READ borderlessMaximizedWindows WRITE setBorderlessMaximizedWindows NOTIFY borderlessMaximizedWindowsChanged) 172 /** 173 * timeout before non-responding application will be killed after attempt to close. 174 */ 175 Q_PROPERTY(int killPingTimeout READ killPingTimeout WRITE setKillPingTimeout NOTIFY killPingTimeoutChanged) 176 /** 177 * Whether to hide utility windows for inactive applications. 178 */ 179 Q_PROPERTY(bool hideUtilityWindowsForInactive READ isHideUtilityWindowsForInactive WRITE setHideUtilityWindowsForInactive NOTIFY hideUtilityWindowsForInactiveChanged) 180 Q_PROPERTY(int compositingMode READ compositingMode WRITE setCompositingMode NOTIFY compositingModeChanged) 181 Q_PROPERTY(bool useCompositing READ isUseCompositing WRITE setUseCompositing NOTIFY useCompositingChanged) 182 Q_PROPERTY(int hiddenPreviews READ hiddenPreviews WRITE setHiddenPreviews NOTIFY hiddenPreviewsChanged) 183 /** 184 * 0 = no, 1 = yes when transformed, 185 * 2 = try trilinear when transformed; else 1, 186 * -1 = auto 187 */ 188 Q_PROPERTY(int glSmoothScale READ glSmoothScale WRITE setGlSmoothScale NOTIFY glSmoothScaleChanged) 189 Q_PROPERTY(bool glStrictBinding READ isGlStrictBinding WRITE setGlStrictBinding NOTIFY glStrictBindingChanged) 190 /** 191 * Whether strict binding follows the driver or has been overwritten by a user defined config value. 192 * If @c true glStrictBinding is set by the OpenGL Scene during initialization. 193 * If @c false glStrictBinding is set from a config value and not updated during scene initialization. 194 */ 195 Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged) 196 Q_PROPERTY(bool glCoreProfile READ glCoreProfile WRITE setGLCoreProfile NOTIFY glCoreProfileChanged) 197 Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged) 198 Q_PROPERTY(KWin::OpenGLPlatformInterface glPlatformInterface READ glPlatformInterface WRITE setGlPlatformInterface NOTIFY glPlatformInterfaceChanged) 199 Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged) 200 Q_PROPERTY(LatencyPolicy latencyPolicy READ latencyPolicy WRITE setLatencyPolicy NOTIFY latencyPolicyChanged) 201 Q_PROPERTY(RenderTimeEstimator renderTimeEstimator READ renderTimeEstimator WRITE setRenderTimeEstimator NOTIFY renderTimeEstimatorChanged) 202 public: 203 204 explicit Options(QObject *parent = nullptr); 205 ~Options() override; 206 207 void updateSettings(); 208 209 /** 210 * This enum type is used to specify the focus policy. 211 * 212 * Note that FocusUnderMouse and FocusStrictlyUnderMouse are not 213 * particulary useful. They are only provided for old-fashined 214 * die-hard UNIX people ;-) 215 */ 216 enum FocusPolicy { 217 /** 218 * Clicking into a window activates it. This is also the default. 219 */ 220 ClickToFocus, 221 /** 222 * Moving the mouse pointer actively onto a normal window activates it. 223 * For convenience, the desktop and windows on the dock are excluded. 224 * They require clicking. 225 */ 226 FocusFollowsMouse, 227 /** 228 * The window that happens to be under the mouse pointer becomes active. 229 * The invariant is: no window can have focus that is not under the mouse. 230 * This also means that Alt-Tab won't work properly and popup dialogs are 231 * usually unsable with the keyboard. Note that the desktop and windows on 232 * the dock are excluded for convenience. They get focus only when clicking 233 * on it. 234 */ 235 FocusUnderMouse, 236 /** 237 * This is even worse than FocusUnderMouse. Only the window under the mouse 238 * pointer is active. If the mouse points nowhere, nothing has the focus. If 239 * the mouse points onto the desktop, the desktop has focus. The same holds 240 * for windows on the dock. 241 */ 242 FocusStrictlyUnderMouse 243 }; Q_ENUM(FocusPolicy)244 Q_ENUM(FocusPolicy) 245 246 FocusPolicy focusPolicy() const { 247 return m_focusPolicy; 248 } isNextFocusPrefersMouse()249 bool isNextFocusPrefersMouse() const { 250 return m_nextFocusPrefersMouse; 251 } 252 xwaylandCrashPolicy()253 XwaylandCrashPolicy xwaylandCrashPolicy() const { 254 return m_xwaylandCrashPolicy; 255 } xwaylandMaxCrashCount()256 int xwaylandMaxCrashCount() const { 257 return m_xwaylandMaxCrashCount; 258 } 259 260 /** 261 * Whether clicking on a window raises it in FocusFollowsMouse 262 * mode or not. 263 */ isClickRaise()264 bool isClickRaise() const { 265 return m_clickRaise; 266 } 267 268 /** 269 * Whether autoraise is enabled FocusFollowsMouse mode or not. 270 */ isAutoRaise()271 bool isAutoRaise() const { 272 return m_autoRaise; 273 } 274 275 /** 276 * Autoraise interval 277 */ autoRaiseInterval()278 int autoRaiseInterval() const { 279 return m_autoRaiseInterval; 280 } 281 282 /** 283 * Delayed focus interval. 284 */ delayFocusInterval()285 int delayFocusInterval() const { 286 return m_delayFocusInterval; 287 } 288 289 /** 290 * Whether shade hover is enabled or not. 291 */ isShadeHover()292 bool isShadeHover() const { 293 return m_shadeHover; 294 } 295 296 /** 297 * Shade hover interval. 298 */ shadeHoverInterval()299 int shadeHoverInterval() { 300 return m_shadeHoverInterval; 301 } 302 303 /** 304 * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client) 305 */ isSeparateScreenFocus()306 bool isSeparateScreenFocus() const { 307 return m_separateScreenFocus; 308 } 309 activeMouseScreen()310 bool activeMouseScreen() const { 311 return m_activeMouseScreen; 312 } 313 placement()314 Placement::Policy placement() const { 315 return m_placement; 316 } 317 focusPolicyIsReasonable()318 bool focusPolicyIsReasonable() { 319 return m_focusPolicy == ClickToFocus || m_focusPolicy == FocusFollowsMouse; 320 } 321 322 /** 323 * The size of the zone that triggers snapping on desktop borders. 324 */ borderSnapZone()325 int borderSnapZone() const { 326 return m_borderSnapZone; 327 } 328 329 /** 330 * The size of the zone that triggers snapping with other windows. 331 */ windowSnapZone()332 int windowSnapZone() const { 333 return m_windowSnapZone; 334 } 335 336 /** 337 * The size of the zone that triggers snapping on the screen center. 338 */ centerSnapZone()339 int centerSnapZone() const { 340 return m_centerSnapZone; 341 } 342 343 344 /** 345 * Snap only when windows will overlap. 346 */ isSnapOnlyWhenOverlapping()347 bool isSnapOnlyWhenOverlapping() const { 348 return m_snapOnlyWhenOverlapping; 349 } 350 351 /** 352 * Whether or not we roll over to the other edge when switching desktops past the edge. 353 */ isRollOverDesktops()354 bool isRollOverDesktops() const { 355 return m_rollOverDesktops; 356 } 357 358 /** 359 * Returns the focus stealing prevention level. 360 * 361 * @see allowClientActivation 362 */ focusStealingPreventionLevel()363 int focusStealingPreventionLevel() const { 364 return m_focusStealingPreventionLevel; 365 } 366 367 enum WindowOperation { 368 MaximizeOp = 5000, 369 RestoreOp, 370 MinimizeOp, 371 MoveOp, 372 UnrestrictedMoveOp, 373 ResizeOp, 374 UnrestrictedResizeOp, 375 CloseOp, 376 OnAllDesktopsOp, 377 ShadeOp, 378 KeepAboveOp, 379 KeepBelowOp, 380 OperationsOp, 381 WindowRulesOp, 382 ToggleStoreSettingsOp = WindowRulesOp, ///< @obsolete 383 HMaximizeOp, 384 VMaximizeOp, 385 LowerOp, 386 FullScreenOp, 387 NoBorderOp, 388 NoOp, 389 SetupWindowShortcutOp, 390 ApplicationRulesOp, 391 }; Q_ENUM(WindowOperation)392 Q_ENUM(WindowOperation) 393 394 WindowOperation operationTitlebarDblClick() const { 395 return OpTitlebarDblClick; 396 } operationMaxButtonLeftClick()397 WindowOperation operationMaxButtonLeftClick() const { 398 return opMaxButtonLeftClick; 399 } operationMaxButtonRightClick()400 WindowOperation operationMaxButtonRightClick() const { 401 return opMaxButtonRightClick; 402 } operationMaxButtonMiddleClick()403 WindowOperation operationMaxButtonMiddleClick() const { 404 return opMaxButtonMiddleClick; 405 } 406 WindowOperation operationMaxButtonClick(Qt::MouseButtons button) const; 407 408 409 enum MouseCommand { 410 MouseRaise, MouseLower, MouseOperationsMenu, MouseToggleRaiseAndLower, 411 MouseActivateAndRaise, MouseActivateAndLower, MouseActivate, 412 MouseActivateRaiseAndPassClick, MouseActivateAndPassClick, 413 MouseMove, MouseUnrestrictedMove, 414 MouseActivateRaiseAndMove, MouseActivateRaiseAndUnrestrictedMove, 415 MouseResize, MouseUnrestrictedResize, 416 MouseShade, MouseSetShade, MouseUnsetShade, 417 MouseMaximize, MouseRestore, MouseMinimize, 418 MouseNextDesktop, MousePreviousDesktop, 419 MouseAbove, MouseBelow, 420 MouseOpacityMore, MouseOpacityLess, 421 MouseClose, 422 MouseNothing 423 }; 424 Q_ENUM(MouseCommand) 425 426 enum MouseWheelCommand { 427 MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore, 428 MouseWheelAboveBelow, MouseWheelPreviousNextDesktop, 429 MouseWheelChangeOpacity, 430 MouseWheelNothing 431 }; Q_ENUM(MouseWheelCommand)432 Q_ENUM(MouseWheelCommand) 433 434 MouseCommand operationTitlebarMouseWheel(int delta) const { 435 return wheelToMouseCommand(CmdTitlebarWheel, delta); 436 } operationWindowMouseWheel(int delta)437 MouseCommand operationWindowMouseWheel(int delta) const { 438 return wheelToMouseCommand(CmdAllWheel, delta); 439 } 440 commandActiveTitlebar1()441 MouseCommand commandActiveTitlebar1() const { 442 return CmdActiveTitlebar1; 443 } commandActiveTitlebar2()444 MouseCommand commandActiveTitlebar2() const { 445 return CmdActiveTitlebar2; 446 } commandActiveTitlebar3()447 MouseCommand commandActiveTitlebar3() const { 448 return CmdActiveTitlebar3; 449 } commandInactiveTitlebar1()450 MouseCommand commandInactiveTitlebar1() const { 451 return CmdInactiveTitlebar1; 452 } commandInactiveTitlebar2()453 MouseCommand commandInactiveTitlebar2() const { 454 return CmdInactiveTitlebar2; 455 } commandInactiveTitlebar3()456 MouseCommand commandInactiveTitlebar3() const { 457 return CmdInactiveTitlebar3; 458 } commandWindow1()459 MouseCommand commandWindow1() const { 460 return CmdWindow1; 461 } commandWindow2()462 MouseCommand commandWindow2() const { 463 return CmdWindow2; 464 } commandWindow3()465 MouseCommand commandWindow3() const { 466 return CmdWindow3; 467 } commandWindowWheel()468 MouseCommand commandWindowWheel() const { 469 return CmdWindowWheel; 470 } commandAll1()471 MouseCommand commandAll1() const { 472 return CmdAll1; 473 } commandAll2()474 MouseCommand commandAll2() const { 475 return CmdAll2; 476 } commandAll3()477 MouseCommand commandAll3() const { 478 return CmdAll3; 479 } commandAllWheel()480 MouseWheelCommand commandAllWheel() const { 481 return CmdAllWheel; 482 } keyCmdAllModKey()483 uint keyCmdAllModKey() const { 484 return CmdAllModKey; 485 } commandAllModifier()486 Qt::KeyboardModifier commandAllModifier() const { 487 switch (CmdAllModKey) { 488 case Qt::Key_Alt: 489 return Qt::AltModifier; 490 case Qt::Key_Meta: 491 return Qt::MetaModifier; 492 default: 493 Q_UNREACHABLE(); 494 } 495 } 496 497 static WindowOperation windowOperation(const QString &name, bool restricted); 498 static MouseCommand mouseCommand(const QString &name, bool restricted); 499 static MouseWheelCommand mouseWheelCommand(const QString &name); 500 501 /** 502 * @returns true if the Geometry Tip should be shown during a window move/resize. 503 */ 504 bool showGeometryTip() const; 505 506 /** 507 * Returns whether the user prefers his caption clean. 508 */ 509 bool condensedTitle() const; 510 511 /** 512 * @returns true if a window gets maximized when it reaches top screen edge 513 * while being moved. 514 */ electricBorderMaximize()515 bool electricBorderMaximize() const { 516 return electric_border_maximize; 517 } 518 /** 519 * @returns true if window is tiled to half screen when reaching left or 520 * right screen edge while been moved. 521 */ electricBorderTiling()522 bool electricBorderTiling() const { 523 return electric_border_tiling; 524 } 525 /** 526 * @returns the factor that determines the corner part of the edge (ie. 0.1 means tiny corner) 527 */ electricBorderCornerRatio()528 float electricBorderCornerRatio() const { 529 return electric_border_corner_ratio; 530 } 531 borderlessMaximizedWindows()532 bool borderlessMaximizedWindows() const { 533 return borderless_maximized_windows; 534 } 535 536 /** 537 * Timeout before non-responding application will be killed after attempt to close. 538 */ killPingTimeout()539 int killPingTimeout() const { 540 return m_killPingTimeout; 541 } 542 543 /** 544 * Whether to hide utility windows for inactive applications. 545 */ isHideUtilityWindowsForInactive()546 bool isHideUtilityWindowsForInactive() const { 547 return m_hideUtilityWindowsForInactive; 548 } 549 550 /** 551 * Returns the animation time factor for desktop effects. 552 */ 553 double animationTimeFactor() const; 554 555 //---------------------- 556 // Compositing settings 557 void reloadCompositingSettings(bool force = false); compositingMode()558 CompositingType compositingMode() const { 559 return m_compositingMode; 560 } setCompositingMode(CompositingType mode)561 void setCompositingMode(CompositingType mode) { 562 m_compositingMode = mode; 563 } 564 // Separate to mode so the user can toggle 565 bool isUseCompositing() const; 566 567 // General preferences hiddenPreviews()568 HiddenPreviews hiddenPreviews() const { 569 return m_hiddenPreviews; 570 } 571 // OpenGL 572 // 1 = yes, 573 // 2 = try trilinear when transformed; else 1, 574 // -1 = auto glSmoothScale()575 int glSmoothScale() const { 576 return m_glSmoothScale; 577 } 578 579 // Settings that should be auto-detected isGlStrictBinding()580 bool isGlStrictBinding() const { 581 return m_glStrictBinding; 582 } isGlStrictBindingFollowsDriver()583 bool isGlStrictBindingFollowsDriver() const { 584 return m_glStrictBindingFollowsDriver; 585 } glCoreProfile()586 bool glCoreProfile() const { 587 return m_glCoreProfile; 588 } glPlatformInterface()589 OpenGLPlatformInterface glPlatformInterface() const { 590 return m_glPlatformInterface; 591 } 592 593 enum GlSwapStrategy { 594 CopyFrontBuffer = 'c', 595 PaintFullScreen = 'p', 596 ExtendDamage = 'e', 597 AutoSwapStrategy = 'a', 598 }; Q_ENUM(GlSwapStrategy)599 Q_ENUM(GlSwapStrategy) 600 GlSwapStrategy glPreferBufferSwap() const { 601 return m_glPreferBufferSwap; 602 } 603 windowsBlockCompositing()604 bool windowsBlockCompositing() const 605 { 606 return m_windowsBlockCompositing; 607 } 608 moveMinimizedWindowsToEndOfTabBoxFocusChain()609 bool moveMinimizedWindowsToEndOfTabBoxFocusChain() const { 610 return m_MoveMinimizedWindowsToEndOfTabBoxFocusChain; 611 } 612 613 QStringList modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const; 614 LatencyPolicy latencyPolicy() const; 615 RenderTimeEstimator renderTimeEstimator() const; 616 617 // setters 618 void setFocusPolicy(FocusPolicy focusPolicy); 619 void setXwaylandCrashPolicy(XwaylandCrashPolicy crashPolicy); 620 void setXwaylandMaxCrashCount(int maxCrashCount); 621 void setNextFocusPrefersMouse(bool nextFocusPrefersMouse); 622 void setClickRaise(bool clickRaise); 623 void setAutoRaise(bool autoRaise); 624 void setAutoRaiseInterval(int autoRaiseInterval); 625 void setDelayFocusInterval(int delayFocusInterval); 626 void setShadeHover(bool shadeHover); 627 void setShadeHoverInterval(int shadeHoverInterval); 628 void setSeparateScreenFocus(bool separateScreenFocus); 629 void setActiveMouseScreen(bool activeMouseScreen); 630 void setPlacement(int placement); 631 void setBorderSnapZone(int borderSnapZone); 632 void setWindowSnapZone(int windowSnapZone); 633 void setCenterSnapZone(int centerSnapZone); 634 void setSnapOnlyWhenOverlapping(bool snapOnlyWhenOverlapping); 635 void setRollOverDesktops(bool rollOverDesktops); 636 void setFocusStealingPreventionLevel(int focusStealingPreventionLevel); 637 void setOperationTitlebarDblClick(WindowOperation operationTitlebarDblClick); 638 void setOperationMaxButtonLeftClick(WindowOperation op); 639 void setOperationMaxButtonRightClick(WindowOperation op); 640 void setOperationMaxButtonMiddleClick(WindowOperation op); 641 void setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1); 642 void setCommandActiveTitlebar2(MouseCommand commandActiveTitlebar2); 643 void setCommandActiveTitlebar3(MouseCommand commandActiveTitlebar3); 644 void setCommandInactiveTitlebar1(MouseCommand commandInactiveTitlebar1); 645 void setCommandInactiveTitlebar2(MouseCommand commandInactiveTitlebar2); 646 void setCommandInactiveTitlebar3(MouseCommand commandInactiveTitlebar3); 647 void setCommandWindow1(MouseCommand commandWindow1); 648 void setCommandWindow2(MouseCommand commandWindow2); 649 void setCommandWindow3(MouseCommand commandWindow3); 650 void setCommandWindowWheel(MouseCommand commandWindowWheel); 651 void setCommandAll1(MouseCommand commandAll1); 652 void setCommandAll2(MouseCommand commandAll2); 653 void setCommandAll3(MouseCommand commandAll3); 654 void setKeyCmdAllModKey(uint keyCmdAllModKey); 655 void setShowGeometryTip(bool showGeometryTip); 656 void setCondensedTitle(bool condensedTitle); 657 void setElectricBorderMaximize(bool electricBorderMaximize); 658 void setElectricBorderTiling(bool electricBorderTiling); 659 void setElectricBorderCornerRatio(float electricBorderCornerRatio); 660 void setBorderlessMaximizedWindows(bool borderlessMaximizedWindows); 661 void setKillPingTimeout(int killPingTimeout); 662 void setHideUtilityWindowsForInactive(bool hideUtilityWindowsForInactive); 663 void setCompositingMode(int compositingMode); 664 void setUseCompositing(bool useCompositing); 665 void setHiddenPreviews(int hiddenPreviews); 666 void setGlSmoothScale(int glSmoothScale); 667 void setGlStrictBinding(bool glStrictBinding); 668 void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver); 669 void setGLCoreProfile(bool glCoreProfile); 670 void setGlPreferBufferSwap(char glPreferBufferSwap); 671 void setGlPlatformInterface(OpenGLPlatformInterface interface); 672 void setWindowsBlockCompositing(bool set); 673 void setMoveMinimizedWindowsToEndOfTabBoxFocusChain(bool set); 674 void setLatencyPolicy(LatencyPolicy policy); 675 void setRenderTimeEstimator(RenderTimeEstimator estimator); 676 677 // default values defaultOperationTitlebarDblClick()678 static WindowOperation defaultOperationTitlebarDblClick() { 679 return MaximizeOp; 680 } defaultOperationMaxButtonLeftClick()681 static WindowOperation defaultOperationMaxButtonLeftClick() { 682 return MaximizeOp; 683 } defaultOperationMaxButtonRightClick()684 static WindowOperation defaultOperationMaxButtonRightClick() { 685 return HMaximizeOp; 686 } defaultOperationMaxButtonMiddleClick()687 static WindowOperation defaultOperationMaxButtonMiddleClick() { 688 return VMaximizeOp; 689 } defaultCommandActiveTitlebar1()690 static MouseCommand defaultCommandActiveTitlebar1() { 691 return MouseRaise; 692 } defaultCommandActiveTitlebar2()693 static MouseCommand defaultCommandActiveTitlebar2() { 694 return MouseNothing; 695 } defaultCommandActiveTitlebar3()696 static MouseCommand defaultCommandActiveTitlebar3() { 697 return MouseOperationsMenu; 698 } defaultCommandInactiveTitlebar1()699 static MouseCommand defaultCommandInactiveTitlebar1() { 700 return MouseActivateAndRaise; 701 } defaultCommandInactiveTitlebar2()702 static MouseCommand defaultCommandInactiveTitlebar2() { 703 return MouseNothing; 704 } defaultCommandInactiveTitlebar3()705 static MouseCommand defaultCommandInactiveTitlebar3() { 706 return MouseOperationsMenu; 707 } defaultCommandWindow1()708 static MouseCommand defaultCommandWindow1() { 709 return MouseActivateRaiseAndPassClick; 710 } defaultCommandWindow2()711 static MouseCommand defaultCommandWindow2() { 712 return MouseActivateAndPassClick; 713 } defaultCommandWindow3()714 static MouseCommand defaultCommandWindow3() { 715 return MouseActivateAndPassClick; 716 } defaultCommandWindowWheel()717 static MouseCommand defaultCommandWindowWheel() { 718 return MouseNothing; 719 } defaultCommandAll1()720 static MouseCommand defaultCommandAll1() { 721 return MouseUnrestrictedMove; 722 } defaultCommandAll2()723 static MouseCommand defaultCommandAll2() { 724 return MouseToggleRaiseAndLower; 725 } defaultCommandAll3()726 static MouseCommand defaultCommandAll3() { 727 return MouseUnrestrictedResize; 728 } defaultCommandTitlebarWheel()729 static MouseWheelCommand defaultCommandTitlebarWheel() { 730 return MouseWheelNothing; 731 } defaultCommandAllWheel()732 static MouseWheelCommand defaultCommandAllWheel() { 733 return MouseWheelNothing; 734 } defaultKeyCmdAllModKey()735 static uint defaultKeyCmdAllModKey() { 736 return Qt::Key_Alt; 737 } defaultCompositingMode()738 static CompositingType defaultCompositingMode() { 739 return OpenGLCompositing; 740 } defaultUseCompositing()741 static bool defaultUseCompositing() { 742 return true; 743 } defaultHiddenPreviews()744 static HiddenPreviews defaultHiddenPreviews() { 745 return HiddenPreviewsShown; 746 } defaultGlSmoothScale()747 static int defaultGlSmoothScale() { 748 return 2; 749 } defaultGlStrictBinding()750 static bool defaultGlStrictBinding() { 751 return true; 752 } defaultGlStrictBindingFollowsDriver()753 static bool defaultGlStrictBindingFollowsDriver() { 754 return true; 755 } defaultGLCoreProfile()756 static bool defaultGLCoreProfile() { 757 return false; 758 } defaultGlPreferBufferSwap()759 static GlSwapStrategy defaultGlPreferBufferSwap() { 760 return AutoSwapStrategy; 761 } defaultGlPlatformInterface()762 static OpenGLPlatformInterface defaultGlPlatformInterface() { 763 return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface; 764 } defaultXwaylandCrashPolicy()765 static XwaylandCrashPolicy defaultXwaylandCrashPolicy() { 766 return XwaylandCrashPolicy::Restart; 767 } defaultXwaylandMaxCrashCount()768 static int defaultXwaylandMaxCrashCount() { 769 return 3; 770 } defaultLatencyPolicy()771 static LatencyPolicy defaultLatencyPolicy() { 772 return LatencyMedium; 773 } defaultRenderTimeEstimator()774 static RenderTimeEstimator defaultRenderTimeEstimator() { 775 return RenderTimeEstimatorMaximum; 776 } 777 /** 778 * Performs loading all settings except compositing related. 779 */ 780 void loadConfig(); 781 /** 782 * Performs loading of compositing settings which do not depend on OpenGL. 783 */ 784 bool loadCompositingConfig(bool force); 785 void reparseConfiguration(); 786 787 //---------------------- 788 Q_SIGNALS: 789 // for properties 790 void focusPolicyChanged(); 791 void focusPolicyIsResonableChanged(); 792 void xwaylandCrashPolicyChanged(); 793 void xwaylandMaxCrashCountChanged(); 794 void nextFocusPrefersMouseChanged(); 795 void clickRaiseChanged(); 796 void autoRaiseChanged(); 797 void autoRaiseIntervalChanged(); 798 void delayFocusIntervalChanged(); 799 void shadeHoverChanged(); 800 void shadeHoverIntervalChanged(); 801 void separateScreenFocusChanged(bool); 802 void activeMouseScreenChanged(); 803 void placementChanged(); 804 void borderSnapZoneChanged(); 805 void windowSnapZoneChanged(); 806 void centerSnapZoneChanged(); 807 void snapOnlyWhenOverlappingChanged(); 808 void rollOverDesktopsChanged(bool enabled); 809 void focusStealingPreventionLevelChanged(); 810 void operationTitlebarDblClickChanged(); 811 void operationMaxButtonLeftClickChanged(); 812 void operationMaxButtonRightClickChanged(); 813 void operationMaxButtonMiddleClickChanged(); 814 void commandActiveTitlebar1Changed(); 815 void commandActiveTitlebar2Changed(); 816 void commandActiveTitlebar3Changed(); 817 void commandInactiveTitlebar1Changed(); 818 void commandInactiveTitlebar2Changed(); 819 void commandInactiveTitlebar3Changed(); 820 void commandWindow1Changed(); 821 void commandWindow2Changed(); 822 void commandWindow3Changed(); 823 void commandWindowWheelChanged(); 824 void commandAll1Changed(); 825 void commandAll2Changed(); 826 void commandAll3Changed(); 827 void keyCmdAllModKeyChanged(); 828 void showGeometryTipChanged(); 829 void condensedTitleChanged(); 830 void electricBorderMaximizeChanged(); 831 void electricBorderTilingChanged(); 832 void electricBorderCornerRatioChanged(); 833 void borderlessMaximizedWindowsChanged(); 834 void killPingTimeoutChanged(); 835 void hideUtilityWindowsForInactiveChanged(); 836 void compositingModeChanged(); 837 void useCompositingChanged(); 838 void hiddenPreviewsChanged(); 839 void glSmoothScaleChanged(); 840 void glStrictBindingChanged(); 841 void glStrictBindingFollowsDriverChanged(); 842 void glCoreProfileChanged(); 843 void glPreferBufferSwapChanged(); 844 void glPlatformInterfaceChanged(); 845 void windowsBlockCompositingChanged(); 846 void animationSpeedChanged(); 847 void latencyPolicyChanged(); 848 void configChanged(); 849 void renderTimeEstimatorChanged(); 850 851 private: 852 void setElectricBorders(int borders); 853 void syncFromKcfgc(); 854 QScopedPointer<Settings> m_settings; 855 KConfigWatcher::Ptr m_configWatcher; 856 857 FocusPolicy m_focusPolicy; 858 bool m_nextFocusPrefersMouse; 859 bool m_clickRaise; 860 bool m_autoRaise; 861 int m_autoRaiseInterval; 862 int m_delayFocusInterval; 863 bool m_shadeHover; 864 int m_shadeHoverInterval; 865 bool m_separateScreenFocus; 866 bool m_activeMouseScreen; 867 Placement::Policy m_placement; 868 int m_borderSnapZone; 869 int m_windowSnapZone; 870 int m_centerSnapZone; 871 bool m_snapOnlyWhenOverlapping; 872 bool m_rollOverDesktops; 873 int m_focusStealingPreventionLevel; 874 int m_killPingTimeout; 875 bool m_hideUtilityWindowsForInactive; 876 XwaylandCrashPolicy m_xwaylandCrashPolicy; 877 int m_xwaylandMaxCrashCount; 878 LatencyPolicy m_latencyPolicy; 879 RenderTimeEstimator m_renderTimeEstimator; 880 881 CompositingType m_compositingMode; 882 bool m_useCompositing; 883 HiddenPreviews m_hiddenPreviews; 884 int m_glSmoothScale; 885 // Settings that should be auto-detected 886 bool m_glStrictBinding; 887 bool m_glStrictBindingFollowsDriver; 888 bool m_glCoreProfile; 889 GlSwapStrategy m_glPreferBufferSwap; 890 OpenGLPlatformInterface m_glPlatformInterface; 891 bool m_windowsBlockCompositing; 892 bool m_MoveMinimizedWindowsToEndOfTabBoxFocusChain; 893 894 WindowOperation OpTitlebarDblClick; 895 WindowOperation opMaxButtonRightClick = defaultOperationMaxButtonRightClick(); 896 WindowOperation opMaxButtonMiddleClick = defaultOperationMaxButtonMiddleClick(); 897 WindowOperation opMaxButtonLeftClick = defaultOperationMaxButtonRightClick(); 898 899 // mouse bindings 900 MouseCommand CmdActiveTitlebar1; 901 MouseCommand CmdActiveTitlebar2; 902 MouseCommand CmdActiveTitlebar3; 903 MouseCommand CmdInactiveTitlebar1; 904 MouseCommand CmdInactiveTitlebar2; 905 MouseCommand CmdInactiveTitlebar3; 906 MouseWheelCommand CmdTitlebarWheel; 907 MouseCommand CmdWindow1; 908 MouseCommand CmdWindow2; 909 MouseCommand CmdWindow3; 910 MouseCommand CmdWindowWheel; 911 MouseCommand CmdAll1; 912 MouseCommand CmdAll2; 913 MouseCommand CmdAll3; 914 MouseWheelCommand CmdAllWheel; 915 uint CmdAllModKey; 916 917 bool electric_border_maximize; 918 bool electric_border_tiling; 919 float electric_border_corner_ratio; 920 bool borderless_maximized_windows; 921 bool show_geometry_tip; 922 bool condensed_title; 923 924 QHash<Qt::KeyboardModifier, QStringList> m_modifierOnlyShortcuts; 925 926 MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const; 927 }; 928 929 extern KWIN_EXPORT Options* options; 930 931 } // namespace 932 933 Q_DECLARE_METATYPE(KWin::Options::WindowOperation) 934 Q_DECLARE_METATYPE(KWin::OpenGLPlatformInterface) 935 936 #endif 937