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 tabboxOutline = config->readBoolEntry("TabboxOutline", true);
00058
00059 QString val;
00060
00061 val = config->readEntry ("FocusPolicy", "ClickToFocus");
00062 focusPolicy = ClickToFocus;
00063 if ( val == "FocusFollowsMouse" )
00064 focusPolicy = FocusFollowsMouse;
00065 else if ( val == "FocusUnderMouse" )
00066 focusPolicy = FocusUnderMouse;
00067 else if ( val == "FocusStrictlyUnderMouse" )
00068 focusPolicy = FocusStrictlyUnderMouse;
00069
00070 val = config->readEntry ("AltTabStyle", "KDE");
00071 altTabStyle = KDE;
00072 if ( val == "CDE" )
00073 altTabStyle = CDE;
00074
00075 rollOverDesktops = config->readBoolEntry("RollOverDesktops", TRUE);
00076
00077
00078
00079 focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 1 );
00080 focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
00081 if( !focusPolicyIsReasonable())
00082 focusStealingPreventionLevel = 0;
00083
00084 KConfig *gc = new KConfig("kdeglobals", false, false);
00085 bool isVirtual = KApplication::desktop()->isVirtualDesktop();
00086 gc->setGroup("Windows");
00087 xineramaEnabled = gc->readBoolEntry ("XineramaEnabled", isVirtual ) &&
00088 isVirtual;
00089 if (xineramaEnabled)
00090 {
00091 xineramaPlacementEnabled = gc->readBoolEntry ("XineramaPlacementEnabled", true);
00092 xineramaMovementEnabled = gc->readBoolEntry ("XineramaMovementEnabled", true);
00093 xineramaMaximizeEnabled = gc->readBoolEntry ("XineramaMaximizeEnabled", true);
00094 xineramaFullscreenEnabled = gc->readBoolEntry ("XineramaFullscreenEnabled", true);
00095 }
00096 else
00097 {
00098 xineramaPlacementEnabled = xineramaMovementEnabled = xineramaMaximizeEnabled = xineramaFullscreenEnabled = false;
00099 }
00100 delete gc;
00101
00102 placement = Placement::policyFromString( config->readEntry("Placement"), true );
00103
00104 animateShade = config->readBoolEntry("AnimateShade", TRUE );
00105
00106 animateMinimize = config->readBoolEntry("AnimateMinimize", TRUE );
00107 animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
00108
00109 if( focusPolicy == ClickToFocus )
00110 {
00111 autoRaise = false;
00112 autoRaiseInterval = 0;
00113 delayFocus = false;
00114 delayFocusInterval = 0;
00115 }
00116 else
00117 {
00118 autoRaise = config->readBoolEntry("AutoRaise", FALSE );
00119 autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
00120 delayFocus = config->readBoolEntry("DelayFocus", FALSE );
00121 delayFocusInterval = config->readNumEntry("DelayFocusInterval", 0 );
00122 }
00123
00124 shadeHover = config->readBoolEntry("ShadeHover", FALSE );
00125 shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
00126
00127
00128 clickRaise = autoRaise || config->readBoolEntry("ClickRaise", TRUE );
00129
00130 borderSnapZone = config->readNumEntry("BorderSnapZone", 10);
00131 windowSnapZone = config->readNumEntry("WindowSnapZone", 10);
00132 snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",FALSE);
00133 electric_borders = config->readNumEntry("ElectricBorders", 0);
00134 electric_border_delay = config->readNumEntry("ElectricBorderDelay", 150);
00135
00136 OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade"), true );
00137 d->OpMaxButtonLeftClick = windowOperation( config->readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true );
00138 d->OpMaxButtonMiddleClick = windowOperation( config->readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true );
00139 d->OpMaxButtonRightClick = windowOperation( config->readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true );
00140
00141 ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
00142 ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
00143
00144
00145 for( QStringList::Iterator it = ignorePositionClasses.begin();
00146 it != ignorePositionClasses.end();
00147 ++it )
00148 (*it) = (*it).lower();
00149 for( QStringList::Iterator it = ignoreFocusStealingClasses.begin();
00150 it != ignoreFocusStealingClasses.end();
00151 ++it )
00152 (*it) = (*it).lower();
00153
00154 killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
00155 hideUtilityWindowsForInactive = config->readBoolEntry( "HideUtilityWindowsForInactive", true );
00156 showDesktopIsMinimizeAll = config->readBoolEntry( "ShowDesktopIsMinimizeAll", false );
00157
00158
00159 config->setGroup( "MouseBindings");
00160 CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
00161 CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
00162 CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
00163 CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
00164 CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
00165 CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
00166 CmdTitlebarWheel = mouseWheelCommand(config->readEntry("CommandTitlebarWheel","Nothing"));
00167 CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false );
00168 CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false );
00169 CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false );
00170 CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
00171 CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
00172 CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
00173 CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
00174 CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
00175
00176
00177 config->setGroup( "Notification Messages" );
00178 useTranslucency = config->readBoolEntry("UseTranslucency", false);
00179 config->setGroup( "Translucency");
00180 translucentActiveWindows = config->readBoolEntry("TranslucentActiveWindows", false);
00181 activeWindowOpacity = uint((config->readNumEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
00182 translucentInactiveWindows = config->readBoolEntry("TranslucentInactiveWindows", false);
00183 inactiveWindowOpacity = uint((config->readNumEntry("InactiveWindowOpacity", 75)/100.0)*0xFFFFFFFF);
00184 translucentMovingWindows = config->readBoolEntry("TranslucentMovingWindows", false);
00185 movingWindowOpacity = uint((config->readNumEntry("MovingWindowOpacity", 50)/100.0)*0xFFFFFFFF);
00186 translucentDocks = config->readBoolEntry("TranslucentDocks", false);
00187 dockOpacity = uint((config->readNumEntry("DockOpacity", 80)/100.0)*0xFFFFFFFF);
00188 keepAboveAsActive = config->readBoolEntry("TreatKeepAboveAsActive", true);
00189
00190 useTitleMenuSlider = true;
00191 activeWindowShadowSize = config->readNumEntry("ActiveWindowShadowSize", 200);
00192 inactiveWindowShadowSize = config->readNumEntry("InactiveWindowShadowSize", 100);
00193 dockShadowSize = config->readNumEntry("DockShadowSize", 80);
00194 removeShadowsOnMove = config->readBoolEntry("RemoveShadowsOnMove", true);
00195 removeShadowsOnResize = config->readBoolEntry("RemoveShadowsOnResize", true);
00196 onlyDecoTranslucent = config->readBoolEntry("OnlyDecoTranslucent",false);
00197 resetKompmgr = config->readBoolEntry("ResetKompmgr", false);
00198 if (resetKompmgr)
00199 config->writeEntry("ResetKompmgr",FALSE);
00200
00201
00202
00203
00204
00205
00206
00207 KConfig globalConfig("kdeglobals");
00208 globalConfig.setGroup("KDE");
00209 topmenus = globalConfig.readBoolEntry( "macStyle", false );
00210
00211 KConfig kdesktopcfg( "kdesktoprc", true );
00212 kdesktopcfg.setGroup( "Menubar" );
00213 desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
00214 if( desktop_topmenu )
00215 topmenus = true;
00216
00217 QToolTip::setGloballyEnabled( d->show_tooltips );
00218
00219 return changed;
00220 }
00221
00222
00223
00224
00225
00226
00227 Options::WindowOperation Options::windowOperation(const QString &name, bool restricted )
00228 {
00229 if (name == "Move")
00230 return restricted ? MoveOp : UnrestrictedMoveOp;
00231 else if (name == "Resize")
00232 return restricted ? ResizeOp : UnrestrictedResizeOp;
00233 else if (name == "Maximize")
00234 return MaximizeOp;
00235 else if (name == "Minimize")
00236 return MinimizeOp;
00237 else if (name == "Close")
00238 return CloseOp;
00239 else if (name == "OnAllDesktops")
00240 return OnAllDesktopsOp;
00241 else if (name == "Shade")
00242 return ShadeOp;
00243 else if (name == "Operations")
00244 return OperationsOp;
00245 else if (name == "Maximize (vertical only)")
00246 return VMaximizeOp;
00247 else if (name == "Maximize (horizontal only)")
00248 return HMaximizeOp;
00249 else if (name == "Lower")
00250 return LowerOp;
00251 return NoOp;
00252 }
00253
00254 Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted )
00255 {
00256 QString lowerName = name.lower();
00257 if (lowerName == "raise") return MouseRaise;
00258 if (lowerName == "lower") return MouseLower;
00259 if (lowerName == "operations menu") return MouseOperationsMenu;
00260 if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
00261 if (lowerName == "activate and raise") return MouseActivateAndRaise;
00262 if (lowerName == "activate and lower") return MouseActivateAndLower;
00263 if (lowerName == "activate") return MouseActivate;
00264 if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
00265 if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
00266 if (lowerName == "activate, raise and move")
00267 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
00268 if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
00269 if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
00270 if (lowerName == "shade") return MouseShade;
00271 if (lowerName == "minimize") return MouseMinimize;
00272 if (lowerName == "nothing") return MouseNothing;
00273 return MouseNothing;
00274 }
00275
00276 Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name)
00277 {
00278 QString lowerName = name.lower();
00279 if (lowerName == "raise/lower") return MouseWheelRaiseLower;
00280 if (lowerName == "shade/unshade") return MouseWheelShadeUnshade;
00281 if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore;
00282 if (lowerName == "above/below") return MouseWheelAboveBelow;
00283 if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop;
00284 if (lowerName == "change opacity") return MouseWheelChangeOpacity;
00285 return MouseWheelNothing;
00286 }
00287
00288 bool Options::showGeometryTip()
00289 {
00290 return show_geometry_tip;
00291 }
00292
00293 int Options::electricBorders()
00294 {
00295 return electric_borders;
00296 }
00297
00298 int Options::electricBorderDelay()
00299 {
00300 return electric_border_delay;
00301 }
00302
00303 bool Options::checkIgnoreFocusStealing( const Client* c )
00304 {
00305 return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass()));
00306 }
00307
00308 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta )
00309 {
00310 switch( com )
00311 {
00312 case MouseWheelRaiseLower:
00313 return delta > 0 ? MouseRaise : MouseLower;
00314 case MouseWheelShadeUnshade:
00315 return delta > 0 ? MouseSetShade : MouseUnsetShade;
00316 case MouseWheelMaximizeRestore:
00317 return delta > 0 ? MouseMaximize : MouseRestore;
00318 case MouseWheelAboveBelow:
00319 return delta > 0 ? MouseAbove : MouseBelow;
00320 case MouseWheelPreviousNextDesktop:
00321 return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
00322 case MouseWheelChangeOpacity:
00323 return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
00324 default:
00325 return MouseNothing;
00326 }
00327 }
00328 #endif
00329
00330 Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s )
00331 {
00332 return s == "Opaque" ? Opaque : Transparent;
00333 }
00334
00335 const char* Options::moveResizeModeToString( MoveResizeMode mode )
00336 {
00337 return mode == Opaque ? "Opaque" : "Transparent";
00338 }
00339
00340 }