2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "options.h"
|
2011-04-29 10:46:04 +00:00
|
|
|
#include "config-kwin.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KCMRULES
|
|
|
|
|
|
|
|
#include <QPalette>
|
|
|
|
#include <QPixmap>
|
2010-11-27 15:27:54 +00:00
|
|
|
#include <QProcess>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <kapplication.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <kglobalsettings.h>
|
2010-11-27 22:09:08 +00:00
|
|
|
#include <klocale.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <QDesktopWidget>
|
|
|
|
|
|
|
|
#include "client.h"
|
2007-09-18 13:59:06 +00:00
|
|
|
#include "compositingprefs.h"
|
2011-02-19 08:58:44 +00:00
|
|
|
#include <kwinglplatform.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-11-15 11:38:26 +00:00
|
|
|
#include <kephal/screens.h>
|
|
|
|
|
2010-11-27 15:27:54 +00:00
|
|
|
#include <X11/extensions/Xrandr.h>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef KCMRULES
|
|
|
|
|
2010-11-27 15:27:54 +00:00
|
|
|
int currentRefreshRate()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-11-27 15:27:54 +00:00
|
|
|
int rate = -1;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (options->refreshRate > 0) // use manually configured refresh rate
|
2010-11-27 15:27:54 +00:00
|
|
|
rate = options->refreshRate;
|
2010-12-05 09:29:40 +00:00
|
|
|
#ifndef KWIN_HAVE_OPENGLES
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (GLPlatform::instance()->driver() == Driver_NVidia) {
|
2010-11-27 15:27:54 +00:00
|
|
|
QProcess nvidia_settings;
|
2011-01-30 14:34:42 +00:00
|
|
|
nvidia_settings.start("nvidia-settings", QStringList() << "-t" << "-q" << "RefreshRate", QIODevice::ReadOnly);
|
2010-11-27 15:27:54 +00:00
|
|
|
nvidia_settings.waitForFinished();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (nvidia_settings.exitStatus() == QProcess::NormalExit) {
|
|
|
|
QString reply = QString::fromLocal8Bit(nvidia_settings.readAllStandardOutput());
|
2010-11-27 15:27:54 +00:00
|
|
|
bool ok;
|
2011-01-30 14:34:42 +00:00
|
|
|
const float frate = reply.split(' ').first().toFloat(&ok);
|
|
|
|
if (!ok)
|
2010-11-27 15:27:54 +00:00
|
|
|
rate = -1;
|
2010-12-18 16:51:43 +00:00
|
|
|
else
|
|
|
|
rate = qRound(frate);
|
2010-11-27 15:27:54 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-12-27 19:12:37 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (Extensions::randrAvailable()) {
|
|
|
|
XRRScreenConfiguration *config = XRRGetScreenInfo(display(), rootWindow());
|
|
|
|
rate = XRRConfigCurrentRate(config);
|
|
|
|
XRRFreeScreenConfigInfo(config);
|
|
|
|
}
|
|
|
|
|
2010-11-27 15:27:54 +00:00
|
|
|
// 0Hz or less is invalid, so we fallback to a default rate
|
2011-01-30 14:34:42 +00:00
|
|
|
if (rate <= 0)
|
2010-11-27 15:27:54 +00:00
|
|
|
rate = 50;
|
|
|
|
// QTimer gives us 1msec (1000Hz) at best, so we ignore anything higher;
|
|
|
|
// however, additional throttling prevents very high rates from taking place anyway
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (rate > 1000)
|
2010-11-27 15:27:54 +00:00
|
|
|
rate = 1000;
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "Refresh rate " << rate << "Hz";
|
2010-11-27 15:27:54 +00:00
|
|
|
return rate;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-27 15:27:54 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
Options::Options()
|
2011-01-30 14:34:42 +00:00
|
|
|
: electric_borders(0)
|
|
|
|
, electric_border_delay(0)
|
|
|
|
{
|
2011-02-27 22:39:32 +00:00
|
|
|
compositingInitialized = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
updateSettings();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Options::~Options()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
unsigned long Options::updateSettings()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
KSharedConfig::Ptr _config = KGlobal::config();
|
2009-12-04 08:50:13 +00:00
|
|
|
unsigned long changed = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
changed |= KDecorationOptions::updateSettings(_config.data()); // read decoration settings
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup config(_config, "Windows");
|
2007-04-29 17:35:43 +00:00
|
|
|
show_geometry_tip = config.readEntry("GeometryTip", false);
|
|
|
|
|
|
|
|
QString val;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
val = config.readEntry("FocusPolicy", "ClickToFocus");
|
2007-04-29 17:35:43 +00:00
|
|
|
focusPolicy = ClickToFocus; // what a default :-)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (val == "FocusFollowsMouse")
|
2007-04-29 17:35:43 +00:00
|
|
|
focusPolicy = FocusFollowsMouse;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (val == "FocusUnderMouse")
|
2007-04-29 17:35:43 +00:00
|
|
|
focusPolicy = FocusUnderMouse;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (val == "FocusStrictlyUnderMouse")
|
2007-04-29 17:35:43 +00:00
|
|
|
focusPolicy = FocusStrictlyUnderMouse;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
separateScreenFocus = config.readEntry("SeparateScreenFocus", false);
|
|
|
|
activeMouseScreen = config.readEntry("ActiveMouseScreen", focusPolicy != ClickToFocus);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
rollOverDesktops = config.readEntry("RollOverDesktops", true);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
legacyFullscreenSupport = config.readEntry("LegacyFullscreenSupport", false);
|
2009-09-08 20:19:20 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// focusStealingPreventionLevel = config.readEntry( "FocusStealingPreventionLevel", 2 );
|
|
|
|
// TODO use low level for now
|
2011-01-30 14:34:42 +00:00
|
|
|
focusStealingPreventionLevel = config.readEntry("FocusStealingPreventionLevel", 1);
|
|
|
|
focusStealingPreventionLevel = qMax(0, qMin(4, focusStealingPreventionLevel));
|
|
|
|
if (!focusPolicyIsReasonable()) // #48786, comments #7 and later
|
2007-04-29 17:35:43 +00:00
|
|
|
focusStealingPreventionLevel = 0;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
xineramaEnabled = config.readEntry("XineramaEnabled", true);
|
|
|
|
xineramaPlacementEnabled = config.readEntry("XineramaPlacementEnabled", true);
|
|
|
|
xineramaMovementEnabled = config.readEntry("XineramaMovementEnabled", true);
|
|
|
|
xineramaMaximizeEnabled = config.readEntry("XineramaMaximizeEnabled", true);
|
|
|
|
xineramaFullscreenEnabled = config.readEntry("XineramaFullscreenEnabled", true);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-04-29 10:46:04 +00:00
|
|
|
#ifdef KWIN_BUILD_DECORATIONS
|
2011-01-30 14:34:42 +00:00
|
|
|
placement = Placement::policyFromString(config.readEntry("Placement"), true);
|
2011-04-29 10:46:04 +00:00
|
|
|
#else
|
|
|
|
placement = Placement::Maximizing;
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
xineramaPlacementScreen = qBound(-1, config.readEntry("XineramaPlacementScreen", -1),
|
|
|
|
Kephal::ScreenUtils::numScreens() - 1);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (focusPolicy == ClickToFocus) {
|
2007-04-29 17:35:43 +00:00
|
|
|
autoRaise = false;
|
|
|
|
autoRaiseInterval = 0;
|
|
|
|
delayFocus = false;
|
|
|
|
delayFocusInterval = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
autoRaise = config.readEntry("AutoRaise", false);
|
2011-01-30 14:34:42 +00:00
|
|
|
autoRaiseInterval = config.readEntry("AutoRaiseInterval", 0);
|
2007-04-29 17:35:43 +00:00
|
|
|
delayFocus = config.readEntry("DelayFocus", false);
|
2011-01-30 14:34:42 +00:00
|
|
|
delayFocusInterval = config.readEntry("DelayFocusInterval", 0);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
shadeHover = config.readEntry("ShadeHover", false);
|
2011-01-30 14:34:42 +00:00
|
|
|
shadeHoverInterval = config.readEntry("ShadeHoverInterval", 250);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
tilingOn = config.readEntry("TilingOn", false);
|
|
|
|
tilingLayout = static_cast<TilingLayoutFactory::Layouts>(config.readEntry("TilingDefaultLayout", 0));
|
|
|
|
tilingRaisePolicy = config.readEntry("TilingRaisePolicy", 0);
|
2010-04-25 16:43:14 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// important: autoRaise implies ClickRaise
|
|
|
|
clickRaise = autoRaise || config.readEntry("ClickRaise", true);
|
|
|
|
|
|
|
|
borderSnapZone = config.readEntry("BorderSnapZone", 10);
|
|
|
|
windowSnapZone = config.readEntry("WindowSnapZone", 10);
|
2008-07-09 15:18:47 +00:00
|
|
|
centerSnapZone = config.readEntry("CenterSnapZone", 0);
|
2007-04-29 17:35:43 +00:00
|
|
|
snapOnlyWhenOverlapping = config.readEntry("SnapOnlyWhenOverlapping", false);
|
2009-02-28 08:33:16 +00:00
|
|
|
|
|
|
|
// Electric borders
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup borderConfig(_config, "ElectricBorders");
|
|
|
|
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"));
|
|
|
|
electric_border_bottom_right = electricBorderAction(borderConfig.readEntry("BottomRight", "None"));
|
|
|
|
electric_border_bottom = electricBorderAction(borderConfig.readEntry("Bottom", "None"));
|
|
|
|
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"));
|
2007-04-29 17:35:43 +00:00
|
|
|
electric_borders = config.readEntry("ElectricBorders", 0);
|
|
|
|
electric_border_delay = config.readEntry("ElectricBorderDelay", 150);
|
2009-02-28 08:33:16 +00:00
|
|
|
electric_border_cooldown = config.readEntry("ElectricBorderCooldown", 350);
|
2009-09-08 20:01:16 +00:00
|
|
|
electric_border_pushback_pixels = config.readEntry("ElectricBorderPushbackPixels", 1);
|
2009-10-27 13:11:58 +00:00
|
|
|
electric_border_maximize = config.readEntry("ElectricBorderMaximize", true);
|
|
|
|
electric_border_tiling = config.readEntry("ElectricBorderTiling", true);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
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));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
ignorePositionClasses = config.readEntry("IgnorePositionClasses", QStringList());
|
|
|
|
ignoreFocusStealingClasses = config.readEntry("IgnoreFocusStealingClasses", QStringList());
|
2007-04-29 17:35:43 +00:00
|
|
|
// Qt3.2 and older had resource class all lowercase, but Qt3.3 has it capitalized
|
|
|
|
// therefore Client::resourceClass() forces lowercase, force here lowercase as well
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QStringList::Iterator it = ignorePositionClasses.begin();
|
|
|
|
it != ignorePositionClasses.end();
|
|
|
|
++it)
|
2007-04-29 17:35:43 +00:00
|
|
|
(*it) = (*it).toLower();
|
2011-01-30 14:34:42 +00:00
|
|
|
for (QStringList::Iterator it = ignoreFocusStealingClasses.begin();
|
|
|
|
it != ignoreFocusStealingClasses.end();
|
|
|
|
++it)
|
2007-04-29 17:35:43 +00:00
|
|
|
(*it) = (*it).toLower();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
killPingTimeout = config.readEntry("KillPingTimeout", 5000);
|
|
|
|
hideUtilityWindowsForInactive = config.readEntry("HideUtilityWindowsForInactive", true);
|
|
|
|
inactiveTabsSkipTaskbar = config.readEntry("InactiveTabsSkipTaskbar", false);
|
|
|
|
autogroupSimilarWindows = config.readEntry("AutogroupSimilarWindows", false);
|
|
|
|
autogroupInForeground = config.readEntry("AutogroupInForeground", true);
|
|
|
|
showDesktopIsMinimizeAll = config.readEntry("ShowDesktopIsMinimizeAll", false);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
borderless_maximized_windows = config.readEntry("BorderlessMaximizedWindows", false);
|
2009-09-21 11:15:28 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Mouse bindings
|
2011-01-30 14:34:42 +00:00
|
|
|
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);
|
|
|
|
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);
|
2009-05-06 06:38:54 +00:00
|
|
|
CmdWindowWheel = mouseCommand(config.readEntry("CommandWindowWheel", "Scroll"), false);
|
2011-01-30 14:34:42 +00:00
|
|
|
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"));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
config = KConfigGroup(_config, "Compositing");
|
|
|
|
maxFpsInterval = qRound(1000.0 / config.readEntry("MaxFPS", 60));
|
|
|
|
refreshRate = config.readEntry("RefreshRate", 0);
|
2008-12-08 05:08:31 +00:00
|
|
|
|
|
|
|
// Read button tooltip animation effect from kdeglobals
|
|
|
|
// Since we want to allow users to enable window decoration tooltips
|
|
|
|
// and not kstyle tooltips and vise-versa, we don't read the
|
|
|
|
// "EffectNoTooltip" setting from kdeglobals.
|
|
|
|
|
|
|
|
|
|
|
|
// QToolTip::setGloballyEnabled( d->show_tooltips );
|
|
|
|
// KDE4 this probably needs to be done manually in clients
|
|
|
|
|
2007-09-25 09:41:23 +00:00
|
|
|
// Driver-specific config detection
|
2011-02-27 22:39:32 +00:00
|
|
|
compositingInitialized = false;
|
2009-11-29 22:11:49 +00:00
|
|
|
reloadCompositingSettings();
|
2007-09-25 09:41:23 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
return changed;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-02-27 22:39:32 +00:00
|
|
|
void Options::reloadCompositingSettings(bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
KSharedConfig::Ptr _config = KGlobal::config();
|
|
|
|
KConfigGroup config(_config, "Compositing");
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-02-27 22:39:32 +00:00
|
|
|
QString compositingBackend = config.readEntry("Backend", "OpenGL");
|
|
|
|
if (compositingBackend == "XRender")
|
|
|
|
compositingMode = XRenderCompositing;
|
|
|
|
else
|
|
|
|
compositingMode = OpenGLCompositing;
|
|
|
|
|
|
|
|
useCompositing = false;
|
|
|
|
if (const char *c = getenv("KWIN_COMPOSE")) {
|
|
|
|
switch(c[0]) {
|
|
|
|
case 'O':
|
|
|
|
kDebug(1212) << "Compositing forced to OpenGL mode by environment variable";
|
|
|
|
compositingMode = OpenGLCompositing;
|
|
|
|
useCompositing = true;
|
|
|
|
break;
|
|
|
|
case 'X':
|
|
|
|
kDebug(1212) << "Compositing forced to XRender mode by environment variable";
|
|
|
|
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";
|
|
|
|
compositingMode = NoCompositing;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
kDebug(1212) << "Unknown KWIN_COMPOSE mode set, ignoring";
|
|
|
|
break;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-02-27 22:39:32 +00:00
|
|
|
|
|
|
|
if (compositingMode == NoCompositing)
|
|
|
|
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
|
|
|
|
useCompositing = useCompositing || force || config.readEntry("Enabled", true);
|
|
|
|
|
|
|
|
if (!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 settigns on compositing activation
|
|
|
|
// see Workspace::setupCompositing(), composite.cpp
|
|
|
|
compositingInitialized = true;
|
|
|
|
|
2009-12-04 09:40:12 +00:00
|
|
|
// Compositing settings
|
|
|
|
CompositingPrefs prefs;
|
|
|
|
prefs.detect();
|
2010-12-03 21:13:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
useCompositing = config.readEntry("Enabled" , prefs.recommendCompositing());
|
2011-07-26 05:55:20 +00:00
|
|
|
glDirect = prefs.enableDirectRendering();
|
2011-01-30 14:34:42 +00:00
|
|
|
glVSync = config.readEntry("GLVSync", prefs.enableVSync());
|
|
|
|
glSmoothScale = qBound(-1, config.readEntry("GLTextureFilter", 2), 2);
|
|
|
|
glStrictBinding = config.readEntry("GLStrictBinding", prefs.strictBinding());
|
2007-09-21 13:27:56 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false);
|
2007-11-13 16:40:28 +00:00
|
|
|
|
2008-08-12 11:02:58 +00:00
|
|
|
hiddenPreviews = HiddenPreviewsShown;
|
2008-10-01 17:27:12 +00:00
|
|
|
// 4 - off, 5 - shown, 6 - always, other are old values
|
2011-01-30 14:34:42 +00:00
|
|
|
int hps = config.readEntry("HiddenPreviews", 5);
|
|
|
|
if (hps == 4)
|
2008-08-12 11:02:58 +00:00
|
|
|
hiddenPreviews = HiddenPreviewsNever;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (hps == 5)
|
2008-08-12 11:02:58 +00:00
|
|
|
hiddenPreviews = HiddenPreviewsShown;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (hps == 6)
|
2008-08-12 11:02:58 +00:00
|
|
|
hiddenPreviews = HiddenPreviewsAlways;
|
2008-11-25 01:45:09 +00:00
|
|
|
|
2011-05-15 07:40:19 +00:00
|
|
|
unredirectFullscreen = config.readEntry("UnredirectFullscreen", false);
|
2011-01-30 14:34:42 +00:00
|
|
|
animationSpeed = qBound(0, config.readEntry("AnimationSpeed", 3), 6);
|
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
ElectricBorderAction Options::electricBorderAction(const QString& name)
|
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
QString lowerName = name.toLower();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (lowerName == "dashboard") return ElectricActionDashboard;
|
|
|
|
else if (lowerName == "showdesktop") return ElectricActionShowDesktop;
|
|
|
|
else if (lowerName == "lockscreen") return ElectricActionLockScreen;
|
|
|
|
else if (lowerName == "preventscreenlocking") return ElectricActionPreventScreenLocking;
|
2009-02-28 08:33:16 +00:00
|
|
|
return ElectricActionNone;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// restricted should be true for operations that the user may not be able to repeat
|
|
|
|
// if the window is moved out of the workspace (e.g. if the user moves a window
|
|
|
|
// by the titlebar, and moves it too high beneath Kicker at the top edge, they
|
|
|
|
// may not be able to move it back, unless they know about Alt+LMB)
|
2011-01-30 14:34:42 +00:00
|
|
|
Options::WindowOperation Options::windowOperation(const QString &name, bool restricted)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
if (name == "Move")
|
|
|
|
return restricted ? MoveOp : UnrestrictedMoveOp;
|
|
|
|
else if (name == "Resize")
|
|
|
|
return restricted ? ResizeOp : UnrestrictedResizeOp;
|
|
|
|
else if (name == "Maximize")
|
|
|
|
return MaximizeOp;
|
|
|
|
else if (name == "Minimize")
|
|
|
|
return MinimizeOp;
|
|
|
|
else if (name == "Close")
|
|
|
|
return CloseOp;
|
|
|
|
else if (name == "OnAllDesktops")
|
|
|
|
return OnAllDesktopsOp;
|
|
|
|
else if (name == "Shade")
|
|
|
|
return ShadeOp;
|
|
|
|
else if (name == "Operations")
|
|
|
|
return OperationsOp;
|
|
|
|
else if (name == "Maximize (vertical only)")
|
|
|
|
return VMaximizeOp;
|
|
|
|
else if (name == "Maximize (horizontal only)")
|
|
|
|
return HMaximizeOp;
|
|
|
|
else if (name == "Lower")
|
|
|
|
return LowerOp;
|
|
|
|
return NoOp;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QString lowerName = name.toLower();
|
|
|
|
if (lowerName == "raise") return MouseRaise;
|
|
|
|
if (lowerName == "lower") return MouseLower;
|
|
|
|
if (lowerName == "operations menu") return MouseOperationsMenu;
|
|
|
|
if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
|
|
|
|
if (lowerName == "activate and raise") return MouseActivateAndRaise;
|
|
|
|
if (lowerName == "activate and lower") return MouseActivateAndLower;
|
|
|
|
if (lowerName == "activate") return MouseActivate;
|
|
|
|
if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
|
|
|
|
if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
|
2009-05-06 06:38:54 +00:00
|
|
|
if (lowerName == "scroll") return MouseNothing;
|
|
|
|
if (lowerName == "activate and scroll") return MouseActivateAndPassClick;
|
|
|
|
if (lowerName == "activate, raise and scroll") return MouseActivateRaiseAndPassClick;
|
2007-04-29 17:35:43 +00:00
|
|
|
if (lowerName == "activate, raise and move")
|
|
|
|
return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
|
|
|
|
if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
|
|
|
|
if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
|
|
|
|
if (lowerName == "shade") return MouseShade;
|
|
|
|
if (lowerName == "minimize") return MouseMinimize;
|
2009-11-17 07:17:49 +00:00
|
|
|
if (lowerName == "start window tab drag") return MouseClientGroupDrag;
|
2009-08-25 04:10:11 +00:00
|
|
|
if (lowerName == "close") return MouseClose;
|
2007-04-29 17:35:43 +00:00
|
|
|
if (lowerName == "nothing") return MouseNothing;
|
|
|
|
return MouseNothing;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QString lowerName = name.toLower();
|
|
|
|
if (lowerName == "raise/lower") return MouseWheelRaiseLower;
|
|
|
|
if (lowerName == "shade/unshade") return MouseWheelShadeUnshade;
|
|
|
|
if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore;
|
|
|
|
if (lowerName == "above/below") return MouseWheelAboveBelow;
|
|
|
|
if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop;
|
|
|
|
if (lowerName == "change opacity") return MouseWheelChangeOpacity;
|
2009-11-17 08:46:20 +00:00
|
|
|
if (lowerName == "switch to window tab to the left/right") return MouseWheelChangeGroupWindow;
|
|
|
|
if (lowerName == "nothing") return MouseWheelNothing;
|
|
|
|
return MouseWheelChangeGroupWindow;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool Options::showGeometryTip()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return show_geometry_tip;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
ElectricBorderAction Options::electricBorderAction(ElectricBorder edge)
|
|
|
|
{
|
|
|
|
switch(edge) {
|
|
|
|
case ElectricTop:
|
|
|
|
return electric_border_top;
|
|
|
|
case ElectricTopRight:
|
|
|
|
return electric_border_top_right;
|
|
|
|
case ElectricRight:
|
|
|
|
return electric_border_right;
|
|
|
|
case ElectricBottomRight:
|
|
|
|
return electric_border_bottom_right;
|
|
|
|
case ElectricBottom:
|
|
|
|
return electric_border_bottom;
|
|
|
|
case ElectricBottomLeft:
|
|
|
|
return electric_border_bottom_left;
|
|
|
|
case ElectricLeft:
|
|
|
|
return electric_border_left;
|
|
|
|
case ElectricTopLeft:
|
|
|
|
return electric_border_top_left;
|
|
|
|
default:
|
|
|
|
// fallthrough
|
|
|
|
break;
|
2009-02-28 08:33:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return ElectricActionNone;
|
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int Options::electricBorders()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return electric_borders;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int Options::electricBorderDelay()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return electric_border_delay;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-02-28 08:33:16 +00:00
|
|
|
int Options::electricBorderCooldown()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
return electric_border_cooldown;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Options::checkIgnoreFocusStealing(const Client* c)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass()));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Options::MouseCommand Options::wheelToMouseCommand(MouseWheelCommand com, int delta)
|
|
|
|
{
|
|
|
|
switch(com) {
|
|
|
|
case MouseWheelRaiseLower:
|
|
|
|
return delta > 0 ? MouseRaise : MouseLower;
|
|
|
|
case MouseWheelShadeUnshade:
|
|
|
|
return delta > 0 ? MouseSetShade : MouseUnsetShade;
|
|
|
|
case MouseWheelMaximizeRestore:
|
|
|
|
return delta > 0 ? MouseMaximize : MouseRestore;
|
|
|
|
case MouseWheelAboveBelow:
|
|
|
|
return delta > 0 ? MouseAbove : MouseBelow;
|
|
|
|
case MouseWheelPreviousNextDesktop:
|
|
|
|
return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
|
|
|
|
case MouseWheelChangeOpacity:
|
|
|
|
return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
|
|
|
|
case MouseWheelChangeGroupWindow:
|
|
|
|
return delta > 0 ? MouseLeftGroupWindow : MouseRightGroupWindow;
|
|
|
|
default:
|
|
|
|
return MouseNothing;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-30 07:25:54 +00:00
|
|
|
double Options::animationTimeFactor() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-08-30 07:25:54 +00:00
|
|
|
const double factors[] = { 0, 0.2, 0.5, 1, 2, 4, 20 };
|
|
|
|
return factors[ animationSpeed ];
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-30 07:25:54 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|