1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7Copyright (C) 2012 Martin Gräßlin <m.graesslin@kde.org>
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************/
22
23#ifndef KWIN_OPTIONS_H
24#define KWIN_OPTIONS_H
25
26#include <QObject>
27#include <QFont>
28#include <QPalette>
29#include <kdecoration.h>
30
31#include "placement.h"
32#include "utils.h"
33
34namespace KWin
35{
36
37class Client;
38class CompositingPrefs;
39class Settings;
40
41class Options : public QObject, public KDecorationOptions
42{
43 Q_OBJECT
44 Q_ENUMS(FocusPolicy)
45 Q_ENUMS(GlSwapStrategy)
46 Q_ENUMS(MouseCommand)
47 Q_ENUMS(MouseWheelCommand)
48
49 Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged)
50 Q_PROPERTY(bool nextFocusPrefersMouse READ isNextFocusPrefersMouse WRITE setNextFocusPrefersMouse NOTIFY nextFocusPrefersMouseChanged)
51 /**
52 Whether clicking on a window raises it in FocusFollowsMouse
53 mode or not.
54 */
55 Q_PROPERTY(bool clickRaise READ isClickRaise WRITE setClickRaise NOTIFY clickRaiseChanged)
56 /**
57 whether autoraise is enabled FocusFollowsMouse mode or not.
58 */
59 Q_PROPERTY(bool autoRaise READ isAutoRaise WRITE setAutoRaise NOTIFY autoRaiseChanged)
60 /**
61 autoraise interval
62 */
63 Q_PROPERTY(int autoRaiseInterval READ autoRaiseInterval WRITE setAutoRaiseInterval NOTIFY autoRaiseIntervalChanged)
64 /**
65 delayed focus interval
66 */
67 Q_PROPERTY(int delayFocusInterval READ delayFocusInterval WRITE setDelayFocusInterval NOTIFY delayFocusIntervalChanged)
68 /**
69 Whether shade hover is enabled or not
70 */
71 Q_PROPERTY(bool shadeHover READ isShadeHover WRITE setShadeHover NOTIFY shadeHoverChanged)
72 /**
73 shade hover interval
74 */
75 Q_PROPERTY(int shadeHoverInterval READ shadeHoverInterval WRITE setShadeHoverInterval NOTIFY shadeHoverIntervalChanged)
76 /**
77 * whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client)
78 **/
79 Q_PROPERTY(bool separateScreenFocus READ isSeparateScreenFocus WRITE setSeparateScreenFocus NOTIFY separateScreenFocusChanged)
80 Q_PROPERTY(int placement READ placement WRITE setPlacement NOTIFY placementChanged)
81 Q_PROPERTY(bool focusPolicyIsReasonable READ focusPolicyIsReasonable NOTIFY configChanged)
82 /**
83 * the size of the zone that triggers snapping on desktop borders
84 */
85 Q_PROPERTY(int borderSnapZone READ borderSnapZone WRITE setBorderSnapZone NOTIFY borderSnapZoneChanged)
86 /**
87 * the size of the zone that triggers snapping with other windows
88 */
89 Q_PROPERTY(int windowSnapZone READ windowSnapZone WRITE setWindowSnapZone NOTIFY windowSnapZoneChanged)
90 /**
91 * the size of the zone that triggers snapping on the screen center
92 */
93 Q_PROPERTY(int centerSnapZone READ centerSnapZone WRITE setCenterSnapZone NOTIFY centerSnapZoneChanged)
94 /**
95 * snap only when windows will overlap
96 */
97 Q_PROPERTY(bool snapOnlyWhenOverlapping READ isSnapOnlyWhenOverlapping WRITE setSnapOnlyWhenOverlapping NOTIFY snapOnlyWhenOverlappingChanged)
98 Q_PROPERTY(bool showDesktopIsMinimizeAll READ isShowDesktopIsMinimizeAll WRITE setShowDesktopIsMinimizeAll NOTIFY showDesktopIsMinimizeAllChanged)
99 /**
100 * whether or not we roll over to the other edge when switching desktops past the edge
101 */
102 Q_PROPERTY(bool rollOverDesktops READ isRollOverDesktops WRITE setRollOverDesktops NOTIFY rollOverDesktopsChanged)
103 /**
104 * 0 - 4 , see Workspace::allowClientActivation()
105 **/
106 Q_PROPERTY(int focusStealingPreventionLevel READ focusStealingPreventionLevel WRITE setFocusStealingPreventionLevel NOTIFY focusStealingPreventionLevelChanged)
107 /**
108 * support legacy fullscreen windows hack: borderless non-netwm windows with screen geometry
109 */
110 Q_PROPERTY(bool legacyFullscreenSupport READ isLegacyFullscreenSupport WRITE setLegacyFullscreenSupport NOTIFY legacyFullscreenSupportChanged)
111 Q_PROPERTY(WindowOperation operationTitlebarDblClick READ operationTitlebarDblClick WRITE setOperationTitlebarDblClick NOTIFY operationTitlebarDblClickChanged)
112 Q_PROPERTY(MouseCommand commandActiveTitlebar1 READ commandActiveTitlebar1 WRITE setCommandActiveTitlebar1 NOTIFY commandActiveTitlebar1Changed)
113 Q_PROPERTY(MouseCommand commandActiveTitlebar2 READ commandActiveTitlebar2 WRITE setCommandActiveTitlebar2 NOTIFY commandActiveTitlebar2Changed)
114 Q_PROPERTY(MouseCommand commandActiveTitlebar3 READ commandActiveTitlebar3 WRITE setCommandActiveTitlebar3 NOTIFY commandActiveTitlebar3Changed)
115 Q_PROPERTY(MouseCommand commandInactiveTitlebar1 READ commandInactiveTitlebar1 WRITE setCommandInactiveTitlebar1 NOTIFY commandInactiveTitlebar1Changed)
116 Q_PROPERTY(MouseCommand commandInactiveTitlebar2 READ commandInactiveTitlebar2 WRITE setCommandInactiveTitlebar2 NOTIFY commandInactiveTitlebar2Changed)
117 Q_PROPERTY(MouseCommand commandInactiveTitlebar3 READ commandInactiveTitlebar3 WRITE setCommandInactiveTitlebar3 NOTIFY commandInactiveTitlebar3Changed)
118 Q_PROPERTY(MouseCommand commandWindow1 READ commandWindow1 WRITE setCommandWindow1 NOTIFY commandWindow1Changed)
119 Q_PROPERTY(MouseCommand commandWindow2 READ commandWindow2 WRITE setCommandWindow2 NOTIFY commandWindow2Changed)
120 Q_PROPERTY(MouseCommand commandWindow3 READ commandWindow3 WRITE setCommandWindow3 NOTIFY commandWindow3Changed)
121 Q_PROPERTY(MouseCommand commandWindowWheel READ commandWindowWheel WRITE setCommandWindowWheel NOTIFY commandWindowWheelChanged)
122 Q_PROPERTY(MouseCommand commandAll1 READ commandAll1 WRITE setCommandAll1 NOTIFY commandAll1Changed)
123 Q_PROPERTY(MouseCommand commandAll2 READ commandAll2 WRITE setCommandAll2 NOTIFY commandAll2Changed)
124 Q_PROPERTY(MouseCommand commandAll3 READ commandAll3 WRITE setCommandAll3 NOTIFY commandAll3Changed)
125 Q_PROPERTY(uint keyCmdAllModKey READ keyCmdAllModKey WRITE setKeyCmdAllModKey NOTIFY keyCmdAllModKeyChanged)
126 /**
127 * whether the Geometry Tip should be shown during a window move/resize.
128 */
129 Q_PROPERTY(bool showGeometryTip READ showGeometryTip WRITE setShowGeometryTip NOTIFY showGeometryTipChanged)
130 /**
131 * whether the visible name should be condensed
132 */
133 Q_PROPERTY(bool condensedTitle READ condensedTitle WRITE setCondensedTitle NOTIFY condensedTitleChanged)
134 /**
135 * Whether a window gets maximized when it reaches top screen edge while being moved.
136 */
137 Q_PROPERTY(bool electricBorderMaximize READ electricBorderMaximize WRITE setElectricBorderMaximize NOTIFY electricBorderMaximizeChanged)
138 /**
139 * Whether a window is tiled to half screen when reaching left or right screen edge while been moved
140 */
141 Q_PROPERTY(bool electricBorderTiling READ electricBorderTiling WRITE setElectricBorderTiling NOTIFY electricBorderTilingChanged)
142 /**
143 * Whether a window is tiled to half screen when reaching left or right screen edge while been moved
144 */
145 Q_PROPERTY(float electricBorderCornerRatio READ electricBorderCornerRatio WRITE setElectricBorderCornerRatio NOTIFY electricBorderCornerRatioChanged)
146 Q_PROPERTY(bool borderlessMaximizedWindows READ borderlessMaximizedWindows WRITE setBorderlessMaximizedWindows NOTIFY borderlessMaximizedWindowsChanged)
147 /**
148 * timeout before non-responding application will be killed after attempt to close
149 **/
150 Q_PROPERTY(int killPingTimeout READ killPingTimeout WRITE setKillPingTimeout NOTIFY killPingTimeoutChanged)
151 /**
152 * Whether to hide utility windows for inactive applications.
153 **/
154 Q_PROPERTY(bool hideUtilityWindowsForInactive READ isHideUtilityWindowsForInactive WRITE setHideUtilityWindowsForInactive NOTIFY hideUtilityWindowsForInactiveChanged)
155 Q_PROPERTY(bool inactiveTabsSkipTaskbar READ isInactiveTabsSkipTaskbar WRITE setInactiveTabsSkipTaskbar NOTIFY inactiveTabsSkipTaskbarChanged)
156 Q_PROPERTY(bool autogroupSimilarWindows READ isAutogroupSimilarWindows WRITE setAutogroupSimilarWindows NOTIFY autogroupSimilarWindowsChanged)
157 Q_PROPERTY(bool autogroupInForeground READ isAutogroupInForeground WRITE setAutogroupInForeground NOTIFY autogroupInForegroundChanged)
158 Q_PROPERTY(int compositingMode READ compositingMode WRITE setCompositingMode NOTIFY compositingModeChanged)
159 Q_PROPERTY(bool useCompositing READ isUseCompositing WRITE setUseCompositing NOTIFY useCompositingChanged)
160 Q_PROPERTY(bool compositingInitialized READ isCompositingInitialized WRITE setCompositingInitialized NOTIFY compositingInitializedChanged)
161 Q_PROPERTY(int hiddenPreviews READ hiddenPreviews WRITE setHiddenPreviews NOTIFY hiddenPreviewsChanged)
162 Q_PROPERTY(bool unredirectFullscreen READ isUnredirectFullscreen WRITE setUnredirectFullscreen NOTIFY unredirectFullscreenChanged)
163 /**
164 * 0 = no, 1 = yes when transformed,
165 * 2 = try trilinear when transformed; else 1,
166 * -1 = auto
167 **/
168 Q_PROPERTY(int glSmoothScale READ glSmoothScale WRITE setGlSmoothScale NOTIFY glSmoothScaleChanged)
169 Q_PROPERTY(bool colorCorrected READ isColorCorrected WRITE setColorCorrected NOTIFY colorCorrectedChanged)
170 Q_PROPERTY(bool xrenderSmoothScale READ isXrenderSmoothScale WRITE setXrenderSmoothScale NOTIFY xrenderSmoothScaleChanged)
171 Q_PROPERTY(qint64 maxFpsInterval READ maxFpsInterval WRITE setMaxFpsInterval NOTIFY maxFpsIntervalChanged)
172 Q_PROPERTY(uint refreshRate READ refreshRate WRITE setRefreshRate NOTIFY refreshRateChanged)
173 Q_PROPERTY(qint64 vBlankTime READ vBlankTime WRITE setVBlankTime NOTIFY vBlankTimeChanged)
174 Q_PROPERTY(bool glDirect READ isGlDirect WRITE setGlDirect NOTIFY glDirectChanged)
175 Q_PROPERTY(bool glStrictBinding READ isGlStrictBinding WRITE setGlStrictBinding NOTIFY glStrictBindingChanged)
176 /**
177 * Whether strict binding follows the driver or has been overwritten by a user defined config value.
178 * If @c true @link glStrictBinding is set by the OpenGL Scene during initialization.
179 * If @c false @link glStrictBinding is set from a config value and not updated during scene initialization.
180 **/
181 Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged)
182 /**
183 * Whether legacy OpenGL should be used or OpenGL (ES) 2
184 **/
185 Q_PROPERTY(bool glLegacy READ isGlLegacy WRITE setGlLegacy NOTIFY glLegacyChanged)
186 Q_PROPERTY(bool glCoreProfile READ glCoreProfile WRITE setGLCoreProfile NOTIFY glCoreProfileChanged)
187 Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged)
188public:
189
190 explicit Options(QObject *parent = NULL);
191 ~Options();
192
193 virtual unsigned long updateSettings();
194
195 /*!
196 Different focus policies:
197 <ul>
198
199 <li>ClickToFocus - Clicking into a window activates it. This is
200 also the default.
201
202 <li>FocusFollowsMouse - Moving the mouse pointer actively onto a
203 normal window activates it. For convenience, the desktop and
204 windows on the dock are excluded. They require clicking.
205
206 <li>FocusUnderMouse - The window that happens to be under the
207 mouse pointer becomes active. The invariant is: no window can
208 have focus that is not under the mouse. This also means that
209 Alt-Tab won't work properly and popup dialogs are usually
210 unsable with the keyboard. Note that the desktop and windows on
211 the dock are excluded for convenience. They get focus only when
212 clicking on it.
213
214 <li>FocusStrictlyUnderMouse - this is even worse than
215 FocusUnderMouse. Only the window under the mouse pointer is
216 active. If the mouse points nowhere, nothing has the focus. If
217 the mouse points onto the desktop, the desktop has focus. The
218 same holds for windows on the dock.
219
220 Note that FocusUnderMouse and FocusStrictlyUnderMouse are not
221 particulary useful. They are only provided for old-fashined
222 die-hard UNIX people ;-)
223
224 </ul>
225 */
226 enum FocusPolicy { ClickToFocus, FocusFollowsMouse, FocusUnderMouse, FocusStrictlyUnderMouse };
227 FocusPolicy focusPolicy() const {
228 return m_focusPolicy;
229 }
230 bool isNextFocusPrefersMouse() const {
231 return m_nextFocusPrefersMouse;
232 }
233
234 /**
235 Whether clicking on a window raises it in FocusFollowsMouse
236 mode or not.
237 */
238 bool isClickRaise() const {
239 return m_clickRaise;
240 }
241
242 /**
243 whether autoraise is enabled FocusFollowsMouse mode or not.
244 */
245 bool isAutoRaise() const {
246 return m_autoRaise;
247 }
248
249 /**
250 autoraise interval
251 */
252 int autoRaiseInterval() const {
253 return m_autoRaiseInterval;
254 }
255
256 /**
257 delayed focus interval
258 */
259 int delayFocusInterval() const {
260 return m_delayFocusInterval;
261 }
262
263 /**
264 Whether shade hover is enabled or not
265 */
266 bool isShadeHover() const {
267 return m_shadeHover;
268 }
269
270 /**
271 shade hover interval
272 */
273 int shadeHoverInterval() {
274 return m_shadeHoverInterval;
275 }
276
277 // whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client)
278 bool isSeparateScreenFocus() const {
279 return m_separateScreenFocus;
280 }
281
282 Placement::Policy placement() const {
283 return m_placement;
284 }
285
286 bool focusPolicyIsReasonable() {
287 return m_focusPolicy == ClickToFocus || m_focusPolicy == FocusFollowsMouse;
288 }
289
290 /**
291 * the size of the zone that triggers snapping on desktop borders
292 */
293 int borderSnapZone() const {
294 return m_borderSnapZone;
295 }
296
297 /**
298 * the size of the zone that triggers snapping with other windows
299 */
300 int windowSnapZone() const {
301 return m_windowSnapZone;
302 }
303
304 /**
305 * the size of the zone that triggers snapping on the screen center
306 */
307 int centerSnapZone() const {
308 return m_centerSnapZone;
309 }
310
311
312 /**
313 * snap only when windows will overlap
314 */
315 bool isSnapOnlyWhenOverlapping() const {
316 return m_snapOnlyWhenOverlapping;
317 }
318
319 bool isShowDesktopIsMinimizeAll() const {
320 return m_showDesktopIsMinimizeAll;
321 }
322
323 /**
324 * whether or not we roll over to the other edge when switching desktops past the edge
325 */
326 bool isRollOverDesktops() const {
327 return m_rollOverDesktops;
328 }
329
330 // 0 - 4 , see Workspace::allowClientActivation()
331 int focusStealingPreventionLevel() const {
332 return m_focusStealingPreventionLevel;
333 }
334
335 /**
336 * support legacy fullscreen windows hack: borderless non-netwm windows with screen geometry
337 */
338 bool isLegacyFullscreenSupport() const {
339 return m_legacyFullscreenSupport;
340 }
341
342 WindowOperation operationTitlebarDblClick() const {
343 return OpTitlebarDblClick;
344 }
345
346 enum MouseCommand {
347 MouseRaise, MouseLower, MouseOperationsMenu, MouseToggleRaiseAndLower,
348 MouseActivateAndRaise, MouseActivateAndLower, MouseActivate,
349 MouseActivateRaiseAndPassClick, MouseActivateAndPassClick,
350 MouseMove, MouseUnrestrictedMove,
351 MouseActivateRaiseAndMove, MouseActivateRaiseAndUnrestrictedMove,
352 MouseResize, MouseUnrestrictedResize,
353 MouseShade, MouseSetShade, MouseUnsetShade,
354 MouseMaximize, MouseRestore, MouseMinimize,
355 MouseNextDesktop, MousePreviousDesktop,
356 MouseAbove, MouseBelow,
357 MouseOpacityMore, MouseOpacityLess,
358 MouseClose, MousePreviousTab, MouseNextTab, MouseDragTab,
359 MouseNothing
360 };
361
362 enum MouseWheelCommand {
363 MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore,
364 MouseWheelAboveBelow, MouseWheelPreviousNextDesktop,
365 MouseWheelChangeOpacity, MouseWheelChangeCurrentTab,
366 MouseWheelNothing
367 };
368
369 MouseCommand operationTitlebarMouseWheel(int delta) const {
370 return wheelToMouseCommand(CmdTitlebarWheel, delta);
371 }
372 MouseCommand operationWindowMouseWheel(int delta) const {
373 return wheelToMouseCommand(CmdAllWheel, delta);
374 }
375
376 MouseCommand commandActiveTitlebar1() const {
377 return CmdActiveTitlebar1;
378 }
379 MouseCommand commandActiveTitlebar2() const {
380 return CmdActiveTitlebar2;
381 }
382 MouseCommand commandActiveTitlebar3() const {
383 return CmdActiveTitlebar3;
384 }
385 MouseCommand commandInactiveTitlebar1() const {
386 return CmdInactiveTitlebar1;
387 }
388 MouseCommand commandInactiveTitlebar2() const {
389 return CmdInactiveTitlebar2;
390 }
391 MouseCommand commandInactiveTitlebar3() const {
392 return CmdInactiveTitlebar3;
393 }
394 MouseCommand commandWindow1() const {
395 return CmdWindow1;
396 }
397 MouseCommand commandWindow2() const {
398 return CmdWindow2;
399 }
400 MouseCommand commandWindow3() const {
401 return CmdWindow3;
402 }
403 MouseCommand commandWindowWheel() const {
404 return CmdWindowWheel;
405 }
406 MouseCommand commandAll1() const {
407 return CmdAll1;
408 }
409 MouseCommand commandAll2() const {
410 return CmdAll2;
411 }
412 MouseCommand commandAll3() const {
413 return CmdAll3;
414 }
415 uint keyCmdAllModKey() const {
416 return CmdAllModKey;
417 }
418
419 static WindowOperation windowOperation(const QString &name, bool restricted);
420 static MouseCommand mouseCommand(const QString &name, bool restricted);
421 static MouseWheelCommand mouseWheelCommand(const QString &name);
422
423 /**
424 * @returns true if the Geometry Tip should be shown during a window move/resize.
425 */
426 bool showGeometryTip() const;
427
428 /**
429 * returns whether the user prefers his caption clean
430 */
431 bool condensedTitle() const;
432
433 /**
434 * @returns true if a window gets maximized when it reaches top screen edge
435 * while being moved.
436 */
437 bool electricBorderMaximize() const {
438 return electric_border_maximize;
439 }
440 /**
441 * @returns true if window is tiled to half screen when reaching left or
442 * right screen edge while been moved
443 */
444 bool electricBorderTiling() const {
445 return electric_border_tiling;
446 }
447 /**
448 * @returns the factor that determines the corner part of the edge (ie. 0.1 means tiny corner)
449 */
450 float electricBorderCornerRatio() const {
451 return electric_border_corner_ratio;
452 }
453
454 bool borderlessMaximizedWindows() const {
455 return borderless_maximized_windows;
456 }
457
458 // timeout before non-responding application will be killed after attempt to close
459 int killPingTimeout() const {
460 return m_killPingTimeout;
461 }
462
463 // Whether to hide utility windows for inactive applications.
464 bool isHideUtilityWindowsForInactive() const {
465 return m_hideUtilityWindowsForInactive;
466 }
467
468 bool isInactiveTabsSkipTaskbar() const {
469 return m_inactiveTabsSkipTaskbar;
470 }
471 bool isAutogroupSimilarWindows() const {
472 return m_autogroupSimilarWindows;
473 }
474 bool isAutogroupInForeground() const {
475 return m_autogroupInForeground;
476 }
477
478 // Desktop effects
479 double animationTimeFactor() const;
480
481 //----------------------
482 // Compositing settings
483 void reloadCompositingSettings(bool force = false);
484 CompositingType compositingMode() const {
485 return m_compositingMode;
486 }
487 void setCompositingMode(CompositingType mode) {
488 m_compositingMode = mode;
489 }
490 // Separate to mode so the user can toggle
491 bool isUseCompositing() const {
492 return m_useCompositing;
493 }
494 bool isCompositingInitialized() const {
495 return m_compositingInitialized;
496 }
497
498 // General preferences
499 HiddenPreviews hiddenPreviews() const {
500 return m_hiddenPreviews;
501 }
502 bool isUnredirectFullscreen() const {
503 return m_unredirectFullscreen;
504 }
505 // OpenGL
506 // 0 = no, 1 = yes when transformed,
507 // 2 = try trilinear when transformed; else 1,
508 // -1 = auto
509 int glSmoothScale() const {
510 return m_glSmoothScale;
511 }
512 bool isColorCorrected() const {
513 return m_colorCorrected;
514 }
515 // XRender
516 bool isXrenderSmoothScale() const {
517 return m_xrenderSmoothScale;
518 }
519
520 qint64 maxFpsInterval() const {
521 return m_maxFpsInterval;
522 }
523 // Settings that should be auto-detected
524 uint refreshRate() const {
525 return m_refreshRate;
526 }
527 qint64 vBlankTime() const {
528 return m_vBlankTime;
529 }
530 bool isGlDirect() const {
531 return m_glDirect;
532 }
533 bool isGlStrictBinding() const {
534 return m_glStrictBinding;
535 }
536 bool isGlStrictBindingFollowsDriver() const {
537 return m_glStrictBindingFollowsDriver;
538 }
539 bool isGlLegacy() const {
540 return m_glLegacy;
541 }
542 bool glCoreProfile() const {
543 return m_glCoreProfile;
544 }
545
546 enum GlSwapStrategy { NoSwapEncourage = 0, CopyFrontBuffer = 'c', PaintFullScreen = 'p', ExtendDamage = 'e', AutoSwapStrategy = 'a' };
547 GlSwapStrategy glPreferBufferSwap() const {
548 return m_glPreferBufferSwap;
549 }
550
551 // setters
552 void setFocusPolicy(FocusPolicy focusPolicy);
553 void setNextFocusPrefersMouse(bool nextFocusPrefersMouse);
554 void setClickRaise(bool clickRaise);
555 void setAutoRaise(bool autoRaise);
556 void setAutoRaiseInterval(int autoRaiseInterval);
557 void setDelayFocusInterval(int delayFocusInterval);
558 void setShadeHover(bool shadeHover);
559 void setShadeHoverInterval(int shadeHoverInterval);
560 void setSeparateScreenFocus(bool separateScreenFocus);
561 void setPlacement(int placement);
562 void setBorderSnapZone(int borderSnapZone);
563 void setWindowSnapZone(int windowSnapZone);
564 void setCenterSnapZone(int centerSnapZone);
565 void setSnapOnlyWhenOverlapping(bool snapOnlyWhenOverlapping);
566 void setShowDesktopIsMinimizeAll(bool showDesktopIsMinimizeAll);
567 void setRollOverDesktops(bool rollOverDesktops);
568 void setFocusStealingPreventionLevel(int focusStealingPreventionLevel);
569 void setLegacyFullscreenSupport(bool legacyFullscreenSupport);
570 void setOperationTitlebarDblClick(WindowOperation operationTitlebarDblClick);
571 void setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1);
572 void setCommandActiveTitlebar2(MouseCommand commandActiveTitlebar2);
573 void setCommandActiveTitlebar3(MouseCommand commandActiveTitlebar3);
574 void setCommandInactiveTitlebar1(MouseCommand commandInactiveTitlebar1);
575 void setCommandInactiveTitlebar2(MouseCommand commandInactiveTitlebar2);
576 void setCommandInactiveTitlebar3(MouseCommand commandInactiveTitlebar3);
577 void setCommandWindow1(MouseCommand commandWindow1);
578 void setCommandWindow2(MouseCommand commandWindow2);
579 void setCommandWindow3(MouseCommand commandWindow3);
580 void setCommandWindowWheel(MouseCommand commandWindowWheel);
581 void setCommandAll1(MouseCommand commandAll1);
582 void setCommandAll2(MouseCommand commandAll2);
583 void setCommandAll3(MouseCommand commandAll3);
584 void setKeyCmdAllModKey(uint keyCmdAllModKey);
585 void setShowGeometryTip(bool showGeometryTip);
586 void setCondensedTitle(bool condensedTitle);
587 void setElectricBorderMaximize(bool electricBorderMaximize);
588 void setElectricBorderTiling(bool electricBorderTiling);
589 void setElectricBorderCornerRatio(float electricBorderCornerRatio);
590 void setBorderlessMaximizedWindows(bool borderlessMaximizedWindows);
591 void setKillPingTimeout(int killPingTimeout);
592 void setHideUtilityWindowsForInactive(bool hideUtilityWindowsForInactive);
593 void setInactiveTabsSkipTaskbar(bool inactiveTabsSkipTaskbar);
594 void setAutogroupSimilarWindows(bool autogroupSimilarWindows);
595 void setAutogroupInForeground(bool autogroupInForeground);
596 void setCompositingMode(int compositingMode);
597 void setUseCompositing(bool useCompositing);
598 void setCompositingInitialized(bool compositingInitialized);
599 void setHiddenPreviews(int hiddenPreviews);
600 void setUnredirectFullscreen(bool unredirectFullscreen);
601 void setGlSmoothScale(int glSmoothScale);
602 void setXrenderSmoothScale(bool xrenderSmoothScale);
603 void setMaxFpsInterval(qint64 maxFpsInterval);
604 void setRefreshRate(uint refreshRate);
605 void setVBlankTime(qint64 vBlankTime);
606 void setGlDirect(bool glDirect);
607 void setGlStrictBinding(bool glStrictBinding);
608 void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver);
609 void setGlLegacy(bool glLegacy);
610 void setGLCoreProfile(bool glCoreProfile);
611 void setGlPreferBufferSwap(char glPreferBufferSwap);
612
613 // default values
614 static WindowOperation defaultOperationTitlebarDblClick() {
615 return MaximizeOp;
616 }
617 static MouseCommand defaultCommandActiveTitlebar1() {
618 return MouseRaise;
619 }
620 static MouseCommand defaultCommandActiveTitlebar2() {
621 return MouseDragTab;
622 }
623 static MouseCommand defaultCommandActiveTitlebar3() {
624 return MouseOperationsMenu;
625 }
626 static MouseCommand defaultCommandInactiveTitlebar1() {
627 return MouseActivateAndRaise;
628 }
629 static MouseCommand defaultCommandInactiveTitlebar2() {
630 return MouseDragTab;
631 }
632 static MouseCommand defaultCommandInactiveTitlebar3() {
633 return MouseOperationsMenu;
634 }
635 static MouseCommand defaultCommandWindow1() {
636 return MouseActivateRaiseAndPassClick;
637 }
638 static MouseCommand defaultCommandWindow2() {
639 return MouseActivateAndPassClick;
640 }
641 static MouseCommand defaultCommandWindow3() {
642 return MouseActivateAndPassClick;
643 }
644 static MouseCommand defaultCommandWindowWheel() {
645 return MouseNothing;
646 }
647 static MouseCommand defaultCommandAll1() {
648 return MouseUnrestrictedMove;
649 }
650 static MouseCommand defaultCommandAll2() {
651 return MouseToggleRaiseAndLower;
652 }
653 static MouseCommand defaultCommandAll3() {
654 return MouseUnrestrictedResize;
655 }
656 static MouseWheelCommand defaultCommandTitlebarWheel() {
657 return MouseWheelChangeCurrentTab;
658 }
659 static MouseWheelCommand defaultCommandAllWheel() {
660 return MouseWheelNothing;
661 }
662 static uint defaultKeyCmdAllModKey() {
663 return Qt::Key_Alt;
664 }
665 static bool defaultAutogroupInForeground() {
666 return true;
667 }
668 static CompositingType defaultCompositingMode() {
669 return OpenGLCompositing;
670 }
671 static bool defaultUseCompositing() {
672 return true;
673 }
674 static bool defaultCompositingInitialized() {
675 return false;
676 }
677 static HiddenPreviews defaultHiddenPreviews() {
678 return HiddenPreviewsShown;
679 }
680 static bool defaultUnredirectFullscreen() {
681 return false;
682 }
683 static int defaultGlSmoothScale() {
684 return 2;
685 }
686 static bool defaultColorCorrected() {
687 return false;
688 }
689 static bool defaultXrenderSmoothScale() {
690 return false;
691 }
692 static qint64 defaultMaxFpsInterval() {
693 return (1 * 1000 * 1000 * 1000) /60.0; // nanoseconds / Hz
694 }
695 static int defaultMaxFps() {
696 return 60;
697 }
698 static uint defaultRefreshRate() {
699 return 0;
700 }
701 static uint defaultVBlankTime() {
702 return 6000; // 6ms
703 }
704 static bool defaultGlDirect() {
705 return true;
706 }
707 static bool defaultGlStrictBinding() {
708 return true;
709 }
710 static bool defaultGlStrictBindingFollowsDriver() {
711 return true;
712 }
713 static bool defaultGlLegacy() {
714 return false;
715 }
716 static bool defaultGLCoreProfile() {
717 return false;
718 }
719 static GlSwapStrategy defaultGlPreferBufferSwap() {
720 return AutoSwapStrategy;
721 }
722 static int defaultAnimationSpeed() {
723 return 3;
724 }
725
726 /**
727 * Performs loading all settings except compositing related.
728 **/
729 unsigned long loadConfig();
730 /**
731 * Performs loading of compositing settings which do not depend on OpenGL.
732 **/
733 bool loadCompositingConfig(bool force);
734 void reparseConfiguration();
735
736 //----------------------
737Q_SIGNALS:
738 void configChanged();
739
740 // for properties
741 void focusPolicyChanged();
742 void nextFocusPrefersMouseChanged();
743 void clickRaiseChanged();
744 void autoRaiseChanged();
745 void autoRaiseIntervalChanged();
746 void delayFocusIntervalChanged();
747 void shadeHoverChanged();
748 void shadeHoverIntervalChanged();
749 void separateScreenFocusChanged(bool);
750 void placementChanged();
751 void borderSnapZoneChanged();
752 void windowSnapZoneChanged();
753 void centerSnapZoneChanged();
754 void snapOnlyWhenOverlappingChanged();
755 void showDesktopIsMinimizeAllChanged();
756 void rollOverDesktopsChanged(bool enabled);
757 void focusStealingPreventionLevelChanged();
758 void legacyFullscreenSupportChanged();
759 void operationTitlebarDblClickChanged();
760 void commandActiveTitlebar1Changed();
761 void commandActiveTitlebar2Changed();
762 void commandActiveTitlebar3Changed();
763 void commandInactiveTitlebar1Changed();
764 void commandInactiveTitlebar2Changed();
765 void commandInactiveTitlebar3Changed();
766 void commandWindow1Changed();
767 void commandWindow2Changed();
768 void commandWindow3Changed();
769 void commandWindowWheelChanged();
770 void commandAll1Changed();
771 void commandAll2Changed();
772 void commandAll3Changed();
773 void keyCmdAllModKeyChanged();
774 void showGeometryTipChanged();
775 void condensedTitleChanged();
776 void electricBorderMaximizeChanged();
777 void electricBorderTilingChanged();
778 void electricBorderCornerRatioChanged();
779 void borderlessMaximizedWindowsChanged();
780 void killPingTimeoutChanged();
781 void hideUtilityWindowsForInactiveChanged();
782 void inactiveTabsSkipTaskbarChanged();
783 void autogroupSimilarWindowsChanged();
784 void autogroupInForegroundChanged();
785 void compositingModeChanged();
786 void useCompositingChanged();
787 void compositingInitializedChanged();
788 void hiddenPreviewsChanged();
789 void unredirectFullscreenChanged();
790 void glSmoothScaleChanged();
791 void colorCorrectedChanged();
792 void xrenderSmoothScaleChanged();
793 void maxFpsIntervalChanged();
794 void refreshRateChanged();
795 void vBlankTimeChanged();
796 void glDirectChanged();
797 void glStrictBindingChanged();
798 void glStrictBindingFollowsDriverChanged();
799 void glLegacyChanged();
800 void glCoreProfileChanged();
801 void glPreferBufferSwapChanged();
802
803public Q_SLOTS:
804 void setColorCorrected(bool colorCorrected = false);
805
806private:
807 void setElectricBorders(int borders);
808 void syncFromKcfgc();
809 QScopedPointer<Settings> m_settings;
810 FocusPolicy m_focusPolicy;
811 bool m_nextFocusPrefersMouse;
812 bool m_clickRaise;
813 bool m_autoRaise;
814 int m_autoRaiseInterval;
815 int m_delayFocusInterval;
816 bool m_shadeHover;
817 int m_shadeHoverInterval;
818 bool m_separateScreenFocus;
819 Placement::Policy m_placement;
820 int m_borderSnapZone;
821 int m_windowSnapZone;
822 int m_centerSnapZone;
823 bool m_snapOnlyWhenOverlapping;
824 bool m_showDesktopIsMinimizeAll;
825 bool m_rollOverDesktops;
826 int m_focusStealingPreventionLevel;
827 bool m_legacyFullscreenSupport;
828 int m_killPingTimeout;
829 bool m_hideUtilityWindowsForInactive;
830 bool m_inactiveTabsSkipTaskbar;
831 bool m_autogroupSimilarWindows;
832 bool m_autogroupInForeground;
833
834 CompositingType m_compositingMode;
835 bool m_useCompositing;
836 bool m_compositingInitialized;
837 HiddenPreviews m_hiddenPreviews;
838 bool m_unredirectFullscreen;
839 int m_glSmoothScale;
840 bool m_colorCorrected;
841 bool m_xrenderSmoothScale;
842 qint64 m_maxFpsInterval;
843 // Settings that should be auto-detected
844 uint m_refreshRate;
845 qint64 m_vBlankTime;
846 bool m_glDirect;
847 bool m_glStrictBinding;
848 bool m_glStrictBindingFollowsDriver;
849 bool m_glLegacy;
850 bool m_glCoreProfile;
851 GlSwapStrategy m_glPreferBufferSwap;
852
853 WindowOperation OpTitlebarDblClick;
854
855 // mouse bindings
856 MouseCommand CmdActiveTitlebar1;
857 MouseCommand CmdActiveTitlebar2;
858 MouseCommand CmdActiveTitlebar3;
859 MouseCommand CmdInactiveTitlebar1;
860 MouseCommand CmdInactiveTitlebar2;
861 MouseCommand CmdInactiveTitlebar3;
862 MouseWheelCommand CmdTitlebarWheel;
863 MouseCommand CmdWindow1;
864 MouseCommand CmdWindow2;
865 MouseCommand CmdWindow3;
866 MouseCommand CmdWindowWheel;
867 MouseCommand CmdAll1;
868 MouseCommand CmdAll2;
869 MouseCommand CmdAll3;
870 MouseWheelCommand CmdAllWheel;
871 uint CmdAllModKey;
872
873 bool electric_border_maximize;
874 bool electric_border_tiling;
875 float electric_border_corner_ratio;
876 bool borderless_maximized_windows;
877 bool show_geometry_tip;
878 bool condensed_title;
879 int animationSpeed; // 0 - instant, 5 - very slow
880
881 MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const;
882};
883
884extern Options* options;
885
886} // namespace
887
888#endif
889