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"
2020-02-22 10:52:13 +00:00
# include "kwinoptions_settings.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_AUTORAISE_INTERVAL "AutoRaiseInterval"
# define KWIN_AUTORAISE "AutoRaise"
# define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval"
# define KWIN_CLICKRAISE "ClickRaise"
# define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel"
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
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 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <em>Click to focus:</em> A window becomes active when you click into it. This behavior is common on other operating systems and likely what you want. " ) ) ;
[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
break ;
case 1 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <em>Click to focus (mouse precedence):</em> Mostly the same as <em>Click to focus</em>. 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 <em>Click to focus</em>. " ) ) ;
[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
break ;
case 2 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <em>Focus follows mouse:</em> Moving the mouse onto a window will activate it. Eg. windows randomly appearing under the mouse will not gain the focus. <em>Focus stealing prevention</em> takes place as usual. Think as <em>Click to focus</em> just without having to actually click. " ) ) ;
[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
break ;
case 3 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " This is mostly the same as <em>Focus follows mouse</em>. 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. " ) ) ;
[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
break ;
case 4 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <em>Focus under mouse:</em> The focus always remains on the window under the mouse.<br/><strong>Warning:</strong> <em>Focus stealing prevention</em> and the <em>tabbox ('Alt+Tab')</em> contradict the activation policy and will not work. You very likely want to use <em>Focus follows mouse (mouse precedence)</em> instead! " ) ) ;
[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
break ;
case 5 :
2020-02-22 10:52:13 +00:00
m_ui - > windowFocusPolicyDescriptionLabel - > setText ( i18n ( " <em>Focus strictly under mouse:</em> 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/><strong>Warning:</strong> <em>Focus stealing prevention</em> and the <em>tabbox ('Alt+Tab')</em> contradict the activation policy and will not work. You very likely want to use <em>Focus follows mouse (mouse precedence)</em> instead! " ) ) ;
[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
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
{
}
2020-02-22 10:52:13 +00:00
KAdvancedConfig : : KAdvancedConfig ( bool _standAlone , QWidget * parent )
: KCModule ( parent ) , m_config ( KWinOptionsSettings : : self ( ) ) , standAlone ( _standAlone )
2012-09-24 03:57:52 +00:00
, m_ui ( new KWinAdvancedConfigForm ( this ) )
{
2020-02-22 10:52:13 +00:00
addConfig ( m_config , this ) ;
2020-02-22 10:50:30 +00:00
2020-02-22 10:52:13 +00:00
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : Smart , " Smart " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : Maximizing , " Maximizing " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : Cascade , " Cascade " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : Random , " Random " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : Centered , " Centered " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : ZeroCornered , " ZeroCornered " ) ;
m_ui - > kcfg_Placement - > setItemData ( KWinOptionsSettings : : PlacementChoices : : UnderMouse , " UnderMouse " ) ;
load ( ) ;
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 : : save ( void )
2007-04-29 17:35:43 +00:00
{
2020-02-22 10:52:13 +00:00
KCModule : : save ( ) ;
2007-04-29 17:35:43 +00:00
2011-01-30 14:34:42 +00:00
if ( standAlone ) {
// 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
}
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
{
}
2020-02-22 10:52:13 +00:00
KMovingConfig : : KMovingConfig ( bool _standAlone , QWidget * parent )
: KCModule ( parent ) , m_config ( KWinOptionsSettings : : self ( ) ) , standAlone ( _standAlone )
2012-09-24 03:24:31 +00:00
, m_ui ( new KWinMovingConfigForm ( this ) )
2007-04-29 17:35:43 +00:00
{
2020-02-22 10:52:13 +00:00
addConfig ( m_config , this ) ;
2007-04-29 17:35:43 +00:00
load ( ) ;
}
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 : : save ( void )
2007-04-29 17:35:43 +00:00
{
2020-02-22 10:52:13 +00:00
m_config - > save ( ) ;
2010-11-10 19:21:56 +00:00
2011-01-30 14:34:42 +00:00
if ( standAlone ) {
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 ( ) ) ;
2020-02-22 10:52:13 +00:00
if ( m_config - > geometryTip ( ) ) {
2015-01-26 10:41:09 +00:00
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
}