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 d->OpMaxButtonLeftClick = windowOperation( config->readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true );
00137 d->OpMaxButtonMiddleClick = windowOperation( config->readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true );
00138 d->OpMaxButtonRightClick = windowOperation( config->readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true );
00139
00140 ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
00141 ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
00142
00143
00144 for( QStringList::Iterator it = ignorePositionClasses.begin();
00145 it != ignorePositionClasses.end();
00146 ++it )
00147 (*it) = (*it).lower();
00148 for( QStringList::Iterator it = ignoreFocusStealingClasses.begin();
00149 it != ignoreFocusStealingClasses.end();
00150 ++it )
00151 (*it) = (*it).lower();
00152
00153 killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
00154
00155
00156 config->setGroup( "MouseBindings");
00157 CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
00158 CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
00159 CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
00160 CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
00161 CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
00162 CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
00163 CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false );
00164 CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false );
00165 CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false );
00166 CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
00167 CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
00168 CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
00169 CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
00170
00171
00172 config->setGroup( "Notification Messages" );
00173 useTranslucency = config->readBoolEntry("UseTranslucency", false);
00174 config->setGroup( "Translucency");
00175 translucentActiveWindows = config->readBoolEntry("TranslucentActiveWindows", false);
00176 activeWindowOpacity = uint((config->readNumEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
00177 translucentInactiveWindows = config->readBoolEntry("TranslucentInactiveWindows", false);
00178 inactiveWindowOpacity = uint((config->readNumEntry("InactiveWindowOpacity", 75)/100.0)*0xFFFFFFFF);
00179 translucentMovingWindows = config->readBoolEntry("TranslucentMovingWindows", false);
00180 movingWindowOpacity = uint((config->readNumEntry("MovingWindowOpacity", 50)/100.0)*0xFFFFFFFF);
00181 translucentDocks = config->readBoolEntry("TranslucentDocks", false);
00182 dockOpacity = uint((config->readNumEntry("DockOpacity", 80)/100.0)*0xFFFFFFFF);
00183 keepAboveAsActive = config->readBoolEntry("TreatKeepAboveAsActive", true);
00184
00185 useTitleMenuSlider = true;
00186 activeWindowShadowSize = config->readNumEntry("ActiveWindowShadowSize", 200);
00187 inactiveWindowShadowSize = config->readNumEntry("InactiveWindowShadowSize", 100);
00188 dockShadowSize = config->readNumEntry("DockShadowSize", 80);
00189 removeShadowsOnMove = config->readBoolEntry("RemoveShadowsOnMove", true);
00190 removeShadowsOnResize = config->readBoolEntry("RemoveShadowsOnResize", true);
00191 if (resetKompmgr = config->readBoolEntry("ResetKompmgr", false))
00192 config->writeEntry("ResetKompmgr",FALSE);
00193
00194
00195
00196
00197
00198
00199
00200 KConfig globalConfig("kdeglobals");
00201 globalConfig.setGroup("KDE");
00202 topmenus = globalConfig.readBoolEntry( "macStyle", false );
00203
00204 KConfig kdesktopcfg( "kdesktoprc", true );
00205 kdesktopcfg.setGroup( "Menubar" );
00206 desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
00207 if( desktop_topmenu )
00208 topmenus = true;
00209
00210 QToolTip::setGloballyEnabled( d->show_tooltips );
00211
00212 return changed;
00213 }
00214
00215
00216
00217
00218
00219
00220 Options::WindowOperation Options::windowOperation(const QString &name, bool restricted )
00221 {
00222 if (name == "Move")
00223 return restricted ? MoveOp : UnrestrictedMoveOp;
00224 else if (name == "Resize")
00225 return restricted ? ResizeOp : UnrestrictedResizeOp;
00226 else if (name == "Maximize")
00227 return MaximizeOp;
00228 else if (name == "Minimize")
00229 return MinimizeOp;
00230 else if (name == "Close")
00231 return CloseOp;
00232 else if (name == "OnAllDesktops")
00233 return OnAllDesktopsOp;
00234 else if (name == "Shade")
00235 return ShadeOp;
00236 else if (name == "Operations")
00237 return OperationsOp;
00238 else if (name == "Maximize (vertical only)")
00239 return VMaximizeOp;
00240 else if (name == "Maximize (horizontal only)")
00241 return HMaximizeOp;
00242 else if (name == "Lower")
00243 return LowerOp;
00244 return NoOp;
00245 }
00246
00247 Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted )
00248 {
00249 QString lowerName = name.lower();
00250 if (lowerName == "raise") return MouseRaise;
00251 if (lowerName == "lower") return MouseLower;
00252 if (lowerName == "operations menu") return MouseOperationsMenu;
00253 if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
00254 if (lowerName == "activate and raise") return MouseActivateAndRaise;
00255 if (lowerName == "activate and lower") return MouseActivateAndLower;
00256 if (lowerName == "activate") return MouseActivate;
00257 if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
00258 if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
00259 if (lowerName == "activate, raise and move")
00260 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
00261 if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
00262 if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
00263 if (lowerName == "shade") return MouseShade;
00264 if (lowerName == "minimize") return MouseMinimize;
00265 if (lowerName == "nothing") return MouseNothing;
00266 return MouseNothing;
00267 }
00268
00269 bool Options::showGeometryTip()
00270 {
00271 return show_geometry_tip;
00272 }
00273
00274 int Options::electricBorders()
00275 {
00276 return electric_borders;
00277 }
00278
00279 int Options::electricBorderDelay()
00280 {
00281 return electric_border_delay;
00282 }
00283
00284 bool Options::checkIgnoreFocusStealing( const Client* c )
00285 {
00286 return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass()));
00287 }
00288 #endif
00289
00290 Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s )
00291 {
00292 return s == "Opaque" ? Opaque : Transparent;
00293 }
00294
00295 const char* Options::moveResizeModeToString( MoveResizeMode mode )
00296 {
00297 return mode == Opaque ? "Opaque" : "Transparent";
00298 }
00299
00300 }