2007-04-29 17:35:43 +00:00
/*
* windows . cpp
*
* Copyright ( c ) 1997 Patrick Dowler dowler @ morgul . fsh . uvic . ca
* Copyright ( c ) 2001 Waldo Bastian bastian @ kde . org
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*
*/
2008-05-12 12:13:52 +00:00
# include <QApplication>
2007-04-29 17:35:43 +00:00
# include <QCheckBox>
# include <QRadioButton>
# include <QLabel>
2009-10-30 08:10:35 +00:00
# include <KComboBox>
2007-04-29 17:35:43 +00:00
# include <QHBoxLayout>
2008-08-25 02:22:56 +00:00
# include <QFormLayout>
2013-02-26 08:00:51 +00:00
# include <QDesktopWidget>
2018-06-05 10:52:57 +00:00
# include <QtDBus>
2013-12-12 21:37:09 +00:00
# include <QGroupBox>
2007-04-29 17:35:43 +00:00
2014-03-17 15:24:10 +00:00
# include <KConfig>
2014-03-18 06:34:33 +00:00
# include <KConfigGroup>
2014-03-17 15:24:10 +00:00
# include <KLocalizedString>
2007-04-29 17:35:43 +00:00
# include "windows.h"
2015-01-26 10:41:09 +00:00
# include <effect_builtins.h>
# include <kwin_effects_interface.h>
2007-04-29 17:35:43 +00:00
// kwin config keywords
# define KWIN_FOCUS "FocusPolicy"
# define KWIN_PLACEMENT "Placement"
# define KWIN_GEOMETRY "GeometryTip"
# define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval"
# define KWIN_AUTORAISE "AutoRaise"
# define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
# define KWIN_CLICKRAISE "ClickRaise"
# define KWIN_SHADEHOVER "ShadeHover"
# define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval"
# define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
# define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive"
2009-11-17 11:25:03 +00:00
# define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar"
2007-05-09 12:34:55 +00:00
# define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus"
# define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen"
2007-04-29 17:35:43 +00:00
//CT 15mar 98 - magics
# define KWM_BRDR_SNAP_ZONE "BorderSnapZone"
# define KWM_BRDR_SNAP_ZONE_DEFAULT 10
# define KWM_WNDW_SNAP_ZONE "WindowSnapZone"
# define KWM_WNDW_SNAP_ZONE_DEFAULT 10
2008-07-09 15:18:47 +00:00
# define KWM_CNTR_SNAP_ZONE "CenterSnapZone"
# define KWM_CNTR_SNAP_ZONE_DEFAULT 0
2007-04-29 17:35:43 +00:00
# define MAX_BRDR_SNAP 100
# define MAX_WNDW_SNAP 100
2008-07-09 15:18:47 +00:00
# define MAX_CNTR_SNAP 100
2007-04-29 17:35:43 +00:00
# define MAX_EDGE_RES 1000
2013-04-13 18:07:08 +00:00
# define CLICK_TO_FOCUS 0
# define FOCUS_FOLLOWS_MOUSE 2
# define FOCUS_UNDER_MOUSE 4
# define FOCUS_STRICTLY_UNDER_MOUSE 5
2007-04-29 17:35:43 +00:00
2011-01-30 14:34:42 +00:00
KFocusConfig : : ~ KFocusConfig ( )
2007-04-29 17:35:43 +00:00
{
if ( standAlone )
delete config ;
}
2012-09-22 10:10:07 +00:00
KWinFocusConfigForm : : KWinFocusConfigForm ( QWidget * parent )
: QWidget ( parent )
{
2012-10-27 21:11:22 +00:00
setupUi ( parent ) ;
2012-09-22 10:10:07 +00:00
}
2007-04-29 17:35:43 +00:00
// removed the LCD display over the slider - this is not good GUI design :) RNolden 051701
2013-09-30 05:29:38 +00:00
KFocusConfig : : KFocusConfig ( bool _standAlone , KConfig * _config , QWidget * parent )
: KCModule ( parent ) , config ( _config ) , standAlone ( _standAlone )
2012-09-22 10:10:07 +00:00
, m_ui ( new KWinFocusConfigForm ( this ) )
2007-04-29 17:35:43 +00:00
{
2012-09-22 10:10:07 +00:00
connect ( m_ui - > focusStealing , SIGNAL ( activated ( int ) ) , SLOT ( changed ( ) ) ) ;
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
connect ( m_ui - > windowFocusPolicyCombo , SIGNAL ( currentIndexChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > windowFocusPolicyCombo , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( focusPolicyChanged ( ) ) ) ;
connect ( m_ui - > windowFocusPolicyCombo , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( setDelayFocusEnabled ( ) ) ) ;
connect ( m_ui - > windowFocusPolicyCombo , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( updateActiveMouseScreen ( ) ) ) ;
2012-09-22 10:10:07 +00:00
connect ( m_ui - > autoRaiseOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > autoRaiseOn , SIGNAL ( toggled ( bool ) ) , SLOT ( autoRaiseOnTog ( bool ) ) ) ;
connect ( m_ui - > clickRaiseOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > autoRaise , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > delayFocus , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > separateScreenFocus , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > activeMouseScreen , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2013-04-13 18:07:08 +00:00
connect ( QApplication : : desktop ( ) , SIGNAL ( screenCountChanged ( int ) ) , SLOT ( updateMultiScreen ( ) ) ) ;
updateMultiScreen ( ) ;
2007-04-29 17:35:43 +00:00
load ( ) ;
}
2013-04-13 18:07:08 +00:00
void KFocusConfig : : updateMultiScreen ( )
{
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
m_ui - > multiscreenBehaviorLabel - > setVisible ( QApplication : : screens ( ) . count ( ) > 1 ) ;
m_ui - > activeMouseScreen - > setVisible ( QApplication : : screens ( ) . count ( ) > 1 ) ;
m_ui - > separateScreenFocus - > setVisible ( QApplication : : screens ( ) . count ( ) > 1 ) ;
2013-04-13 18:07:08 +00:00
}
2007-04-29 17:35:43 +00:00
int KFocusConfig : : getFocus ( )
{
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
int policy = m_ui - > windowFocusPolicyCombo - > currentIndex ( ) ;
2013-04-13 18:07:08 +00:00
if ( policy = = 1 | | policy = = 3 )
- - policy ; // fix the NextFocusPrefersMouse condition
return policy ;
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setFocus ( int foc )
{
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
m_ui - > windowFocusPolicyCombo - > setCurrentIndex ( foc ) ;
2007-04-29 17:35:43 +00:00
// this will disable/hide the auto raise delay widget if focus==click
2008-09-07 21:08:26 +00:00
focusPolicyChanged ( ) ;
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setAutoRaiseInterval ( int tb )
{
2012-09-22 10:10:07 +00:00
m_ui - > autoRaise - > setValue ( tb ) ;
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setDelayFocusInterval ( int tb )
{
2012-09-22 10:10:07 +00:00
m_ui - > delayFocus - > setValue ( tb ) ;
2007-04-29 17:35:43 +00:00
}
int KFocusConfig : : getAutoRaiseInterval ( )
{
2012-09-22 10:10:07 +00:00
return m_ui - > autoRaise - > value ( ) ;
2007-04-29 17:35:43 +00:00
}
int KFocusConfig : : getDelayFocusInterval ( )
{
2012-09-22 10:10:07 +00:00
return m_ui - > delayFocus - > value ( ) ;
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setAutoRaise ( bool on )
{
2012-09-22 10:10:07 +00:00
m_ui - > autoRaiseOn - > setChecked ( on ) ;
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setClickRaise ( bool on )
{
2012-09-22 10:10:07 +00:00
m_ui - > clickRaiseOn - > setChecked ( on ) ;
2007-04-29 17:35:43 +00:00
}
2008-09-07 21:08:26 +00:00
void KFocusConfig : : focusPolicyChanged ( )
2007-04-29 17:35:43 +00:00
{
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
switch ( m_ui - > windowFocusPolicyCombo - > currentIndex ( ) ) {
case 0 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p><span style= \" font-style:italic; \" >Click to focus:</span> A window becomes active when you click into it. This behavior is common on other operating systems and likely what you want.</p></body></html> " ) ) ;
break ;
case 1 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p><span style= \" font-style:italic; \" >Click to focus (mouse precedence):</span> Mostly the same as <span style= \" font-style:italic; \" >Click to focus</span>. If an active window has to be chosen by the system (eg. because the currently active one was closed) the window under the mouse is the preferred candidate. Unusual, but possible variant of <span style= \" font-style:italic; \" >Click to focus</span>.</p></body></html> " ) ) ;
break ;
case 2 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p><span style= \" font-style:italic; \" >Focus follows mouse:</span> Moving the mouse onto a window will activate it. Eg. windows randomly appearing under the mouse will not gain the focus. <span style= \" font-style:italic; \" >Focus stealing prevention</span> takes place as usual. Think as <span style= \" font-style:italic; \" >Click to focus</span> just without having to actually click.</p></body></html> " ) ) ;
break ;
case 3 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p>This is mostly the same as <span style= \" font-style:italic; \" >Focus follows mouse</span>. If an active window has to be chosen by the system (eg. because the currently active one was closed) the window under the mouse is the preferred candidate. Choose this, if you want a hover controlled focus.</p></body></html> " ) ) ;
break ;
case 4 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p><span style= \" font-style:italic; \" >Focus under mouse:</span> The focus always remains on the window under the mouse.<br/><span style= \" font-weight:600; \" >Warning: </span><span style= \" font-style:italic; \" >Focus stealing prevention</span> and the <span style= \" font-style:italic; \" >tabbox ('Alt+Tab') </span>contradict the activation policy and will not work. You very likely want to use <span style= \" font-style:italic; \" >Focus follows mouse (mouse precedence)</span> instead!</p></body></html> " ) ) ;
break ;
case 5 :
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <html><head/><body><p><span style= \" font-style:italic; \" >Focus strictly under mouse:</span> The focus is always on the window under the mouse (in doubt nowhere) very much like the focus behavior in an unmanaged legacy X11 environment.<br/><span style= \" font-weight:600; \" >Warning: </span><span style= \" font-style:italic; \" >Focus stealing prevention</span> and the <span style= \" font-style:italic; \" >tabbox ('Alt+Tab') </span>contradict the activation policy and will not work. You very likely want to use <span style= \" font-style:italic; \" >Focus follows mouse (mouse precedence)</span> instead!</p></body></html> " ) ) ;
break ;
}
2013-04-13 18:07:08 +00:00
int policyIndex = getFocus ( ) ;
2008-09-07 21:08:26 +00:00
2007-04-29 17:35:43 +00:00
// the auto raise related widgets are: autoRaise
2012-09-22 10:10:07 +00:00
m_ui - > autoRaiseOn - > setEnabled ( policyIndex ! = CLICK_TO_FOCUS ) ;
autoRaiseOnTog ( policyIndex ! = CLICK_TO_FOCUS & & m_ui - > autoRaiseOn - > isChecked ( ) ) ;
2008-09-07 21:08:26 +00:00
2012-09-22 10:10:07 +00:00
m_ui - > focusStealing - > setDisabled ( policyIndex = = FOCUS_UNDER_MOUSE | | policyIndex = = FOCUS_STRICTLY_UNDER_MOUSE ) ;
2013-04-13 18:07:08 +00:00
m_ui - > focusStealingLabel - > setEnabled ( m_ui - > focusStealing - > isEnabled ( ) ) ;
2008-09-07 21:08:26 +00:00
2013-04-13 18:07:08 +00:00
setDelayFocusEnabled ( ) ;
2011-08-22 11:53:03 +00:00
2007-04-29 17:35:43 +00:00
}
void KFocusConfig : : setDelayFocusEnabled ( )
{
2013-04-13 18:07:08 +00:00
int policyIndex = getFocus ( ) ;
2008-09-07 21:08:26 +00:00
2007-04-29 17:35:43 +00:00
// the delayed focus related widgets are: delayFocus
2012-09-22 10:10:07 +00:00
m_ui - > delayFocusOnLabel - > setEnabled ( policyIndex ! = CLICK_TO_FOCUS ) ;
2011-11-28 19:12:58 +00:00
delayFocusOnTog ( policyIndex ! = CLICK_TO_FOCUS ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : autoRaiseOnTog ( bool a )
{
2012-09-22 10:10:07 +00:00
m_ui - > autoRaise - > setEnabled ( a ) ;
m_ui - > clickRaiseOn - > setEnabled ( ! a ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : delayFocusOnTog ( bool a )
{
2012-09-22 10:10:07 +00:00
m_ui - > delayFocus - > setEnabled ( a ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : setFocusStealing ( int l )
{
l = qMax ( 0 , qMin ( 4 , l ) ) ;
2012-09-22 10:10:07 +00:00
m_ui - > focusStealing - > setCurrentIndex ( l ) ;
2008-09-07 21:08:26 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : setSeparateScreenFocus ( bool s )
{
2012-09-22 10:10:07 +00:00
m_ui - > separateScreenFocus - > setChecked ( s ) ;
2007-05-09 12:34:55 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : setActiveMouseScreen ( bool a )
{
2012-09-22 10:10:07 +00:00
m_ui - > activeMouseScreen - > setChecked ( a ) ;
2007-05-09 12:34:55 +00:00
}
void KFocusConfig : : updateActiveMouseScreen ( )
{
// on by default for non click to focus policies
2011-01-30 14:34:42 +00:00
KConfigGroup cfg ( config , " Windows " ) ;
if ( ! cfg . hasKey ( KWIN_ACTIVE_MOUSE_SCREEN ) )
2013-04-13 18:07:08 +00:00
setActiveMouseScreen ( getFocus ( ) ! = 0 ) ;
2007-05-09 12:34:55 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : showEvent ( QShowEvent * ev )
2009-12-14 03:18:43 +00:00
{
2011-01-30 14:34:42 +00:00
if ( ! standAlone ) {
QWidget : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
return ;
}
2011-01-30 14:34:42 +00:00
KCModule : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : load ( void )
2007-04-29 17:35:43 +00:00
{
QString key ;
KConfigGroup cg ( config , " Windows " ) ;
2013-04-13 18:07:08 +00:00
const bool focusNextToMouse = cg . readEntry ( " NextFocusPrefersMouse " , false ) ;
2007-04-29 17:35:43 +00:00
key = cg . readEntry ( KWIN_FOCUS ) ;
2011-01-30 14:34:42 +00:00
if ( key = = " ClickToFocus " )
2013-04-13 18:07:08 +00:00
setFocus ( CLICK_TO_FOCUS + focusNextToMouse ) ;
2011-01-30 14:34:42 +00:00
else if ( key = = " FocusFollowsMouse " )
2013-04-13 18:07:08 +00:00
setFocus ( FOCUS_FOLLOWS_MOUSE + focusNextToMouse ) ;
2011-01-30 14:34:42 +00:00
else if ( key = = " FocusUnderMouse " )
2007-04-29 17:35:43 +00:00
setFocus ( FOCUS_UNDER_MOUSE ) ;
2011-01-30 14:34:42 +00:00
else if ( key = = " FocusStrictlyUnderMouse " )
2007-04-29 17:35:43 +00:00
setFocus ( FOCUS_STRICTLY_UNDER_MOUSE ) ;
2011-01-30 14:34:42 +00:00
int k = cg . readEntry ( KWIN_AUTORAISE_INTERVAL , 750 ) ;
2007-04-29 17:35:43 +00:00
setAutoRaiseInterval ( k ) ;
2013-01-09 08:14:35 +00:00
k = cg . readEntry ( KWIN_DELAYFOCUS_INTERVAL , 300 ) ;
2007-04-29 17:35:43 +00:00
setDelayFocusInterval ( k ) ;
2011-01-30 14:34:42 +00:00
setAutoRaise ( cg . readEntry ( KWIN_AUTORAISE , false ) ) ;
setClickRaise ( cg . readEntry ( KWIN_CLICKRAISE , true ) ) ;
2008-09-07 21:08:26 +00:00
focusPolicyChanged ( ) ; // this will disable/hide the auto raise delay widget if focus==click
2007-09-18 14:44:41 +00:00
2011-01-30 14:34:42 +00:00
setSeparateScreenFocus ( cg . readEntry ( KWIN_SEPARATE_SCREEN_FOCUS , false ) ) ;
2007-05-09 12:34:55 +00:00
// on by default for non click to focus policies
2013-04-13 18:07:08 +00:00
setActiveMouseScreen ( cg . readEntry ( KWIN_ACTIVE_MOUSE_SCREEN , getFocus ( ) ! = 0 ) ) ;
2007-04-29 17:35:43 +00:00
2008-09-07 21:08:26 +00:00
// setFocusStealing( cg.readEntry(KWIN_FOCUS_STEALING, 2 ));
// TODO default to low for now
2011-01-30 14:34:42 +00:00
setFocusStealing ( cg . readEntry ( KWIN_FOCUS_STEALING , 1 ) ) ;
2008-09-07 21:08:26 +00:00
2011-08-22 11:53:03 +00:00
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( false ) ;
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : save ( void )
2007-04-29 17:35:43 +00:00
{
int v ;
KConfigGroup cg ( config , " Windows " ) ;
v = getFocus ( ) ;
if ( v = = CLICK_TO_FOCUS )
2011-01-30 14:34:42 +00:00
cg . writeEntry ( KWIN_FOCUS , " ClickToFocus " ) ;
2007-04-29 17:35:43 +00:00
else if ( v = = FOCUS_UNDER_MOUSE )
2011-01-30 14:34:42 +00:00
cg . writeEntry ( KWIN_FOCUS , " FocusUnderMouse " ) ;
2007-04-29 17:35:43 +00:00
else if ( v = = FOCUS_STRICTLY_UNDER_MOUSE )
2011-01-30 14:34:42 +00:00
cg . writeEntry ( KWIN_FOCUS , " FocusStrictlyUnderMouse " ) ;
2007-04-29 17:35:43 +00:00
else
2011-01-30 14:34:42 +00:00
cg . writeEntry ( KWIN_FOCUS , " FocusFollowsMouse " ) ;
2007-04-29 17:35:43 +00:00
[kcmkwin/options] Improve the look of the KWin options KCM UIs
Summary:
Apply the KDE HIG, use form layouts, make desktop files consistent and make the KCMs look better.
{F7323519}
{F7330485}
{F7330486}
{F7302318}
{F7302319}
Test Plan: Open the {nav Window Behavior} KCMs. All options should still work
Reviewers: #kwin, #plasma, #vdg, ngraham, zzag
Reviewed By: #kwin, #plasma, #vdg, ngraham, zzag
Subscribers: ngraham, davidedmundson, zzag, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10273
Differential Revision: https://phabricator.kde.org/D23615
2019-09-05 17:41:27 +00:00
cg . writeEntry ( " NextFocusPrefersMouse " , v ! = m_ui - > windowFocusPolicyCombo - > currentIndex ( ) ) ;
2013-04-13 18:07:08 +00:00
2007-04-29 17:35:43 +00:00
v = getAutoRaiseInterval ( ) ;
2011-01-30 14:34:42 +00:00
if ( v < 0 ) v = 0 ;
cg . writeEntry ( KWIN_AUTORAISE_INTERVAL , v ) ;
2007-04-29 17:35:43 +00:00
v = getDelayFocusInterval ( ) ;
2011-01-30 14:34:42 +00:00
if ( v < 0 ) v = 0 ;
cg . writeEntry ( KWIN_DELAYFOCUS_INTERVAL , v ) ;
2007-04-29 17:35:43 +00:00
2012-09-22 10:10:07 +00:00
cg . writeEntry ( KWIN_AUTORAISE , m_ui - > autoRaiseOn - > isChecked ( ) ) ;
2007-04-29 17:35:43 +00:00
2012-09-22 10:10:07 +00:00
cg . writeEntry ( KWIN_CLICKRAISE , m_ui - > clickRaiseOn - > isChecked ( ) ) ;
2007-04-29 17:35:43 +00:00
2012-09-22 10:10:07 +00:00
cg . writeEntry ( KWIN_SEPARATE_SCREEN_FOCUS , m_ui - > separateScreenFocus - > isChecked ( ) ) ;
cg . writeEntry ( KWIN_ACTIVE_MOUSE_SCREEN , m_ui - > activeMouseScreen - > isChecked ( ) ) ;
2007-05-09 12:34:55 +00:00
2012-09-22 10:10:07 +00:00
cg . writeEntry ( KWIN_FOCUS_STEALING , m_ui - > focusStealing - > currentIndex ( ) ) ;
2008-09-07 21:08:26 +00:00
2012-09-22 10:10:07 +00:00
cg . writeEntry ( KWIN_SEPARATE_SCREEN_FOCUS , m_ui - > separateScreenFocus - > isChecked ( ) ) ;
cg . writeEntry ( KWIN_ACTIVE_MOUSE_SCREEN , m_ui - > activeMouseScreen - > isChecked ( ) ) ;
2011-08-22 11:53:03 +00:00
2008-09-07 21:08:26 +00:00
2011-01-30 14:34:42 +00:00
if ( standAlone ) {
2007-04-29 17:35:43 +00:00
config - > sync ( ) ;
2011-01-30 14:34:42 +00:00
// Send signal to all kwin instances
QDBusMessage message =
QDBusMessage : : createSignal ( " /KWin " , " org.kde.KWin " , " reloadConfig " ) ;
QDBusConnection : : sessionBus ( ) . send ( message ) ;
2007-04-29 17:35:43 +00:00
}
emit KCModule : : changed ( false ) ;
}
void KFocusConfig : : defaults ( )
{
setAutoRaiseInterval ( 0 ) ;
setDelayFocusInterval ( 0 ) ;
setFocus ( CLICK_TO_FOCUS ) ;
setAutoRaise ( false ) ;
setClickRaise ( true ) ;
2011-01-30 14:34:42 +00:00
setSeparateScreenFocus ( false ) ;
2008-09-07 21:08:26 +00:00
// setFocusStealing(2);
// TODO default to low for now
setFocusStealing ( 1 ) ;
2007-05-09 12:34:55 +00:00
// on by default for non click to focus policies
2013-04-13 18:07:08 +00:00
setActiveMouseScreen ( getFocus ( ) ! = 0 ) ;
2007-10-25 21:12:59 +00:00
setDelayFocusEnabled ( ) ;
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( true ) ;
}
2012-09-24 03:57:52 +00:00
KWinAdvancedConfigForm : : KWinAdvancedConfigForm ( QWidget * parent )
: QWidget ( parent )
{
2012-10-27 21:11:22 +00:00
setupUi ( parent ) ;
2012-09-24 03:57:52 +00:00
}
2011-01-30 14:34:42 +00:00
KAdvancedConfig : : ~ KAdvancedConfig ( )
2007-04-29 17:35:43 +00:00
{
if ( standAlone )
delete config ;
}
2013-09-30 05:29:38 +00:00
KAdvancedConfig : : KAdvancedConfig ( bool _standAlone , KConfig * _config , QWidget * parent )
: KCModule ( parent ) , config ( _config ) , standAlone ( _standAlone )
2012-09-24 03:57:52 +00:00
, m_ui ( new KWinAdvancedConfigForm ( this ) )
{
m_ui - > placementCombo - > setItemData ( 0 , " Smart " ) ;
m_ui - > placementCombo - > setItemData ( 1 , " Maximizing " ) ;
m_ui - > placementCombo - > setItemData ( 2 , " Cascade " ) ;
m_ui - > placementCombo - > setItemData ( 3 , " Random " ) ;
m_ui - > placementCombo - > setItemData ( 4 , " Centered " ) ;
m_ui - > placementCombo - > setItemData ( 5 , " ZeroCornered " ) ;
m_ui - > placementCombo - > setItemData ( 6 , " UnderMouse " ) ;
connect ( m_ui - > shadeHoverOn , SIGNAL ( toggled ( bool ) ) , this , SLOT ( shadeHoverChanged ( bool ) ) ) ;
connect ( m_ui - > shadeHoverOn , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > shadeHover , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > placementCombo , SIGNAL ( activated ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > hideUtilityWindowsForInactive , SIGNAL ( toggled ( bool ) ) , SLOT ( changed ( ) ) ) ;
2007-04-29 17:35:43 +00:00
load ( ) ;
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : setShadeHover ( bool on )
{
2012-09-24 03:57:52 +00:00
m_ui - > shadeHoverOn - > setChecked ( on ) ;
m_ui - > shadeHover - > setEnabled ( on ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : setShadeHoverInterval ( int k )
{
2012-09-24 03:57:52 +00:00
m_ui - > shadeHover - > setValue ( k ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
int KAdvancedConfig : : getShadeHoverInterval ( )
{
2007-04-29 17:35:43 +00:00
2012-09-24 03:57:52 +00:00
return m_ui - > shadeHover - > value ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : shadeHoverChanged ( bool a )
{
2012-09-24 03:57:52 +00:00
m_ui - > shadeHover - > setEnabled ( a ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : showEvent ( QShowEvent * ev )
2009-12-14 03:18:43 +00:00
{
2011-01-30 14:34:42 +00:00
if ( ! standAlone ) {
QWidget : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
return ;
}
2011-01-30 14:34:42 +00:00
KCModule : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : load ( void )
2007-04-29 17:35:43 +00:00
{
KConfigGroup cg ( config , " Windows " ) ;
setShadeHover ( cg . readEntry ( KWIN_SHADEHOVER , false ) ) ;
setShadeHoverInterval ( cg . readEntry ( KWIN_SHADEHOVER_INTERVAL , 250 ) ) ;
2008-09-07 21:08:26 +00:00
QString key ;
key = cg . readEntry ( KWIN_PLACEMENT ) ;
2012-09-24 03:57:52 +00:00
int idx = m_ui - > placementCombo - > findData ( key ) ;
2012-04-17 13:25:53 +00:00
if ( idx < 0 )
2012-09-24 03:57:52 +00:00
idx = m_ui - > placementCombo - > findData ( " Smart " ) ;
m_ui - > placementCombo - > setCurrentIndex ( idx ) ;
2008-09-07 21:08:26 +00:00
2011-01-30 14:34:42 +00:00
setHideUtilityWindowsForInactive ( cg . readEntry ( KWIN_HIDE_UTILITY , true ) ) ;
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( false ) ;
}
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : save ( void )
2007-04-29 17:35:43 +00:00
{
int v ;
KConfigGroup cg ( config , " Windows " ) ;
2012-09-24 03:57:52 +00:00
cg . writeEntry ( KWIN_SHADEHOVER , m_ui - > shadeHoverOn - > isChecked ( ) ) ;
2007-04-29 17:35:43 +00:00
v = getShadeHoverInterval ( ) ;
2011-01-30 14:34:42 +00:00
if ( v < 0 ) v = 0 ;
2007-04-29 17:35:43 +00:00
cg . writeEntry ( KWIN_SHADEHOVER_INTERVAL , v ) ;
2012-09-24 03:57:52 +00:00
cg . writeEntry ( KWIN_PLACEMENT , m_ui - > placementCombo - > itemData ( m_ui - > placementCombo - > currentIndex ( ) ) . toString ( ) ) ;
cg . writeEntry ( KWIN_HIDE_UTILITY , m_ui - > hideUtilityWindowsForInactive - > isChecked ( ) ) ;
2007-04-29 17:35:43 +00:00
2011-01-30 14:34:42 +00:00
if ( standAlone ) {
2007-04-29 17:35:43 +00:00
config - > sync ( ) ;
2011-01-30 14:34:42 +00:00
// Send signal to all kwin instances
QDBusMessage message =
QDBusMessage : : createSignal ( " /KWin " , " org.kde.KWin " , " reloadConfig " ) ;
QDBusConnection : : sessionBus ( ) . send ( message ) ;
2007-04-30 11:32:47 +00:00
2007-04-29 17:35:43 +00:00
}
emit KCModule : : changed ( false ) ;
}
void KAdvancedConfig : : defaults ( )
{
setShadeHover ( false ) ;
setShadeHoverInterval ( 250 ) ;
2012-09-24 03:57:52 +00:00
m_ui - > placementCombo - > setCurrentIndex ( 0 ) ; // default to Smart
2011-01-30 14:34:42 +00:00
setHideUtilityWindowsForInactive ( true ) ;
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( true ) ;
}
2008-09-07 21:08:26 +00:00
2011-01-30 14:34:42 +00:00
void KAdvancedConfig : : setHideUtilityWindowsForInactive ( bool s )
{
2012-09-24 03:57:52 +00:00
m_ui - > hideUtilityWindowsForInactive - > setChecked ( s ) ;
2008-09-07 21:08:26 +00:00
}
2007-04-29 17:35:43 +00:00
2012-09-24 03:24:31 +00:00
KWinMovingConfigForm : : KWinMovingConfigForm ( QWidget * parent )
: QWidget ( parent )
{
2012-10-27 21:11:22 +00:00
setupUi ( parent ) ;
2012-09-24 03:24:31 +00:00
}
2011-01-30 14:34:42 +00:00
KMovingConfig : : ~ KMovingConfig ( )
2007-04-29 17:35:43 +00:00
{
if ( standAlone )
delete config ;
}
2013-09-30 05:29:38 +00:00
KMovingConfig : : KMovingConfig ( bool _standAlone , KConfig * _config , QWidget * parent )
: KCModule ( parent ) , config ( _config ) , standAlone ( _standAlone )
2012-09-24 03:24:31 +00:00
, m_ui ( new KWinMovingConfigForm ( this ) )
2007-04-29 17:35:43 +00:00
{
2012-09-24 03:24:31 +00:00
// Any changes goes to slotChanged()
connect ( m_ui - > geometryTipOn , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > borderSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > windowSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > centerSnap , SIGNAL ( valueChanged ( int ) ) , SLOT ( changed ( ) ) ) ;
connect ( m_ui - > OverlapSnap , SIGNAL ( clicked ( ) ) , SLOT ( changed ( ) ) ) ;
2007-04-29 17:35:43 +00:00
load ( ) ;
}
void KMovingConfig : : setGeometryTip ( bool showGeometryTip )
{
2012-09-24 03:24:31 +00:00
m_ui - > geometryTipOn - > setChecked ( showGeometryTip ) ;
2007-04-29 17:35:43 +00:00
}
bool KMovingConfig : : getGeometryTip ( )
{
2012-09-24 03:24:31 +00:00
return m_ui - > geometryTipOn - > isChecked ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : showEvent ( QShowEvent * ev )
2009-12-14 03:18:43 +00:00
{
2011-01-30 14:34:42 +00:00
if ( ! standAlone ) {
QWidget : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
return ;
}
2011-01-30 14:34:42 +00:00
KCModule : : showEvent ( ev ) ;
2009-12-14 03:18:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : load ( void )
2007-04-29 17:35:43 +00:00
{
QString key ;
KConfigGroup cg ( config , " Windows " ) ;
//KS 10Jan2003 - Geometry Tip during window move/resize
bool showGeomTip = cg . readEntry ( KWIN_GEOMETRY , false ) ;
2011-01-30 14:34:42 +00:00
setGeometryTip ( showGeomTip ) ;
2007-04-29 17:35:43 +00:00
int v ;
v = cg . readEntry ( KWM_BRDR_SNAP_ZONE , KWM_BRDR_SNAP_ZONE_DEFAULT ) ;
if ( v > MAX_BRDR_SNAP ) setBorderSnapZone ( MAX_BRDR_SNAP ) ;
2011-01-30 14:34:42 +00:00
else if ( v < 0 ) setBorderSnapZone ( 0 ) ;
2007-04-29 17:35:43 +00:00
else setBorderSnapZone ( v ) ;
v = cg . readEntry ( KWM_WNDW_SNAP_ZONE , KWM_WNDW_SNAP_ZONE_DEFAULT ) ;
if ( v > MAX_WNDW_SNAP ) setWindowSnapZone ( MAX_WNDW_SNAP ) ;
2011-01-30 14:34:42 +00:00
else if ( v < 0 ) setWindowSnapZone ( 0 ) ;
2007-04-29 17:35:43 +00:00
else setWindowSnapZone ( v ) ;
2008-07-09 15:18:47 +00:00
v = cg . readEntry ( KWM_CNTR_SNAP_ZONE , KWM_CNTR_SNAP_ZONE_DEFAULT ) ;
if ( v > MAX_CNTR_SNAP ) setCenterSnapZone ( MAX_CNTR_SNAP ) ;
2011-01-30 14:34:42 +00:00
else if ( v < 0 ) setCenterSnapZone ( 0 ) ;
2008-07-09 15:18:47 +00:00
else setCenterSnapZone ( v ) ;
2012-09-24 03:24:31 +00:00
m_ui - > OverlapSnap - > setChecked ( cg . readEntry ( " SnapOnlyWhenOverlapping " , false ) ) ;
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( false ) ;
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : save ( void )
2007-04-29 17:35:43 +00:00
{
KConfigGroup cg ( config , " Windows " ) ;
2012-04-14 21:18:21 +00:00
cg . writeEntry ( KWIN_GEOMETRY , getGeometryTip ( ) ) ;
2007-04-29 17:35:43 +00:00
2011-01-30 14:34:42 +00:00
cg . writeEntry ( KWM_BRDR_SNAP_ZONE , getBorderSnapZone ( ) ) ;
cg . writeEntry ( KWM_WNDW_SNAP_ZONE , getWindowSnapZone ( ) ) ;
cg . writeEntry ( KWM_CNTR_SNAP_ZONE , getCenterSnapZone ( ) ) ;
2012-09-24 03:24:31 +00:00
cg . writeEntry ( " SnapOnlyWhenOverlapping " , m_ui - > OverlapSnap - > isChecked ( ) ) ;
2007-04-29 17:35:43 +00:00
2015-01-26 10:41:09 +00:00
const bool geometryTip = getGeometryTip ( ) ;
KConfigGroup ( config , " Plugins " ) . writeEntry ( " windowgeometryEnabled " , geometryTip ) ;
2010-11-10 19:21:56 +00:00
2011-01-30 14:34:42 +00:00
if ( standAlone ) {
2007-04-29 17:35:43 +00:00
config - > sync ( ) ;
2007-04-30 11:32:47 +00:00
// Send signal to all kwin instances
QDBusMessage message =
2011-01-30 14:34:42 +00:00
QDBusMessage : : createSignal ( " /KWin " , " org.kde.KWin " , " reloadConfig " ) ;
2007-04-30 11:32:47 +00:00
QDBusConnection : : sessionBus ( ) . send ( message ) ;
2007-04-29 17:35:43 +00:00
}
2015-01-26 10:41:09 +00:00
// and reconfigure the effect
OrgKdeKwinEffectsInterface interface ( QStringLiteral ( " org.kde.KWin " ) ,
QStringLiteral ( " /Effects " ) ,
QDBusConnection : : sessionBus ( ) ) ;
if ( geometryTip ) {
interface . loadEffect ( KWin : : BuiltInEffects : : nameForEffect ( KWin : : BuiltInEffect : : WindowGeometry ) ) ;
} else {
interface . unloadEffect ( KWin : : BuiltInEffects : : nameForEffect ( KWin : : BuiltInEffect : : WindowGeometry ) ) ;
}
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( false ) ;
}
void KMovingConfig : : defaults ( )
{
setGeometryTip ( false ) ;
//copied from kcontrol/konq/kwindesktop, aleXXX
setWindowSnapZone ( KWM_WNDW_SNAP_ZONE_DEFAULT ) ;
setBorderSnapZone ( KWM_BRDR_SNAP_ZONE_DEFAULT ) ;
2008-07-09 15:18:47 +00:00
setCenterSnapZone ( KWM_CNTR_SNAP_ZONE_DEFAULT ) ;
2012-09-24 03:24:31 +00:00
m_ui - > OverlapSnap - > setChecked ( false ) ;
2007-04-29 17:35:43 +00:00
emit KCModule : : changed ( true ) ;
}
2011-01-30 14:34:42 +00:00
int KMovingConfig : : getBorderSnapZone ( )
{
2012-09-24 03:24:31 +00:00
return m_ui - > borderSnap - > value ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : setBorderSnapZone ( int pxls )
{
2012-09-24 03:24:31 +00:00
m_ui - > borderSnap - > setValue ( pxls ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
int KMovingConfig : : getWindowSnapZone ( )
{
2012-09-24 03:24:31 +00:00
return m_ui - > windowSnap - > value ( ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : setWindowSnapZone ( int pxls )
{
2012-09-24 03:24:31 +00:00
m_ui - > windowSnap - > setValue ( pxls ) ;
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
int KMovingConfig : : getCenterSnapZone ( )
{
2012-09-24 03:24:31 +00:00
return m_ui - > centerSnap - > value ( ) ;
2008-07-09 15:18:47 +00:00
}
2011-01-30 14:34:42 +00:00
void KMovingConfig : : setCenterSnapZone ( int pxls )
{
2012-09-24 03:24:31 +00:00
m_ui - > centerSnap - > setValue ( pxls ) ;
2008-07-09 15:18:47 +00:00
}