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