2007-04-29 17:35:43 +00:00
/*
2020-08-02 22:22:19 +00:00
windows . cpp
2020-08-02 22:32:38 +00:00
SPDX - FileCopyrightText : 1997 Patrick Dowler < dowler @ morgul . fsh . uvic . ca >
SPDX - FileCopyrightText : 2001 Waldo Bastian < bastian @ kde . org >
2020-08-02 22:22:19 +00:00
SPDX - License - Identifier : GPL - 2.0 - or - later
*/
2007-04-29 17:35:43 +00:00
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>
2018-06-05 10:52:57 +00:00
# include <QtDBus>
2013-12-12 21:37:09 +00:00
# include <QGroupBox>
2020-03-30 07:54:09 +00:00
# include <QScreen>
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>
2020-08-28 16:43:51 +00:00
# include <KWindowSystem>
2007-04-29 17:35:43 +00:00
# include "windows.h"
2020-02-05 10:46:29 +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
2020-03-30 07:54:09 +00:00
# include "kwinoptions_settings.h"
2020-08-28 16:43:51 +00:00
# include "kwinoptions_kdeglobals_settings.h"
2020-03-30 07:54:09 +00:00
# include <KConfigDialogManager>
2013-04-13 18:07:08 +00:00
2020-03-30 07:54:09 +00:00
# define CLICK_TO_FOCUS 0
# define CLICK_TO_FOCUS_MOUSE_PRECEDENT 1
# define FOCUS_FOLLOWS_MOUSE 2
# define FOCUS_FOLLOWS_MOUSE_PRECEDENT 3
# define FOCUS_UNDER_MOUSE 4
# define FOCUS_STRICTLY_UNDER_MOUSE 5
2007-04-29 17:35:43 +00:00
2020-08-04 08:11:27 +00:00
namespace
{
constexpr int defaultFocusPolicyIndex = CLICK_TO_FOCUS ;
}
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
}
2020-03-30 07:54:09 +00:00
KFocusConfig : : KFocusConfig ( bool _standAlone , KWinOptionsSettings * settings , QWidget * parent )
: KCModule ( parent ) , standAlone ( _standAlone )
2012-09-22 10:10:07 +00:00
, m_ui ( new KWinFocusConfigForm ( this ) )
2007-04-29 17:35:43 +00:00
{
2020-06-18 10:03:04 +00:00
if ( settings ) {
initialize ( settings ) ;
}
}
void KFocusConfig : : initialize ( KWinOptionsSettings * settings )
{
m_settings = settings ;
2020-03-30 07:54:09 +00:00
addConfig ( m_settings , this ) ;
connect ( m_ui - > windowFocusPolicy , qOverload < int > ( & QComboBox : : currentIndexChanged ) , this , & KFocusConfig : : focusPolicyChanged ) ;
2020-08-04 08:11:27 +00:00
connect ( m_ui - > windowFocusPolicy , qOverload < int > ( & QComboBox : : currentIndexChanged ) , this , & KFocusConfig : : updateDefaultIndicator ) ;
connect ( this , SIGNAL ( defaultsIndicatorsVisibleChanged ( bool ) ) , this , SLOT ( updateDefaultIndicator ( ) ) ) ;
2020-03-30 07:54:09 +00:00
connect ( qApp , & QGuiApplication : : screenAdded , this , & KFocusConfig : : updateMultiScreen ) ;
connect ( qApp , & QGuiApplication : : screenRemoved , this , & KFocusConfig : : updateMultiScreen ) ;
2013-04-13 18:07:08 +00:00
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 ) ;
2020-03-30 07:54:09 +00:00
m_ui - > kcfg_ActiveMouseScreen - > setVisible ( QApplication : : screens ( ) . count ( ) > 1 ) ;
m_ui - > kcfg_SeparateScreenFocus - > setVisible ( QApplication : : screens ( ) . count ( ) > 1 ) ;
2007-04-29 17:35:43 +00:00
}
2020-08-04 08:11:27 +00:00
void KFocusConfig : : updateDefaultIndicator ( )
{
const bool isDefault = m_ui - > windowFocusPolicy - > currentIndex ( ) = = defaultFocusPolicyIndex ;
m_ui - > windowFocusPolicy - > setProperty ( " _kde_highlight_neutral " , defaultsIndicatorsVisible ( ) & & ! isDefault ) ;
m_ui - > windowFocusPolicy - > update ( ) ;
}
2008-09-07 21:08:26 +00:00
void KFocusConfig : : focusPolicyChanged ( )
2007-04-29 17:35:43 +00:00
{
2020-03-30 07:54:09 +00:00
int selectedFocusPolicy = 0 ;
bool selectedNextFocusPrefersMouseItem = false ;
const bool loadedNextFocusPrefersMouseItem = m_settings - > nextFocusPrefersMouse ( ) ;
int focusPolicy = m_ui - > windowFocusPolicy - > currentIndex ( ) ;
switch ( focusPolicy ) {
case CLICK_TO_FOCUS :
2020-02-01 16:52:33 +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. " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : ClickToFocus ;
[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 ;
2020-03-30 07:54:09 +00:00
case CLICK_TO_FOCUS_MOUSE_PRECEDENT :
2020-02-01 16:52:33 +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>. " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : ClickToFocus ;
selectedNextFocusPrefersMouseItem = true ;
[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 ;
2020-03-30 07:54:09 +00:00
case FOCUS_FOLLOWS_MOUSE :
2020-02-01 16:52:33 +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. " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : FocusFollowsMouse ;
[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 ;
2020-03-30 07:54:09 +00:00
case FOCUS_FOLLOWS_MOUSE_PRECEDENT :
2020-02-01 16:52:33 +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. " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : FocusFollowsMouse ;
selectedNextFocusPrefersMouseItem = true ;
[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 ;
2020-03-30 07:54:09 +00:00
case FOCUS_UNDER_MOUSE :
2020-02-01 16:52:33 +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! " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : FocusUnderMouse ;
[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 ;
2020-03-30 07:54:09 +00:00
case FOCUS_STRICTLY_UNDER_MOUSE :
2020-02-01 16:52:33 +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! " ) ) ;
2020-03-30 07:54:09 +00:00
selectedFocusPolicy = KWinOptionsSettings : : EnumFocusPolicy : : FocusStrictlyUnderMouse ;
[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 ;
}
2020-03-30 07:54:09 +00:00
const bool changed = m_settings - > focusPolicy ( ) ! = selectedFocusPolicy | | loadedNextFocusPrefersMouseItem ! = selectedNextFocusPrefersMouseItem ;
unmanagedWidgetChangeState ( changed ) ;
emit unmanagedWidgetStateChanged ( changed ) ;
2008-09-07 21:08:26 +00:00
2020-08-04 08:11:27 +00:00
const bool isDefault = focusPolicy = = defaultFocusPolicyIndex ;
2020-03-30 07:54:09 +00:00
unmanagedWidgetDefaultState ( isDefault ) ;
emit unmanagedWidgetDefaulted ( isDefault ) ;
2011-08-22 11:53:03 +00:00
2020-03-30 07:54:09 +00:00
// the auto raise related widgets are: autoRaise
m_ui - > kcfg_AutoRaise - > setEnabled ( focusPolicy ! = CLICK_TO_FOCUS & & focusPolicy ! = CLICK_TO_FOCUS_MOUSE_PRECEDENT ) ;
2007-04-29 17:35:43 +00:00
2020-03-30 07:54:09 +00:00
m_ui - > kcfg_FocusStealingPreventionLevel - > setDisabled ( focusPolicy = = FOCUS_UNDER_MOUSE | | focusPolicy = = FOCUS_STRICTLY_UNDER_MOUSE ) ;
2008-09-07 21:08:26 +00:00
2007-04-29 17:35:43 +00:00
// the delayed focus related widgets are: delayFocus
2020-03-30 07:54:09 +00:00
m_ui - > delayFocusOnLabel - > setEnabled ( focusPolicy ! = CLICK_TO_FOCUS ) ;
m_ui - > kcfg_DelayFocusInterval - > setEnabled ( focusPolicy ! = CLICK_TO_FOCUS ) ;
2007-04-29 17:35:43 +00:00
2007-05-09 12:34:55 +00:00
// on by default for non click to focus policies
2020-03-30 07:54:09 +00:00
if ( m_settings - > activeMouseScreen ( ) = = m_settings - > defaultActiveMouseScreenValue ( ) ) {
m_ui - > kcfg_ActiveMouseScreen - > setChecked ( focusPolicy ! = CLICK_TO_FOCUS & & focusPolicy ! = CLICK_TO_FOCUS_MOUSE_PRECEDENT ) ;
}
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
{
2020-03-30 07:54:09 +00:00
KCModule : : load ( ) ;
2007-04-29 17:35:43 +00:00
2020-03-30 07:54:09 +00:00
const bool loadedNextFocusPrefersMouseItem = m_settings - > nextFocusPrefersMouse ( ) ;
2007-04-29 17:35:43 +00:00
2020-03-30 07:54:09 +00:00
int focusPolicy = m_settings - > focusPolicy ( ) ;
2007-04-29 17:35:43 +00:00
2020-03-30 07:54:09 +00:00
switch ( focusPolicy ) {
// the ClickToFocus and FocusFollowsMouse have special values when
// NextFocusPrefersMouse is true
case KWinOptionsSettings : : EnumFocusPolicy : : ClickToFocus :
m_ui - > windowFocusPolicy - > setCurrentIndex ( CLICK_TO_FOCUS + loadedNextFocusPrefersMouseItem ) ;
break ;
case KWinOptionsSettings : : EnumFocusPolicy : : FocusFollowsMouse :
m_ui - > windowFocusPolicy - > setCurrentIndex ( FOCUS_FOLLOWS_MOUSE + loadedNextFocusPrefersMouseItem ) ;
break ;
default :
// +2 to ignore the two special values
m_ui - > windowFocusPolicy - > setCurrentIndex ( focusPolicy + 2 ) ;
break ;
}
2007-04-29 17:35:43 +00:00
}
2011-01-30 14:34:42 +00:00
void KFocusConfig : : save ( void )
2007-04-29 17:35:43 +00:00
{
2020-03-30 07:54:09 +00:00
KCModule : : save ( ) ;
2008-09-07 21:08:26 +00:00
2020-03-30 07:54:09 +00:00
int idxFocusPolicy = m_ui - > windowFocusPolicy - > currentIndex ( ) ;
switch ( idxFocusPolicy ) {
case CLICK_TO_FOCUS :
case CLICK_TO_FOCUS_MOUSE_PRECEDENT :
m_settings - > setFocusPolicy ( KWinOptionsSettings : : EnumFocusPolicy : : ClickToFocus ) ;
break ;
case FOCUS_FOLLOWS_MOUSE :
case FOCUS_FOLLOWS_MOUSE_PRECEDENT :
// the ClickToFocus and FocusFollowsMouse have special values when
// NextFocusPrefersMouse is true
m_settings - > setFocusPolicy ( KWinOptionsSettings : : EnumFocusPolicy : : FocusFollowsMouse ) ;
break ;
case FOCUS_UNDER_MOUSE :
m_settings - > setFocusPolicy ( KWinOptionsSettings : : EnumFocusPolicy : : FocusUnderMouse ) ;
break ;
case FOCUS_STRICTLY_UNDER_MOUSE :
m_settings - > setFocusPolicy ( KWinOptionsSettings : : EnumFocusPolicy : : FocusStrictlyUnderMouse ) ;
break ;
}
m_settings - > setNextFocusPrefersMouse ( idxFocusPolicy = = CLICK_TO_FOCUS_MOUSE_PRECEDENT | | idxFocusPolicy = = FOCUS_FOLLOWS_MOUSE_PRECEDENT ) ;
2011-08-22 11:53:03 +00:00
2020-03-30 07:54:09 +00:00
m_settings - > save ( ) ;
2008-09-07 21:08:26 +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-29 17:35:43 +00:00
}
emit KCModule : : changed ( false ) ;
}
void KFocusConfig : : defaults ( )
{
2020-03-30 07:54:09 +00:00
KCModule : : defaults ( ) ;
2020-08-04 08:11:27 +00:00
m_ui - > windowFocusPolicy - > setCurrentIndex ( defaultFocusPolicyIndex ) ;
2007-04-29 17:35:43 +00:00
}
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
}
2020-08-28 16:43:51 +00:00
KAdvancedConfig : : KAdvancedConfig ( bool _standAlone , KWinOptionsSettings * settings , KWinOptionsKDEGlobalsSettings * globalSettings , QWidget * parent )
2020-03-30 07:54:09 +00:00
: KCModule ( parent ) , standAlone ( _standAlone )
2012-09-24 03:57:52 +00:00
, m_ui ( new KWinAdvancedConfigForm ( this ) )
{
2020-08-28 16:43:51 +00:00
if ( settings & & globalSettings ) {
initialize ( settings , globalSettings ) ;
2020-06-18 10:03:04 +00:00
}
}
2020-08-28 16:43:51 +00:00
void KAdvancedConfig : : initialize ( KWinOptionsSettings * settings , KWinOptionsKDEGlobalsSettings * globalSettings )
2020-06-18 10:03:04 +00:00
{
m_settings = settings ;
2020-03-30 07:54:09 +00:00
addConfig ( m_settings , this ) ;
2020-08-28 16:43:51 +00:00
addConfig ( globalSettings , this ) ;
2007-04-29 17:35:43 +00:00
2020-02-05 15:32:01 +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 " ) ;
2020-08-28 16:43:51 +00:00
// Don't show the option to prevent KDE apps from remembering their window
// positions on Wayland because it doesn't work on Wayland and the feature
// will eventually be implemented in a different way there.
// This option lives in the kdeglobals file because it is consumed by
// kxmlgui.
m_ui - > kcfg_AllowKDEAppsToRememberWindowPositions - > setVisible ( KWindowSystem : : isPlatformX11 ( ) ) ;
2020-02-05 15:32:01 +00:00
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-05 15:32:01 +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
}
2020-03-30 07:54:09 +00:00
KMovingConfig : : KMovingConfig ( bool _standAlone , KWinOptionsSettings * settings , QWidget * parent )
2020-06-18 10:03:04 +00:00
: KCModule ( parent ) , standAlone ( _standAlone )
2012-09-24 03:24:31 +00:00
, m_ui ( new KWinMovingConfigForm ( this ) )
2007-04-29 17:35:43 +00:00
{
2020-06-18 10:03:04 +00:00
if ( settings ) {
initialize ( settings ) ;
}
}
void KMovingConfig : : initialize ( KWinOptionsSettings * settings )
{
m_settings = settings ;
addConfig ( m_settings , 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-03-30 07:54:09 +00:00
KCModule : : 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-06-18 10:03:04 +00:00
if ( m_settings - > 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
}