options.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "options.h"
00013
00014 #ifndef KCMRULES
00015
00016 #include <qpalette.h>
00017 #include <qpixmap.h>
00018 #include <kapplication.h>
00019 #include <kconfig.h>
00020 #include <kglobal.h>
00021 #include <kglobalsettings.h>
00022 #include <qtooltip.h>
00023
00024 #include "client.h"
00025
00026 #endif
00027
00028 namespace KWinInternal
00029 {
00030
00031 #ifndef KCMRULES
00032
00033 Options::Options()
00034 : electric_borders( 0 ),
00035 electric_border_delay(0)
00036 {
00037 d = new KDecorationOptionsPrivate;
00038 d->defaultKWinSettings();
00039 updateSettings();
00040 }
00041
00042 Options::~Options()
00043 {
00044 delete d;
00045 }
00046
00047 unsigned long Options::updateSettings()
00048 {
00049 KConfig *config = KGlobal::config();
00050 unsigned long changed = 0;
00051 changed |= d->updateKWinSettings( config );
00052
00053 config->setGroup( "Windows" );
00054 moveMode = stringToMoveResizeMode( config->readEntry("MoveMode", "Opaque" ));
00055 resizeMode = stringToMoveResizeMode( config->readEntry("ResizeMode", "Opaque" ));
00056 show_geometry_tip = config->readBoolEntry("GeometryTip", false);
00057
00058 QString val;
00059
00060 val = config->readEntry ("FocusPolicy", "ClickToFocus");
00061 focusPolicy = ClickToFocus;
00062 if ( val == "FocusFollowsMouse" )
00063 focusPolicy = FocusFollowsMouse;
00064 else if ( val == "FocusUnderMouse" )
00065 focusPolicy = FocusUnderMouse;
00066 else if ( val == "FocusStrictlyUnderMouse" )
00067 focusPolicy = FocusStrictlyUnderMouse;
00068
00069 val = config->readEntry ("AltTabStyle", "KDE");
00070 altTabStyle = KDE;
00071 if ( val == "CDE" )
00072 altTabStyle = CDE;
00073
00074 rollOverDesktops = config->readBoolEntry("RollOverDesktops", TRUE);
00075
00076
00077
00078 focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 1 );
00079 focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
00080 if( !focusPolicyIsReasonable())
00081 focusStealingPreventionLevel = 0;
00082
00083 KConfig *gc = new KConfig("kdeglobals", false, false);
00084 bool isVirtual = KApplication::desktop()->isVirtualDesktop();
00085 gc->setGroup("Windows");
00086 xineramaEnabled = gc->readBoolEntry ("XineramaEnabled", isVirtual ) &&
00087 isVirtual;
00088 if (xineramaEnabled)
00089 {
00090 xineramaPlacementEnabled = gc->readBoolEntry ("XineramaPlacementEnabled", true);
00091 xineramaMovementEnabled = gc->readBoolEntry ("XineramaMovementEnabled", true);
00092 xineramaMaximizeEnabled = gc->readBoolEntry ("XineramaMaximizeEnabled", true);
00093 xineramaFullscreenEnabled = gc->readBoolEntry ("XineramaFullscreenEnabled", true);
00094 }
00095 else
00096 {
00097 xineramaPlacementEnabled = xineramaMovementEnabled = xineramaMaximizeEnabled = xineramaFullscreenEnabled = false;
00098 }
00099 delete gc;
00100
00101 placement = Placement::policyFromString( config->readEntry("Placement"), true );
00102
00103 animateShade = config->readBoolEntry("AnimateShade", TRUE );
00104
00105 animateMinimize = config->readBoolEntry("AnimateMinimize", TRUE );
00106 animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
00107
00108 if( focusPolicy == ClickToFocus )
00109 {
00110 autoRaise = false;
00111 autoRaiseInterval = 0;
00112 delayFocus = false;
00113 delayFocusInterval = 0;
00114 }
00115 else
00116 {
00117 autoRaise = config->readBoolEntry("AutoRaise", FALSE );
00118 autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
00119 delayFocus = config->readBoolEntry("DelayFocus", FALSE );
00120 delayFocusInterval = config->readNumEntry("DelayFocusInterval", 0 );
00121 }
00122
00123 shadeHover = config->readBoolEntry("ShadeHover", FALSE );
00124 shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
00125
00126
00127 clickRaise = autoRaise || config->readBoolEntry("ClickRaise", TRUE );
00128
00129 borderSnapZone = config->readNumEntry("BorderSnapZone", 10);
00130 windowSnapZone = config->readNumEntry("WindowSnapZone", 10);
00131 snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",FALSE);
00132 electric_borders = config->readNumEntry("ElectricBorders", 0);
00133 electric_border_delay = config->readNumEntry("ElectricBorderDelay", 150);
00134
00135 OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade"), true );
00136
00137 ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
00138 ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
00139
00140
00141 for( QStringList::Iterator it = ignorePositionClasses.begin();
00142 it != ignorePositionClasses.end();
00143 ++it )
00144 (*it) = (*it).lower();
00145 for( QStringList::Iterator it = ignoreFocusStealingClasses.begin();
00146 it != ignoreFocusStealingClasses.end();
00147 ++it )
00148 (*it) = (*it).lower();
00149
00150 killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
00151
00152
00153 config->setGroup( "MouseBindings");
00154 CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
00155 CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
00156 CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
00157 CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
00158 CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
00159 CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
00160 CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false );
00161 CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false );
00162 CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false );
00163 CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
00164 CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
00165 CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
00166 CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
00167
00168
00169
00170
00171
00172 KConfig globalConfig("kdeglobals");
00173 globalConfig.setGroup("KDE");
00174 topmenus = globalConfig.readBoolEntry( "macStyle", false );
00175
00176 KConfig kdesktopcfg( "kdesktoprc", true );
00177 kdesktopcfg.setGroup( "Menubar" );
00178 desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
00179 if( desktop_topmenu )
00180 topmenus = true;
00181
00182 QToolTip::setGloballyEnabled( d->show_tooltips );
00183
00184 return changed;
00185 }
00186
00187
00188
00189
00190
00191
00192 Options::WindowOperation Options::windowOperation(const QString &name, bool restricted )
00193 {
00194 if (name == "Move")
00195 return restricted ? MoveOp : UnrestrictedMoveOp;
00196 else if (name == "Resize")
00197 return restricted ? ResizeOp : UnrestrictedResizeOp;
00198 else if (name == "Maximize")
00199 return MaximizeOp;
00200 else if (name == "Minimize")
00201 return MinimizeOp;
00202 else if (name == "Close")
00203 return CloseOp;
00204 else if (name == "OnAllDesktops")
00205 return OnAllDesktopsOp;
00206 else if (name == "Shade")
00207 return ShadeOp;
00208 else if (name == "Operations")
00209 return OperationsOp;
00210 else if (name == "Maximize (vertical only)")
00211 return VMaximizeOp;
00212 else if (name == "Maximize (horizontal only)")
00213 return HMaximizeOp;
00214 else if (name == "Lower")
00215 return LowerOp;
00216 return NoOp;
00217 }
00218
00219 Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted )
00220 {
00221 QString lowerName = name.lower();
00222 if (lowerName == "raise") return MouseRaise;
00223 if (lowerName == "lower") return MouseLower;
00224 if (lowerName == "operations menu") return MouseOperationsMenu;
00225 if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
00226 if (lowerName == "activate and raise") return MouseActivateAndRaise;
00227 if (lowerName == "activate and lower") return MouseActivateAndLower;
00228 if (lowerName == "activate") return MouseActivate;
00229 if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
00230 if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
00231 if (lowerName == "activate, raise and move")
00232 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
00233 if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
00234 if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
00235 if (lowerName == "shade") return MouseShade;
00236 if (lowerName == "minimize") return MouseMinimize;
00237 if (lowerName == "nothing") return MouseNothing;
00238 return MouseNothing;
00239 }
00240
00241 bool Options::showGeometryTip()
00242 {
00243 return show_geometry_tip;
00244 }
00245
00246 int Options::electricBorders()
00247 {
00248 return electric_borders;
00249 }
00250
00251 int Options::electricBorderDelay()
00252 {
00253 return electric_border_delay;
00254 }
00255
00256 bool Options::checkIgnoreFocusStealing( const Client* c )
00257 {
00258 return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass()));
00259 }
00260 #endif
00261
00262 Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s )
00263 {
00264 return s == "Opaque" ? Opaque : Transparent;
00265 }
00266
00267 const char* Options::moveResizeModeToString( MoveResizeMode mode )
00268 {
00269 return mode == Opaque ? "Opaque" : "Transparent";
00270 }
00271
00272 }
This file is part of the documentation for kwin Library Version 3.3.0.