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