kwin Library API Documentation

windows.cpp

00001 /*
00002  * windows.cpp
00003  *
00004  * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca
00005  * Copyright (c) 2001 Waldo Bastian bastian@kde.org
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  *
00021  *
00022  */
00023 
00024 #include <config.h>
00025 
00026 #include <qlayout.h>
00027 #include <qslider.h>
00028 #include <qwhatsthis.h>
00029 #include <qvbuttongroup.h>
00030 #include <qcheckbox.h>
00031 #include <qradiobutton.h>
00032 #include <qlabel.h>
00033 #include <qcombobox.h>
00034 
00035 #include <klocale.h>
00036 #include <kconfig.h>
00037 #include <knuminput.h>
00038 #include <kapplication.h>
00039 #include <kdialog.h>
00040 #include <dcopclient.h>
00041 #include <kglobal.h>
00042 
00043 #include <X11/X.h>
00044 #include <X11/Xlib.h>
00045 #include <X11/Xutil.h>
00046 
00047 #include "windows.h"
00048 
00049 
00050 // kwin config keywords
00051 #define KWIN_FOCUS                 "FocusPolicy"
00052 #define KWIN_PLACEMENT             "Placement"
00053 #define KWIN_MOVE                  "MoveMode"
00054 #define KWIN_MINIMIZE_ANIM         "AnimateMinimize"
00055 #define KWIN_MINIMIZE_ANIM_SPEED   "AnimateMinimizeSpeed"
00056 #define KWIN_RESIZE_OPAQUE         "ResizeMode"
00057 #define KWIN_GEOMETRY              "GeometryTip"
00058 #define KWIN_AUTORAISE_INTERVAL    "AutoRaiseInterval"
00059 #define KWIN_AUTORAISE             "AutoRaise"
00060 #define KWIN_DELAYFOCUS_INTERVAL   "DelayFocusInterval"
00061 #define KWIN_DELAYFOCUS            "DelayFocus"
00062 #define KWIN_CLICKRAISE            "ClickRaise"
00063 #define KWIN_ANIMSHADE             "AnimateShade"
00064 #define KWIN_MOVE_RESIZE_MAXIMIZED "MoveResizeMaximizedWindows"
00065 #define KWIN_ALTTABMODE            "AltTabStyle"
00066 #define KWIN_TRAVERSE_ALL          "TraverseAll"
00067 #define KWIN_SHOW_POPUP            "ShowPopup"
00068 #define KWIN_ROLL_OVER_DESKTOPS    "RollOverDesktops"
00069 #define KWIN_SHADEHOVER            "ShadeHover"
00070 #define KWIN_SHADEHOVER_INTERVAL   "ShadeHoverInterval"
00071 #define KWIN_FOCUS_STEALING        "FocusStealingPreventionLevel"
00072 
00073 // kwm config keywords
00074 #define KWM_ELECTRIC_BORDER                  "ElectricBorders"
00075 #define KWM_ELECTRIC_BORDER_DELAY            "ElectricBorderDelay"
00076 
00077 //CT 15mar 98 - magics
00078 #define KWM_BRDR_SNAP_ZONE                   "BorderSnapZone"
00079 #define KWM_BRDR_SNAP_ZONE_DEFAULT           10
00080 #define KWM_WNDW_SNAP_ZONE                   "WindowSnapZone"
00081 #define KWM_WNDW_SNAP_ZONE_DEFAULT           10
00082 
00083 #define MAX_BRDR_SNAP                          100
00084 #define MAX_WNDW_SNAP                          100
00085 #define MAX_EDGE_RES                          1000
00086 
00087 
00088 KFocusConfig::~KFocusConfig ()
00089 {
00090     if (standAlone)
00091         delete config;
00092 }
00093 
00094 // removed the LCD display over the slider - this is not good GUI design :) RNolden 051701
00095 KFocusConfig::KFocusConfig (bool _standAlone, KConfig *_config, QWidget * parent, const char *)
00096     : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00097 {
00098     QString wtstr;
00099     QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00100 
00101     //iTLabel = new QLabel(i18n("  Allowed overlap:\n"
00102     //                         "(% of desktop space)"),
00103     //             plcBox);
00104     //iTLabel->setAlignment(AlignTop|AlignHCenter);
00105     //pLay->addWidget(iTLabel,1,1);
00106 
00107     //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
00108     //pLay->addWidget(interactiveTrigger,1,2);
00109 
00110     //pLay->addRowSpacing(2,KDialog::spacingHint());
00111 
00112     //lay->addWidget(plcBox);
00113 
00114     // focus policy
00115     fcsBox = new QButtonGroup(i18n("Focus"),this);
00116     fcsBox->setColumnLayout( 0, Qt::Horizontal );
00117 
00118     QBoxLayout *fLay = new QVBoxLayout(fcsBox->layout(),
00119         KDialog::spacingHint());
00120 
00121     QBoxLayout *cLay = new QHBoxLayout(fLay);
00122     QLabel *fLabel = new QLabel(i18n("&Policy:"), fcsBox);
00123     cLay->addWidget(fLabel, 0);
00124     focusCombo =  new QComboBox(false, fcsBox);
00125     focusCombo->insertItem(i18n("Click to Focus"), CLICK_TO_FOCUS);
00126     focusCombo->insertItem(i18n("Focus Follows Mouse"), FOCUS_FOLLOWS_MOUSE);
00127     focusCombo->insertItem(i18n("Focus Under Mouse"), FOCUS_UNDER_MOUSE);
00128     focusCombo->insertItem(i18n("Focus Strictly Under Mouse"), FOCUS_STRICTLY_UNDER_MOUSE);
00129     cLay->addWidget(focusCombo,1 ,Qt::AlignLeft);
00130     fLabel->setBuddy(focusCombo);
00131 
00132     // FIXME, when more policies have been added to KWin
00133     wtstr = i18n("The focus policy is used to determine the active window, i.e."
00134                                       " the window you can work in. <ul>"
00135                                       " <li><em>Click to focus:</em> A window becomes active when you click into it."
00136                                       " This is the behavior you might know from other operating systems.</li>"
00137                                       " <li><em>Focus follows mouse:</em> Moving the mouse pointer actively on to a"
00138                                       " normal window activates it. New windows will receive the focus,"
00139                                       " without you having to point the mouse at them explicitly."
00140                                       " Very practical if you are using the mouse a lot.</li>"
00141                                       " <li><em>Focus under mouse:</em> The window that happens to be under the"
00142                                       " mouse pointer is active. If the mouse points nowhere, the last window"
00143                                       " that was under the mouse has focus."
00144                                       " New windows will not automatically receive the focus.</li>"
00145                                       " <li><em>Focus strictly under mouse:</em> Only the window under the mouse pointer is"
00146                                       " active. If the mouse points nowhere, nothing has focus."
00147                                       " </ul>"
00148                                       "Note that 'Focus under mouse' and 'Focus strictly under mouse' prevent certain"
00149                                       " features such as the Alt+Tab walk through windows dialog in the KDE mode"
00150                                       " from working properly."
00151                          );
00152     QWhatsThis::add( focusCombo, wtstr);
00153     QWhatsThis::add(fLabel, wtstr);
00154 
00155     connect(focusCombo, SIGNAL(activated(int)), this, SLOT(setAutoRaiseEnabled()) );
00156 
00157     // autoraise delay
00158     autoRaiseOn = new QCheckBox(i18n("Auto &raise"), fcsBox);
00159     fLay->addWidget(autoRaiseOn);
00160     connect(autoRaiseOn,SIGNAL(toggled(bool)), this, SLOT(autoRaiseOnTog(bool)));
00161 
00162     autoRaise = new KIntNumInput(500, fcsBox);
00163     autoRaise->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00164     autoRaise->setRange(0, 3000, 100, true);
00165     autoRaise->setSteps(100,100);
00166     autoRaise->setSuffix(i18n(" msec"));
00167     fLay->addWidget(autoRaise);
00168 
00169     connect(focusCombo, SIGNAL(activated(int)), this, SLOT(setDelayFocusEnabled()) );
00170     
00171     delayFocusOn = new QCheckBox(i18n("Delay focus"), fcsBox);
00172     fLay->addWidget(delayFocusOn);
00173     connect(delayFocusOn,SIGNAL(toggled(bool)), this, SLOT(delayFocusOnTog(bool)));
00174 
00175     delayFocus = new KIntNumInput(500, fcsBox);
00176     delayFocus->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00177     delayFocus->setRange(0, 3000, 100, true);
00178     delayFocus->setSteps(100,100);
00179     delayFocus->setSuffix(i18n(" msec"));
00180     fLay->addWidget(delayFocus);
00181     
00182     clickRaiseOn = new QCheckBox(i18n("C&lick raise active window"), fcsBox);
00183     connect(clickRaiseOn,SIGNAL(toggled(bool)), this, SLOT(clickRaiseOnTog(bool)));
00184     fLay->addWidget(clickRaiseOn);
00185 
00186 //     fLay->addColSpacing(0,QMAX(autoRaiseOn->sizeHint().width(),
00187 //                                clickRaiseOn->sizeHint().width()) + 15);
00188 
00189     QWhatsThis::add( autoRaiseOn, i18n("When this option is enabled, a window in the background will automatically"
00190                                        " come to the front when the mouse pointer has been over it for some time.") );
00191     wtstr = i18n("This is the delay after which the window that the mouse pointer is over will automatically"
00192                  " come to the front.");
00193     QWhatsThis::add( autoRaise, wtstr );
00194 
00195     QWhatsThis::add( clickRaiseOn, i18n("When this option is enabled, the active window will be brought to the"
00196                                         " front when you click somewhere into the window contents. To change"
00197                                         " it for inactive windows, you need to change the settings"
00198                                         " in the Actions tab.") );
00199 
00200     QWhatsThis::add( delayFocusOn, i18n("When this option is enabled, there will be a delay after which the"
00201                                         " window the mouse pointer is over will become active (receive focus).") );
00202     QWhatsThis::add( delayFocus, i18n("This is the delay after which the window the mouse pointer is over"
00203                                        " will automatically receive focus.") );
00204 
00205     lay->addWidget(fcsBox);
00206 
00207     kbdBox = new QButtonGroup(i18n("Navigation"), this);
00208     kbdBox->setColumnLayout( 0, Qt::Horizontal );
00209     QVBoxLayout *kLay = new QVBoxLayout(kbdBox->layout(), KDialog::spacingHint());
00210 
00211     altTabPopup = new QCheckBox( i18n("Show window list while switching windows"), kbdBox );
00212     kLay->addWidget( altTabPopup );
00213 
00214     wtstr = i18n("Hold down the Alt key and press the Tab key repeatedly to walk"
00215                  " through the windows on the current desktop (the Alt+Tab"
00216                  " combination can be reconfigured).\n\n"
00217                  "If this checkbox is checked"
00218                  " a popup widget is shown, displaying the icons of all windows to"
00219                  " walk through and the title of the currently selected one.\n\n"
00220                  "Otherwise, the focus is passed to a new window each time Tab"
00221                  " is pressed, with no popup widget.  In addition, the previously"
00222                  " activated window will be sent to the back in this mode.");
00223     QWhatsThis::add( altTabPopup, wtstr );
00224 
00225     traverseAll = new QCheckBox( i18n( "&Traverse windows on all desktops" ), kbdBox );
00226     kLay->addWidget( traverseAll );
00227 
00228     wtstr = i18n( "Leave this option disabled if you want to limit walking through"
00229                   " windows to the current desktop." );
00230     QWhatsThis::add( traverseAll, wtstr );
00231 
00232     rollOverDesktops = new QCheckBox( i18n("Desktop navi&gation wraps around"), kbdBox );
00233     kLay->addWidget(rollOverDesktops);
00234 
00235     wtstr = i18n( "Enable this option if you want keyboard or active desktop border navigation beyond"
00236                   " the edge of a desktop to take you to the opposite edge of the new desktop." );
00237     QWhatsThis::add( rollOverDesktops, wtstr );
00238 
00239     showPopupinfo = new QCheckBox( i18n("Popup desktop name on desktop &switch"), kbdBox );
00240     kLay->addWidget(showPopupinfo);
00241 
00242     wtstr = i18n( "Enable this option if you wish to see the current desktop"
00243                   " name popup whenever the current desktop is changed." );
00244     QWhatsThis::add( showPopupinfo, wtstr );
00245 
00246     lay->addWidget(kbdBox);
00247 
00248     lay->addStretch();
00249 
00250     // Any changes goes to slotChanged()
00251     connect(focusCombo, SIGNAL(activated(int)), SLOT(changed()));
00252     connect(fcsBox, SIGNAL(clicked(int)), SLOT(changed()));
00253     connect(autoRaise, SIGNAL(valueChanged(int)), SLOT(changed()));
00254     connect(delayFocus, SIGNAL(valueChanged(int)), SLOT(changed()));
00255     connect(altTabPopup, SIGNAL(clicked()), SLOT(changed()));
00256     connect(traverseAll, SIGNAL(clicked()), SLOT(changed()));
00257     connect(rollOverDesktops, SIGNAL(clicked()), SLOT(changed()));
00258     connect(showPopupinfo, SIGNAL(clicked()), SLOT(changed()));
00259 
00260     load();
00261 }
00262 
00263 
00264 int KFocusConfig::getFocus()
00265 {
00266     return focusCombo->currentItem();
00267 }
00268 
00269 void KFocusConfig::setFocus(int foc)
00270 {
00271     focusCombo->setCurrentItem(foc);
00272 
00273     // this will disable/hide the auto raise delay widget if focus==click
00274     setAutoRaiseEnabled();
00275 }
00276 
00277 void KFocusConfig::setAutoRaiseInterval(int tb)
00278 {
00279     autoRaise->setValue(tb);
00280 }
00281 
00282 void KFocusConfig::setDelayFocusInterval(int tb)
00283 {
00284     delayFocus->setValue(tb);
00285 }
00286 
00287 int KFocusConfig::getAutoRaiseInterval()
00288 {
00289     return autoRaise->value();
00290 }
00291 
00292 int KFocusConfig::getDelayFocusInterval()
00293 {
00294     return delayFocus->value();
00295 }
00296 
00297 void KFocusConfig::setAutoRaise(bool on)
00298 {
00299     autoRaiseOn->setChecked(on);
00300 }
00301 
00302 void KFocusConfig::setDelayFocus(bool on)
00303 {
00304     delayFocusOn->setChecked(on);
00305 }
00306 
00307 void KFocusConfig::setClickRaise(bool on)
00308 {
00309     clickRaiseOn->setChecked(on);
00310 }
00311 
00312 void KFocusConfig::setAutoRaiseEnabled()
00313 {
00314     // the auto raise related widgets are: autoRaise
00315     if ( focusCombo->currentItem() != CLICK_TO_FOCUS )
00316     {
00317         autoRaiseOn->setEnabled(true);
00318         autoRaiseOnTog(autoRaiseOn->isChecked());
00319     }
00320     else
00321     {
00322         autoRaiseOn->setEnabled(false);
00323         autoRaiseOnTog(false);
00324     }
00325 }
00326 
00327 void KFocusConfig::setDelayFocusEnabled()
00328 {
00329     // the delayed focus related widgets are: delayFocus
00330     if ( focusCombo->currentItem() != CLICK_TO_FOCUS )
00331     {
00332         delayFocusOn->setEnabled(true);
00333         delayFocusOnTog(delayFocusOn->isChecked());
00334     }
00335     else
00336     {
00337         delayFocusOn->setEnabled(false);
00338         delayFocusOnTog(false);
00339     }
00340 }
00341 
00342 void KFocusConfig::autoRaiseOnTog(bool a) {
00343     autoRaise->setEnabled(a);
00344     clickRaiseOn->setEnabled( !a );
00345 }
00346 
00347 void KFocusConfig::delayFocusOnTog(bool a) {
00348     delayFocus->setEnabled(a);
00349 }
00350 
00351 void KFocusConfig::clickRaiseOnTog(bool ) {
00352 }
00353 
00354 void KFocusConfig::setAltTabMode(bool a) {
00355     altTabPopup->setChecked(a);
00356 }
00357 
00358 void KFocusConfig::setTraverseAll(bool a) {
00359     traverseAll->setChecked(a);
00360 }
00361 
00362 void KFocusConfig::setRollOverDesktops(bool a) {
00363     rollOverDesktops->setChecked(a);
00364 }
00365 
00366 void KFocusConfig::setShowPopupinfo(bool a) {
00367     showPopupinfo->setChecked(a);
00368 }
00369 
00370 void KFocusConfig::load( void )
00371 {
00372     QString key;
00373 
00374     config->setGroup( "Windows" );
00375 
00376     key = config->readEntry(KWIN_FOCUS);
00377     if( key == "ClickToFocus")
00378         setFocus(CLICK_TO_FOCUS);
00379     else if( key == "FocusFollowsMouse")
00380         setFocus(FOCUS_FOLLOWS_MOUSE);
00381     else if(key == "FocusUnderMouse")
00382         setFocus(FOCUS_UNDER_MOUSE);
00383     else if(key == "FocusStrictlyUnderMouse")
00384         setFocus(FOCUS_STRICTLY_UNDER_MOUSE);
00385 
00386     int k = config->readNumEntry(KWIN_AUTORAISE_INTERVAL,750);
00387     setAutoRaiseInterval(k);
00388 
00389     k = config->readNumEntry(KWIN_DELAYFOCUS_INTERVAL,750);
00390     setDelayFocusInterval(k);
00391     
00392     key = config->readEntry(KWIN_AUTORAISE);
00393     setAutoRaise(key == "on");
00394     key = config->readEntry(KWIN_DELAYFOCUS);
00395     setDelayFocus(key == "on");
00396     key = config->readEntry(KWIN_CLICKRAISE);
00397     setClickRaise(key != "off");
00398     setAutoRaiseEnabled();      // this will disable/hide the auto raise delay widget if focus==click
00399     setDelayFocusEnabled();
00400 
00401     key = config->readEntry(KWIN_ALTTABMODE, "KDE");
00402     setAltTabMode(key == "KDE");
00403 
00404     setRollOverDesktops( config->readBoolEntry(KWIN_ROLL_OVER_DESKTOPS, true ));
00405 
00406     config->setGroup( "PopupInfo" );
00407     setShowPopupinfo( config->readBoolEntry(KWIN_SHOW_POPUP, false ));
00408 
00409     config->setGroup( "TabBox" );
00410     setTraverseAll( config->readBoolEntry(KWIN_TRAVERSE_ALL, false ));
00411 
00412     config->setGroup("Desktops");
00413     emit KCModule::changed(false);
00414 }
00415 
00416 void KFocusConfig::save( void )
00417 {
00418     int v;
00419 
00420     config->setGroup( "Windows" );
00421 
00422     v = getFocus();
00423     if (v == CLICK_TO_FOCUS)
00424         config->writeEntry(KWIN_FOCUS,"ClickToFocus");
00425     else if (v == FOCUS_UNDER_MOUSE)
00426         config->writeEntry(KWIN_FOCUS,"FocusUnderMouse");
00427     else if (v == FOCUS_STRICTLY_UNDER_MOUSE)
00428         config->writeEntry(KWIN_FOCUS,"FocusStrictlyUnderMouse");
00429     else
00430         config->writeEntry(KWIN_FOCUS,"FocusFollowsMouse");
00431 
00432     v = getAutoRaiseInterval();
00433     if (v <0) v = 0;
00434     config->writeEntry(KWIN_AUTORAISE_INTERVAL,v);
00435 
00436     v = getDelayFocusInterval();
00437     if (v <0) v = 0;
00438     config->writeEntry(KWIN_DELAYFOCUS_INTERVAL,v);
00439     
00440     if (autoRaiseOn->isChecked())
00441         config->writeEntry(KWIN_AUTORAISE, "on");
00442     else
00443         config->writeEntry(KWIN_AUTORAISE, "off");
00444 
00445     if (delayFocusOn->isChecked())
00446         config->writeEntry(KWIN_DELAYFOCUS, "on");
00447     else
00448         config->writeEntry(KWIN_DELAYFOCUS, "off");
00449 
00450     if (clickRaiseOn->isChecked())
00451         config->writeEntry(KWIN_CLICKRAISE, "on");
00452     else
00453         config->writeEntry(KWIN_CLICKRAISE, "off");
00454 
00455     if (altTabPopup->isChecked())
00456         config->writeEntry(KWIN_ALTTABMODE, "KDE");
00457     else
00458         config->writeEntry(KWIN_ALTTABMODE, "CDE");
00459 
00460     config->writeEntry( KWIN_ROLL_OVER_DESKTOPS, rollOverDesktops->isChecked());
00461 
00462     config->setGroup( "PopupInfo" );
00463     config->writeEntry( KWIN_SHOW_POPUP, showPopupinfo->isChecked());
00464 
00465     config->setGroup( "TabBox" );
00466     config->writeEntry( KWIN_TRAVERSE_ALL , traverseAll->isChecked());
00467 
00468     config->setGroup("Desktops");
00469 
00470     if (standAlone)
00471     {
00472         config->sync();
00473         if ( !kapp->dcopClient()->isAttached() )
00474             kapp->dcopClient()->attach();
00475         kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
00476     }
00477     emit KCModule::changed(false);
00478 }
00479 
00480 void KFocusConfig::defaults()
00481 {
00482     setAutoRaiseInterval(0);
00483     setDelayFocusInterval(0);
00484     setFocus(CLICK_TO_FOCUS);
00485     setAutoRaise(false);
00486     setDelayFocus(false);
00487     setClickRaise(true);
00488     setAltTabMode(true);
00489     setTraverseAll( false );
00490     setRollOverDesktops(true);
00491     setShowPopupinfo(false);
00492     emit KCModule::changed(true);
00493 }
00494 
00495 KAdvancedConfig::~KAdvancedConfig ()
00496 {
00497     if (standAlone)
00498         delete config;
00499 }
00500 
00501 KAdvancedConfig::KAdvancedConfig (bool _standAlone, KConfig *_config, QWidget *parent, const char *)
00502     : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00503 {
00504     QString wtstr;
00505     QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00506 
00507     //iTLabel = new QLabel(i18n("  Allowed overlap:\n"
00508     //                         "(% of desktop space)"),
00509     //             plcBox);
00510     //iTLabel->setAlignment(AlignTop|AlignHCenter);
00511     //pLay->addWidget(iTLabel,1,1);
00512 
00513     //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
00514     //pLay->addWidget(interactiveTrigger,1,2);
00515 
00516     //pLay->addRowSpacing(2,KDialog::spacingHint());
00517 
00518     //lay->addWidget(plcBox);
00519 
00520     shBox = new QVButtonGroup(i18n("Shading"), this);
00521 
00522     animateShade = new QCheckBox(i18n("Anima&te"), shBox);
00523     QWhatsThis::add(animateShade, i18n("Animate the action of reducing the window to its titlebar (shading)"
00524                                        " as well as the expansion of a shaded window") );
00525 
00526     shadeHoverOn = new QCheckBox(i18n("&Enable hover"), shBox);
00527 
00528     connect(shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool)));
00529 
00530     shadeHover = new KIntNumInput(500, shBox);
00531     shadeHover->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00532     shadeHover->setRange(0, 3000, 100, true);
00533     shadeHover->setSteps(100, 100);
00534     shadeHover->setSuffix(i18n(" msec"));
00535 
00536     QWhatsThis::add(shadeHoverOn, i18n("If Shade Hover is enabled, a shaded window will un-shade automatically "
00537                                        "when the mouse pointer has been over the title bar for some time."));
00538 
00539     wtstr = i18n("Sets the time in milliseconds before the window unshades "
00540                 "when the mouse pointer goes over the shaded window.");
00541     QWhatsThis::add(shadeHover, wtstr);
00542 
00543     lay->addWidget(shBox);
00544 
00545     // Any changes goes to slotChanged()
00546     connect(animateShade, SIGNAL(toggled(bool)), SLOT(changed()));
00547     connect(shadeHoverOn, SIGNAL(toggled(bool)), SLOT(changed()));
00548     connect(shadeHover, SIGNAL(valueChanged(int)), SLOT(changed()));
00549 
00550     electricBox = new QVButtonGroup(i18n("Active Desktop Borders"), this);
00551     electricBox->setMargin(15);
00552 
00553     QWhatsThis::add( electricBox, i18n("If this option is enabled, moving the mouse to a screen border"
00554        " will change your desktop. This is e.g. useful if you want to drag windows from one desktop"
00555        " to the other.") );
00556     active_disable = new QRadioButton(i18n("D&isabled"), electricBox);
00557     active_move    = new QRadioButton(i18n("Only &when moving windows"), electricBox);
00558     active_always  = new QRadioButton(i18n("A&lways enabled"), electricBox);
00559 
00560     delays = new KIntNumInput(10, electricBox);
00561     delays->setRange(0, MAX_EDGE_RES, 50, true);
00562     delays->setSuffix(i18n(" msec"));
00563     delays->setLabel(i18n("Desktop &switch delay:"));
00564     QWhatsThis::add( delays, i18n("Here you can set a delay for switching desktops using the active"
00565        " borders feature. Desktops will be switched after the mouse has been pushed against a screen border"
00566        " for the specified number of milliseconds.") );
00567 
00568     connect( electricBox, SIGNAL(clicked(int)), this, SLOT(setEBorders()));
00569 
00570     // Any changes goes to slotChanged()
00571     connect(electricBox, SIGNAL(clicked(int)), SLOT(changed()));
00572     connect(delays, SIGNAL(valueChanged(int)), SLOT(changed()));
00573 
00574     lay->addWidget(electricBox);
00575 
00576     QHBoxLayout* focusStealingLayout = new QHBoxLayout( lay,KDialog::spacingHint());
00577     QLabel* focusStealingLabel = new QLabel( i18n( "Focus stealing prevention level:" ), this );
00578     focusStealing = new QComboBox( this );
00579     focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "None" ));
00580     focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Low" ));
00581     focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Normal" ));
00582     focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "High" ));
00583     focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Extreme" ));
00584     focusStealingLabel->setBuddy( focusStealing );
00585     focusStealingLayout->addWidget( focusStealingLabel );
00586     focusStealingLayout->addWidget( focusStealing, AlignLeft );
00587     wtstr = i18n( "This option specifies how much KWin will try to prevent unwanted focus stealing "
00588                   "caused by unexpected activation of new windows. (Note: This feature does not "
00589                   "work with the Focus Under Mouse or Focus Strictly Under Mouse focus policies.)"
00590                   "<ul>"
00591                   "<li><em>None:</em> Prevention is turned off "
00592                   "and new windows always become activated.</li>"
00593                   "<li><em>Low:</em> Prevention is enabled; when some window does not have support "
00594                   "for the underlying mechanism and KWin cannot reliably decide whether to "
00595                   "activate the window or not, it will be activated. This setting may have both "
00596                   "worse and better results than normal level, depending on the applications.</li>"
00597                   "<li><em>Normal:</em> Prevention is enabled.</li>"
00598                   "<li><em>High:</em> New windows get activated only if no window is currently active "
00599                   "or if they belong to the currently active application. This setting is probably "
00600                   "not really usable when not using mouse focus policy.</li>"
00601                   "<li><em>Extreme:</em> All windows must be explicitly activated by the user.</li>"
00602                   "</ul>" );
00603     QWhatsThis::add( focusStealing, wtstr );
00604     QWhatsThis::add( focusStealingLabel, wtstr );
00605 
00606     connect(focusStealing, SIGNAL(activated(int)), SLOT(changed()));
00607 
00608     lay->addStretch();
00609     load();
00610 
00611 }
00612 
00613 void KAdvancedConfig::setShadeHover(bool on) {
00614     shadeHoverOn->setChecked(on);
00615     shadeHover->setEnabled(on);
00616 }
00617 
00618 void KAdvancedConfig::setShadeHoverInterval(int k) {
00619     shadeHover->setValue(k);
00620 }
00621 
00622 int KAdvancedConfig::getShadeHoverInterval() {
00623 
00624     return shadeHover->value();
00625 }
00626 
00627 void KAdvancedConfig::shadeHoverChanged(bool a) {
00628     shadeHover->setEnabled(a);
00629 }
00630 
00631 void KAdvancedConfig::setAnimateShade(bool a) {
00632     animateShade->setChecked(a);
00633 }
00634 
00635 void KAdvancedConfig::setFocusStealing(int l) {
00636     l = KMAX( 0, KMIN( 4, l ));
00637     focusStealing->setCurrentItem(l);
00638 }
00639 
00640 void KAdvancedConfig::load( void )
00641 {
00642     config->setGroup( "Windows" );
00643 
00644     setAnimateShade(config->readBoolEntry(KWIN_ANIMSHADE, true));
00645     setShadeHover(config->readBoolEntry(KWIN_SHADEHOVER, false));
00646     setShadeHoverInterval(config->readNumEntry(KWIN_SHADEHOVER_INTERVAL, 250));
00647 
00648     setElectricBorders(config->readNumEntry(KWM_ELECTRIC_BORDER, false));
00649     setElectricBorderDelay(config->readNumEntry(KWM_ELECTRIC_BORDER_DELAY, 150));
00650 
00651 //    setFocusStealing( config->readNumEntry(KWIN_FOCUS_STEALING, 2 ));
00652     // TODO default to low for now
00653     setFocusStealing( config->readNumEntry(KWIN_FOCUS_STEALING, 1 ));
00654 
00655     emit KCModule::changed(false);
00656 }
00657 
00658 void KAdvancedConfig::save( void )
00659 {
00660     int v;
00661 
00662     config->setGroup( "Windows" );
00663     config->writeEntry(KWIN_ANIMSHADE, animateShade->isChecked());
00664     if (shadeHoverOn->isChecked())
00665         config->writeEntry(KWIN_SHADEHOVER, "on");
00666     else
00667         config->writeEntry(KWIN_SHADEHOVER, "off");
00668 
00669     v = getShadeHoverInterval();
00670     if (v<0) v = 0;
00671     config->writeEntry(KWIN_SHADEHOVER_INTERVAL, v);
00672 
00673     config->writeEntry(KWM_ELECTRIC_BORDER, getElectricBorders());
00674     config->writeEntry(KWM_ELECTRIC_BORDER_DELAY,getElectricBorderDelay());
00675 
00676     config->writeEntry(KWIN_FOCUS_STEALING, focusStealing->currentItem());
00677 
00678     if (standAlone)
00679     {
00680         config->sync();
00681         if ( !kapp->dcopClient()->isAttached() )
00682             kapp->dcopClient()->attach();
00683         kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
00684     }
00685     emit KCModule::changed(false);
00686 }
00687 
00688 void KAdvancedConfig::defaults()
00689 {
00690     setAnimateShade(true);
00691     setShadeHover(false);
00692     setShadeHoverInterval(250);
00693     setElectricBorders(0);
00694     setElectricBorderDelay(150);
00695 //    setFocusStealing(2);
00696     // TODO default to low for now
00697     setFocusStealing(1);
00698     emit KCModule::changed(true);
00699 }
00700 
00701 void KAdvancedConfig::setEBorders()
00702 {
00703     delays->setEnabled(!active_disable->isChecked());
00704 }
00705 
00706 int KAdvancedConfig::getElectricBorders()
00707 {
00708     if (active_move->isChecked())
00709        return 1;
00710     if (active_always->isChecked())
00711        return 2;
00712     return 0;
00713 }
00714 
00715 int KAdvancedConfig::getElectricBorderDelay()
00716 {
00717     return delays->value();
00718 }
00719 
00720 void KAdvancedConfig::setElectricBorders(int i){
00721     switch(i)
00722     {
00723       case 1: active_move->setChecked(true); break;
00724       case 2: active_always->setChecked(true); break;
00725       default: active_disable->setChecked(true); break;
00726     }
00727     setEBorders();
00728 }
00729 
00730 void KAdvancedConfig::setElectricBorderDelay(int delay)
00731 {
00732     delays->setValue(delay);
00733 }
00734 
00735 
00736 KMovingConfig::~KMovingConfig ()
00737 {
00738     if (standAlone)
00739         delete config;
00740 }
00741 
00742 KMovingConfig::KMovingConfig (bool _standAlone, KConfig *_config, QWidget *parent, const char *)
00743     : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00744 {
00745     QString wtstr;
00746     QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00747 
00748     windowsBox = new QButtonGroup(i18n("Windows"), this);
00749     windowsBox->setColumnLayout( 0, Qt::Horizontal );
00750 
00751     QBoxLayout *wLay = new QVBoxLayout (windowsBox->layout(), KDialog::spacingHint());
00752 
00753     QBoxLayout *bLay = new QVBoxLayout;
00754     wLay->addLayout(bLay);
00755 
00756     opaque = new QCheckBox(i18n("Di&splay content in moving windows"), windowsBox);
00757     bLay->addWidget(opaque);
00758     QWhatsThis::add( opaque, i18n("Enable this option if you want a window's content to be fully shown"
00759                                   " while moving it, instead of just showing a window 'skeleton'. The result may not be satisfying"
00760                                   " on slow machines without graphic acceleration.") );
00761 
00762     resizeOpaqueOn = new QCheckBox(i18n("Display content in &resizing windows"), windowsBox);
00763     bLay->addWidget(resizeOpaqueOn);
00764     QWhatsThis::add( resizeOpaqueOn, i18n("Enable this option if you want a window's content to be shown"
00765                                           " while resizing it, instead of just showing a window 'skeleton'. The result may not be satisfying"
00766                                           " on slow machines.") );
00767 
00768     geometryTipOn = new QCheckBox(i18n("Display window &geometry when moving or resizing"), windowsBox);
00769     bLay->addWidget(geometryTipOn);
00770     QWhatsThis::add(geometryTipOn, i18n("Enable this option if you want a window's geometry to be displayed"
00771                                         " while it is being moved or resized. The window position relative"
00772                                         " to the top-left corner of the screen is displayed together with"
00773                                         " its size."));
00774 
00775     QGridLayout *rLay = new QGridLayout(2,3);
00776     bLay->addLayout(rLay);
00777     rLay->setColStretch(0,0);
00778     rLay->setColStretch(1,1);
00779 
00780     minimizeAnimOn = new QCheckBox(i18n("Animate minimi&ze and restore"),
00781                                    windowsBox);
00782     QWhatsThis::add( minimizeAnimOn, i18n("Enable this option if you want an animation shown when"
00783                                           " windows are minimized or restored." ) );
00784     rLay->addWidget(minimizeAnimOn,0,0);
00785 
00786     minimizeAnimSlider = new QSlider(0,10,10,0,QSlider::Horizontal, windowsBox);
00787     minimizeAnimSlider->setSteps(1, 1);
00788     // QSlider::Below clashes with a X11/X.h #define
00789     #undef Below
00790     minimizeAnimSlider->setTickmarks(QSlider::Below);
00791     rLay->addMultiCellWidget(minimizeAnimSlider,0,0,1,2);
00792 
00793     connect(minimizeAnimOn, SIGNAL(toggled(bool)), this, SLOT(setMinimizeAnim(bool)));
00794     connect(minimizeAnimSlider, SIGNAL(valueChanged(int)), this, SLOT(setMinimizeAnimSpeed(int)));
00795 
00796     minimizeAnimSlowLabel= new QLabel(i18n("Slow"),windowsBox);
00797     minimizeAnimSlowLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
00798     rLay->addWidget(minimizeAnimSlowLabel,1,1);
00799 
00800     minimizeAnimFastLabel= new QLabel(i18n("Fast"),windowsBox);
00801     minimizeAnimFastLabel->setAlignment(Qt::AlignTop|Qt::AlignRight);
00802     rLay->addWidget(minimizeAnimFastLabel,1,2);
00803 
00804     wtstr = i18n("Here you can set the speed of the animation shown when windows are"
00805                  " minimized and restored. ");
00806     QWhatsThis::add( minimizeAnimSlider, wtstr );
00807     QWhatsThis::add( minimizeAnimSlowLabel, wtstr );
00808     QWhatsThis::add( minimizeAnimFastLabel, wtstr );
00809 
00810     moveResizeMaximized = new QCheckBox( i18n("Allow moving and resizing o&f maximized windows"), windowsBox);
00811     bLay->addWidget(moveResizeMaximized);
00812     QWhatsThis::add(moveResizeMaximized, i18n("When enabled, this feature activates the border of maximized windows"
00813                                               " and allows you to move or resize them,"
00814                                               " just like for normal windows"));
00815 
00816     QBoxLayout *vLay = new QHBoxLayout(bLay);
00817 
00818     QLabel *plcLabel = new QLabel(i18n("&Placement:"),windowsBox);
00819 
00820     placementCombo = new QComboBox(false, windowsBox);
00821     placementCombo->insertItem(i18n("Smart"), SMART_PLACEMENT);
00822     placementCombo->insertItem(i18n("Cascade"), CASCADE_PLACEMENT);
00823     placementCombo->insertItem(i18n("Random"), RANDOM_PLACEMENT);
00824     placementCombo->insertItem(i18n("Centered"), CENTERED_PLACEMENT);
00825     placementCombo->insertItem(i18n("Zero-Cornered"), ZEROCORNERED_PLACEMENT);
00826     // CT: disabling is needed as long as functionality misses in kwin
00827     //placementCombo->insertItem(i18n("Interactive"), INTERACTIVE_PLACEMENT);
00828     //placementCombo->insertItem(i18n("Manual"), MANUAL_PLACEMENT);
00829     placementCombo->setCurrentItem(SMART_PLACEMENT);
00830 
00831     // FIXME, when more policies have been added to KWin
00832     wtstr = i18n("The placement policy determines where a new window"
00833                  " will appear on the desktop. For now, there are three different policies:"
00834                  " <ul><li><em>Smart</em> will try to achieve a minimum overlap of windows</li>"
00835                  " <li><em>Cascade</em> will cascade the windows</li>"
00836                  " <li><em>Random</em> will use a random position</li></ul>") ;
00837 
00838     QWhatsThis::add( plcLabel, wtstr);
00839     QWhatsThis::add( placementCombo, wtstr);
00840 
00841     plcLabel->setBuddy(placementCombo);
00842     vLay->addWidget(plcLabel, 0);
00843     vLay->addWidget(placementCombo, 1, Qt::AlignLeft);
00844 
00845     bLay->addSpacing(10);
00846 
00847     lay->addWidget(windowsBox);
00848 
00849     //iTLabel = new QLabel(i18n("  Allowed overlap:\n"
00850     //                         "(% of desktop space)"),
00851     //             plcBox);
00852     //iTLabel->setAlignment(AlignTop|AlignHCenter);
00853     //pLay->addWidget(iTLabel,1,1);
00854 
00855     //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
00856     //pLay->addWidget(interactiveTrigger,1,2);
00857 
00858     //pLay->addRowSpacing(2,KDialog::spacingHint());
00859 
00860     //lay->addWidget(plcBox);
00861 
00862 
00863     //CT 15mar98 - add EdgeResistance, BorderAttractor, WindowsAttractor config
00864     MagicBox = new QVButtonGroup(i18n("Snap Zones"), this);
00865     MagicBox->setMargin(15);
00866 
00867     BrdrSnap = new KIntNumInput(10, MagicBox);
00868     BrdrSnap->setSpecialValueText( i18n("none") );
00869     BrdrSnap->setRange( 0, MAX_BRDR_SNAP);
00870     BrdrSnap->setLabel(i18n("&Border snap zone:"));
00871     BrdrSnap->setSuffix(i18n(" pixels"));
00872     BrdrSnap->setSteps(1,10);
00873     QWhatsThis::add( BrdrSnap, i18n("Here you can set the snap zone for screen borders, i.e."
00874                                     " the 'strength' of the magnetic field which will make windows snap to the border when"
00875                                     " moved near it.") );
00876 
00877     WndwSnap = new KIntNumInput(10, MagicBox);
00878     WndwSnap->setSpecialValueText( i18n("none") );
00879     WndwSnap->setRange( 0, MAX_WNDW_SNAP);
00880     WndwSnap->setLabel(i18n("&Window snap zone:"));
00881     WndwSnap->setSuffix( i18n(" pixels"));
00882     BrdrSnap->setSteps(1,10);
00883     QWhatsThis::add( WndwSnap, i18n("Here you can set the snap zone for windows, i.e."
00884                                     " the 'strength' of the magnetic field which will make windows snap to each other when"
00885                                     " they're moved near another window.") );
00886 
00887     OverlapSnap=new QCheckBox(i18n("Snap windows onl&y when overlapping"),MagicBox);
00888     QWhatsThis::add( OverlapSnap, i18n("Here you can set that windows will be only"
00889                                        " snapped if you try to overlap them, i.e. they will not be snapped if the windows"
00890                                        " comes only near another window or border.") );
00891 
00892     lay->addWidget(MagicBox);
00893     lay->addStretch();
00894 
00895     load();
00896 
00897     // Any changes goes to slotChanged()
00898     connect( opaque, SIGNAL(clicked()), SLOT(changed()));
00899     connect( resizeOpaqueOn, SIGNAL(clicked()), SLOT(changed()));
00900     connect( geometryTipOn, SIGNAL(clicked()), SLOT(changed()));
00901     connect( minimizeAnimOn, SIGNAL(clicked() ), SLOT(changed()));
00902     connect( minimizeAnimSlider, SIGNAL(valueChanged(int)), SLOT(changed()));
00903     connect( moveResizeMaximized, SIGNAL(toggled(bool)), SLOT(changed()));
00904     connect( placementCombo, SIGNAL(activated(int)), SLOT(changed()));
00905     connect( BrdrSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
00906     connect( WndwSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
00907     connect( OverlapSnap, SIGNAL(clicked()), SLOT(changed()));
00908 }
00909 
00910 int KMovingConfig::getMove()
00911 {
00912     return (opaque->isChecked())? OPAQUE : TRANSPARENT;
00913 }
00914 
00915 void KMovingConfig::setMove(int trans)
00916 {
00917     opaque->setChecked(trans == OPAQUE);
00918 }
00919 
00920 void KMovingConfig::setGeometryTip(bool showGeometryTip)
00921 {
00922     geometryTipOn->setChecked(showGeometryTip);
00923 }
00924 
00925 bool KMovingConfig::getGeometryTip()
00926 {
00927     return geometryTipOn->isChecked();
00928 }
00929 
00930 // placement policy --- CT 31jan98 ---
00931 int KMovingConfig::getPlacement()
00932 {
00933     return placementCombo->currentItem();
00934 }
00935 
00936 void KMovingConfig::setPlacement(int plac)
00937 {
00938     placementCombo->setCurrentItem(plac);
00939 }
00940 
00941 bool KMovingConfig::getMinimizeAnim()
00942 {
00943     return minimizeAnimOn->isChecked();
00944 }
00945 
00946 int KMovingConfig::getMinimizeAnimSpeed()
00947 {
00948     return minimizeAnimSlider->value();
00949 }
00950 
00951 void KMovingConfig::setMinimizeAnim(bool anim)
00952 {
00953     minimizeAnimOn->setChecked( anim );
00954     minimizeAnimSlider->setEnabled( anim );
00955     minimizeAnimSlowLabel->setEnabled( anim );
00956     minimizeAnimFastLabel->setEnabled( anim );
00957 }
00958 
00959 void KMovingConfig::setMinimizeAnimSpeed(int speed)
00960 {
00961     minimizeAnimSlider->setValue(speed);
00962 }
00963 
00964 int KMovingConfig::getResizeOpaque()
00965 {
00966     return (resizeOpaqueOn->isChecked())? RESIZE_OPAQUE : RESIZE_TRANSPARENT;
00967 }
00968 
00969 void KMovingConfig::setResizeOpaque(int opaque)
00970 {
00971     resizeOpaqueOn->setChecked(opaque == RESIZE_OPAQUE);
00972 }
00973 
00974 void KMovingConfig::setMoveResizeMaximized(bool a) {
00975     moveResizeMaximized->setChecked(a);
00976 }
00977 
00978 void KMovingConfig::load( void )
00979 {
00980     QString key;
00981 
00982     config->setGroup( "Windows" );
00983 
00984     key = config->readEntry(KWIN_MOVE, "Opaque");
00985     if( key == "Transparent")
00986         setMove(TRANSPARENT);
00987     else if( key == "Opaque")
00988         setMove(OPAQUE);
00989 
00990     //CT 17Jun1998 - variable animation speed from 0 (none!!) to 10 (max)
00991     bool anim = config->readBoolEntry(KWIN_MINIMIZE_ANIM, true );
00992     int animSpeed = config->readNumEntry(KWIN_MINIMIZE_ANIM_SPEED, 5);
00993     if( animSpeed < 1 ) animSpeed = 0;
00994     if( animSpeed > 10 ) animSpeed = 10;
00995     setMinimizeAnim( anim );
00996     setMinimizeAnimSpeed( animSpeed );
00997 
00998     // DF: please keep the default consistent with kwin (options.cpp line 145)
00999     key = config->readEntry(KWIN_RESIZE_OPAQUE, "Opaque");
01000     if( key == "Opaque")
01001         setResizeOpaque(RESIZE_OPAQUE);
01002     else if ( key == "Transparent")
01003         setResizeOpaque(RESIZE_TRANSPARENT);
01004 
01005     //KS 10Jan2003 - Geometry Tip during window move/resize
01006     bool showGeomTip = config->readBoolEntry(KWIN_GEOMETRY, false);
01007     setGeometryTip( showGeomTip );
01008 
01009     // placement policy --- CT 19jan98 ---
01010     key = config->readEntry(KWIN_PLACEMENT);
01011     //CT 13mar98 interactive placement
01012 //   if( key.left(11) == "interactive") {
01013 //     setPlacement(INTERACTIVE_PLACEMENT);
01014 //     int comma_pos = key.find(',');
01015 //     if (comma_pos < 0)
01016 //       interactiveTrigger->setValue(0);
01017 //     else
01018 //       interactiveTrigger->setValue (key.right(key.length()
01019 //                           - comma_pos).toUInt(0));
01020 //     iTLabel->setEnabled(true);
01021 //     interactiveTrigger->show();
01022 //   }
01023 //   else {
01024 //     interactiveTrigger->setValue(0);
01025 //     iTLabel->setEnabled(false);
01026 //     interactiveTrigger->hide();
01027     if( key == "Random")
01028         setPlacement(RANDOM_PLACEMENT);
01029     else if( key == "Cascade")
01030         setPlacement(CASCADE_PLACEMENT); //CT 31jan98
01031     //CT 31mar98 manual placement
01032     else if( key == "manual")
01033         setPlacement(MANUAL_PLACEMENT);
01034     else if( key == "Centered")
01035         setPlacement(CENTERED_PLACEMENT);
01036     else if( key == "ZeroCornered")
01037         setPlacement(ZEROCORNERED_PLACEMENT);
01038 
01039     else
01040         setPlacement(SMART_PLACEMENT);
01041 //  }
01042 
01043     setMoveResizeMaximized(config->readBoolEntry(KWIN_MOVE_RESIZE_MAXIMIZED, true));
01044 
01045     int v;
01046 
01047     v = config->readNumEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT);
01048     if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP);
01049     else if (v < 0) setBorderSnapZone (0);
01050     else setBorderSnapZone(v);
01051 
01052     v = config->readNumEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT);
01053     if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP);
01054     else if (v < 0) setWindowSnapZone (0);
01055     else setWindowSnapZone(v);
01056 
01057     OverlapSnap->setChecked(config->readBoolEntry("SnapOnlyWhenOverlapping",false));
01058     emit KCModule::changed(false);
01059 }
01060 
01061 void KMovingConfig::save( void )
01062 {
01063     int v;
01064 
01065     config->setGroup( "Windows" );
01066 
01067     v = getMove();
01068     if (v == TRANSPARENT)
01069         config->writeEntry(KWIN_MOVE,"Transparent");
01070     else
01071         config->writeEntry(KWIN_MOVE,"Opaque");
01072 
01073     config->writeEntry(KWIN_GEOMETRY, getGeometryTip());
01074 
01075     // placement policy --- CT 31jan98 ---
01076     v =getPlacement();
01077     if (v == RANDOM_PLACEMENT)
01078         config->writeEntry(KWIN_PLACEMENT, "Random");
01079     else if (v == CASCADE_PLACEMENT)
01080         config->writeEntry(KWIN_PLACEMENT, "Cascade");
01081     else if (v == CENTERED_PLACEMENT)
01082         config->writeEntry(KWIN_PLACEMENT, "Centered");
01083     else if (v == ZEROCORNERED_PLACEMENT)
01084         config->writeEntry(KWIN_PLACEMENT, "ZeroCornered");
01085 //CT 13mar98 manual and interactive placement
01086 //   else if (v == MANUAL_PLACEMENT)
01087 //     config->writeEntry(KWIN_PLACEMENT, "Manual");
01088 //   else if (v == INTERACTIVE_PLACEMENT) {
01089 //       QString tmpstr = QString("Interactive,%1").arg(interactiveTrigger->value());
01090 //       config->writeEntry(KWIN_PLACEMENT, tmpstr);
01091 //   }
01092     else
01093         config->writeEntry(KWIN_PLACEMENT, "Smart");
01094 
01095     config->writeEntry(KWIN_MINIMIZE_ANIM, getMinimizeAnim());
01096     config->writeEntry(KWIN_MINIMIZE_ANIM_SPEED, getMinimizeAnimSpeed());
01097 
01098     v = getResizeOpaque();
01099     if (v == RESIZE_OPAQUE)
01100         config->writeEntry(KWIN_RESIZE_OPAQUE, "Opaque");
01101     else
01102         config->writeEntry(KWIN_RESIZE_OPAQUE, "Transparent");
01103 
01104     config->writeEntry(KWIN_MOVE_RESIZE_MAXIMIZED, moveResizeMaximized->isChecked());
01105 
01106 
01107     config->writeEntry(KWM_BRDR_SNAP_ZONE,getBorderSnapZone());
01108     config->writeEntry(KWM_WNDW_SNAP_ZONE,getWindowSnapZone());
01109     config->writeEntry("SnapOnlyWhenOverlapping",OverlapSnap->isChecked());
01110 
01111     if (standAlone)
01112     {
01113         config->sync();
01114         if ( !kapp->dcopClient()->isAttached() )
01115             kapp->dcopClient()->attach();
01116         kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
01117     }
01118     emit KCModule::changed(false);
01119 }
01120 
01121 void KMovingConfig::defaults()
01122 {
01123     setMove(OPAQUE);
01124     setResizeOpaque(RESIZE_TRANSPARENT);
01125     setGeometryTip(false);
01126     setPlacement(SMART_PLACEMENT);
01127     setMoveResizeMaximized(true);
01128 
01129     //copied from kcontrol/konq/kwindesktop, aleXXX
01130     setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT);
01131     setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT);
01132     OverlapSnap->setChecked(false);
01133 
01134     setMinimizeAnim( true );
01135     setMinimizeAnimSpeed( 5 );
01136     emit KCModule::changed(true);
01137 }
01138 
01139 int KMovingConfig::getBorderSnapZone() {
01140   return BrdrSnap->value();
01141 }
01142 
01143 void KMovingConfig::setBorderSnapZone(int pxls) {
01144   BrdrSnap->setValue(pxls);
01145 }
01146 
01147 int KMovingConfig::getWindowSnapZone() {
01148   return WndwSnap->value();
01149 }
01150 
01151 void KMovingConfig::setWindowSnapZone(int pxls) {
01152   WndwSnap->setValue(pxls);
01153 }
01154 
01155 #include "windows.moc"
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 11:22:00 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003