4 * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca
5 * Copyright (c) 2001 Waldo Bastian bastian@kde.org
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #include <config-workspace.h>
26 #include <QApplication>
28 #include <QRadioButton>
31 #include <QHBoxLayout>
32 #include <QFormLayout>
33 #include <QtDBus/QtDBus>
35 #include <KButtonGroup>
37 #include <knuminput.h>
42 #include <X11/Xutil.h>
46 #include <kephal/screens.h>
48 // kwin config keywords
49 #define KWIN_FOCUS "FocusPolicy"
50 #define KWIN_PLACEMENT "Placement"
51 #define KWIN_MOVE "MoveMode"
52 #define KWIN_RESIZE_OPAQUE "ResizeMode"
53 #define KWIN_GEOMETRY "GeometryTip"
54 #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval"
55 #define KWIN_AUTORAISE "AutoRaise"
56 #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
57 #define KWIN_DELAYFOCUS "DelayFocus"
58 #define KWIN_CLICKRAISE "ClickRaise"
59 #define KWIN_MOVE_RESIZE_MAXIMIZED "MoveResizeMaximizedWindows"
60 #define KWIN_ALTTABMODE "AltTabStyle"
61 #define KWIN_TRAVERSE_ALL "TraverseAll"
62 #define KWIN_SHOW_POPUP "ShowPopup"
63 #define KWIN_ROLL_OVER_DESKTOPS "RollOverDesktops"
64 #define KWIN_SHADEHOVER "ShadeHover"
65 #define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval"
66 #define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
67 #define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive"
68 #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus"
69 #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen"
71 // kwm config keywords
72 #define KWM_ELECTRIC_BORDER "ElectricBorders"
73 #define KWM_ELECTRIC_BORDER_DELAY "ElectricBorderDelay"
75 //CT 15mar 98 - magics
76 #define KWM_BRDR_SNAP_ZONE "BorderSnapZone"
77 #define KWM_BRDR_SNAP_ZONE_DEFAULT 10
78 #define KWM_WNDW_SNAP_ZONE "WindowSnapZone"
79 #define KWM_WNDW_SNAP_ZONE_DEFAULT 10
80 #define KWM_CNTR_SNAP_ZONE "CenterSnapZone"
81 #define KWM_CNTR_SNAP_ZONE_DEFAULT 0
83 #define MAX_BRDR_SNAP 100
84 #define MAX_WNDW_SNAP 100
85 #define MAX_CNTR_SNAP 100
86 #define MAX_EDGE_RES 1000
89 KFocusConfig::~KFocusConfig ()
95 // removed the LCD display over the slider - this is not good GUI design :) RNolden 051701
96 KFocusConfig::KFocusConfig (bool _standAlone
, KConfig
*_config
, const KComponentData
&inst
, QWidget
* parent
)
97 : KCModule(inst
, parent
), config(_config
), standAlone(_standAlone
)
100 QBoxLayout
*lay
= new QVBoxLayout(this);
103 //iTLabel = new QLabel(i18n(" Allowed overlap:\n"
104 // "(% of desktop space)"),
106 //iTLabel->setAlignment(AlignTop|AlignHCenter);
107 //pLay->addWidget(iTLabel,1,1);
109 //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
110 //pLay->addWidget(interactiveTrigger,1,2);
112 //pLay->addRowSpacing(2,KDialog::spacingHint());
114 //lay->addWidget(plcBox);
117 //fcsBox = new QGroupBox(i18n("Focus"),this);
118 fcsBox
= new QWidget(this);
120 QGridLayout
*gLay
= new QGridLayout();
122 fcsBox
->setLayout( gLay
);
124 focusStealing
= new QComboBox( this );
125 focusStealing
->addItem( i18nc( "Focus Stealing Prevention Level", "None" ));
126 focusStealing
->addItem( i18nc( "Focus Stealing Prevention Level", "Low" ));
127 focusStealing
->addItem( i18nc( "Focus Stealing Prevention Level", "Normal" ));
128 focusStealing
->addItem( i18nc( "Focus Stealing Prevention Level", "High" ));
129 focusStealing
->addItem( i18nc( "Focus Stealing Prevention Level", "Extreme" ));
130 wtstr
= i18n( "<p>This option specifies how much KWin will try to prevent unwanted focus stealing "
131 "caused by unexpected activation of new windows. (Note: This feature does not "
132 "work with the Focus Under Mouse or Focus Strictly Under Mouse focus policies.)"
134 "<li><em>None:</em> Prevention is turned off "
135 "and new windows always become activated.</li>"
136 "<li><em>Low:</em> Prevention is enabled; when some window does not have support "
137 "for the underlying mechanism and KWin cannot reliably decide whether to "
138 "activate the window or not, it will be activated. This setting may have both "
139 "worse and better results than normal level, depending on the applications.</li>"
140 "<li><em>Normal:</em> Prevention is enabled.</li>"
141 "<li><em>High:</em> New windows get activated only if no window is currently active "
142 "or if they belong to the currently active application. This setting is probably "
143 "not really usable when not using mouse focus policy.</li>"
144 "<li><em>Extreme:</em> All windows must be explicitly activated by the user.</li>"
146 "<p>Windows that are prevented from stealing focus are marked as demanding attention, "
147 "which by default means their taskbar entry will be highlighted. This can be changed "
148 "in the Notifications control module.</p>" );
149 focusStealing
->setWhatsThis( wtstr
);
150 connect(focusStealing
, SIGNAL(activated(int)), SLOT(changed()));
151 focusStealing
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
152 label
= new QLabel(i18n("Focus stealing prevention level:"), this);
153 label
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
154 label
->setBuddy(focusStealing
);
155 gLay
->addWidget(label
, 0, 0, 1, 2);
156 gLay
->addWidget(focusStealing
, 0, 2);
158 focusCombo
= new QComboBox(fcsBox
);
159 focusCombo
->setEditable( false );
160 focusCombo
->addItem(i18n("Click to Focus"), CLICK_TO_FOCUS
);
161 focusCombo
->addItem(i18n("Focus Follows Mouse"), FOCUS_FOLLOWS_MOUSE
);
162 focusCombo
->addItem(i18n("Focus Under Mouse"), FOCUS_UNDER_MOUSE
);
163 focusCombo
->addItem(i18n("Focus Strictly Under Mouse"), FOCUS_STRICTLY_UNDER_MOUSE
);
164 focusCombo
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
165 label
= new QLabel(i18n("&Policy:"), this);
166 label
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
167 label
->setBuddy(focusCombo
);
168 gLay
->addWidget(label
, 1, 0, 1, 2);
169 gLay
->addWidget(focusCombo
, 1, 2);
172 // FIXME, when more policies have been added to KWin
173 wtstr
= i18n("The focus policy is used to determine the active window, i.e."
174 " the window you can work in. <ul>"
175 " <li><em>Click to focus:</em> A window becomes active when you click into it."
176 " This is the behavior you might know from other operating systems.</li>"
177 " <li><em>Focus follows mouse:</em> Moving the mouse pointer actively on to a"
178 " normal window activates it. New windows will receive the focus,"
179 " without you having to point the mouse at them explicitly."
180 " Very practical if you are using the mouse a lot.</li>"
181 " <li><em>Focus under mouse:</em> The window that happens to be under the"
182 " mouse pointer is active. If the mouse points nowhere, the last window"
183 " that was under the mouse has focus."
184 " New windows will not automatically receive the focus.</li>"
185 " <li><em>Focus strictly under mouse:</em> Only the window under the mouse pointer is"
186 " active. If the mouse points nowhere, nothing has focus.</li>"
188 "Note that 'Focus under mouse' and 'Focus strictly under mouse' prevent certain"
189 " features such as the Alt+Tab walk through windows dialog in the KDE mode"
190 " from working properly."
192 focusCombo
->setWhatsThis( wtstr
);
194 connect(focusCombo
, SIGNAL(activated(int)), this, SLOT(focusPolicyChanged()) );
197 autoRaiseOn
= new QCheckBox(fcsBox
);
198 connect(autoRaiseOn
,SIGNAL(toggled(bool)), this, SLOT(autoRaiseOnTog(bool)));
199 autoRaise
= new KIntNumInput(500, fcsBox
);
200 autoRaise
->setRange(0, 3000, 100);
201 autoRaise
->setSteps(100,100);
202 autoRaise
->setSuffix(i18n(" ms"));
203 autoRaise
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
204 autoRaiseOnLabel
= new QLabel(i18n("&Raise, with the following delay:"), this);
205 autoRaiseOnLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
206 autoRaiseOnLabel
->setBuddy(autoRaise
);
207 gLay
->addWidget(autoRaiseOn
, 2, 0);
208 gLay
->addWidget(autoRaiseOnLabel
, 2, 1);
209 gLay
->addWidget(autoRaise
, 2, 2);
211 connect(focusCombo
, SIGNAL(activated(int)), this, SLOT(setDelayFocusEnabled()) );
213 delayFocusOn
= new QCheckBox(fcsBox
);
214 connect(delayFocusOn
,SIGNAL(toggled(bool)), this, SLOT(delayFocusOnTog(bool)));
215 delayFocus
= new KIntNumInput(500, fcsBox
);
216 delayFocus
->setRange(0, 3000, 100);
217 delayFocus
->setSteps(100,100);
218 delayFocus
->setSuffix(i18n(" ms"));
219 delayFocus
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
220 delayFocusOnLabel
= new QLabel(i18n("Delay focus by:"), this);
221 delayFocusOnLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
222 delayFocusOnLabel
->setBuddy(delayFocus
);
223 gLay
->addWidget(delayFocusOn
, 3, 0);
224 gLay
->addWidget(delayFocusOnLabel
, 3, 1);
225 gLay
->addWidget(delayFocus
, 3, 2);
227 clickRaiseOn
= new QCheckBox(i18n("C&lick raises active window"), fcsBox
);
228 connect(clickRaiseOn
,SIGNAL(toggled(bool)), this, SLOT(clickRaiseOnTog(bool)));
229 gLay
->addWidget(clickRaiseOn
, 4, 0, 1, 3);
231 autoRaiseOn
->setWhatsThis( i18n("When this option is enabled, a window in the background will automatically"
232 " come to the front when the mouse pointer has been over it for some time.") );
233 wtstr
= i18n("This is the delay after which the window that the mouse pointer is over will automatically"
234 " come to the front.");
235 autoRaise
->setWhatsThis( wtstr
);
237 clickRaiseOn
->setWhatsThis( i18n("When this option is enabled, the active window will be brought to the"
238 " front when you click somewhere into the window contents. To change"
239 " it for inactive windows, you need to change the settings"
240 " in the Actions tab.") );
242 delayFocusOn
->setWhatsThis( i18n("When this option is enabled, there will be a delay after which the"
243 " window the mouse pointer is over will become active (receive focus).") );
244 delayFocus
->setWhatsThis( i18n("This is the delay after which the window the mouse pointer is over"
245 " will automatically receive focus.") );
247 separateScreenFocus
= new QCheckBox( i18n( "S&eparate screen focus" ), fcsBox
);
248 gLay
->addWidget(separateScreenFocus
, 5, 0, 1, 3);
249 wtstr
= i18n( "When this option is enabled, focus operations are limited only to the active Xinerama screen" );
250 separateScreenFocus
->setWhatsThis( wtstr
);
252 activeMouseScreen
= new QCheckBox( i18n( "Active screen follows &mouse" ), fcsBox
);
253 gLay
->addWidget(activeMouseScreen
, 6, 0, 1, 3);
254 wtstr
= i18n( "When this option is enabled, the active Xinerama screen (where new windows appear, for example)"
255 " is the screen containing the mouse pointer. When disabled, the active Xinerama screen is the "
256 " screen containing the focused window. By default this option is disabled for Click to focus and"
257 " enabled for other focus policies." );
258 activeMouseScreen
->setWhatsThis( wtstr
);
259 connect(focusCombo
, SIGNAL(activated(int)), this, SLOT(updateActiveMouseScreen()));
261 if (Kephal::ScreenUtils::numScreens() == 1) // No Ximerama
263 separateScreenFocus
->hide();
264 activeMouseScreen
->hide();
267 lay
->addWidget(fcsBox
);
273 kbdBox
= new KButtonGroup(this);
274 kbdBox
->setTitle(i18nc("@title:group", "Window Switching"));
275 QVBoxLayout
*kLay
= new QVBoxLayout(kbdBox
);
277 altTabPopup
= new QCheckBox( i18n("Show window list while switching windows"), kbdBox
);
278 kLay
->addWidget( altTabPopup
);
280 wtstr
= i18n("Hold down the Alt key and press the Tab key repeatedly to walk"
281 " through the windows on the current desktop (the Alt+Tab"
282 " combination can be reconfigured).\n\n"
283 "If this checkbox is checked"
284 " a popup widget is shown, displaying the icons of all windows to"
285 " walk through and the title of the currently selected one.\n\n"
286 "Otherwise, the focus is passed to a new window each time Tab"
287 " is pressed, with no popup widget. In addition, the previously"
288 " activated window will be sent to the back in this mode.");
289 altTabPopup
->setWhatsThis( wtstr
);
290 connect(focusCombo
, SIGNAL(activated(int)), this, SLOT(updateAltTabMode()));
291 kLay
->addWidget(altTabPopup
);
293 traverseAll
= new QCheckBox( i18n( "&Traverse windows on all desktops" ), kbdBox
);
294 kLay
->addWidget( traverseAll
);
296 wtstr
= i18n( "Leave this option disabled if you want to limit walking through"
297 " windows to the current desktop." );
298 traverseAll
->setWhatsThis( wtstr
);
299 kLay
->addWidget(traverseAll
);
301 rollOverDesktops
= new QCheckBox( i18n("Desktop navi&gation wraps around"), kbdBox
);
302 kLay
->addWidget(rollOverDesktops
);
304 wtstr
= i18n( "Enable this option if you want keyboard or active desktop border navigation beyond"
305 " the edge of a desktop to take you to the opposite edge of the new desktop." );
306 rollOverDesktops
->setWhatsThis( wtstr
);
307 kLay
->addWidget(rollOverDesktops
);
309 showPopupinfo
= new QCheckBox( i18n("Popup desktop name on desktop &switch"), kbdBox
);
310 kLay
->addWidget(showPopupinfo
);
312 wtstr
= i18n( "Enable this option if you wish to see the current desktop"
313 " name popup whenever the current desktop is changed." );
314 showPopupinfo
->setWhatsThis( wtstr
);
315 kLay
->addWidget(showPopupinfo
);
317 lay
->addWidget(kbdBox
);
321 // Any changes goes to slotChanged()
322 connect(focusCombo
, SIGNAL(activated(int)), SLOT(changed()));
323 connect(autoRaiseOn
,SIGNAL(clicked()), SLOT(changed()));
324 connect(delayFocusOn
, SIGNAL(clicked()), SLOT(changed()));
325 connect(clickRaiseOn
, SIGNAL(clicked()), SLOT(changed()));
326 connect(autoRaise
, SIGNAL(valueChanged(int)), SLOT(changed()));
327 connect(delayFocus
, SIGNAL(valueChanged(int)), SLOT(changed()));
328 connect(separateScreenFocus
, SIGNAL(clicked()), SLOT(changed()));
329 connect(activeMouseScreen
, SIGNAL(clicked()), SLOT(changed()));
330 connect(altTabPopup
, SIGNAL(clicked()), SLOT(changed()));
331 connect(traverseAll
, SIGNAL(clicked()), SLOT(changed()));
332 connect(rollOverDesktops
, SIGNAL(clicked()), SLOT(changed()));
333 connect(showPopupinfo
, SIGNAL(clicked()), SLOT(changed()));
339 int KFocusConfig::getFocus()
341 return focusCombo
->currentIndex();
344 void KFocusConfig::setFocus(int foc
)
346 focusCombo
->setCurrentIndex(foc
);
348 // this will disable/hide the auto raise delay widget if focus==click
349 focusPolicyChanged();
353 void KFocusConfig::updateAltTabMode()
355 // not KDE-style Alt+Tab with unreasonable focus policies
356 altTabPopup
->setEnabled( focusCombo
->currentIndex() == 0 || focusCombo
->currentIndex() == 1 );
359 void KFocusConfig::setAutoRaiseInterval(int tb
)
361 autoRaise
->setValue(tb
);
364 void KFocusConfig::setDelayFocusInterval(int tb
)
366 delayFocus
->setValue(tb
);
369 int KFocusConfig::getAutoRaiseInterval()
371 return autoRaise
->value();
374 int KFocusConfig::getDelayFocusInterval()
376 return delayFocus
->value();
379 void KFocusConfig::setAutoRaise(bool on
)
381 autoRaiseOn
->setChecked(on
);
384 void KFocusConfig::setDelayFocus(bool on
)
386 delayFocusOn
->setChecked(on
);
389 void KFocusConfig::setClickRaise(bool on
)
391 clickRaiseOn
->setChecked(on
);
394 void KFocusConfig::focusPolicyChanged()
396 int policyIndex
=focusCombo
->currentIndex();
398 // the auto raise related widgets are: autoRaise
399 autoRaiseOn
->setEnabled(policyIndex
!= CLICK_TO_FOCUS
);
400 autoRaiseOnLabel
->setEnabled(policyIndex
!= CLICK_TO_FOCUS
);
401 autoRaiseOnTog(policyIndex
!= CLICK_TO_FOCUS
&& autoRaiseOn
->isChecked());
403 focusStealing
->setDisabled(policyIndex
== FOCUS_UNDER_MOUSE
|| policyIndex
== FOCUS_STRICTLY_UNDER_MOUSE
);
407 void KFocusConfig::setDelayFocusEnabled()
409 int policyIndex
=focusCombo
->currentIndex();
411 // the delayed focus related widgets are: delayFocus
412 delayFocusOn
->setEnabled(policyIndex
!= CLICK_TO_FOCUS
);
413 delayFocusOnLabel
->setEnabled(policyIndex
!= CLICK_TO_FOCUS
);
414 delayFocusOnTog(policyIndex
!= CLICK_TO_FOCUS
&& delayFocusOn
->isChecked());
417 void KFocusConfig::autoRaiseOnTog(bool a
) {
418 autoRaise
->setEnabled(a
);
419 clickRaiseOn
->setEnabled( !a
);
422 void KFocusConfig::delayFocusOnTog(bool a
) {
423 delayFocus
->setEnabled(a
);
426 void KFocusConfig::clickRaiseOnTog(bool ) {
429 void KFocusConfig::setFocusStealing(int l
) {
430 l
= qMax( 0, qMin( 4, l
));
431 focusStealing
->setCurrentIndex(l
);
434 void KFocusConfig::setSeparateScreenFocus(bool s
) {
435 separateScreenFocus
->setChecked(s
);
438 void KFocusConfig::setActiveMouseScreen(bool a
) {
439 activeMouseScreen
->setChecked(a
);
442 void KFocusConfig::updateActiveMouseScreen()
444 // on by default for non click to focus policies
445 KConfigGroup
cfg( config
, "Windows" );
446 if( !cfg
.hasKey( KWIN_ACTIVE_MOUSE_SCREEN
))
447 setActiveMouseScreen( focusCombo
->currentIndex() != 0 );
450 void KFocusConfig::setAltTabMode(bool a
) {
451 altTabPopup
->setChecked(a
);
454 void KFocusConfig::setTraverseAll(bool a
) {
455 traverseAll
->setChecked(a
);
458 void KFocusConfig::setRollOverDesktops(bool a
) {
459 rollOverDesktops
->setChecked(a
);
462 void KFocusConfig::setShowPopupinfo(bool a
) {
463 showPopupinfo
->setChecked(a
);
466 void KFocusConfig::load( void )
470 KConfigGroup
cg(config
, "Windows");
472 key
= cg
.readEntry(KWIN_FOCUS
);
473 if( key
== "ClickToFocus")
474 setFocus(CLICK_TO_FOCUS
);
475 else if( key
== "FocusFollowsMouse")
476 setFocus(FOCUS_FOLLOWS_MOUSE
);
477 else if(key
== "FocusUnderMouse")
478 setFocus(FOCUS_UNDER_MOUSE
);
479 else if(key
== "FocusStrictlyUnderMouse")
480 setFocus(FOCUS_STRICTLY_UNDER_MOUSE
);
482 int k
= cg
.readEntry(KWIN_AUTORAISE_INTERVAL
,750);
483 setAutoRaiseInterval(k
);
485 k
= cg
.readEntry(KWIN_DELAYFOCUS_INTERVAL
,750);
486 setDelayFocusInterval(k
);
488 setAutoRaise( cg
.readEntry(KWIN_AUTORAISE
, false));
489 setDelayFocus( cg
.readEntry(KWIN_DELAYFOCUS
, false));
490 setClickRaise( cg
.readEntry(KWIN_CLICKRAISE
, true));
491 focusPolicyChanged(); // this will disable/hide the auto raise delay widget if focus==click
492 setDelayFocusEnabled();
494 setSeparateScreenFocus( cg
.readEntry(KWIN_SEPARATE_SCREEN_FOCUS
, false));
495 // on by default for non click to focus policies
496 setActiveMouseScreen( cg
.readEntry(KWIN_ACTIVE_MOUSE_SCREEN
, focusCombo
->currentIndex() != 0 ));
498 key
= cg
.readEntry(KWIN_ALTTABMODE
, "KDE");
499 setAltTabMode(key
== "KDE");
501 setRollOverDesktops( cg
.readEntry(KWIN_ROLL_OVER_DESKTOPS
, true));
503 setShowPopupinfo( config
->group("PopupInfo").readEntry(KWIN_SHOW_POPUP
, false));
505 setTraverseAll( config
->group("TabBox").readEntry(KWIN_TRAVERSE_ALL
, false));
508 // setFocusStealing( cg.readEntry(KWIN_FOCUS_STEALING, 2 ));
509 // TODO default to low for now
510 setFocusStealing( cg
.readEntry(KWIN_FOCUS_STEALING
, 1 ));
512 emit
KCModule::changed(false);
515 void KFocusConfig::save( void )
519 KConfigGroup
cg(config
, "Windows");
522 if (v
== CLICK_TO_FOCUS
)
523 cg
.writeEntry(KWIN_FOCUS
,"ClickToFocus");
524 else if (v
== FOCUS_UNDER_MOUSE
)
525 cg
.writeEntry(KWIN_FOCUS
,"FocusUnderMouse");
526 else if (v
== FOCUS_STRICTLY_UNDER_MOUSE
)
527 cg
.writeEntry(KWIN_FOCUS
,"FocusStrictlyUnderMouse");
529 cg
.writeEntry(KWIN_FOCUS
,"FocusFollowsMouse");
531 v
= getAutoRaiseInterval();
533 cg
.writeEntry(KWIN_AUTORAISE_INTERVAL
,v
);
535 v
= getDelayFocusInterval();
537 cg
.writeEntry(KWIN_DELAYFOCUS_INTERVAL
,v
);
539 cg
.writeEntry(KWIN_AUTORAISE
, autoRaiseOn
->isChecked());
541 cg
.writeEntry(KWIN_DELAYFOCUS
, delayFocusOn
->isChecked());
543 cg
.writeEntry(KWIN_CLICKRAISE
, clickRaiseOn
->isChecked());
545 cg
.writeEntry(KWIN_SEPARATE_SCREEN_FOCUS
, separateScreenFocus
->isChecked());
546 cg
.writeEntry(KWIN_ACTIVE_MOUSE_SCREEN
, activeMouseScreen
->isChecked());
548 if (altTabPopup
->isChecked())
549 cg
.writeEntry(KWIN_ALTTABMODE
, "KDE");
551 cg
.writeEntry(KWIN_ALTTABMODE
, "CDE");
553 cg
.writeEntry( KWIN_ROLL_OVER_DESKTOPS
, rollOverDesktops
->isChecked());
555 config
->group("PopupInfo").writeEntry( KWIN_SHOW_POPUP
, showPopupinfo
->isChecked());
557 config
->group("TabBox").writeEntry( KWIN_TRAVERSE_ALL
, traverseAll
->isChecked());
559 cg
.writeEntry(KWIN_FOCUS_STEALING
, focusStealing
->currentIndex());
565 // Send signal to all kwin instances
566 QDBusMessage message
=
567 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
568 QDBusConnection::sessionBus().send(message
);
570 emit
KCModule::changed(false);
573 void KFocusConfig::defaults()
575 setAutoRaiseInterval(0);
576 setDelayFocusInterval(0);
577 setFocus(CLICK_TO_FOCUS
);
579 setDelayFocus(false);
581 setSeparateScreenFocus( false );
583 // setFocusStealing(2);
584 // TODO default to low for now
587 // on by default for non click to focus policies
588 setActiveMouseScreen( focusCombo
->currentIndex() != 0 );
590 setTraverseAll( false );
591 setRollOverDesktops(true);
592 setShowPopupinfo(false);
593 setDelayFocusEnabled();
594 emit
KCModule::changed(true);
597 KAdvancedConfig::~KAdvancedConfig ()
603 KAdvancedConfig::KAdvancedConfig (bool _standAlone
, KConfig
*_config
, const KComponentData
&inst
, QWidget
*parent
)
604 : KCModule(inst
, parent
), config(_config
), standAlone(_standAlone
)
608 QGridLayout
*lay
= new QGridLayout (this);
610 //iTLabel = new QLabel(i18n(" Allowed overlap:\n"
611 // "(% of desktop space)"),
613 //iTLabel->setAlignment(AlignTop|AlignHCenter);
614 //pLay->addWidget(iTLabel,1,1);
616 //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
617 //pLay->addWidget(interactiveTrigger,1,2);
619 //pLay->addRowSpacing(2,KDialog::spacingHint());
621 //lay->addWidget(plcBox);
623 shBox
= new KButtonGroup(this);
624 shBox
->setTitle(i18n("Shading"));
625 QGridLayout
*kLay
= new QGridLayout(shBox
);
627 shadeHoverOn
= new QCheckBox(i18n("&Enable hover"), shBox
);
629 connect(shadeHoverOn
, SIGNAL(toggled(bool)), this, SLOT(shadeHoverChanged(bool)));
630 kLay
->addWidget(shadeHoverOn
, 0, 0, 1, 2);
632 shadeHover
= new KIntNumInput(500, shBox
);
633 shadeHover
->setRange(0, 3000, 100);
634 shadeHover
->setSteps(100, 100);
635 shadeHover
->setSuffix(i18n(" ms"));
637 shadeHoverOn
->setWhatsThis( i18n("If Shade Hover is enabled, a shaded window will un-shade automatically "
638 "when the mouse pointer has been over the title bar for some time."));
640 wtstr
= i18n("Sets the time in milliseconds before the window unshades "
641 "when the mouse pointer goes over the shaded window.");
642 shadeHover
->setWhatsThis( wtstr
);
643 shadeHover
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
644 shadeHoverLabel
= new QLabel(i18n("Dela&y:"), this);
645 shadeHoverLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
646 shadeHoverLabel
->setBuddy(shadeHover
);
647 kLay
->addWidget(shadeHoverLabel
, 1, 0);
648 kLay
->addWidget(shadeHover
, 1, 1);
650 kLay
->setRowStretch(2, 1);
651 lay
->addWidget(shBox
, 0, 0);
653 // Any changes goes to slotChanged()
654 connect(shadeHoverOn
, SIGNAL(toggled(bool)), SLOT(changed()));
655 connect(shadeHover
, SIGNAL(valueChanged(int)), SLOT(changed()));
657 electricBox
= new KButtonGroup(this);
658 electricBox
->setTitle(i18n("Active Desktop Borders"));
659 QGridLayout
*bLay
= new QGridLayout(electricBox
);
661 electricBox
->setWhatsThis( i18n("If this option is enabled, moving the mouse to a screen border"
662 " will change your desktop. This is e.g. useful if you want to drag windows from one desktop"
664 active_disable
= new QRadioButton(i18n("D&isabled"), electricBox
);
665 bLay
->addWidget(active_disable
, 0, 0, 1, 2);
666 active_move
= new QRadioButton(i18n("Only &when moving windows"), electricBox
);
667 bLay
->addWidget(active_move
, 1, 0, 1, 2);
668 active_always
= new QRadioButton(i18n("A&lways enabled"), electricBox
);
669 bLay
->addWidget(active_always
, 2, 0, 1, 2);
671 delays
= new KIntNumInput(10, electricBox
);
672 delays
->setRange(0, MAX_EDGE_RES
, 50);
673 delays
->setSuffix(i18n(" ms"));
674 delays
->setWhatsThis( i18n("Here you can set a delay for switching desktops using the active"
675 " borders feature. Desktops will be switched after the mouse has been pushed against a screen border"
676 " for the specified number of milliseconds.") );
677 delays
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
678 delaysLabel
= new QLabel(i18n("Desktop &switch delay:"), this);
679 delaysLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
680 delaysLabel
->setBuddy(delays
);
681 bLay
->addWidget(delaysLabel
, 3, 0);
682 bLay
->addWidget(delays
, 3, 1);
684 connect( electricBox
, SIGNAL(clicked(int)), this, SLOT(setEBorders()));
686 // Any changes goes to slotChanged()
687 connect(electricBox
, SIGNAL(clicked(int)), SLOT(changed()));
688 connect(delays
, SIGNAL(valueChanged(int)), SLOT(changed()));
690 lay
->addWidget(electricBox
, 0, 1);
693 QGridLayout
*vLay
= new QGridLayout();
694 lay
->addLayout( vLay
, 1, 0, 1, 2 );
696 placementCombo
= new QComboBox(this);
697 placementCombo
->setEditable( false );
698 placementCombo
->addItem(i18n("Smart"), SMART_PLACEMENT
);
699 placementCombo
->addItem(i18n("Maximizing"), MAXIMIZING_PLACEMENT
);
700 placementCombo
->addItem(i18n("Cascade"), CASCADE_PLACEMENT
);
701 placementCombo
->addItem(i18n("Random"), RANDOM_PLACEMENT
);
702 placementCombo
->addItem(i18n("Centered"), CENTERED_PLACEMENT
);
703 placementCombo
->addItem(i18n("Zero-Cornered"), ZEROCORNERED_PLACEMENT
);
704 // CT: disabling is needed as long as functionality misses in kwin
705 //placementCombo->addItem(i18n("Interactive"), INTERACTIVE_PLACEMENT);
706 //placementCombo->addItem(i18n("Manual"), MANUAL_PLACEMENT);
707 placementCombo
->setCurrentIndex(SMART_PLACEMENT
);
709 // FIXME, when more policies have been added to KWin
710 wtstr
= i18n("The placement policy determines where a new window"
711 " will appear on the desktop."
713 " <li><em>Smart</em> will try to achieve a minimum overlap of windows</li>"
714 " <li><em>Maximizing</em> will try to maximize every window to fill the whole screen."
715 " It might be useful to selectively affect placement of some windows using"
716 " the window-specific settings.</li>"
717 " <li><em>Cascade</em> will cascade the windows</li>"
718 " <li><em>Random</em> will use a random position</li>"
719 " <li><em>Centered</em> will place the window centered</li>"
720 " <li><em>Zero-Cornered</em> will place the window in the top-left corner</li>"
723 placementCombo
->setWhatsThis( wtstr
);
725 placementCombo
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
726 label
= new QLabel(i18n("&Placement:"), this);
727 label
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
728 label
->setBuddy(placementCombo
);
729 vLay
->addWidget(label
, 0, 0);
730 vLay
->addWidget(placementCombo
, 0, 1);
732 connect( placementCombo
, SIGNAL(activated(int)), SLOT(changed()));
734 hideUtilityWindowsForInactive
= new QCheckBox( i18n( "Hide utility windows for inactive applications" ), this );
735 hideUtilityWindowsForInactive
->setWhatsThis(
736 i18n( "When turned on, utility windows (tool windows, torn-off menus,...) of inactive applications will be"
737 " hidden and will be shown only when the application becomes active. Note that applications"
738 " have to mark the windows with the proper window type for this feature to work." ));
739 connect(hideUtilityWindowsForInactive
, SIGNAL(toggled(bool)), SLOT(changed()));
740 vLay
->addWidget( hideUtilityWindowsForInactive
, 1, 0, 1, 2 );
743 lay
->setRowStretch(2, 1);
748 void KAdvancedConfig::setShadeHover(bool on
) {
749 shadeHoverOn
->setChecked(on
);
750 shadeHoverLabel
->setEnabled(on
);
751 shadeHover
->setEnabled(on
);
754 void KAdvancedConfig::setShadeHoverInterval(int k
) {
755 shadeHover
->setValue(k
);
758 int KAdvancedConfig::getShadeHoverInterval() {
760 return shadeHover
->value();
763 void KAdvancedConfig::shadeHoverChanged(bool a
) {
764 shadeHoverLabel
->setEnabled(a
);
765 shadeHover
->setEnabled(a
);
769 void KAdvancedConfig::load( void )
771 KConfigGroup
cg(config
, "Windows");
773 setShadeHover(cg
.readEntry(KWIN_SHADEHOVER
, false));
774 setShadeHoverInterval(cg
.readEntry(KWIN_SHADEHOVER_INTERVAL
, 250));
776 setElectricBorders(cg
.readEntry(KWM_ELECTRIC_BORDER
, 0));
777 setElectricBorderDelay(cg
.readEntry(KWM_ELECTRIC_BORDER_DELAY
, 150));
780 // placement policy --- CT 19jan98 ---
781 key
= cg
.readEntry(KWIN_PLACEMENT
);
782 //CT 13mar98 interactive placement
783 // if( key.left(11) == "interactive") {
784 // setPlacement(INTERACTIVE_PLACEMENT);
785 // int comma_pos = key.find(',');
786 // if (comma_pos < 0)
787 // interactiveTrigger->setValue(0);
789 // interactiveTrigger->setValue (key.right(key.length()
790 // - comma_pos).toUInt(0));
791 // iTLabel->setEnabled(true);
792 // interactiveTrigger->show();
795 // interactiveTrigger->setValue(0);
796 // iTLabel->setEnabled(false);
797 // interactiveTrigger->hide();
799 setPlacement(RANDOM_PLACEMENT
);
800 else if( key
== "Cascade")
801 setPlacement(CASCADE_PLACEMENT
); //CT 31jan98
802 //CT 31mar98 manual placement
803 else if( key
== "manual")
804 setPlacement(MANUAL_PLACEMENT
);
805 else if( key
== "Centered")
806 setPlacement(CENTERED_PLACEMENT
);
807 else if( key
== "ZeroCornered")
808 setPlacement(ZEROCORNERED_PLACEMENT
);
809 else if( key
== "Maximizing")
810 setPlacement(MAXIMIZING_PLACEMENT
);
812 setPlacement(SMART_PLACEMENT
);
815 setHideUtilityWindowsForInactive( cg
.readEntry( KWIN_HIDE_UTILITY
, true));
817 emit
KCModule::changed(false);
820 void KAdvancedConfig::save( void )
824 KConfigGroup
cg(config
, "Windows");
825 cg
.writeEntry(KWIN_SHADEHOVER
, shadeHoverOn
->isChecked());
827 v
= getShadeHoverInterval();
829 cg
.writeEntry(KWIN_SHADEHOVER_INTERVAL
, v
);
831 cg
.writeEntry(KWM_ELECTRIC_BORDER
, getElectricBorders());
832 cg
.writeEntry(KWM_ELECTRIC_BORDER_DELAY
,getElectricBorderDelay());
834 // placement policy --- CT 31jan98 ---
836 if (v
== RANDOM_PLACEMENT
)
837 cg
.writeEntry(KWIN_PLACEMENT
, "Random");
838 else if (v
== CASCADE_PLACEMENT
)
839 cg
.writeEntry(KWIN_PLACEMENT
, "Cascade");
840 else if (v
== CENTERED_PLACEMENT
)
841 cg
.writeEntry(KWIN_PLACEMENT
, "Centered");
842 else if (v
== ZEROCORNERED_PLACEMENT
)
843 cg
.writeEntry(KWIN_PLACEMENT
, "ZeroCornered");
844 else if (v
== MAXIMIZING_PLACEMENT
)
845 cg
.writeEntry(KWIN_PLACEMENT
, "Maximizing");
846 //CT 13mar98 manual and interactive placement
847 // else if (v == MANUAL_PLACEMENT)
848 // cg.writeEntry(KWIN_PLACEMENT, "Manual");
849 // else if (v == INTERACTIVE_PLACEMENT) {
850 // QString tmpstr = QString("Interactive,%1").arg(interactiveTrigger->value());
851 // cg.writeEntry(KWIN_PLACEMENT, tmpstr);
854 cg
.writeEntry(KWIN_PLACEMENT
, "Smart");
856 cg
.writeEntry(KWIN_HIDE_UTILITY
, hideUtilityWindowsForInactive
->isChecked());
861 // Send signal to all kwin instances
862 QDBusMessage message
=
863 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
864 QDBusConnection::sessionBus().send(message
);
867 emit
KCModule::changed(false);
870 void KAdvancedConfig::defaults()
872 setShadeHover(false);
873 setShadeHoverInterval(250);
874 setElectricBorders(0);
875 setElectricBorderDelay(150);
876 setPlacement(SMART_PLACEMENT
);
877 setHideUtilityWindowsForInactive( true );
878 emit
KCModule::changed(true);
881 // placement policy --- CT 31jan98 ---
882 int KAdvancedConfig::getPlacement()
884 return placementCombo
->currentIndex();
887 void KAdvancedConfig::setPlacement(int plac
)
889 placementCombo
->setCurrentIndex(plac
);
893 void KAdvancedConfig::setEBorders()
895 delaysLabel
->setEnabled(!active_disable
->isChecked());
896 delays
->setEnabled(!active_disable
->isChecked());
899 int KAdvancedConfig::getElectricBorders()
901 if (active_move
->isChecked())
903 if (active_always
->isChecked())
908 int KAdvancedConfig::getElectricBorderDelay()
910 return delays
->value();
913 void KAdvancedConfig::setElectricBorders(int i
){
916 case 1: active_move
->setChecked(true); break;
917 case 2: active_always
->setChecked(true); break;
918 default: active_disable
->setChecked(true); break;
923 void KAdvancedConfig::setElectricBorderDelay(int delay
)
925 delays
->setValue(delay
);
928 void KAdvancedConfig::setHideUtilityWindowsForInactive(bool s
) {
929 hideUtilityWindowsForInactive
->setChecked( s
);
932 KMovingConfig::~KMovingConfig ()
938 KMovingConfig::KMovingConfig (bool _standAlone
, KConfig
*_config
, const KComponentData
&inst
, QWidget
*parent
)
939 : KCModule(inst
, parent
), config(_config
), standAlone(_standAlone
)
942 QBoxLayout
*lay
= new QVBoxLayout (this);
944 windowsBox
= new KButtonGroup(this);
945 windowsBox
->setTitle(i18n("Windows"));
947 QBoxLayout
*wLay
= new QVBoxLayout (windowsBox
);
949 QBoxLayout
*bLay
= new QVBoxLayout
;
950 wLay
->addLayout(bLay
);
952 opaque
= new QCheckBox(i18n("Di&splay content in moving windows"), windowsBox
);
953 bLay
->addWidget(opaque
);
954 opaque
->setWhatsThis( i18n("Enable this option if you want a window's content to be fully shown"
955 " while moving it, instead of just showing a window 'skeleton'. The result may not be satisfying"
956 " on slow machines without graphic acceleration.") );
958 resizeOpaqueOn
= new QCheckBox(i18n("Display content in &resizing windows"), windowsBox
);
959 bLay
->addWidget(resizeOpaqueOn
);
960 resizeOpaqueOn
->setWhatsThis( i18n("Enable this option if you want a window's content to be shown"
961 " while resizing it, instead of just showing a window 'skeleton'. The result may not be satisfying"
962 " on slow machines.") );
964 geometryTipOn
= new QCheckBox(i18n("Display window &geometry when moving or resizing"), windowsBox
);
965 bLay
->addWidget(geometryTipOn
);
966 geometryTipOn
->setWhatsThis( i18n("Enable this option if you want a window's geometry to be displayed"
967 " while it is being moved or resized. The window position relative"
968 " to the top-left corner of the screen is displayed together with"
971 QGridLayout
*rLay
= new QGridLayout();
972 bLay
->addLayout(rLay
);
973 rLay
->setColumnStretch(0,0);
974 rLay
->setColumnStretch(1,1);
976 moveResizeMaximized
= new QCheckBox( i18n("Allow moving and resizing o&f maximized windows"), windowsBox
);
977 bLay
->addWidget(moveResizeMaximized
);
978 moveResizeMaximized
->setWhatsThis( i18n("When enabled, this feature activates the border of maximized windows"
979 " and allows you to move or resize them,"
980 " just like for normal windows"));
983 bLay
->addSpacing(10);
985 lay
->addWidget(windowsBox
);
987 //iTLabel = new QLabel(i18n(" Allowed overlap:\n"
988 // "(% of desktop space)"),
990 //iTLabel->setAlignment(AlignTop|AlignHCenter);
991 //pLay->addWidget(iTLabel,1,1);
993 //interactiveTrigger = new QSpinBox(0, 500, 1, plcBox);
994 //pLay->addWidget(interactiveTrigger,1,2);
996 //pLay->addRowSpacing(2,KDialog::spacingHint());
998 //lay->addWidget(plcBox);
1004 //CT 15mar98 - add EdgeResistance, BorderAttractor, WindowsAttractor config
1005 MagicBox
= new KButtonGroup(this);
1006 MagicBox
->setTitle(i18n("Snap Zones"));
1007 QGridLayout
*kLay
= new QGridLayout(MagicBox
);
1009 BrdrSnap
= new KIntNumInput(10, MagicBox
);
1010 BrdrSnap
->setSpecialValueText( i18n("none") );
1011 BrdrSnap
->setRange( 0, MAX_BRDR_SNAP
);
1012 BrdrSnap
->setSteps(1,10);
1013 BrdrSnap
->setWhatsThis( i18n("Here you can set the snap zone for screen borders, i.e."
1014 " the 'strength' of the magnetic field which will make windows snap to the border when"
1015 " moved near it.") );
1016 BrdrSnap
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
1017 BrdrSnapLabel
= new QLabel(i18n("&Border snap zone:"), this);
1018 BrdrSnapLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
1019 BrdrSnapLabel
->setBuddy(BrdrSnap
);
1020 kLay
->addWidget(BrdrSnapLabel
, 0, 0);
1021 kLay
->addWidget(BrdrSnap
, 0, 1);
1023 WndwSnap
= new KIntNumInput(10, MagicBox
);
1024 WndwSnap
->setSpecialValueText( i18n("none") );
1025 WndwSnap
->setRange( 0, MAX_WNDW_SNAP
);
1026 WndwSnap
->setSteps(1,10);
1027 WndwSnap
->setWhatsThis( i18n("Here you can set the snap zone for windows, i.e."
1028 " the 'strength' of the magnetic field which will make windows snap to each other when"
1029 " they are moved near another window.") );
1030 BrdrSnap
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
1031 WndwSnapLabel
= new QLabel(i18n("&Window snap zone:"), this);
1032 WndwSnapLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
1033 WndwSnapLabel
->setBuddy(WndwSnap
);
1034 kLay
->addWidget(WndwSnapLabel
, 1, 0);
1035 kLay
->addWidget(WndwSnap
, 1, 1);
1037 CntrSnap
= new KIntNumInput(10, MagicBox
);
1038 CntrSnap
->setSpecialValueText( i18n("none") );
1039 CntrSnap
->setRange( 0, MAX_CNTR_SNAP
);
1040 CntrSnap
->setSteps(1,10);
1041 CntrSnap
->setWhatsThis( i18n("Here you can set the snap zone for the screen center, i.e."
1042 " the 'strength' of the magnetic field which will make windows snap to the center of"
1043 " the screen when moved near it.") );
1044 BrdrSnap
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Fixed
);
1045 CntrSnapLabel
= new QLabel(i18n("&Center snap zone:"), this);
1046 CntrSnapLabel
->setAlignment(Qt::AlignVCenter
|Qt::AlignRight
);
1047 CntrSnapLabel
->setBuddy(CntrSnap
);
1048 kLay
->addWidget(CntrSnapLabel
, 2, 0);
1049 kLay
->addWidget(CntrSnap
, 2, 1);
1051 OverlapSnap
=new QCheckBox(i18n("Snap windows onl&y when overlapping"),MagicBox
);
1052 OverlapSnap
->setWhatsThis( i18n("Here you can set that windows will be only"
1053 " snapped if you try to overlap them, i.e. they will not be snapped if the windows"
1054 " comes only near another window or border.") );
1055 kLay
->addWidget(OverlapSnap
, 3, 0, 1, 2);
1057 lay
->addWidget(MagicBox
);
1062 // Any changes goes to slotChanged()
1063 connect( opaque
, SIGNAL(clicked()), SLOT(changed()));
1064 connect( resizeOpaqueOn
, SIGNAL(clicked()), SLOT(changed()));
1065 connect( geometryTipOn
, SIGNAL(clicked()), SLOT(changed()));
1066 connect( moveResizeMaximized
, SIGNAL(toggled(bool)), SLOT(changed()));
1067 connect( BrdrSnap
, SIGNAL(valueChanged(int)), SLOT(changed()));
1068 connect( BrdrSnap
, SIGNAL(valueChanged(int)), SLOT(slotBrdrSnapChanged(int)));
1069 connect( WndwSnap
, SIGNAL(valueChanged(int)), SLOT(changed()));
1070 connect( WndwSnap
, SIGNAL(valueChanged(int)), SLOT(slotWndwSnapChanged(int)));
1071 connect( CntrSnap
, SIGNAL(valueChanged(int)), SLOT(changed()));
1072 connect( CntrSnap
, SIGNAL(valueChanged(int)), SLOT(slotCntrSnapChanged(int)));
1073 connect( OverlapSnap
, SIGNAL(clicked()), SLOT(changed()));
1075 // To get suffix to BrdrSnap, WndwSnap and CntrSnap inputs with default values.
1076 slotBrdrSnapChanged(BrdrSnap
->value());
1077 slotWndwSnapChanged(WndwSnap
->value());
1078 slotCntrSnapChanged(CntrSnap
->value());
1081 int KMovingConfig::getMove()
1083 return (opaque
->isChecked())? OPAQUE
: TRANSPARENT
;
1086 void KMovingConfig::setMove(int trans
)
1088 opaque
->setChecked(trans
== OPAQUE
);
1091 void KMovingConfig::setGeometryTip(bool showGeometryTip
)
1093 geometryTipOn
->setChecked(showGeometryTip
);
1096 bool KMovingConfig::getGeometryTip()
1098 return geometryTipOn
->isChecked();
1101 int KMovingConfig::getResizeOpaque()
1103 return (resizeOpaqueOn
->isChecked())? RESIZE_OPAQUE
: RESIZE_TRANSPARENT
;
1106 void KMovingConfig::setResizeOpaque(int opaque
)
1108 resizeOpaqueOn
->setChecked(opaque
== RESIZE_OPAQUE
);
1111 void KMovingConfig::setMoveResizeMaximized(bool a
) {
1112 moveResizeMaximized
->setChecked(a
);
1115 void KMovingConfig::slotBrdrSnapChanged(int value
) {
1116 BrdrSnap
->setSuffix(i18np(" pixel", " pixels", value
));
1119 void KMovingConfig::slotWndwSnapChanged(int value
) {
1120 WndwSnap
->setSuffix(i18np(" pixel", " pixels", value
));
1123 void KMovingConfig::slotCntrSnapChanged(int value
) {
1124 CntrSnap
->setSuffix(i18np(" pixel", " pixels", value
));
1127 void KMovingConfig::load( void )
1131 KConfigGroup
cg(config
, "Windows");
1133 key
= cg
.readEntry(KWIN_MOVE
, "Opaque");
1134 if( key
== "Transparent")
1135 setMove(TRANSPARENT
);
1136 else if( key
== "Opaque")
1139 // DF: please keep the default consistent with kwin (options.cpp line 145)
1140 key
= cg
.readEntry(KWIN_RESIZE_OPAQUE
, "Opaque");
1141 if( key
== "Opaque")
1142 setResizeOpaque(RESIZE_OPAQUE
);
1143 else if ( key
== "Transparent")
1144 setResizeOpaque(RESIZE_TRANSPARENT
);
1146 //KS 10Jan2003 - Geometry Tip during window move/resize
1147 bool showGeomTip
= cg
.readEntry(KWIN_GEOMETRY
, false);
1148 setGeometryTip( showGeomTip
);
1151 setMoveResizeMaximized(cg
.readEntry(KWIN_MOVE_RESIZE_MAXIMIZED
, false));
1155 v
= cg
.readEntry(KWM_BRDR_SNAP_ZONE
, KWM_BRDR_SNAP_ZONE_DEFAULT
);
1156 if (v
> MAX_BRDR_SNAP
) setBorderSnapZone(MAX_BRDR_SNAP
);
1157 else if (v
< 0) setBorderSnapZone (0);
1158 else setBorderSnapZone(v
);
1160 v
= cg
.readEntry(KWM_WNDW_SNAP_ZONE
, KWM_WNDW_SNAP_ZONE_DEFAULT
);
1161 if (v
> MAX_WNDW_SNAP
) setWindowSnapZone(MAX_WNDW_SNAP
);
1162 else if (v
< 0) setWindowSnapZone (0);
1163 else setWindowSnapZone(v
);
1165 v
= cg
.readEntry(KWM_CNTR_SNAP_ZONE
, KWM_CNTR_SNAP_ZONE_DEFAULT
);
1166 if (v
> MAX_CNTR_SNAP
) setCenterSnapZone(MAX_CNTR_SNAP
);
1167 else if (v
< 0) setCenterSnapZone (0);
1168 else setCenterSnapZone(v
);
1170 OverlapSnap
->setChecked(cg
.readEntry("SnapOnlyWhenOverlapping", false));
1171 emit
KCModule::changed(false);
1174 void KMovingConfig::save( void )
1178 KConfigGroup
cg(config
, "Windows");
1181 if (v
== TRANSPARENT
)
1182 cg
.writeEntry(KWIN_MOVE
,"Transparent");
1184 cg
.writeEntry(KWIN_MOVE
,"Opaque");
1186 cg
.writeEntry(KWIN_GEOMETRY
, getGeometryTip());
1188 v
= getResizeOpaque();
1189 if (v
== RESIZE_OPAQUE
)
1190 cg
.writeEntry(KWIN_RESIZE_OPAQUE
, "Opaque");
1192 cg
.writeEntry(KWIN_RESIZE_OPAQUE
, "Transparent");
1194 cg
.writeEntry(KWIN_MOVE_RESIZE_MAXIMIZED
, moveResizeMaximized
->isChecked());
1197 cg
.writeEntry(KWM_BRDR_SNAP_ZONE
,getBorderSnapZone());
1198 cg
.writeEntry(KWM_WNDW_SNAP_ZONE
,getWindowSnapZone());
1199 cg
.writeEntry(KWM_CNTR_SNAP_ZONE
,getCenterSnapZone());
1200 cg
.writeEntry("SnapOnlyWhenOverlapping",OverlapSnap
->isChecked());
1205 // Send signal to all kwin instances
1206 QDBusMessage message
=
1207 QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
1208 QDBusConnection::sessionBus().send(message
);
1210 emit
KCModule::changed(false);
1213 void KMovingConfig::defaults()
1216 setResizeOpaque(RESIZE_TRANSPARENT
);
1217 setGeometryTip(false);
1218 setMoveResizeMaximized(false);
1220 //copied from kcontrol/konq/kwindesktop, aleXXX
1221 setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT
);
1222 setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT
);
1223 setCenterSnapZone(KWM_CNTR_SNAP_ZONE_DEFAULT
);
1224 OverlapSnap
->setChecked(false);
1226 emit
KCModule::changed(true);
1229 int KMovingConfig::getBorderSnapZone() {
1230 return BrdrSnap
->value();
1233 void KMovingConfig::setBorderSnapZone(int pxls
) {
1234 BrdrSnap
->setValue(pxls
);
1237 int KMovingConfig::getWindowSnapZone() {
1238 return WndwSnap
->value();
1241 void KMovingConfig::setWindowSnapZone(int pxls
) {
1242 WndwSnap
->setValue(pxls
);
1245 int KMovingConfig::getCenterSnapZone() {
1246 return CntrSnap
->value();
1249 void KMovingConfig::setCenterSnapZone(int pxls
) {
1250 CntrSnap
->setValue(pxls
);
1253 #include "windows.moc"