2000-03-24 22:23:02 +00:00
|
|
|
/*****************************************************************
|
2003-09-16 19:28:03 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2000-12-08 00:54:19 +00:00
|
|
|
|
2000-03-24 22:23:02 +00:00
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
2003-09-16 19:28:03 +00:00
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
2000-03-24 22:23:02 +00:00
|
|
|
******************************************************************/
|
2003-09-16 19:28:03 +00:00
|
|
|
|
1999-10-09 09:55:16 +00:00
|
|
|
#include "options.h"
|
1999-10-10 03:22:21 +00:00
|
|
|
#include <qpalette.h>
|
1999-11-07 15:48:24 +00:00
|
|
|
#include <qpixmap.h>
|
2001-12-29 17:33:05 +00:00
|
|
|
#include <kapplication.h>
|
1999-10-10 03:22:21 +00:00
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kglobal.h>
|
2000-09-23 19:58:45 +00:00
|
|
|
#include <kglobalsettings.h>
|
2003-11-20 13:01:09 +00:00
|
|
|
#include <qtooltip.h>
|
1999-10-09 09:55:16 +00:00
|
|
|
|
2001-04-20 07:19:03 +00:00
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
1999-10-11 02:00:06 +00:00
|
|
|
Options::Options()
|
2003-09-16 19:28:03 +00:00
|
|
|
: electric_borders( 0 ),
|
|
|
|
electric_border_delay(0)
|
|
|
|
{
|
|
|
|
d = new KDecorationOptionsPrivate;
|
|
|
|
d->defaultKWinSettings();
|
|
|
|
updateSettings();
|
1999-10-11 02:00:06 +00:00
|
|
|
}
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
Options::~Options()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
1999-10-10 03:22:21 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
unsigned long Options::updateSettings()
|
|
|
|
{
|
1999-10-10 03:22:21 +00:00
|
|
|
KConfig *config = KGlobal::config();
|
2003-09-16 19:28:03 +00:00
|
|
|
unsigned long changed = 0;
|
|
|
|
changed |= d->updateKWinSettings( config ); // read decoration settings
|
1999-11-20 06:27:07 +00:00
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
config->setGroup( "Windows" );
|
|
|
|
moveMode = config->readEntry("MoveMode", "Opaque" ) == "Opaque"?Opaque:Transparent;
|
|
|
|
resizeMode = config->readEntry("ResizeMode", "Opaque" ) == "Opaque"?Opaque:Transparent;
|
2003-09-16 19:28:03 +00:00
|
|
|
show_geometry_tip = config->readBoolEntry("GeometryTip", false);
|
1999-12-22 04:49:43 +00:00
|
|
|
|
1999-11-20 06:27:07 +00:00
|
|
|
QString val;
|
2000-03-24 22:23:02 +00:00
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
val = config->readEntry ("FocusPolicy", "ClickToFocus");
|
|
|
|
focusPolicy = ClickToFocus; // what a default :-)
|
|
|
|
if ( val == "FocusFollowsMouse" )
|
2001-01-20 03:55:42 +00:00
|
|
|
focusPolicy = FocusFollowsMouse;
|
2000-06-22 18:08:35 +00:00
|
|
|
else if ( val == "FocusUnderMouse" )
|
2001-01-20 03:55:42 +00:00
|
|
|
focusPolicy = FocusUnderMouse;
|
2000-06-22 18:08:35 +00:00
|
|
|
else if ( val == "FocusStrictlyUnderMouse" )
|
2001-01-20 03:55:42 +00:00
|
|
|
focusPolicy = FocusStrictlyUnderMouse;
|
2000-06-22 18:08:35 +00:00
|
|
|
|
|
|
|
val = config->readEntry ("AltTabStyle", "KDE");
|
|
|
|
altTabStyle = KDE; // what a default :-)
|
|
|
|
if ( val == "CDE" )
|
2001-01-20 03:55:42 +00:00
|
|
|
altTabStyle = CDE;
|
1999-12-22 04:49:43 +00:00
|
|
|
|
2002-02-28 21:04:36 +00:00
|
|
|
rollOverDesktops = config->readBoolEntry("RollOverDesktops", TRUE);
|
2003-09-29 11:23:14 +00:00
|
|
|
|
|
|
|
focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 2 );
|
|
|
|
focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
|
2002-02-28 21:04:36 +00:00
|
|
|
|
2003-02-18 04:55:07 +00:00
|
|
|
KConfig *gc = new KConfig("kdeglobals", false, false);
|
2003-02-18 04:34:53 +00:00
|
|
|
bool isVirtual = KApplication::desktop()->isVirtualDesktop();
|
|
|
|
gc->setGroup("Windows");
|
|
|
|
xineramaEnabled = gc->readBoolEntry ("XineramaEnabled", isVirtual ) &&
|
|
|
|
isVirtual;
|
2003-09-16 19:28:03 +00:00
|
|
|
if (xineramaEnabled)
|
|
|
|
{
|
2003-02-18 05:05:43 +00:00
|
|
|
xineramaPlacementEnabled = gc->readBoolEntry ("XineramaPlacementEnabled", true);
|
|
|
|
xineramaMovementEnabled = gc->readBoolEntry ("XineramaMovementEnabled", true);
|
|
|
|
xineramaMaximizeEnabled = gc->readBoolEntry ("XineramaMaximizeEnabled", true);
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xineramaPlacementEnabled = xineramaMovementEnabled = xineramaMaximizeEnabled = false;
|
|
|
|
}
|
2003-02-18 04:55:07 +00:00
|
|
|
delete gc;
|
2001-06-03 09:04:03 +00:00
|
|
|
|
1999-11-20 06:27:07 +00:00
|
|
|
val = config->readEntry("Placement","Smart");
|
2003-09-16 19:28:03 +00:00
|
|
|
if (val == "Random") placement = Random;
|
2002-06-29 06:31:33 +00:00
|
|
|
else if (val == "Cascade") placement = Cascade;
|
2002-07-15 20:28:55 +00:00
|
|
|
else if (val == "Centered") placement = Centered;
|
|
|
|
else if (val == "ZeroCornered") placement = ZeroCornered;
|
2003-09-16 19:28:03 +00:00
|
|
|
else placement = Smart;
|
|
|
|
|
2000-07-09 20:29:53 +00:00
|
|
|
animateShade = config->readBoolEntry("AnimateShade", TRUE );
|
1999-11-20 06:27:07 +00:00
|
|
|
|
2000-09-25 15:30:51 +00:00
|
|
|
animateMinimize = config->readBoolEntry("AnimateMinimize", TRUE );
|
2000-10-23 14:56:55 +00:00
|
|
|
animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
|
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
if( focusPolicy == ClickToFocus )
|
|
|
|
{
|
2002-12-17 20:20:31 +00:00
|
|
|
autoRaise = false;
|
|
|
|
autoRaiseInterval = 0;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-12-17 20:20:31 +00:00
|
|
|
autoRaise = config->readBoolEntry("AutoRaise", FALSE );
|
|
|
|
autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
2000-07-09 20:29:53 +00:00
|
|
|
|
2001-01-20 03:55:42 +00:00
|
|
|
shadeHover = config->readBoolEntry("ShadeHover", FALSE );
|
2001-01-14 20:16:04 +00:00
|
|
|
shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
|
|
|
|
|
2000-07-09 20:29:53 +00:00
|
|
|
// important: autoRaise implies ClickRaise
|
2003-09-16 19:28:03 +00:00
|
|
|
clickRaise = autoRaise || config->readBoolEntry("ClickRaise", TRUE );
|
2000-07-09 20:29:53 +00:00
|
|
|
|
|
|
|
borderSnapZone = config->readNumEntry("BorderSnapZone", 10);
|
|
|
|
windowSnapZone = config->readNumEntry("WindowSnapZone", 10);
|
2000-11-02 18:15:39 +00:00
|
|
|
snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",FALSE);
|
2003-09-16 19:28:03 +00:00
|
|
|
electric_borders = config->readNumEntry("ElectricBorders", 0);
|
|
|
|
electric_border_delay = config->readNumEntry("ElectricBorderDelay", 150);
|
1999-12-22 04:49:43 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade"), true );
|
1999-11-29 02:06:41 +00:00
|
|
|
|
2000-10-23 18:27:23 +00:00
|
|
|
ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
|
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
// Mouse bindings
|
|
|
|
config->setGroup( "MouseBindings");
|
2003-09-16 19:28:03 +00:00
|
|
|
CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
|
|
|
|
CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
|
|
|
|
CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
|
|
|
|
CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
|
|
|
|
CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
|
|
|
|
CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
|
|
|
|
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 );
|
2002-03-02 13:50:26 +00:00
|
|
|
CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
|
2003-09-16 19:28:03 +00:00
|
|
|
CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
|
|
|
|
CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
|
|
|
|
CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
|
2001-07-01 10:10:17 +00:00
|
|
|
|
2001-07-02 12:40:14 +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.
|
|
|
|
KConfig globalConfig("kdeglobals");
|
|
|
|
globalConfig.setGroup("KDE");
|
2003-09-16 19:28:03 +00:00
|
|
|
fade_tooltips = globalConfig.readBoolEntry("EffectFadeTooltip", false);
|
|
|
|
animate_tooltips = globalConfig.readBoolEntry("EffectAnimateTooltip", false);
|
2003-11-12 09:47:13 +00:00
|
|
|
topmenus = globalConfig.readBoolEntry( "macStyle", false );
|
|
|
|
|
|
|
|
KConfig kdesktopcfg( "kdesktoprc", true );
|
|
|
|
kdesktopcfg.setGroup( "Menubar" );
|
|
|
|
desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
|
|
|
|
if( desktop_topmenu )
|
|
|
|
topmenus = true;
|
2003-11-20 13:01:09 +00:00
|
|
|
|
|
|
|
QToolTip::setGloballyEnabled( d->show_tooltips );
|
2002-03-07 03:19:57 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
return changed;
|
|
|
|
}
|
1999-11-29 02:06:41 +00:00
|
|
|
|
1999-11-25 23:12:32 +00:00
|
|
|
|
2003-09-16 19:28:03 +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)
|
|
|
|
Options::WindowOperation Options::windowOperation(const QString &name, bool restricted )
|
|
|
|
{
|
1999-11-29 02:06:41 +00:00
|
|
|
if (name == "Move")
|
2003-09-16 19:28:03 +00:00
|
|
|
return restricted ? MoveOp : UnrestrictedMoveOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
else if (name == "Resize")
|
2003-09-16 19:28:03 +00:00
|
|
|
return restricted ? ResizeOp : UnrestrictedResizeOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
else if (name == "Maximize")
|
2001-01-20 03:55:42 +00:00
|
|
|
return MaximizeOp;
|
2003-09-16 19:28:03 +00:00
|
|
|
else if (name == "Minimize")
|
|
|
|
return MinimizeOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
else if (name == "Close")
|
2001-01-20 03:55:42 +00:00
|
|
|
return CloseOp;
|
2003-09-16 19:28:03 +00:00
|
|
|
else if (name == "OnAllDesktops")
|
|
|
|
return OnAllDesktopsOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
else if (name == "Shade")
|
2001-01-20 03:55:42 +00:00
|
|
|
return ShadeOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
else if (name == "Operations")
|
2001-01-20 03:55:42 +00:00
|
|
|
return OperationsOp;
|
2001-02-27 07:19:52 +00:00
|
|
|
else if (name == "Maximize (vertical only)")
|
|
|
|
return VMaximizeOp;
|
|
|
|
else if (name == "Maximize (horizontal only)")
|
|
|
|
return HMaximizeOp;
|
|
|
|
else if (name == "Lower")
|
|
|
|
return LowerOp;
|
1999-11-29 02:06:41 +00:00
|
|
|
return NoOp;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
1999-11-29 02:06:41 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted )
|
|
|
|
{
|
2002-07-13 02:34:13 +00:00
|
|
|
QString lowerName = name.lower();
|
2002-08-03 19:27:21 +00:00
|
|
|
if (lowerName == "raise") return MouseRaise;
|
2002-07-13 02:34:13 +00:00
|
|
|
if (lowerName == "lower") return MouseLower;
|
2002-08-03 19:27:21 +00:00
|
|
|
if (lowerName == "operations menu") return MouseOperationsMenu;
|
2002-07-13 02:34:13 +00:00
|
|
|
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;
|
2003-09-16 19:28:03 +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;
|
2002-07-13 02:34:13 +00:00
|
|
|
if (lowerName == "shade") return MouseShade;
|
2003-09-16 19:28:03 +00:00
|
|
|
if (lowerName == "minimize") return MouseMinimize;
|
2002-07-13 02:34:13 +00:00
|
|
|
if (lowerName == "nothing") return MouseNothing;
|
1999-11-29 02:06:41 +00:00
|
|
|
return MouseNothing;
|
2003-09-16 19:28:03 +00:00
|
|
|
}
|
2000-06-09 00:20:21 +00:00
|
|
|
|
2003-01-10 10:54:57 +00:00
|
|
|
bool Options::showGeometryTip()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return show_geometry_tip;
|
|
|
|
}
|
2001-07-01 10:10:17 +00:00
|
|
|
|
2001-07-02 12:40:14 +00:00
|
|
|
bool Options::fadeTooltips()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return fade_tooltips;
|
|
|
|
}
|
2001-07-02 12:40:14 +00:00
|
|
|
|
|
|
|
bool Options::animateTooltips()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return animate_tooltips;
|
|
|
|
}
|
2001-07-02 12:40:14 +00:00
|
|
|
|
2001-11-03 00:05:33 +00:00
|
|
|
int Options::electricBorders()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return electric_borders;
|
|
|
|
}
|
2001-08-27 05:42:32 +00:00
|
|
|
|
2001-09-06 19:44:06 +00:00
|
|
|
int Options::electricBorderDelay()
|
2003-09-16 19:28:03 +00:00
|
|
|
{
|
|
|
|
return electric_border_delay;
|
|
|
|
}
|
2000-06-09 00:20:21 +00:00
|
|
|
|
2003-09-16 19:28:03 +00:00
|
|
|
} // namespace
|