00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <config.h>
00025
00026 #include <qdir.h>
00027 #include <qlayout.h>
00028 #include <qslider.h>
00029 #include <qwhatsthis.h>
00030 #include <qvbuttongroup.h>
00031 #include <qcheckbox.h>
00032 #include <qradiobutton.h>
00033 #include <qlabel.h>
00034 #include <qcombobox.h>
00035 #include <kmessagebox.h>
00036
00037 #include <kactivelabel.h>
00038 #include <klocale.h>
00039 #include <kcolorbutton.h>
00040 #include <kconfig.h>
00041 #include <knuminput.h>
00042 #include <kapplication.h>
00043 #include <kdialog.h>
00044 #include <dcopclient.h>
00045 #include <kglobal.h>
00046 #include <kprocess.h>
00047 #include <qtabwidget.h>
00048
00049 #include <X11/X.h>
00050 #include <X11/Xlib.h>
00051 #include <X11/Xutil.h>
00052
00053 #include "windows.h"
00054
00055
00056
00057 #define KWIN_FOCUS "FocusPolicy"
00058 #define KWIN_PLACEMENT "Placement"
00059 #define KWIN_MOVE "MoveMode"
00060 #define KWIN_MINIMIZE_ANIM "AnimateMinimize"
00061 #define KWIN_MINIMIZE_ANIM_SPEED "AnimateMinimizeSpeed"
00062 #define KWIN_RESIZE_OPAQUE "ResizeMode"
00063 #define KWIN_GEOMETRY "GeometryTip"
00064 #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval"
00065 #define KWIN_AUTORAISE "AutoRaise"
00066 #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
00067 #define KWIN_DELAYFOCUS "DelayFocus"
00068 #define KWIN_CLICKRAISE "ClickRaise"
00069 #define KWIN_ANIMSHADE "AnimateShade"
00070 #define KWIN_MOVE_RESIZE_MAXIMIZED "MoveResizeMaximizedWindows"
00071 #define KWIN_ALTTABMODE "AltTabStyle"
00072 #define KWIN_TRAVERSE_ALL "TraverseAll"
00073 #define KWIN_SHOW_POPUP "ShowPopup"
00074 #define KWIN_ROLL_OVER_DESKTOPS "RollOverDesktops"
00075 #define KWIN_SHADEHOVER "ShadeHover"
00076 #define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval"
00077 #define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
00078
00079
00080 #define KWM_ELECTRIC_BORDER "ElectricBorders"
00081 #define KWM_ELECTRIC_BORDER_DELAY "ElectricBorderDelay"
00082
00083
00084 #define KWM_BRDR_SNAP_ZONE "BorderSnapZone"
00085 #define KWM_BRDR_SNAP_ZONE_DEFAULT 10
00086 #define KWM_WNDW_SNAP_ZONE "WindowSnapZone"
00087 #define KWM_WNDW_SNAP_ZONE_DEFAULT 10
00088
00089 #define MAX_BRDR_SNAP 100
00090 #define MAX_WNDW_SNAP 100
00091 #define MAX_EDGE_RES 1000
00092
00093
00094 KFocusConfig::~KFocusConfig ()
00095 {
00096 if (standAlone)
00097 delete config;
00098 }
00099
00100
00101 KFocusConfig::KFocusConfig (bool _standAlone, KConfig *_config, QWidget * parent, const char *)
00102 : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00103 {
00104 QString wtstr;
00105 QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 fcsBox = new QButtonGroup(i18n("Focus"),this);
00122 fcsBox->setColumnLayout( 0, Qt::Horizontal );
00123
00124 QBoxLayout *fLay = new QVBoxLayout(fcsBox->layout(),
00125 KDialog::spacingHint());
00126
00127 QBoxLayout *cLay = new QHBoxLayout(fLay);
00128 QLabel *fLabel = new QLabel(i18n("&Policy:"), fcsBox);
00129 cLay->addWidget(fLabel, 0);
00130 focusCombo = new QComboBox(false, fcsBox);
00131 focusCombo->insertItem(i18n("Click to Focus"), CLICK_TO_FOCUS);
00132 focusCombo->insertItem(i18n("Focus Follows Mouse"), FOCUS_FOLLOWS_MOUSE);
00133 focusCombo->insertItem(i18n("Focus Under Mouse"), FOCUS_UNDER_MOUSE);
00134 focusCombo->insertItem(i18n("Focus Strictly Under Mouse"), FOCUS_STRICTLY_UNDER_MOUSE);
00135 cLay->addWidget(focusCombo,1 ,Qt::AlignLeft);
00136 fLabel->setBuddy(focusCombo);
00137
00138
00139 wtstr = i18n("The focus policy is used to determine the active window, i.e."
00140 " the window you can work in. <ul>"
00141 " <li><em>Click to focus:</em> A window becomes active when you click into it."
00142 " This is the behavior you might know from other operating systems.</li>"
00143 " <li><em>Focus follows mouse:</em> Moving the mouse pointer actively on to a"
00144 " normal window activates it. New windows will receive the focus,"
00145 " without you having to point the mouse at them explicitly."
00146 " Very practical if you are using the mouse a lot.</li>"
00147 " <li><em>Focus under mouse:</em> The window that happens to be under the"
00148 " mouse pointer is active. If the mouse points nowhere, the last window"
00149 " that was under the mouse has focus."
00150 " New windows will not automatically receive the focus.</li>"
00151 " <li><em>Focus strictly under mouse:</em> Only the window under the mouse pointer is"
00152 " active. If the mouse points nowhere, nothing has focus."
00153 " </ul>"
00154 "Note that 'Focus under mouse' and 'Focus strictly under mouse' prevent certain"
00155 " features such as the Alt+Tab walk through windows dialog in the KDE mode"
00156 " from working properly."
00157 );
00158 QWhatsThis::add( focusCombo, wtstr);
00159 QWhatsThis::add(fLabel, wtstr);
00160
00161 connect(focusCombo, SIGNAL(activated(int)), this, SLOT(setAutoRaiseEnabled()) );
00162
00163
00164 autoRaiseOn = new QCheckBox(i18n("Auto &raise"), fcsBox);
00165 fLay->addWidget(autoRaiseOn);
00166 connect(autoRaiseOn,SIGNAL(toggled(bool)), this, SLOT(autoRaiseOnTog(bool)));
00167
00168 autoRaise = new KIntNumInput(500, fcsBox);
00169 autoRaise->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00170 autoRaise->setRange(0, 3000, 100, true);
00171 autoRaise->setSteps(100,100);
00172 autoRaise->setSuffix(i18n(" msec"));
00173 fLay->addWidget(autoRaise);
00174
00175 connect(focusCombo, SIGNAL(activated(int)), this, SLOT(setDelayFocusEnabled()) );
00176
00177 delayFocusOn = new QCheckBox(i18n("Delay focus"), fcsBox);
00178 fLay->addWidget(delayFocusOn);
00179 connect(delayFocusOn,SIGNAL(toggled(bool)), this, SLOT(delayFocusOnTog(bool)));
00180
00181 delayFocus = new KIntNumInput(500, fcsBox);
00182 delayFocus->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00183 delayFocus->setRange(0, 3000, 100, true);
00184 delayFocus->setSteps(100,100);
00185 delayFocus->setSuffix(i18n(" msec"));
00186 fLay->addWidget(delayFocus);
00187
00188 clickRaiseOn = new QCheckBox(i18n("C&lick raise active window"), fcsBox);
00189 connect(clickRaiseOn,SIGNAL(toggled(bool)), this, SLOT(clickRaiseOnTog(bool)));
00190 fLay->addWidget(clickRaiseOn);
00191
00192
00193
00194
00195 QWhatsThis::add( autoRaiseOn, i18n("When this option is enabled, a window in the background will automatically"
00196 " come to the front when the mouse pointer has been over it for some time.") );
00197 wtstr = i18n("This is the delay after which the window that the mouse pointer is over will automatically"
00198 " come to the front.");
00199 QWhatsThis::add( autoRaise, wtstr );
00200
00201 QWhatsThis::add( clickRaiseOn, i18n("When this option is enabled, the active window will be brought to the"
00202 " front when you click somewhere into the window contents. To change"
00203 " it for inactive windows, you need to change the settings"
00204 " in the Actions tab.") );
00205
00206 QWhatsThis::add( delayFocusOn, i18n("When this option is enabled, there will be a delay after which the"
00207 " window the mouse pointer is over will become active (receive focus).") );
00208 QWhatsThis::add( delayFocus, i18n("This is the delay after which the window the mouse pointer is over"
00209 " will automatically receive focus.") );
00210
00211 lay->addWidget(fcsBox);
00212
00213 kbdBox = new QButtonGroup(i18n("Navigation"), this);
00214 kbdBox->setColumnLayout( 0, Qt::Horizontal );
00215 QVBoxLayout *kLay = new QVBoxLayout(kbdBox->layout(), KDialog::spacingHint());
00216
00217 altTabPopup = new QCheckBox( i18n("Show window list while switching windows"), kbdBox );
00218 kLay->addWidget( altTabPopup );
00219
00220 wtstr = i18n("Hold down the Alt key and press the Tab key repeatedly to walk"
00221 " through the windows on the current desktop (the Alt+Tab"
00222 " combination can be reconfigured).\n\n"
00223 "If this checkbox is checked"
00224 " a popup widget is shown, displaying the icons of all windows to"
00225 " walk through and the title of the currently selected one.\n\n"
00226 "Otherwise, the focus is passed to a new window each time Tab"
00227 " is pressed, with no popup widget. In addition, the previously"
00228 " activated window will be sent to the back in this mode.");
00229 QWhatsThis::add( altTabPopup, wtstr );
00230
00231 traverseAll = new QCheckBox( i18n( "&Traverse windows on all desktops" ), kbdBox );
00232 kLay->addWidget( traverseAll );
00233
00234 wtstr = i18n( "Leave this option disabled if you want to limit walking through"
00235 " windows to the current desktop." );
00236 QWhatsThis::add( traverseAll, wtstr );
00237
00238 rollOverDesktops = new QCheckBox( i18n("Desktop navi&gation wraps around"), kbdBox );
00239 kLay->addWidget(rollOverDesktops);
00240
00241 wtstr = i18n( "Enable this option if you want keyboard or active desktop border navigation beyond"
00242 " the edge of a desktop to take you to the opposite edge of the new desktop." );
00243 QWhatsThis::add( rollOverDesktops, wtstr );
00244
00245 showPopupinfo = new QCheckBox( i18n("Popup desktop name on desktop &switch"), kbdBox );
00246 kLay->addWidget(showPopupinfo);
00247
00248 wtstr = i18n( "Enable this option if you wish to see the current desktop"
00249 " name popup whenever the current desktop is changed." );
00250 QWhatsThis::add( showPopupinfo, wtstr );
00251
00252 lay->addWidget(kbdBox);
00253
00254 lay->addStretch();
00255
00256
00257 connect(focusCombo, SIGNAL(activated(int)), SLOT(changed()));
00258 connect(fcsBox, SIGNAL(clicked(int)), SLOT(changed()));
00259 connect(autoRaise, SIGNAL(valueChanged(int)), SLOT(changed()));
00260 connect(delayFocus, SIGNAL(valueChanged(int)), SLOT(changed()));
00261 connect(altTabPopup, SIGNAL(clicked()), SLOT(changed()));
00262 connect(traverseAll, SIGNAL(clicked()), SLOT(changed()));
00263 connect(rollOverDesktops, SIGNAL(clicked()), SLOT(changed()));
00264 connect(showPopupinfo, SIGNAL(clicked()), SLOT(changed()));
00265
00266 load();
00267 }
00268
00269
00270 int KFocusConfig::getFocus()
00271 {
00272 return focusCombo->currentItem();
00273 }
00274
00275 void KFocusConfig::setFocus(int foc)
00276 {
00277 focusCombo->setCurrentItem(foc);
00278
00279
00280 setAutoRaiseEnabled();
00281 }
00282
00283 void KFocusConfig::setAutoRaiseInterval(int tb)
00284 {
00285 autoRaise->setValue(tb);
00286 }
00287
00288 void KFocusConfig::setDelayFocusInterval(int tb)
00289 {
00290 delayFocus->setValue(tb);
00291 }
00292
00293 int KFocusConfig::getAutoRaiseInterval()
00294 {
00295 return autoRaise->value();
00296 }
00297
00298 int KFocusConfig::getDelayFocusInterval()
00299 {
00300 return delayFocus->value();
00301 }
00302
00303 void KFocusConfig::setAutoRaise(bool on)
00304 {
00305 autoRaiseOn->setChecked(on);
00306 }
00307
00308 void KFocusConfig::setDelayFocus(bool on)
00309 {
00310 delayFocusOn->setChecked(on);
00311 }
00312
00313 void KFocusConfig::setClickRaise(bool on)
00314 {
00315 clickRaiseOn->setChecked(on);
00316 }
00317
00318 void KFocusConfig::setAutoRaiseEnabled()
00319 {
00320
00321 if ( focusCombo->currentItem() != CLICK_TO_FOCUS )
00322 {
00323 autoRaiseOn->setEnabled(true);
00324 autoRaiseOnTog(autoRaiseOn->isChecked());
00325 }
00326 else
00327 {
00328 autoRaiseOn->setEnabled(false);
00329 autoRaiseOnTog(false);
00330 }
00331 }
00332
00333 void KFocusConfig::setDelayFocusEnabled()
00334 {
00335
00336 if ( focusCombo->currentItem() != CLICK_TO_FOCUS )
00337 {
00338 delayFocusOn->setEnabled(true);
00339 delayFocusOnTog(delayFocusOn->isChecked());
00340 }
00341 else
00342 {
00343 delayFocusOn->setEnabled(false);
00344 delayFocusOnTog(false);
00345 }
00346 }
00347
00348 void KFocusConfig::autoRaiseOnTog(bool a) {
00349 autoRaise->setEnabled(a);
00350 clickRaiseOn->setEnabled( !a );
00351 }
00352
00353 void KFocusConfig::delayFocusOnTog(bool a) {
00354 delayFocus->setEnabled(a);
00355 }
00356
00357 void KFocusConfig::clickRaiseOnTog(bool ) {
00358 }
00359
00360 void KFocusConfig::setAltTabMode(bool a) {
00361 altTabPopup->setChecked(a);
00362 }
00363
00364 void KFocusConfig::setTraverseAll(bool a) {
00365 traverseAll->setChecked(a);
00366 }
00367
00368 void KFocusConfig::setRollOverDesktops(bool a) {
00369 rollOverDesktops->setChecked(a);
00370 }
00371
00372 void KFocusConfig::setShowPopupinfo(bool a) {
00373 showPopupinfo->setChecked(a);
00374 }
00375
00376 void KFocusConfig::load( void )
00377 {
00378 QString key;
00379
00380 config->setGroup( "Windows" );
00381
00382 key = config->readEntry(KWIN_FOCUS);
00383 if( key == "ClickToFocus")
00384 setFocus(CLICK_TO_FOCUS);
00385 else if( key == "FocusFollowsMouse")
00386 setFocus(FOCUS_FOLLOWS_MOUSE);
00387 else if(key == "FocusUnderMouse")
00388 setFocus(FOCUS_UNDER_MOUSE);
00389 else if(key == "FocusStrictlyUnderMouse")
00390 setFocus(FOCUS_STRICTLY_UNDER_MOUSE);
00391
00392 int k = config->readNumEntry(KWIN_AUTORAISE_INTERVAL,750);
00393 setAutoRaiseInterval(k);
00394
00395 k = config->readNumEntry(KWIN_DELAYFOCUS_INTERVAL,750);
00396 setDelayFocusInterval(k);
00397
00398 key = config->readEntry(KWIN_AUTORAISE);
00399 setAutoRaise(key == "on");
00400 key = config->readEntry(KWIN_DELAYFOCUS);
00401 setDelayFocus(key == "on");
00402 key = config->readEntry(KWIN_CLICKRAISE);
00403 setClickRaise(key != "off");
00404 setAutoRaiseEnabled();
00405 setDelayFocusEnabled();
00406
00407 key = config->readEntry(KWIN_ALTTABMODE, "KDE");
00408 setAltTabMode(key == "KDE");
00409
00410 setRollOverDesktops( config->readBoolEntry(KWIN_ROLL_OVER_DESKTOPS, true ));
00411
00412 config->setGroup( "PopupInfo" );
00413 setShowPopupinfo( config->readBoolEntry(KWIN_SHOW_POPUP, false ));
00414
00415 config->setGroup( "TabBox" );
00416 setTraverseAll( config->readBoolEntry(KWIN_TRAVERSE_ALL, false ));
00417
00418 config->setGroup("Desktops");
00419 emit KCModule::changed(false);
00420 }
00421
00422 void KFocusConfig::save( void )
00423 {
00424 int v;
00425
00426 config->setGroup( "Windows" );
00427
00428 v = getFocus();
00429 if (v == CLICK_TO_FOCUS)
00430 config->writeEntry(KWIN_FOCUS,"ClickToFocus");
00431 else if (v == FOCUS_UNDER_MOUSE)
00432 config->writeEntry(KWIN_FOCUS,"FocusUnderMouse");
00433 else if (v == FOCUS_STRICTLY_UNDER_MOUSE)
00434 config->writeEntry(KWIN_FOCUS,"FocusStrictlyUnderMouse");
00435 else
00436 config->writeEntry(KWIN_FOCUS,"FocusFollowsMouse");
00437
00438 v = getAutoRaiseInterval();
00439 if (v <0) v = 0;
00440 config->writeEntry(KWIN_AUTORAISE_INTERVAL,v);
00441
00442 v = getDelayFocusInterval();
00443 if (v <0) v = 0;
00444 config->writeEntry(KWIN_DELAYFOCUS_INTERVAL,v);
00445
00446 if (autoRaiseOn->isChecked())
00447 config->writeEntry(KWIN_AUTORAISE, "on");
00448 else
00449 config->writeEntry(KWIN_AUTORAISE, "off");
00450
00451 if (delayFocusOn->isChecked())
00452 config->writeEntry(KWIN_DELAYFOCUS, "on");
00453 else
00454 config->writeEntry(KWIN_DELAYFOCUS, "off");
00455
00456 if (clickRaiseOn->isChecked())
00457 config->writeEntry(KWIN_CLICKRAISE, "on");
00458 else
00459 config->writeEntry(KWIN_CLICKRAISE, "off");
00460
00461 if (altTabPopup->isChecked())
00462 config->writeEntry(KWIN_ALTTABMODE, "KDE");
00463 else
00464 config->writeEntry(KWIN_ALTTABMODE, "CDE");
00465
00466 config->writeEntry( KWIN_ROLL_OVER_DESKTOPS, rollOverDesktops->isChecked());
00467
00468 config->setGroup( "PopupInfo" );
00469 config->writeEntry( KWIN_SHOW_POPUP, showPopupinfo->isChecked());
00470
00471 config->setGroup( "TabBox" );
00472 config->writeEntry( KWIN_TRAVERSE_ALL , traverseAll->isChecked());
00473
00474 config->setGroup("Desktops");
00475
00476 if (standAlone)
00477 {
00478 config->sync();
00479 if ( !kapp->dcopClient()->isAttached() )
00480 kapp->dcopClient()->attach();
00481 kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
00482 }
00483 emit KCModule::changed(false);
00484 }
00485
00486 void KFocusConfig::defaults()
00487 {
00488 setAutoRaiseInterval(0);
00489 setDelayFocusInterval(0);
00490 setFocus(CLICK_TO_FOCUS);
00491 setAutoRaise(false);
00492 setDelayFocus(false);
00493 setClickRaise(true);
00494 setAltTabMode(true);
00495 setTraverseAll( false );
00496 setRollOverDesktops(true);
00497 setShowPopupinfo(false);
00498 emit KCModule::changed(true);
00499 }
00500
00501 KAdvancedConfig::~KAdvancedConfig ()
00502 {
00503 if (standAlone)
00504 delete config;
00505 }
00506
00507 KAdvancedConfig::KAdvancedConfig (bool _standAlone, KConfig *_config, QWidget *parent, const char *)
00508 : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00509 {
00510 QString wtstr;
00511 QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 shBox = new QVButtonGroup(i18n("Shading"), this);
00527
00528 animateShade = new QCheckBox(i18n("Anima&te"), shBox);
00529 QWhatsThis::add(animateShade, i18n("Animate the action of reducing the window to its titlebar (shading)"
00530 " as well as the expansion of a shaded window") );
00531
00532 shadeHoverOn = new QCheckBox(i18n("&Enable hover"), shBox);
00533
00534 connect(shadeHoverOn, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool)));
00535
00536 shadeHover = new KIntNumInput(500, shBox);
00537 shadeHover->setLabel(i18n("Dela&y:"), Qt::AlignVCenter|Qt::AlignLeft);
00538 shadeHover->setRange(0, 3000, 100, true);
00539 shadeHover->setSteps(100, 100);
00540 shadeHover->setSuffix(i18n(" msec"));
00541
00542 QWhatsThis::add(shadeHoverOn, i18n("If Shade Hover is enabled, a shaded window will un-shade automatically "
00543 "when the mouse pointer has been over the title bar for some time."));
00544
00545 wtstr = i18n("Sets the time in milliseconds before the window unshades "
00546 "when the mouse pointer goes over the shaded window.");
00547 QWhatsThis::add(shadeHover, wtstr);
00548
00549 lay->addWidget(shBox);
00550
00551
00552 connect(animateShade, SIGNAL(toggled(bool)), SLOT(changed()));
00553 connect(shadeHoverOn, SIGNAL(toggled(bool)), SLOT(changed()));
00554 connect(shadeHover, SIGNAL(valueChanged(int)), SLOT(changed()));
00555
00556 electricBox = new QVButtonGroup(i18n("Active Desktop Borders"), this);
00557 electricBox->setMargin(15);
00558
00559 QWhatsThis::add( electricBox, i18n("If this option is enabled, moving the mouse to a screen border"
00560 " will change your desktop. This is e.g. useful if you want to drag windows from one desktop"
00561 " to the other.") );
00562 active_disable = new QRadioButton(i18n("D&isabled"), electricBox);
00563 active_move = new QRadioButton(i18n("Only &when moving windows"), electricBox);
00564 active_always = new QRadioButton(i18n("A&lways enabled"), electricBox);
00565
00566 delays = new KIntNumInput(10, electricBox);
00567 delays->setRange(0, MAX_EDGE_RES, 50, true);
00568 delays->setSuffix(i18n(" msec"));
00569 delays->setLabel(i18n("Desktop &switch delay:"));
00570 QWhatsThis::add( delays, i18n("Here you can set a delay for switching desktops using the active"
00571 " borders feature. Desktops will be switched after the mouse has been pushed against a screen border"
00572 " for the specified number of milliseconds.") );
00573
00574 connect( electricBox, SIGNAL(clicked(int)), this, SLOT(setEBorders()));
00575
00576
00577 connect(electricBox, SIGNAL(clicked(int)), SLOT(changed()));
00578 connect(delays, SIGNAL(valueChanged(int)), SLOT(changed()));
00579
00580 lay->addWidget(electricBox);
00581
00582 QHBoxLayout* focusStealingLayout = new QHBoxLayout( lay,KDialog::spacingHint());
00583 QLabel* focusStealingLabel = new QLabel( i18n( "Focus stealing prevention level:" ), this );
00584 focusStealing = new QComboBox( this );
00585 focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "None" ));
00586 focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Low" ));
00587 focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Normal" ));
00588 focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "High" ));
00589 focusStealing->insertItem( i18n( "Focus Stealing Prevention Level", "Extreme" ));
00590 focusStealingLabel->setBuddy( focusStealing );
00591 focusStealingLayout->addWidget( focusStealingLabel );
00592 focusStealingLayout->addWidget( focusStealing, AlignLeft );
00593 wtstr = i18n( "This option specifies how much KWin will try to prevent unwanted focus stealing "
00594 "caused by unexpected activation of new windows. (Note: This feature does not "
00595 "work with the Focus Under Mouse or Focus Strictly Under Mouse focus policies.)"
00596 "<ul>"
00597 "<li><em>None:</em> Prevention is turned off "
00598 "and new windows always become activated.</li>"
00599 "<li><em>Low:</em> Prevention is enabled; when some window does not have support "
00600 "for the underlying mechanism and KWin cannot reliably decide whether to "
00601 "activate the window or not, it will be activated. This setting may have both "
00602 "worse and better results than normal level, depending on the applications.</li>"
00603 "<li><em>Normal:</em> Prevention is enabled.</li>"
00604 "<li><em>High:</em> New windows get activated only if no window is currently active "
00605 "or if they belong to the currently active application. This setting is probably "
00606 "not really usable when not using mouse focus policy.</li>"
00607 "<li><em>Extreme:</em> All windows must be explicitly activated by the user.</li>"
00608 "</ul>" );
00609 QWhatsThis::add( focusStealing, wtstr );
00610 QWhatsThis::add( focusStealingLabel, wtstr );
00611
00612 connect(focusStealing, SIGNAL(activated(int)), SLOT(changed()));
00613
00614 lay->addStretch();
00615 load();
00616
00617 }
00618
00619 void KAdvancedConfig::setShadeHover(bool on) {
00620 shadeHoverOn->setChecked(on);
00621 shadeHover->setEnabled(on);
00622 }
00623
00624 void KAdvancedConfig::setShadeHoverInterval(int k) {
00625 shadeHover->setValue(k);
00626 }
00627
00628 int KAdvancedConfig::getShadeHoverInterval() {
00629
00630 return shadeHover->value();
00631 }
00632
00633 void KAdvancedConfig::shadeHoverChanged(bool a) {
00634 shadeHover->setEnabled(a);
00635 }
00636
00637 void KAdvancedConfig::setAnimateShade(bool a) {
00638 animateShade->setChecked(a);
00639 }
00640
00641 void KAdvancedConfig::setFocusStealing(int l) {
00642 l = KMAX( 0, KMIN( 4, l ));
00643 focusStealing->setCurrentItem(l);
00644 }
00645
00646 void KAdvancedConfig::load( void )
00647 {
00648 config->setGroup( "Windows" );
00649
00650 setAnimateShade(config->readBoolEntry(KWIN_ANIMSHADE, true));
00651 setShadeHover(config->readBoolEntry(KWIN_SHADEHOVER, false));
00652 setShadeHoverInterval(config->readNumEntry(KWIN_SHADEHOVER_INTERVAL, 250));
00653
00654 setElectricBorders(config->readNumEntry(KWM_ELECTRIC_BORDER, false));
00655 setElectricBorderDelay(config->readNumEntry(KWM_ELECTRIC_BORDER_DELAY, 150));
00656
00657
00658
00659 setFocusStealing( config->readNumEntry(KWIN_FOCUS_STEALING, 1 ));
00660
00661 emit KCModule::changed(false);
00662 }
00663
00664 void KAdvancedConfig::save( void )
00665 {
00666 int v;
00667
00668 config->setGroup( "Windows" );
00669 config->writeEntry(KWIN_ANIMSHADE, animateShade->isChecked());
00670 if (shadeHoverOn->isChecked())
00671 config->writeEntry(KWIN_SHADEHOVER, "on");
00672 else
00673 config->writeEntry(KWIN_SHADEHOVER, "off");
00674
00675 v = getShadeHoverInterval();
00676 if (v<0) v = 0;
00677 config->writeEntry(KWIN_SHADEHOVER_INTERVAL, v);
00678
00679 config->writeEntry(KWM_ELECTRIC_BORDER, getElectricBorders());
00680 config->writeEntry(KWM_ELECTRIC_BORDER_DELAY,getElectricBorderDelay());
00681
00682 config->writeEntry(KWIN_FOCUS_STEALING, focusStealing->currentItem());
00683
00684 if (standAlone)
00685 {
00686 config->sync();
00687 if ( !kapp->dcopClient()->isAttached() )
00688 kapp->dcopClient()->attach();
00689 kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
00690 }
00691 emit KCModule::changed(false);
00692 }
00693
00694 void KAdvancedConfig::defaults()
00695 {
00696 setAnimateShade(true);
00697 setShadeHover(false);
00698 setShadeHoverInterval(250);
00699 setElectricBorders(0);
00700 setElectricBorderDelay(150);
00701
00702
00703 setFocusStealing(1);
00704 emit KCModule::changed(true);
00705 }
00706
00707 void KAdvancedConfig::setEBorders()
00708 {
00709 delays->setEnabled(!active_disable->isChecked());
00710 }
00711
00712 int KAdvancedConfig::getElectricBorders()
00713 {
00714 if (active_move->isChecked())
00715 return 1;
00716 if (active_always->isChecked())
00717 return 2;
00718 return 0;
00719 }
00720
00721 int KAdvancedConfig::getElectricBorderDelay()
00722 {
00723 return delays->value();
00724 }
00725
00726 void KAdvancedConfig::setElectricBorders(int i){
00727 switch(i)
00728 {
00729 case 1: active_move->setChecked(true); break;
00730 case 2: active_always->setChecked(true); break;
00731 default: active_disable->setChecked(true); break;
00732 }
00733 setEBorders();
00734 }
00735
00736 void KAdvancedConfig::setElectricBorderDelay(int delay)
00737 {
00738 delays->setValue(delay);
00739 }
00740
00741
00742 KMovingConfig::~KMovingConfig ()
00743 {
00744 if (standAlone)
00745 delete config;
00746 }
00747
00748 KMovingConfig::KMovingConfig (bool _standAlone, KConfig *_config, QWidget *parent, const char *)
00749 : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
00750 {
00751 QString wtstr;
00752 QBoxLayout *lay = new QVBoxLayout (this, 0, KDialog::spacingHint());
00753
00754 windowsBox = new QButtonGroup(i18n("Windows"), this);
00755 windowsBox->setColumnLayout( 0, Qt::Horizontal );
00756
00757 QBoxLayout *wLay = new QVBoxLayout (windowsBox->layout(), KDialog::spacingHint());
00758
00759 QBoxLayout *bLay = new QVBoxLayout;
00760 wLay->addLayout(bLay);
00761
00762 opaque = new QCheckBox(i18n("Di&splay content in moving windows"), windowsBox);
00763 bLay->addWidget(opaque);
00764 QWhatsThis::add( opaque, i18n("Enable this option if you want a window's content to be fully shown"
00765 " while moving it, instead of just showing a window 'skeleton'. The result may not be satisfying"
00766 " on slow machines without graphic acceleration.") );
00767
00768 resizeOpaqueOn = new QCheckBox(i18n("Display content in &resizing windows"), windowsBox);
00769 bLay->addWidget(resizeOpaqueOn);
00770 QWhatsThis::add( resizeOpaqueOn, i18n("Enable this option if you want a window's content to be shown"
00771 " while resizing it, instead of just showing a window 'skeleton'. The result may not be satisfying"
00772 " on slow machines.") );
00773
00774 geometryTipOn = new QCheckBox(i18n("Display window &geometry when moving or resizing"), windowsBox);
00775 bLay->addWidget(geometryTipOn);
00776 QWhatsThis::add(geometryTipOn, i18n("Enable this option if you want a window's geometry to be displayed"
00777 " while it is being moved or resized. The window position relative"
00778 " to the top-left corner of the screen is displayed together with"
00779 " its size."));
00780
00781 QGridLayout *rLay = new QGridLayout(2,3);
00782 bLay->addLayout(rLay);
00783 rLay->setColStretch(0,0);
00784 rLay->setColStretch(1,1);
00785
00786 minimizeAnimOn = new QCheckBox(i18n("Animate minimi&ze and restore"),
00787 windowsBox);
00788 QWhatsThis::add( minimizeAnimOn, i18n("Enable this option if you want an animation shown when"
00789 " windows are minimized or restored." ) );
00790 rLay->addWidget(minimizeAnimOn,0,0);
00791
00792 minimizeAnimSlider = new QSlider(0,10,10,0,QSlider::Horizontal, windowsBox);
00793 minimizeAnimSlider->setSteps(1, 1);
00794
00795 #undef Below
00796 minimizeAnimSlider->setTickmarks(QSlider::Below);
00797 rLay->addMultiCellWidget(minimizeAnimSlider,0,0,1,2);
00798
00799 connect(minimizeAnimOn, SIGNAL(toggled(bool)), this, SLOT(setMinimizeAnim(bool)));
00800 connect(minimizeAnimSlider, SIGNAL(valueChanged(int)), this, SLOT(setMinimizeAnimSpeed(int)));
00801
00802 minimizeAnimSlowLabel= new QLabel(i18n("Slow"),windowsBox);
00803 minimizeAnimSlowLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
00804 rLay->addWidget(minimizeAnimSlowLabel,1,1);
00805
00806 minimizeAnimFastLabel= new QLabel(i18n("Fast"),windowsBox);
00807 minimizeAnimFastLabel->setAlignment(Qt::AlignTop|Qt::AlignRight);
00808 rLay->addWidget(minimizeAnimFastLabel,1,2);
00809
00810 wtstr = i18n("Here you can set the speed of the animation shown when windows are"
00811 " minimized and restored. ");
00812 QWhatsThis::add( minimizeAnimSlider, wtstr );
00813 QWhatsThis::add( minimizeAnimSlowLabel, wtstr );
00814 QWhatsThis::add( minimizeAnimFastLabel, wtstr );
00815
00816 moveResizeMaximized = new QCheckBox( i18n("Allow moving and resizing o&f maximized windows"), windowsBox);
00817 bLay->addWidget(moveResizeMaximized);
00818 QWhatsThis::add(moveResizeMaximized, i18n("When enabled, this feature activates the border of maximized windows"
00819 " and allows you to move or resize them,"
00820 " just like for normal windows"));
00821
00822 QBoxLayout *vLay = new QHBoxLayout(bLay);
00823
00824 QLabel *plcLabel = new QLabel(i18n("&Placement:"),windowsBox);
00825
00826 placementCombo = new QComboBox(false, windowsBox);
00827 placementCombo->insertItem(i18n("Smart"), SMART_PLACEMENT);
00828 placementCombo->insertItem(i18n("Cascade"), CASCADE_PLACEMENT);
00829 placementCombo->insertItem(i18n("Random"), RANDOM_PLACEMENT);
00830 placementCombo->insertItem(i18n("Centered"), CENTERED_PLACEMENT);
00831 placementCombo->insertItem(i18n("Zero-Cornered"), ZEROCORNERED_PLACEMENT);
00832
00833
00834
00835 placementCombo->setCurrentItem(SMART_PLACEMENT);
00836
00837
00838 wtstr = i18n("The placement policy determines where a new window"
00839 " will appear on the desktop."
00840 " <ul>"
00841 " <li><em>Smart</em> will try to achieve a minimum overlap of windows</li>"
00842 " <li><em>Cascade</em> will cascade the windows</li>"
00843 " <li><em>Random</em> will use a random position</li>"
00844 " <li><em>Centered</em> will place the window centered</li>"
00845 " <li><em>Zero-Cornered</em> will place the window in the top-left corner</li>"
00846 "</ul>") ;
00847
00848 QWhatsThis::add( plcLabel, wtstr);
00849 QWhatsThis::add( placementCombo, wtstr);
00850
00851 plcLabel->setBuddy(placementCombo);
00852 vLay->addWidget(plcLabel, 0);
00853 vLay->addWidget(placementCombo, 1, Qt::AlignLeft);
00854
00855 bLay->addSpacing(10);
00856
00857 lay->addWidget(windowsBox);
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874 MagicBox = new QVButtonGroup(i18n("Snap Zones"), this);
00875 MagicBox->setMargin(15);
00876
00877 BrdrSnap = new KIntNumInput(10, MagicBox);
00878 BrdrSnap->setSpecialValueText( i18n("none") );
00879 BrdrSnap->setRange( 0, MAX_BRDR_SNAP);
00880 BrdrSnap->setLabel(i18n("&Border snap zone:"));
00881 BrdrSnap->setSuffix(i18n(" pixels"));
00882 BrdrSnap->setSteps(1,10);
00883 QWhatsThis::add( BrdrSnap, i18n("Here you can set the snap zone for screen borders, i.e."
00884 " the 'strength' of the magnetic field which will make windows snap to the border when"
00885 " moved near it.") );
00886
00887 WndwSnap = new KIntNumInput(10, MagicBox);
00888 WndwSnap->setSpecialValueText( i18n("none") );
00889 WndwSnap->setRange( 0, MAX_WNDW_SNAP);
00890 WndwSnap->setLabel(i18n("&Window snap zone:"));
00891 WndwSnap->setSuffix( i18n(" pixels"));
00892 BrdrSnap->setSteps(1,10);
00893 QWhatsThis::add( WndwSnap, i18n("Here you can set the snap zone for windows, i.e."
00894 " the 'strength' of the magnetic field which will make windows snap to each other when"
00895 " they're moved near another window.") );
00896
00897 OverlapSnap=new QCheckBox(i18n("Snap windows onl&y when overlapping"),MagicBox);
00898 QWhatsThis::add( OverlapSnap, i18n("Here you can set that windows will be only"
00899 " snapped if you try to overlap them, i.e. they will not be snapped if the windows"
00900 " comes only near another window or border.") );
00901
00902 lay->addWidget(MagicBox);
00903 lay->addStretch();
00904
00905 load();
00906
00907
00908 connect( opaque, SIGNAL(clicked()), SLOT(changed()));
00909 connect( resizeOpaqueOn, SIGNAL(clicked()), SLOT(changed()));
00910 connect( geometryTipOn, SIGNAL(clicked()), SLOT(changed()));
00911 connect( minimizeAnimOn, SIGNAL(clicked() ), SLOT(changed()));
00912 connect( minimizeAnimSlider, SIGNAL(valueChanged(int)), SLOT(changed()));
00913 connect( moveResizeMaximized, SIGNAL(toggled(bool)), SLOT(changed()));
00914 connect( placementCombo, SIGNAL(activated(int)), SLOT(changed()));
00915 connect( BrdrSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
00916 connect( WndwSnap, SIGNAL(valueChanged(int)), SLOT(changed()));
00917 connect( OverlapSnap, SIGNAL(clicked()), SLOT(changed()));
00918 }
00919
00920 int KMovingConfig::getMove()
00921 {
00922 return (opaque->isChecked())? OPAQUE : TRANSPARENT;
00923 }
00924
00925 void KMovingConfig::setMove(int trans)
00926 {
00927 opaque->setChecked(trans == OPAQUE);
00928 }
00929
00930 void KMovingConfig::setGeometryTip(bool showGeometryTip)
00931 {
00932 geometryTipOn->setChecked(showGeometryTip);
00933 }
00934
00935 bool KMovingConfig::getGeometryTip()
00936 {
00937 return geometryTipOn->isChecked();
00938 }
00939
00940
00941 int KMovingConfig::getPlacement()
00942 {
00943 return placementCombo->currentItem();
00944 }
00945
00946 void KMovingConfig::setPlacement(int plac)
00947 {
00948 placementCombo->setCurrentItem(plac);
00949 }
00950
00951 bool KMovingConfig::getMinimizeAnim()
00952 {
00953 return minimizeAnimOn->isChecked();
00954 }
00955
00956 int KMovingConfig::getMinimizeAnimSpeed()
00957 {
00958 return minimizeAnimSlider->value();
00959 }
00960
00961 void KMovingConfig::setMinimizeAnim(bool anim)
00962 {
00963 minimizeAnimOn->setChecked( anim );
00964 minimizeAnimSlider->setEnabled( anim );
00965 minimizeAnimSlowLabel->setEnabled( anim );
00966 minimizeAnimFastLabel->setEnabled( anim );
00967 }
00968
00969 void KMovingConfig::setMinimizeAnimSpeed(int speed)
00970 {
00971 minimizeAnimSlider->setValue(speed);
00972 }
00973
00974 int KMovingConfig::getResizeOpaque()
00975 {
00976 return (resizeOpaqueOn->isChecked())? RESIZE_OPAQUE : RESIZE_TRANSPARENT;
00977 }
00978
00979 void KMovingConfig::setResizeOpaque(int opaque)
00980 {
00981 resizeOpaqueOn->setChecked(opaque == RESIZE_OPAQUE);
00982 }
00983
00984 void KMovingConfig::setMoveResizeMaximized(bool a) {
00985 moveResizeMaximized->setChecked(a);
00986 }
00987
00988 void KMovingConfig::load( void )
00989 {
00990 QString key;
00991
00992 config->setGroup( "Windows" );
00993
00994 key = config->readEntry(KWIN_MOVE, "Opaque");
00995 if( key == "Transparent")
00996 setMove(TRANSPARENT);
00997 else if( key == "Opaque")
00998 setMove(OPAQUE);
00999
01000
01001 bool anim = config->readBoolEntry(KWIN_MINIMIZE_ANIM, true );
01002 int animSpeed = config->readNumEntry(KWIN_MINIMIZE_ANIM_SPEED, 5);
01003 if( animSpeed < 1 ) animSpeed = 0;
01004 if( animSpeed > 10 ) animSpeed = 10;
01005 setMinimizeAnim( anim );
01006 setMinimizeAnimSpeed( animSpeed );
01007
01008
01009 key = config->readEntry(KWIN_RESIZE_OPAQUE, "Opaque");
01010 if( key == "Opaque")
01011 setResizeOpaque(RESIZE_OPAQUE);
01012 else if ( key == "Transparent")
01013 setResizeOpaque(RESIZE_TRANSPARENT);
01014
01015
01016 bool showGeomTip = config->readBoolEntry(KWIN_GEOMETRY, false);
01017 setGeometryTip( showGeomTip );
01018
01019
01020 key = config->readEntry(KWIN_PLACEMENT);
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037 if( key == "Random")
01038 setPlacement(RANDOM_PLACEMENT);
01039 else if( key == "Cascade")
01040 setPlacement(CASCADE_PLACEMENT);
01041
01042 else if( key == "manual")
01043 setPlacement(MANUAL_PLACEMENT);
01044 else if( key == "Centered")
01045 setPlacement(CENTERED_PLACEMENT);
01046 else if( key == "ZeroCornered")
01047 setPlacement(ZEROCORNERED_PLACEMENT);
01048
01049 else
01050 setPlacement(SMART_PLACEMENT);
01051
01052
01053 setMoveResizeMaximized(config->readBoolEntry(KWIN_MOVE_RESIZE_MAXIMIZED, true));
01054
01055 int v;
01056
01057 v = config->readNumEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT);
01058 if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP);
01059 else if (v < 0) setBorderSnapZone (0);
01060 else setBorderSnapZone(v);
01061
01062 v = config->readNumEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT);
01063 if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP);
01064 else if (v < 0) setWindowSnapZone (0);
01065 else setWindowSnapZone(v);
01066
01067 OverlapSnap->setChecked(config->readBoolEntry("SnapOnlyWhenOverlapping",false));
01068 emit KCModule::changed(false);
01069 }
01070
01071 void KMovingConfig::save( void )
01072 {
01073 int v;
01074
01075 config->setGroup( "Windows" );
01076
01077 v = getMove();
01078 if (v == TRANSPARENT)
01079 config->writeEntry(KWIN_MOVE,"Transparent");
01080 else
01081 config->writeEntry(KWIN_MOVE,"Opaque");
01082
01083 config->writeEntry(KWIN_GEOMETRY, getGeometryTip());
01084
01085
01086 v =getPlacement();
01087 if (v == RANDOM_PLACEMENT)
01088 config->writeEntry(KWIN_PLACEMENT, "Random");
01089 else if (v == CASCADE_PLACEMENT)
01090 config->writeEntry(KWIN_PLACEMENT, "Cascade");
01091 else if (v == CENTERED_PLACEMENT)
01092 config->writeEntry(KWIN_PLACEMENT, "Centered");
01093 else if (v == ZEROCORNERED_PLACEMENT)
01094 config->writeEntry(KWIN_PLACEMENT, "ZeroCornered");
01095
01096
01097
01098
01099
01100
01101
01102 else
01103 config->writeEntry(KWIN_PLACEMENT, "Smart");
01104
01105 config->writeEntry(KWIN_MINIMIZE_ANIM, getMinimizeAnim());
01106 config->writeEntry(KWIN_MINIMIZE_ANIM_SPEED, getMinimizeAnimSpeed());
01107
01108 v = getResizeOpaque();
01109 if (v == RESIZE_OPAQUE)
01110 config->writeEntry(KWIN_RESIZE_OPAQUE, "Opaque");
01111 else
01112 config->writeEntry(KWIN_RESIZE_OPAQUE, "Transparent");
01113
01114 config->writeEntry(KWIN_MOVE_RESIZE_MAXIMIZED, moveResizeMaximized->isChecked());
01115
01116
01117 config->writeEntry(KWM_BRDR_SNAP_ZONE,getBorderSnapZone());
01118 config->writeEntry(KWM_WNDW_SNAP_ZONE,getWindowSnapZone());
01119 config->writeEntry("SnapOnlyWhenOverlapping",OverlapSnap->isChecked());
01120
01121 if (standAlone)
01122 {
01123 config->sync();
01124 if ( !kapp->dcopClient()->isAttached() )
01125 kapp->dcopClient()->attach();
01126 kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
01127 }
01128 emit KCModule::changed(false);
01129 }
01130
01131 void KMovingConfig::defaults()
01132 {
01133 setMove(OPAQUE);
01134 setResizeOpaque(RESIZE_TRANSPARENT);
01135 setGeometryTip(false);
01136 setPlacement(SMART_PLACEMENT);
01137 setMoveResizeMaximized(true);
01138
01139
01140 setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT);
01141 setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT);
01142 OverlapSnap->setChecked(false);
01143
01144 setMinimizeAnim( true );
01145 setMinimizeAnimSpeed( 5 );
01146 emit KCModule::changed(true);
01147 }
01148
01149 int KMovingConfig::getBorderSnapZone() {
01150 return BrdrSnap->value();
01151 }
01152
01153 void KMovingConfig::setBorderSnapZone(int pxls) {
01154 BrdrSnap->setValue(pxls);
01155 }
01156
01157 int KMovingConfig::getWindowSnapZone() {
01158 return WndwSnap->value();
01159 }
01160
01161 void KMovingConfig::setWindowSnapZone(int pxls) {
01162 WndwSnap->setValue(pxls);
01163 }
01164
01165 KTranslucencyConfig::~KTranslucencyConfig ()
01166 {
01167 if (standAlone)
01168 delete config;
01169 if (kompmgr)
01170 kompmgr->detach();
01171 }
01172
01173 KTranslucencyConfig::KTranslucencyConfig (bool _standAlone, KConfig *_config, QWidget *parent, const char *)
01174 : KCModule(parent, "kcmkwm"), config(_config), standAlone(_standAlone)
01175 {
01176 kompmgr = 0L;
01177 resetKompmgr_ = FALSE;
01178 QVBoxLayout *lay = new QVBoxLayout (this);
01179 kompmgrAvailable_ = kompmgrAvailable();
01180 if (!kompmgrAvailable_){
01181 KActiveLabel *label = new KActiveLabel(i18n("<qt><b>It seems that alpha channel support is not available.</b><br><br>"
01182 "Please make sure you have "
01183 "<a href=\"http://www.freedesktop.org/\">Xorg ≥ 6.8</a>,"
01184 " and installed the kompmgr that came with kwin.<br>"
01185 "Also, make sure you have the following entries in your XConfig (e.g. /etc/X11/xorg.conf):<br><br>"
01186 "<i>Section \"Extensions\"<br>"
01187 "Option \"Composite\" \"Enable\"<br>"
01188 "EndSection</i><br><br>"
01189 "And if your GPU provides hardware-accelerated Xrender support (mainly nVidia cards):<br><br>"
01190 "<i>Option \"RenderAccel\" \"true\"</i><br>"
01191 "In <i>Section \"Device\"</i></qt>"), this);
01192 lay->addWidget(label);
01193 }
01194 else
01195 {
01196 QTabWidget *tabW = new QTabWidget(this);
01197 QWidget *tGroup = new QWidget(tabW);
01198 QVBoxLayout *vLay = new QVBoxLayout (tGroup,KDialog::marginHint(), KDialog::spacingHint());
01199 vLay->addSpacing(11);
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212 QGridLayout *gLay = new QGridLayout(vLay,4,2,KDialog::spacingHint());
01213 gLay->setColStretch(1,1);
01214
01215 activeWindowTransparency = new QCheckBox(i18n("Active windows:"),tGroup);
01216 gLay->addWidget(activeWindowTransparency,0,0);
01217 activeWindowOpacity = new KIntNumInput(100, tGroup);
01218 activeWindowOpacity->setRange(0,100);
01219 activeWindowOpacity->setSuffix("%");
01220 gLay->addWidget(activeWindowOpacity,0,1);
01221
01222 inactiveWindowTransparency = new QCheckBox(i18n("Inactive windows:"),tGroup);
01223 gLay->addWidget(inactiveWindowTransparency,1,0);
01224 inactiveWindowOpacity = new KIntNumInput(100, tGroup);
01225 inactiveWindowOpacity->setRange(0,100);
01226 inactiveWindowOpacity->setSuffix("%");
01227 gLay->addWidget(inactiveWindowOpacity,1,1);
01228
01229 movingWindowTransparency = new QCheckBox(i18n("Moving windows:"),tGroup);
01230 gLay->addWidget(movingWindowTransparency,2,0);
01231 movingWindowOpacity = new KIntNumInput(100, tGroup);
01232 movingWindowOpacity->setRange(0,100);
01233 movingWindowOpacity->setSuffix("%");
01234 gLay->addWidget(movingWindowOpacity,2,1);
01235
01236 dockWindowTransparency = new QCheckBox(i18n("Dock windows:"),tGroup);
01237 gLay->addWidget(dockWindowTransparency,3,0);
01238 dockWindowOpacity = new KIntNumInput(100, tGroup);
01239 dockWindowOpacity->setRange(0,100);
01240 dockWindowOpacity->setSuffix("%");
01241 gLay->addWidget(dockWindowOpacity,3,1);
01242
01243 vLay->addSpacing(11);
01244
01245 keepAboveAsActive = new QCheckBox(i18n("Treat 'keep above' windows as active ones"),tGroup);
01246 vLay->addWidget(keepAboveAsActive);
01247
01248 disableARGB = new QCheckBox(i18n("Disable ARGB windows (ignores window alpha maps, fixes gtk1 apps)"),tGroup);
01249 vLay->addWidget(disableARGB);
01250
01251 vLay->addStretch();
01252 tabW->addTab(tGroup, i18n("Translucency"));
01253
01254 QWidget *sGroup = new QWidget(tabW);
01255
01256 QVBoxLayout *vLay2 = new QVBoxLayout (sGroup,11,6);
01257 vLay2->addSpacing(11);
01258 useShadows = new QCheckBox(i18n("Use shadows"),sGroup);
01259 vLay2->addWidget(useShadows);
01260
01261 vLay2->addSpacing(11);
01262
01263 QGridLayout *gLay2 = new QGridLayout(vLay2,6,2);
01264 gLay2->setColStretch(1,1);
01265
01266 QLabel *label1 = new QLabel(i18n("Active window size:"),sGroup);
01267 gLay2->addWidget(label1,0,0);
01268 activeWindowShadowSize = new KIntNumInput(12,sGroup);
01269 activeWindowShadowSize->setRange(0,32);
01270
01271 gLay2->addWidget(activeWindowShadowSize,0,1);
01272
01273 QLabel *label2 = new QLabel(i18n("Inactive window size:"),sGroup);
01274 gLay2->addWidget(label2,1,0);
01275 inactiveWindowShadowSize = new KIntNumInput(6,sGroup);
01276 inactiveWindowShadowSize->setRange(0,32);
01277
01278 gLay2->addWidget(inactiveWindowShadowSize,1,1);
01279
01280 QLabel *label3 = new QLabel(i18n("Dock window size:"),sGroup);
01281 gLay2->addWidget(label3,2,0);
01282 dockWindowShadowSize = new KIntNumInput(6,sGroup);
01283 dockWindowShadowSize->setRange(0,32);
01284
01285 gLay2->addWidget(dockWindowShadowSize,2,1);
01286
01287 QLabel *label4 = new QLabel(i18n("Vertical offset:"),sGroup);
01288 gLay2->addWidget(label4,3,0);
01289 shadowTopOffset = new KIntNumInput(80,sGroup);
01290 shadowTopOffset->setSuffix("%");
01291 shadowTopOffset->setRange(-200,200);
01292 gLay2->addWidget(shadowTopOffset,3,1);
01293
01294 QLabel *label5 = new QLabel(i18n("Horizontal offset:"),sGroup);
01295 gLay2->addWidget(label5,4,0);
01296 shadowLeftOffset = new KIntNumInput(0,sGroup);
01297 shadowLeftOffset->setSuffix("%");
01298 shadowLeftOffset->setRange(-200,200);
01299 gLay2->addWidget(shadowLeftOffset,4,1);
01300
01301 QLabel *label6 = new QLabel(i18n("Shadow color:"),sGroup);
01302 gLay2->addWidget(label6,5,0);
01303 shadowColor = new KColorButton(Qt::black,sGroup);
01304 gLay2->addWidget(shadowColor,5,1);
01305 gLay2->setColStretch(1,1);
01306 vLay2->addSpacing(11);
01307 removeShadowsOnMove = new QCheckBox(i18n("Remove shadows on move"),sGroup);
01308 vLay2->addWidget(removeShadowsOnMove);
01309 removeShadowsOnResize = new QCheckBox(i18n("Remove shadows on resize"),sGroup);
01310 vLay2->addWidget(removeShadowsOnResize);
01311 vLay2->addStretch();
01312 tabW->addTab(sGroup, i18n("Shadows"));
01313
01314 QWidget *eGroup = new QWidget(this);
01315 QVBoxLayout *vLay3 = new QVBoxLayout (eGroup,11,6);
01316
01317 fadeInWindows = new QCheckBox(i18n("Fade-in windows (including popups)"),eGroup);
01318 fadeOnOpacityChange = new QCheckBox(i18n("Fade between opacity changes"),eGroup);
01319 fadeInSpeed = new KIntNumInput(100, eGroup);
01320 fadeInSpeed->setRange(1,100);
01321 fadeInSpeed->setLabel("Fade-in speed:");
01322 fadeOutSpeed = new KIntNumInput(100, eGroup);
01323 fadeOutSpeed->setRange(1,100);
01324 fadeOutSpeed->setLabel("Fade-out speed:");
01325 vLay3->addWidget(fadeInWindows);
01326 vLay3->addWidget(fadeOnOpacityChange);
01327 vLay3->addWidget(fadeInSpeed);
01328 vLay3->addWidget(fadeOutSpeed);
01329 vLay3->addStretch();
01330
01331 tabW->addTab(eGroup, i18n("Effects"));
01332
01333 useTranslucency = new QCheckBox(i18n("Use translucency/shadows"),this);
01334 lay->addWidget(useTranslucency);
01335 lay->addWidget(tabW);
01336
01337 connect(useTranslucency, SIGNAL(toggled(bool)), tabW, SLOT(setEnabled(bool)));
01338
01339 connect(activeWindowTransparency, SIGNAL(toggled(bool)), activeWindowOpacity, SLOT(setEnabled(bool)));
01340 connect(inactiveWindowTransparency, SIGNAL(toggled(bool)), inactiveWindowOpacity, SLOT(setEnabled(bool)));
01341 connect(movingWindowTransparency, SIGNAL(toggled(bool)), movingWindowOpacity, SLOT(setEnabled(bool)));
01342 connect(dockWindowTransparency, SIGNAL(toggled(bool)), dockWindowOpacity, SLOT(setEnabled(bool)));
01343
01344 connect(useTranslucency, SIGNAL(toggled(bool)), SLOT(changed()));
01345
01346 connect(activeWindowTransparency, SIGNAL(toggled(bool)), SLOT(changed()));
01347 connect(inactiveWindowTransparency, SIGNAL(toggled(bool)), SLOT(changed()));
01348 connect(movingWindowTransparency, SIGNAL(toggled(bool)), SLOT(changed()));
01349 connect(dockWindowTransparency, SIGNAL(toggled(bool)), SLOT(changed()));
01350 connect(keepAboveAsActive, SIGNAL(toggled(bool)), SLOT(changed()));
01351 connect(disableARGB, SIGNAL(toggled(bool)), SLOT(changed()));
01352 connect(useShadows, SIGNAL(toggled(bool)), SLOT(changed()));
01353 connect(removeShadowsOnResize, SIGNAL(toggled(bool)), SLOT(changed()));
01354 connect(removeShadowsOnMove, SIGNAL(toggled(bool)), SLOT(changed()));
01355
01356 connect(activeWindowOpacity, SIGNAL(valueChanged(int)), SLOT(changed()));
01357 connect(inactiveWindowOpacity, SIGNAL(valueChanged(int)), SLOT(changed()));
01358 connect(movingWindowOpacity, SIGNAL(valueChanged(int)), SLOT(changed()));
01359 connect(dockWindowOpacity, SIGNAL(valueChanged(int)), SLOT(changed()));
01360 connect(dockWindowShadowSize, SIGNAL(valueChanged(int)), SLOT(changed()));
01361 connect(activeWindowShadowSize, SIGNAL(valueChanged(int)), SLOT(changed()));
01362 connect(inactiveWindowShadowSize, SIGNAL(valueChanged(int)), SLOT(changed()));
01363 connect(shadowTopOffset, SIGNAL(valueChanged(int)), SLOT(changed()));
01364 connect(shadowLeftOffset, SIGNAL(valueChanged(int)), SLOT(changed()));
01365 connect(shadowColor, SIGNAL(changed(const QColor&)), SLOT(changed()));
01366 connect(fadeInWindows, SIGNAL(toggled(bool)), SLOT(changed()));
01367 connect(fadeOnOpacityChange, SIGNAL(toggled(bool)), SLOT(changed()));
01368 connect(fadeInSpeed, SIGNAL(valueChanged(int)), SLOT(changed()));
01369 connect(fadeOutSpeed, SIGNAL(valueChanged(int)), SLOT(changed()));
01370
01371 connect(useShadows, SIGNAL(toggled(bool)), dockWindowShadowSize, SLOT(setEnabled(bool)));
01372 connect(useShadows, SIGNAL(toggled(bool)), activeWindowShadowSize, SLOT(setEnabled(bool)));
01373 connect(useShadows, SIGNAL(toggled(bool)), inactiveWindowShadowSize, SLOT(setEnabled(bool)));
01374 connect(useShadows, SIGNAL(toggled(bool)), shadowTopOffset, SLOT(setEnabled(bool)));
01375 connect(useShadows, SIGNAL(toggled(bool)), shadowLeftOffset, SLOT(setEnabled(bool)));
01376 connect(useShadows, SIGNAL(toggled(bool)), shadowColor, SLOT(setEnabled(bool)));
01377
01378 load();
01379
01380 tabW->setEnabled(useTranslucency->isChecked());
01381
01382 connect(useTranslucency, SIGNAL(toggled(bool)), this, SLOT(showWarning(bool)));
01383
01384
01385 connect(useTranslucency, SIGNAL(toggled(bool)), SLOT(resetKompmgr()));
01386
01387 connect(disableARGB, SIGNAL(toggled(bool)), SLOT(resetKompmgr()));
01388 connect(useShadows, SIGNAL(toggled(bool)), SLOT(resetKompmgr()));
01389 connect(inactiveWindowShadowSize, SIGNAL(valueChanged(int)), SLOT(resetKompmgr()));
01390 connect(shadowTopOffset, SIGNAL(valueChanged(int)), SLOT(resetKompmgr()));
01391 connect(shadowLeftOffset, SIGNAL(valueChanged(int)), SLOT(resetKompmgr()));
01392 connect(shadowColor, SIGNAL(changed(const QColor&)), SLOT(resetKompmgr()));
01393 connect(fadeInWindows, SIGNAL(toggled(bool)), SLOT(resetKompmgr()));
01394 connect(fadeOnOpacityChange, SIGNAL(toggled(bool)), SLOT(resetKompmgr()));
01395 connect(fadeInSpeed, SIGNAL(valueChanged(int)), SLOT(resetKompmgr()));
01396 connect(fadeOutSpeed, SIGNAL(valueChanged(int)), SLOT(resetKompmgr()));
01397
01398 }
01399 }
01400
01401 void KTranslucencyConfig::resetKompmgr()
01402 {
01403 resetKompmgr_ = TRUE;
01404 }
01405 void KTranslucencyConfig::load( void )
01406 {
01407
01408 if (!kompmgrAvailable_)
01409 return;
01410 config->setGroup( "Notification Messages" );
01411 useTranslucency->setChecked(config->readBoolEntry("UseTranslucency",false));
01412
01413 config->setGroup( "Translucency" );
01414 activeWindowTransparency->setChecked(config->readBoolEntry("TranslucentActiveWindows",false));
01415 inactiveWindowTransparency->setChecked(config->readBoolEntry("TranslucentInactiveWindows",true));
01416 movingWindowTransparency->setChecked(config->readBoolEntry("TranslucentMovingWindows",false));
01417 removeShadowsOnMove->setChecked(config->readBoolEntry("RemoveShadowsOnMove",FALSE));
01418 removeShadowsOnResize->setChecked(config->readBoolEntry("RemoveShadowsOnResize",FALSE));
01419 dockWindowTransparency->setChecked(config->readBoolEntry("TranslucentDocks",true));
01420 keepAboveAsActive->setChecked(config->readBoolEntry("TreatKeepAboveAsActive",true));
01421
01422 activeWindowOpacity->setValue(config->readNumEntry("ActiveWindowOpacity",100));
01423 inactiveWindowOpacity->setValue(config->readNumEntry("InactiveWindowOpacity",75));
01424 movingWindowOpacity->setValue(config->readNumEntry("MovingWindowOpacity",25));
01425 dockWindowOpacity->setValue(config->readNumEntry("DockOpacity",80));
01426
01427 int ass, iss, dss;
01428 dss = config->readNumEntry("DockShadowSize", 50);
01429 ass = config->readNumEntry("ActiveWindowShadowSize", 200);
01430 iss = config->readNumEntry("InactiveWindowShadowSize", 100);
01431
01432 activeWindowOpacity->setEnabled(activeWindowTransparency->isChecked());
01433 inactiveWindowOpacity->setEnabled(inactiveWindowTransparency->isChecked());
01434 movingWindowOpacity->setEnabled(movingWindowTransparency->isChecked());
01435 dockWindowOpacity->setEnabled(dockWindowTransparency->isChecked());
01436
01437 KConfig conf_(QDir::homeDirPath() + "/.xcompmgrrc");
01438 conf_.setGroup("xcompmgr");
01439
01440
01441
01442
01443 disableARGB->setChecked(conf_.readBoolEntry("DisableARGB",FALSE));
01444
01445 useShadows->setChecked(conf_.readEntry("Compmode","CompClientShadows").compare("CompClientShadows") == 0);
01446 shadowTopOffset->setValue(-1*(conf_.readNumEntry("ShadowOffsetY",-80)));
01447 shadowLeftOffset->setValue(-1*(conf_.readNumEntry("ShadowOffsetX",0)));
01448
01449 int ss = conf_.readNumEntry("ShadowRadius",6);
01450 dockWindowShadowSize->setValue((int)(dss*ss/100.0));
01451 activeWindowShadowSize->setValue((int)(ass*ss/100.0));
01452 inactiveWindowShadowSize->setValue((int)(iss*ss/100.0));
01453
01454 QString hex = conf_.readEntry("ShadowColor","#000000");
01455 uint r, g, b;
01456 r = g = b = 256;
01457
01458 if (sscanf(hex.latin1(), "0x%02x%02x%02x", &r, &g, &b)!=3 || r > 255 || g > 255 || b > 255)
01459 shadowColor->setColor(Qt::black);
01460 else
01461 shadowColor->setColor(QColor(r,g,b));
01462
01463 fadeInWindows->setChecked(conf_.readBoolEntry("FadeWindows",TRUE));
01464 fadeOnOpacityChange->setChecked(conf_.readBoolEntry("FadeTrans",FALSE));
01465 fadeInSpeed->setValue((int)(conf_.readDoubleNumEntry("FadeInStep",0.020)*1000.0));
01466 fadeOutSpeed->setValue((int)(conf_.readDoubleNumEntry("FadeOutStep",0.070)*1000.0));
01467
01468 emit KCModule::changed(false);
01469 }
01470
01471 void KTranslucencyConfig::save( void )
01472 {
01473 if (!kompmgrAvailable_)
01474 return;
01475 config->setGroup( "Notification Messages" );
01476 config->writeEntry("UseTranslucency",useTranslucency->isChecked());
01477
01478 config->setGroup( "Translucency" );
01479 config->writeEntry("TranslucentActiveWindows",activeWindowTransparency->isChecked());
01480 config->writeEntry("TranslucentInactiveWindows",inactiveWindowTransparency->isChecked());
01481 config->writeEntry("TranslucentMovingWindows",movingWindowTransparency->isChecked());
01482 config->writeEntry("TranslucentDocks",dockWindowTransparency->isChecked());
01483 config->writeEntry("TreatKeepAboveAsActive",keepAboveAsActive->isChecked());
01484 config->writeEntry("ActiveWindowOpacity",activeWindowOpacity->value());
01485 config->writeEntry("InactiveWindowOpacity",inactiveWindowOpacity->value());
01486 config->writeEntry("MovingWindowOpacity",movingWindowOpacity->value());
01487 config->writeEntry("DockOpacity",dockWindowOpacity->value());
01488
01489
01490
01491
01492
01493 config->writeEntry("DockShadowSize",(int)(100.0*dockWindowShadowSize->value()/inactiveWindowShadowSize->value()));
01494 config->writeEntry("ActiveWindowShadowSize",(int)(100.0*activeWindowShadowSize->value()/inactiveWindowShadowSize->value()));
01495 config->writeEntry("InctiveWindowShadowSize",100);
01496 config->writeEntry("RemoveShadowsOnMove",removeShadowsOnMove->isChecked());
01497 config->writeEntry("RemoveShadowsOnResize",removeShadowsOnResize->isChecked());
01498 config->writeEntry("ResetKompmgr",resetKompmgr_);
01499
01500 KConfig *conf_ = new KConfig(QDir::homeDirPath() + "/.xcompmgrrc");
01501 conf_->setGroup("xcompmgr");
01502
01503 conf_->writeEntry("Compmode",useShadows->isChecked()?"CompClientShadows":"");
01504 conf_->writeEntry("DisableARGB",disableARGB->isChecked());
01505 conf_->writeEntry("ShadowOffsetY",-1*shadowTopOffset->value());
01506 conf_->writeEntry("ShadowOffsetX",-1*shadowLeftOffset->value());
01507
01508
01509
01510 int r, g, b;
01511 shadowColor->color().rgb( &r, &g, &b );
01512 QString hex;
01513 hex.sprintf("0x%02X%02X%02X", r,g,b);
01514 conf_->writeEntry("ShadowColor",hex);
01515 conf_->writeEntry("ShadowRadius",inactiveWindowShadowSize->value());
01516 conf_->writeEntry("FadeWindows",fadeInWindows->isChecked());
01517 conf_->writeEntry("FadeTrans",fadeOnOpacityChange->isChecked());
01518 conf_->writeEntry("FadeInStep",fadeInSpeed->value()/1000.0);
01519 conf_->writeEntry("FadeOutStep",fadeOutSpeed->value()/1000.0);
01520
01521 delete conf_;
01522
01523 if (standAlone)
01524 {
01525 config->sync();
01526 if ( !kapp->dcopClient()->isAttached() )
01527 kapp->dcopClient()->attach();
01528 kapp->dcopClient()->send("kwin*", "", "reconfigure()", "");
01529 }
01530 emit KCModule::changed(false);
01531 }
01532
01533 void KTranslucencyConfig::defaults()
01534 {
01535 if (!kompmgrAvailable_)
01536 return;
01537 useTranslucency->setChecked(false);
01538
01539 activeWindowTransparency->setChecked(false);
01540 inactiveWindowTransparency->setChecked(true);
01541 movingWindowTransparency->setChecked(false);
01542 dockWindowTransparency->setChecked(true);
01543 keepAboveAsActive->setChecked(true);
01544 disableARGB->setChecked(false);
01545
01546 activeWindowOpacity->setValue(100);
01547 inactiveWindowOpacity->setValue(75);
01548 movingWindowOpacity->setValue(25);
01549 dockWindowOpacity->setValue(80);
01550
01551 dockWindowShadowSize->setValue(6);
01552 activeWindowShadowSize->setValue(12);
01553 inactiveWindowShadowSize->setValue(6);
01554 shadowTopOffset->setValue(80);
01555 shadowLeftOffset->setValue(0);
01556
01557 activeWindowOpacity->setEnabled(false);
01558 inactiveWindowOpacity->setEnabled(true);
01559 movingWindowOpacity->setEnabled(false);
01560 dockWindowOpacity->setEnabled(true);
01561 useShadows->setChecked(TRUE);
01562 removeShadowsOnMove->setChecked(FALSE);
01563 removeShadowsOnResize->setChecked(FALSE);
01564 shadowColor->setColor(Qt::black);
01565 fadeInWindows->setChecked(TRUE);
01566 fadeOnOpacityChange->setChecked(FALSE);
01567 fadeInSpeed->setValue(70);
01568 fadeOutSpeed->setValue(20);
01569 emit KCModule::changed(true);
01570 }
01571
01572
01573 bool KTranslucencyConfig::kompmgrAvailable()
01574 {
01575 bool ret;
01576 KProcess proc;
01577 proc << "kompmgr" << "-v";
01578 ret = proc.start(KProcess::DontCare, KProcess::AllOutput);
01579 proc.detach();
01580 return ret;
01581 }
01582
01583 void KTranslucencyConfig::showWarning(bool alphaActivated)
01584 {
01585 if (alphaActivated)
01586 KMessageBox::information(this, i18n("<qt>Translucency support is new and may cause problems<br> including crashes (sometimes the translucency engine, seldom even X).</qt>"), i18n("Warning"));
01587 }
01588
01589 #include "windows.moc"