• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • @topname@
  • Sitemap
  • Contact Us
 

kwin

options.cpp

00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
00006 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
00007 
00008 You can Freely distribute this program under the GNU General Public
00009 License. See the file "COPYING" for the exact licensing terms.
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 ); // read decoration settings
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; // what a default :-)
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; // what a default :-)
00072     if ( val == "CDE" )
00073         altTabStyle = CDE;
00074         
00075     separateScreenFocus = config->readBoolEntry( "SeparateScreenFocus", false );
00076     activeMouseScreen = config->readBoolEntry( "ActiveMouseScreen", focusPolicy != ClickToFocus );
00077 
00078     rollOverDesktops = config->readBoolEntry("RollOverDesktops", TRUE);
00079     
00080 //    focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 2 );
00081     // TODO use low level for now
00082     focusStealingPreventionLevel = config->readNumEntry( "FocusStealingPreventionLevel", 1 );
00083     focusStealingPreventionLevel = KMAX( 0, KMIN( 4, focusStealingPreventionLevel ));
00084     if( !focusPolicyIsReasonable()) // #48786, comments #7 and later
00085         focusStealingPreventionLevel = 0;
00086 
00087     KConfig *gc = new KConfig("kdeglobals", false, false);
00088     gc->setGroup("Windows");
00089     xineramaEnabled = gc->readBoolEntry ("XineramaEnabled", true );
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     delete gc;
00095 
00096     placement = Placement::policyFromString( config->readEntry("Placement"), true );
00097     xineramaPlacementScreen = KCLAMP( config->readNumEntry( "XineramaPlacementScreen", -1 ),
00098         -1, qApp->desktop()->numScreens() - 1 );
00099 
00100     animateShade = config->readBoolEntry("AnimateShade", TRUE );
00101     animateMinimize = config->readBoolEntry("AnimateMinimize", TRUE );
00102     animateMinimizeSpeed = config->readNumEntry("AnimateMinimizeSpeed", 5 );
00103 
00104     if( focusPolicy == ClickToFocus ) 
00105         {
00106         autoRaise = false;
00107         autoRaiseInterval = 0;
00108         delayFocus = false;
00109         delayFocusInterval = 0;
00110         }
00111     else 
00112         {
00113         autoRaise = config->readBoolEntry("AutoRaise", FALSE );
00114         autoRaiseInterval = config->readNumEntry("AutoRaiseInterval", 0 );
00115         delayFocus = config->readBoolEntry("DelayFocus", FALSE );
00116         delayFocusInterval = config->readNumEntry("DelayFocusInterval", 0 );
00117         }
00118 
00119     shadeHover = config->readBoolEntry("ShadeHover", FALSE );
00120     shadeHoverInterval = config->readNumEntry("ShadeHoverInterval", 250 );
00121 
00122     // important: autoRaise implies ClickRaise
00123     clickRaise = autoRaise || config->readBoolEntry("ClickRaise", TRUE );
00124 
00125     borderSnapZone = config->readNumEntry("BorderSnapZone", 10);
00126     windowSnapZone = config->readNumEntry("WindowSnapZone", 10);
00127     snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",FALSE);
00128     electric_borders = config->readNumEntry("ElectricBorders", 0);
00129     electric_border_delay = config->readNumEntry("ElectricBorderDelay", 150);
00130 
00131     OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade"), true );
00132     d->OpMaxButtonLeftClick = windowOperation( config->readEntry("MaximizeButtonLeftClickCommand", "Maximize"), true );
00133     d->OpMaxButtonMiddleClick = windowOperation( config->readEntry("MaximizeButtonMiddleClickCommand", "Maximize (vertical only)"), true );
00134     d->OpMaxButtonRightClick = windowOperation( config->readEntry("MaximizeButtonRightClickCommand", "Maximize (horizontal only)"), true );
00135 
00136     ignorePositionClasses = config->readListEntry("IgnorePositionClasses");
00137     ignoreFocusStealingClasses = config->readListEntry("IgnoreFocusStealingClasses");
00138     // Qt3.2 and older had resource class all lowercase, but Qt3.3 has it capitalized
00139     // therefore Client::resourceClass() forces lowercase, force here lowercase as well
00140     for( QStringList::Iterator it = ignorePositionClasses.begin();
00141          it != ignorePositionClasses.end();
00142          ++it )
00143         (*it) = (*it).lower();
00144     for( QStringList::Iterator it = ignoreFocusStealingClasses.begin();
00145          it != ignoreFocusStealingClasses.end();
00146          ++it )
00147         (*it) = (*it).lower();
00148 
00149     killPingTimeout = config->readNumEntry( "KillPingTimeout", 5000 );
00150     hideUtilityWindowsForInactive = config->readBoolEntry( "HideUtilityWindowsForInactive", true );
00151     showDesktopIsMinimizeAll = config->readBoolEntry( "ShowDesktopIsMinimizeAll", false );
00152 
00153     // Mouse bindings
00154     config->setGroup( "MouseBindings");
00155     CmdActiveTitlebar1 = mouseCommand(config->readEntry("CommandActiveTitlebar1","Raise"), true );
00156     CmdActiveTitlebar2 = mouseCommand(config->readEntry("CommandActiveTitlebar2","Lower"), true );
00157     CmdActiveTitlebar3 = mouseCommand(config->readEntry("CommandActiveTitlebar3","Operations menu"), true );
00158     CmdInactiveTitlebar1 = mouseCommand(config->readEntry("CommandInactiveTitlebar1","Activate and raise"), true );
00159     CmdInactiveTitlebar2 = mouseCommand(config->readEntry("CommandInactiveTitlebar2","Activate and lower"), true );
00160     CmdInactiveTitlebar3 = mouseCommand(config->readEntry("CommandInactiveTitlebar3","Operations menu"), true );
00161     CmdTitlebarWheel = mouseWheelCommand(config->readEntry("CommandTitlebarWheel","Nothing"));
00162     CmdWindow1 = mouseCommand(config->readEntry("CommandWindow1","Activate, raise and pass click"), false );
00163     CmdWindow2 = mouseCommand(config->readEntry("CommandWindow2","Activate and pass click"), false );
00164     CmdWindow3 = mouseCommand(config->readEntry("CommandWindow3","Activate and pass click"), false );
00165     CmdAllModKey = (config->readEntry("CommandAllKey","Alt") == "Meta") ? Qt::Key_Meta : Qt::Key_Alt;
00166     CmdAll1 = mouseCommand(config->readEntry("CommandAll1","Move"), false );
00167     CmdAll2 = mouseCommand(config->readEntry("CommandAll2","Toggle raise and lower"), false );
00168     CmdAll3 = mouseCommand(config->readEntry("CommandAll3","Resize"), false );
00169     CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
00170 
00171     //translucency settings
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     //TODO: remove this variable
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     onlyDecoTranslucent = config->readBoolEntry("OnlyDecoTranslucent",false);
00192     resetKompmgr = config->readBoolEntry("ResetKompmgr", false);
00193     if (resetKompmgr)
00194         config->writeEntry("ResetKompmgr",FALSE);
00195     
00196     
00197     
00198     // Read button tooltip animation effect from kdeglobals
00199     // Since we want to allow users to enable window decoration tooltips
00200     // and not kstyle tooltips and vise-versa, we don't read the
00201     // "EffectNoTooltip" setting from kdeglobals.
00202     KConfig globalConfig("kdeglobals");
00203     globalConfig.setGroup("KDE");
00204     topmenus = globalConfig.readBoolEntry( "macStyle", false );
00205 
00206     KConfig kdesktopcfg( "kdesktoprc", true );
00207     kdesktopcfg.setGroup( "Menubar" );
00208     desktop_topmenu = kdesktopcfg.readBoolEntry( "ShowMenubar", false );
00209     if( desktop_topmenu )
00210         topmenus = true;
00211         
00212     QToolTip::setGloballyEnabled( d->show_tooltips );
00213 
00214     return changed;
00215     }
00216 
00217 
00218 // restricted should be true for operations that the user may not be able to repeat
00219 // if the window is moved out of the workspace (e.g. if the user moves a window
00220 // by the titlebar, and moves it too high beneath Kicker at the top edge, they
00221 // may not be able to move it back, unless they know about Alt+LMB)
00222 Options::WindowOperation Options::windowOperation(const QString &name, bool restricted )
00223     {
00224     if (name == "Move")
00225         return restricted ? MoveOp : UnrestrictedMoveOp;
00226     else if (name == "Resize")
00227         return restricted ? ResizeOp : UnrestrictedResizeOp;
00228     else if (name == "Maximize")
00229         return MaximizeOp;
00230     else if (name == "Minimize")
00231         return MinimizeOp;
00232     else if (name == "Close")
00233         return CloseOp;
00234     else if (name == "OnAllDesktops")
00235         return OnAllDesktopsOp;
00236     else if (name == "Shade")
00237         return ShadeOp;
00238     else if (name == "Operations")
00239         return OperationsOp;
00240     else if (name == "Maximize (vertical only)")
00241         return VMaximizeOp;
00242     else if (name == "Maximize (horizontal only)")
00243         return HMaximizeOp;
00244     else if (name == "Lower")
00245         return LowerOp;
00246     return NoOp;
00247     }
00248 
00249 Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted )
00250     {
00251     QString lowerName = name.lower();
00252     if (lowerName == "raise") return MouseRaise;
00253     if (lowerName == "lower") return MouseLower;
00254     if (lowerName == "operations menu") return MouseOperationsMenu;
00255     if (lowerName == "toggle raise and lower") return MouseToggleRaiseAndLower;
00256     if (lowerName == "activate and raise") return MouseActivateAndRaise;
00257     if (lowerName == "activate and lower") return MouseActivateAndLower;
00258     if (lowerName == "activate") return MouseActivate;
00259     if (lowerName == "activate, raise and pass click") return MouseActivateRaiseAndPassClick;
00260     if (lowerName == "activate and pass click") return MouseActivateAndPassClick;
00261     if (lowerName == "activate, raise and move")
00262         return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
00263     if (lowerName == "move") return restricted ? MouseMove : MouseUnrestrictedMove;
00264     if (lowerName == "resize") return restricted ? MouseResize : MouseUnrestrictedResize;
00265     if (lowerName == "shade") return MouseShade;
00266     if (lowerName == "minimize") return MouseMinimize;
00267     if (lowerName == "nothing") return MouseNothing;
00268     return MouseNothing;
00269     }
00270 
00271 Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name)
00272     {
00273     QString lowerName = name.lower();
00274     if (lowerName == "raise/lower") return MouseWheelRaiseLower;
00275     if (lowerName == "shade/unshade") return MouseWheelShadeUnshade;
00276     if (lowerName == "maximize/restore") return MouseWheelMaximizeRestore;
00277     if (lowerName == "above/below") return MouseWheelAboveBelow;
00278     if (lowerName == "previous/next desktop") return MouseWheelPreviousNextDesktop;
00279     if (lowerName == "change opacity") return MouseWheelChangeOpacity;
00280     return MouseWheelNothing;
00281     }
00282 
00283 bool Options::showGeometryTip()
00284     {
00285     return show_geometry_tip;
00286     }
00287 
00288 int Options::electricBorders()
00289     {
00290     return electric_borders;
00291     }
00292 
00293 int Options::electricBorderDelay()
00294     {
00295     return electric_border_delay;
00296     }
00297 
00298 bool Options::checkIgnoreFocusStealing( const Client* c )
00299     {
00300     return ignoreFocusStealingClasses.contains(QString::fromLatin1(c->resourceClass()));
00301     }
00302 
00303 Options::MouseCommand Options::wheelToMouseCommand( MouseWheelCommand com, int delta )
00304     {
00305     switch( com )
00306         {
00307         case MouseWheelRaiseLower:
00308             return delta > 0 ? MouseRaise : MouseLower;
00309         case MouseWheelShadeUnshade:
00310             return delta > 0 ? MouseSetShade : MouseUnsetShade;
00311         case MouseWheelMaximizeRestore:
00312             return delta > 0 ? MouseMaximize : MouseRestore;
00313         case MouseWheelAboveBelow:
00314             return delta > 0 ? MouseAbove : MouseBelow;
00315         case MouseWheelPreviousNextDesktop:
00316             return delta > 0 ? MousePreviousDesktop : MouseNextDesktop;
00317         case MouseWheelChangeOpacity:
00318             return delta > 0 ? MouseOpacityMore : MouseOpacityLess;
00319         default:
00320             return MouseNothing;
00321         }
00322     }
00323 #endif
00324 
00325 Options::MoveResizeMode Options::stringToMoveResizeMode( const QString& s )
00326     {
00327     return s == "Opaque" ? Opaque : Transparent;
00328     }
00329 
00330 const char* Options::moveResizeModeToString( MoveResizeMode mode )
00331     {
00332     return mode == Opaque ? "Opaque" : "Transparent";
00333     }
00334 
00335 } // namespace

kwin

Skip menu "kwin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

@topname@

Skip menu "@topname@"
  • kate
  • kwin
  •   lib
  • libkonq
Generated for @topname@ by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal