Use setters for parsing the config options
Use setter when changing a value to ensure that signal gets emitted and the option dependencies are applied. Also use the default values as provided by the static getters. REVIEW: 104561
This commit is contained in:
parent
53a36b3757
commit
5c71a75e8e
2 changed files with 101 additions and 100 deletions
200
options.cpp
200
options.cpp
|
@ -4,6 +4,7 @@
|
|||
|
||||
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
||||
Copyright (C) 2012 Martin Gräßlin <m.graesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -787,68 +788,59 @@ unsigned long Options::updateSettings()
|
|||
changed |= KDecorationOptions::updateSettings(_config.data()); // read decoration settings
|
||||
|
||||
KConfigGroup config(_config, "Windows");
|
||||
show_geometry_tip = config.readEntry("GeometryTip", false);
|
||||
setShowGeometryTip(config.readEntry("GeometryTip", Options::defaultShowGeometryTip()));
|
||||
|
||||
QString val;
|
||||
|
||||
val = config.readEntry("FocusPolicy", "ClickToFocus");
|
||||
m_focusPolicy = ClickToFocus; // what a default :-)
|
||||
if (val == "FocusFollowsMouse")
|
||||
m_focusPolicy = FocusFollowsMouse;
|
||||
else if (val == "FocusUnderMouse")
|
||||
m_focusPolicy = FocusUnderMouse;
|
||||
else if (val == "FocusStrictlyUnderMouse")
|
||||
m_focusPolicy = FocusStrictlyUnderMouse;
|
||||
|
||||
m_nextFocusPrefersMouse = config.readEntry("NextFocusPrefersMouse", false);
|
||||
|
||||
m_separateScreenFocus = config.readEntry("SeparateScreenFocus", false);
|
||||
m_activeMouseScreen = config.readEntry("ActiveMouseScreen", m_focusPolicy != ClickToFocus);
|
||||
|
||||
m_rollOverDesktops = config.readEntry("RollOverDesktops", true);
|
||||
|
||||
m_legacyFullscreenSupport = config.readEntry("LegacyFullscreenSupport", false);
|
||||
|
||||
// focusStealingPreventionLevel = config.readEntry( "FocusStealingPreventionLevel", 2 );
|
||||
// TODO use low level for now
|
||||
m_focusStealingPreventionLevel = config.readEntry("FocusStealingPreventionLevel", 1);
|
||||
m_focusStealingPreventionLevel = qMax(0, qMin(4, m_focusStealingPreventionLevel));
|
||||
if (!focusPolicyIsReasonable()) // #48786, comments #7 and later
|
||||
m_focusStealingPreventionLevel = 0;
|
||||
|
||||
#ifdef KWIN_BUILD_DECORATIONS
|
||||
m_placement = Placement::policyFromString(config.readEntry("Placement"), true);
|
||||
#else
|
||||
m_placement = Placement::Maximizing;
|
||||
#endif
|
||||
|
||||
if (m_focusPolicy == ClickToFocus) {
|
||||
m_autoRaise = false;
|
||||
m_autoRaiseInterval = 0;
|
||||
m_delayFocusInterval = 0;
|
||||
if (val == "FocusFollowsMouse") {
|
||||
setFocusPolicy(FocusFollowsMouse);
|
||||
} else if (val == "FocusUnderMouse") {
|
||||
setFocusPolicy(FocusUnderMouse);
|
||||
} else if (val == "FocusStrictlyUnderMouse") {
|
||||
setFocusPolicy(FocusStrictlyUnderMouse);
|
||||
} else {
|
||||
m_autoRaise = config.readEntry("AutoRaise", false);
|
||||
m_autoRaiseInterval = config.readEntry("AutoRaiseInterval", 0);
|
||||
m_delayFocusInterval = config.readEntry("DelayFocusInterval", 0);
|
||||
setFocusPolicy(Options::defaultFocusPolicy());
|
||||
}
|
||||
|
||||
m_shadeHover = config.readEntry("ShadeHover", false);
|
||||
m_shadeHoverInterval = config.readEntry("ShadeHoverInterval", 250);
|
||||
setNextFocusPrefersMouse(config.readEntry("NextFocusPrefersMouse", Options::defaultNextFocusPrefersMouse()));
|
||||
|
||||
m_tilingOn = config.readEntry("TilingOn", false);
|
||||
m_tilingLayout = static_cast<TilingLayoutFactory::Layouts>(config.readEntry("TilingDefaultLayout", 0));
|
||||
m_tilingRaisePolicy = config.readEntry("TilingRaisePolicy", 0);
|
||||
setSeparateScreenFocus(config.readEntry("SeparateScreenFocus", Options::defaultSeparateScreenFocus()));
|
||||
setActiveMouseScreen(config.readEntry("ActiveMouseScreen", m_focusPolicy != ClickToFocus));
|
||||
|
||||
// important: autoRaise implies ClickRaise
|
||||
m_clickRaise = m_autoRaise || config.readEntry("ClickRaise", true);
|
||||
setRollOverDesktops(config.readEntry("RollOverDesktops", Options::defaultRollOverDesktops()));
|
||||
|
||||
m_borderSnapZone = config.readEntry("BorderSnapZone", 10);
|
||||
m_windowSnapZone = config.readEntry("WindowSnapZone", 10);
|
||||
m_centerSnapZone = config.readEntry("CenterSnapZone", 0);
|
||||
m_snapOnlyWhenOverlapping = config.readEntry("SnapOnlyWhenOverlapping", false);
|
||||
setLegacyFullscreenSupport(config.readEntry("LegacyFullscreenSupport", Options::defaultLegacyFullscreenSupport()));
|
||||
|
||||
setFocusStealingPreventionLevel(config.readEntry("FocusStealingPreventionLevel", Options::defaultFocusStealingPreventionLevel()));
|
||||
|
||||
#ifdef KWIN_BUILD_DECORATIONS
|
||||
setPlacement(Placement::policyFromString(config.readEntry("Placement"), true));
|
||||
#else
|
||||
setPlacement(Placement::Maximizing);
|
||||
#endif
|
||||
|
||||
setAutoRaise(config.readEntry("AutoRaise", Options::defaultAutoRaise()));
|
||||
setAutoRaiseInterval(config.readEntry("AutoRaiseInterval", Options::defaultAutoRaiseInterval()));
|
||||
setDelayFocusInterval(config.readEntry("DelayFocusInterval", Options::defaultDelayFocusInterval()));
|
||||
|
||||
setShadeHover(config.readEntry("ShadeHover", Options::defaultShadeHover()));
|
||||
setShadeHoverInterval(config.readEntry("ShadeHoverInterval", Options::defaultShadeHoverInterval()));
|
||||
|
||||
setTiling(config.readEntry("TilingOn", Options::defaultTiling()));
|
||||
setTilingLayout(config.readEntry<int>("TilingDefaultLayout", Options::defaultTilingLayout()));
|
||||
setTilingRaisePolicy(config.readEntry("TilingRaisePolicy", Options::defaultTilingRaisePolicy()));
|
||||
|
||||
setClickRaise(config.readEntry("ClickRaise", Options::defaultClickRaise()));
|
||||
|
||||
setBorderSnapZone(config.readEntry("BorderSnapZone", Options::defaultBorderSnapZone()));
|
||||
setWindowSnapZone(config.readEntry("WindowSnapZone", Options::defaultWindowSnapZone()));
|
||||
setCenterSnapZone(config.readEntry("CenterSnapZone", Options::defaultCenterSnapZone()));
|
||||
setSnapOnlyWhenOverlapping(config.readEntry("SnapOnlyWhenOverlapping", Options::defaultSnapOnlyWhenOverlapping()));
|
||||
|
||||
// Electric borders
|
||||
KConfigGroup borderConfig(_config, "ElectricBorders");
|
||||
// TODO: add setters
|
||||
electric_border_top = electricBorderAction(borderConfig.readEntry("Top", "None"));
|
||||
electric_border_top_right = electricBorderAction(borderConfig.readEntry("TopRight", "None"));
|
||||
electric_border_right = electricBorderAction(borderConfig.readEntry("Right", "None"));
|
||||
|
@ -857,49 +849,51 @@ unsigned long Options::updateSettings()
|
|||
electric_border_bottom_left = electricBorderAction(borderConfig.readEntry("BottomLeft", "None"));
|
||||
electric_border_left = electricBorderAction(borderConfig.readEntry("Left", "None"));
|
||||
electric_border_top_left = electricBorderAction(borderConfig.readEntry("TopLeft", "None"));
|
||||
electric_borders = config.readEntry("ElectricBorders", 0);
|
||||
electric_border_delay = config.readEntry("ElectricBorderDelay", 150);
|
||||
electric_border_cooldown = config.readEntry("ElectricBorderCooldown", 350);
|
||||
electric_border_pushback_pixels = config.readEntry("ElectricBorderPushbackPixels", 1);
|
||||
electric_border_maximize = config.readEntry("ElectricBorderMaximize", true);
|
||||
electric_border_tiling = config.readEntry("ElectricBorderTiling", true);
|
||||
setElectricBorders(config.readEntry("ElectricBorders", Options::defaultElectricBorders()));
|
||||
setElectricBorderDelay(config.readEntry("ElectricBorderDelay", Options::defaultElectricBorderDelay()));
|
||||
setElectricBorderCooldown(config.readEntry("ElectricBorderCooldown", Options::defaultElectricBorderCooldown()));
|
||||
setElectricBorderPushbackPixels(config.readEntry("ElectricBorderPushbackPixels", Options::defaultElectricBorderPushbackPixels()));
|
||||
setElectricBorderMaximize(config.readEntry("ElectricBorderMaximize", Options::defaultElectricBorderMaximize()));
|
||||
setElectricBorderTiling(config.readEntry("ElectricBorderTiling", Options::defaultElectricBorderTiling()));
|
||||
|
||||
OpTitlebarDblClick = windowOperation(config.readEntry("TitlebarDoubleClickCommand", "Maximize"), true);
|
||||
setOpMaxButtonLeftClick(windowOperation(config.readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true));
|
||||
setOpMaxButtonMiddleClick(windowOperation(config.readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true));
|
||||
setOpMaxButtonRightClick(windowOperation(config.readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true));
|
||||
|
||||
m_killPingTimeout = config.readEntry("KillPingTimeout", 5000);
|
||||
m_hideUtilityWindowsForInactive = config.readEntry("HideUtilityWindowsForInactive", true);
|
||||
m_inactiveTabsSkipTaskbar = config.readEntry("InactiveTabsSkipTaskbar", false);
|
||||
m_autogroupSimilarWindows = config.readEntry("AutogroupSimilarWindows", false);
|
||||
m_autogroupInForeground = config.readEntry("AutogroupInForeground", true);
|
||||
m_showDesktopIsMinimizeAll = config.readEntry("ShowDesktopIsMinimizeAll", false);
|
||||
setKillPingTimeout(config.readEntry("KillPingTimeout", Options::defaultKillPingTimeout()));
|
||||
setHideUtilityWindowsForInactive(config.readEntry("HideUtilityWindowsForInactive", Options::defaultHideUtilityWindowsForInactive()));
|
||||
setInactiveTabsSkipTaskbar(config.readEntry("InactiveTabsSkipTaskbar", Options::defaultInactiveTabsSkipTaskbar()));
|
||||
setAutogroupSimilarWindows(config.readEntry("AutogroupSimilarWindows", Options::defaultAutogroupSimilarWindows()));
|
||||
setAutogroupInForeground(config.readEntry("AutogroupInForeground", Options::defaultAutogroupInForeground()));
|
||||
setShowDesktopIsMinimizeAll(config.readEntry("ShowDesktopIsMinimizeAll", Options::defaultShowDesktopIsMinimizeAll()));
|
||||
|
||||
borderless_maximized_windows = config.readEntry("BorderlessMaximizedWindows", false);
|
||||
setBorderlessMaximizedWindows(config.readEntry("BorderlessMaximizedWindows", Options::defaultBorderlessMaximizedWindows()));
|
||||
|
||||
// Mouse bindings
|
||||
config = KConfigGroup(_config, "MouseBindings");
|
||||
CmdActiveTitlebar1 = mouseCommand(config.readEntry("CommandActiveTitlebar1", "Raise"), true);
|
||||
CmdActiveTitlebar2 = mouseCommand(config.readEntry("CommandActiveTitlebar2", "Start Window Tab Drag"), true);
|
||||
CmdActiveTitlebar3 = mouseCommand(config.readEntry("CommandActiveTitlebar3", "Operations menu"), true);
|
||||
CmdInactiveTitlebar1 = mouseCommand(config.readEntry("CommandInactiveTitlebar1", "Activate and raise"), true);
|
||||
CmdInactiveTitlebar2 = mouseCommand(config.readEntry("CommandInactiveTitlebar2", "Start Window Tab Drag"), true);
|
||||
CmdInactiveTitlebar3 = mouseCommand(config.readEntry("CommandInactiveTitlebar3", "Operations menu"), true);
|
||||
// TODO: add properties for missing options
|
||||
CmdTitlebarWheel = mouseWheelCommand(config.readEntry("CommandTitlebarWheel", "Switch to Window Tab to the Left/Right"));
|
||||
CmdWindow1 = mouseCommand(config.readEntry("CommandWindow1", "Activate, raise and pass click"), false);
|
||||
CmdWindow2 = mouseCommand(config.readEntry("CommandWindow2", "Activate and pass click"), false);
|
||||
CmdWindow3 = mouseCommand(config.readEntry("CommandWindow3", "Activate and pass click"), false);
|
||||
CmdWindowWheel = mouseCommand(config.readEntry("CommandWindowWheel", "Scroll"), false);
|
||||
CmdAllModKey = (config.readEntry("CommandAllKey", "Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
|
||||
CmdAll1 = mouseCommand(config.readEntry("CommandAll1", "Move"), false);
|
||||
CmdAll2 = mouseCommand(config.readEntry("CommandAll2", "Toggle raise and lower"), false);
|
||||
CmdAll3 = mouseCommand(config.readEntry("CommandAll3", "Resize"), false);
|
||||
CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel", "Nothing"));
|
||||
setCommandActiveTitlebar1(mouseCommand(config.readEntry("CommandActiveTitlebar1", "Raise"), true));
|
||||
setCommandActiveTitlebar2(mouseCommand(config.readEntry("CommandActiveTitlebar2", "Start Window Tab Drag"), true));
|
||||
setCommandActiveTitlebar3(mouseCommand(config.readEntry("CommandActiveTitlebar3", "Operations menu"), true));
|
||||
setCommandInactiveTitlebar1(mouseCommand(config.readEntry("CommandInactiveTitlebar1", "Activate and raise"), true));
|
||||
setCommandInactiveTitlebar2(mouseCommand(config.readEntry("CommandInactiveTitlebar2", "Start Window Tab Drag"), true));
|
||||
setCommandInactiveTitlebar3(mouseCommand(config.readEntry("CommandInactiveTitlebar3", "Operations menu"), true));
|
||||
setCommandWindow1(mouseCommand(config.readEntry("CommandWindow1", "Activate, raise and pass click"), false));
|
||||
setCommandWindow2(mouseCommand(config.readEntry("CommandWindow2", "Activate and pass click"), false));
|
||||
setCommandWindow3(mouseCommand(config.readEntry("CommandWindow3", "Activate and pass click"), false));
|
||||
setCommandWindowWheel(mouseCommand(config.readEntry("CommandWindowWheel", "Scroll"), false));
|
||||
setCommandAll1(mouseCommand(config.readEntry("CommandAll1", "Move"), false));
|
||||
setCommandAll2(mouseCommand(config.readEntry("CommandAll2", "Toggle raise and lower"), false));
|
||||
setCommandAll3(mouseCommand(config.readEntry("CommandAll3", "Resize"), false));
|
||||
|
||||
// TODO: should they be moved into reloadCompositingSettings?
|
||||
config = KConfigGroup(_config, "Compositing");
|
||||
m_maxFpsInterval = qRound(1000.0 / config.readEntry("MaxFPS", 60));
|
||||
m_refreshRate = config.readEntry("RefreshRate", 0);
|
||||
setMaxFpsInterval(qRound(1000.0 / config.readEntry("MaxFPS", Options::defaultMaxFps())));
|
||||
setRefreshRate(config.readEntry("RefreshRate", Options::defaultRefreshRate()));
|
||||
|
||||
// Read button tooltip animation effect from kdeglobals
|
||||
// Since we want to allow users to enable window decoration tooltips
|
||||
|
@ -911,7 +905,7 @@ unsigned long Options::updateSettings()
|
|||
// KDE4 this probably needs to be done manually in clients
|
||||
|
||||
// Driver-specific config detection
|
||||
m_compositingInitialized = false;
|
||||
setCompositingInitialized(false);
|
||||
reloadCompositingSettings();
|
||||
|
||||
emit configChanged();
|
||||
|
@ -924,75 +918,81 @@ void Options::reloadCompositingSettings(bool force)
|
|||
KSharedConfig::Ptr _config = KGlobal::config();
|
||||
KConfigGroup config(_config, "Compositing");
|
||||
|
||||
bool useCompositing = false;
|
||||
CompositingType compositingMode = NoCompositing;
|
||||
QString compositingBackend = config.readEntry("Backend", "OpenGL");
|
||||
if (compositingBackend == "XRender")
|
||||
m_compositingMode = XRenderCompositing;
|
||||
compositingMode = XRenderCompositing;
|
||||
else
|
||||
m_compositingMode = OpenGLCompositing;
|
||||
compositingMode = OpenGLCompositing;
|
||||
|
||||
m_useCompositing = false;
|
||||
if (const char *c = getenv("KWIN_COMPOSE")) {
|
||||
switch(c[0]) {
|
||||
case 'O':
|
||||
kDebug(1212) << "Compositing forced to OpenGL mode by environment variable";
|
||||
m_compositingMode = OpenGLCompositing;
|
||||
m_useCompositing = true;
|
||||
compositingMode = OpenGLCompositing;
|
||||
useCompositing = true;
|
||||
break;
|
||||
case 'X':
|
||||
kDebug(1212) << "Compositing forced to XRender mode by environment variable";
|
||||
m_compositingMode = XRenderCompositing;
|
||||
m_useCompositing = true;
|
||||
compositingMode = XRenderCompositing;
|
||||
useCompositing = true;
|
||||
break;
|
||||
case 'N':
|
||||
if (getenv("KDE_FAILSAFE"))
|
||||
kDebug(1212) << "Compositing disabled forcefully by KDE failsafe mode";
|
||||
else
|
||||
kDebug(1212) << "Compositing disabled forcefully by environment variable";
|
||||
m_compositingMode = NoCompositing;
|
||||
compositingMode = NoCompositing;
|
||||
break;
|
||||
default:
|
||||
kDebug(1212) << "Unknown KWIN_COMPOSE mode set, ignoring";
|
||||
break;
|
||||
}
|
||||
}
|
||||
setCompositingMode(compositingMode);
|
||||
|
||||
if (m_compositingMode == NoCompositing)
|
||||
if (m_compositingMode == NoCompositing) {
|
||||
setUseCompositing(false);
|
||||
return; // do not even detect compositing preferences if explicitly disabled
|
||||
}
|
||||
|
||||
// it's either enforced by env or by initial resume from "suspend" or we check the settings
|
||||
m_useCompositing = m_useCompositing || force || config.readEntry("Enabled", true);
|
||||
setUseCompositing(useCompositing || force || config.readEntry("Enabled", Options::defaultUseCompositing()));
|
||||
|
||||
if (!m_useCompositing)
|
||||
return; // not enforced or necessary and not "enabled" by setting
|
||||
|
||||
// from now on we've an initial setup and don't have to reload settings on compositing activation
|
||||
// see Workspace::setupCompositing(), composite.cpp
|
||||
m_compositingInitialized = true;
|
||||
setCompositingInitialized(true);
|
||||
|
||||
// Compositing settings
|
||||
CompositingPrefs prefs;
|
||||
prefs.detect();
|
||||
|
||||
m_useCompositing = config.readEntry("Enabled" , prefs.recommendCompositing());
|
||||
m_glDirect = prefs.enableDirectRendering();
|
||||
m_glVSync = config.readEntry("GLVSync", prefs.enableVSync());
|
||||
m_glSmoothScale = qBound(-1, config.readEntry("GLTextureFilter", 2), 2);
|
||||
m_glStrictBinding = config.readEntry("GLStrictBinding", prefs.strictBinding());
|
||||
setUseCompositing(config.readEntry("Enabled" , prefs.recommendCompositing()));
|
||||
setGlDirect(prefs.enableDirectRendering());
|
||||
setGlVSync(config.readEntry("GLVSync", prefs.enableVSync()));
|
||||
setGlSmoothScale(qBound(-1, config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), 2));
|
||||
setGlStrictBinding(config.readEntry("GLStrictBinding", prefs.strictBinding()));
|
||||
|
||||
m_xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false);
|
||||
|
||||
m_hiddenPreviews = HiddenPreviewsShown;
|
||||
HiddenPreviews previews = Options::defaultHiddenPreviews();
|
||||
// 4 - off, 5 - shown, 6 - always, other are old values
|
||||
int hps = config.readEntry("HiddenPreviews", 5);
|
||||
if (hps == 4)
|
||||
m_hiddenPreviews = HiddenPreviewsNever;
|
||||
previews = HiddenPreviewsNever;
|
||||
else if (hps == 5)
|
||||
m_hiddenPreviews = HiddenPreviewsShown;
|
||||
previews = HiddenPreviewsShown;
|
||||
else if (hps == 6)
|
||||
m_hiddenPreviews = HiddenPreviewsAlways;
|
||||
previews = HiddenPreviewsAlways;
|
||||
setHiddenPreviews(previews);
|
||||
|
||||
m_unredirectFullscreen = config.readEntry("UnredirectFullscreen", false);
|
||||
animationSpeed = qBound(0, config.readEntry("AnimationSpeed", 3), 6);
|
||||
setUnredirectFullscreen(config.readEntry("UnredirectFullscreen", Options::defaultUnredirectFullscreen()));
|
||||
// TOOD: add setter
|
||||
animationSpeed = qBound(0, config.readEntry("AnimationSpeed", Options::defaultAnimationSpeed()), 6);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
||||
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
||||
Copyright (C) 2012 Martin Gräßlin <m.graesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
Loading…
Reference in a new issue