Commit 5ba3793c authored by Nate Graham's avatar Nate Graham 💤
Browse files

[kcmkwin/kwinoptions] Add option to disable window position memory for KDE apps

This adds a setting to the window options KCM to disable KDE apps
remembering their own window positions on X11, and instead always use
the KWin placement modes.

The setting sets an option in `kdeglobals`, rather than kwinrc, as it is not
a KWin-specific option *per se*. The UI is also hidden on Wayland, as it it
not relevant there because the functionality it disables does not work on
Wayland. Instead, remembering window positions will eventually be implemented
in a different way and affect all windows, not just KDE windows.

See frameworks/kxmlgui!14 for
more details.

CCBUG: 415150
parent 4e481d0e
......@@ -18,6 +18,7 @@ ki18n_wrap_ui(kcm_kwinoptions_PART_SRCS
)
kconfig_add_kcfg_files(kcm_kwinoptions_PART_SRCS kwinoptions_settings.kcfgc GENERATE_MOC)
kconfig_add_kcfg_files(kcm_kwinoptions_PART_SRCS kwinoptions_kdeglobals_settings.kcfgc GENERATE_MOC)
qt5_add_dbus_interface(kcm_kwinoptions_PART_SRCS ${KWin_SOURCE_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface)
add_library(kcm_kwinoptions MODULE ${kcm_kwinoptions_PART_SRCS})
......
......@@ -112,7 +112,17 @@
</item>
</widget>
</item>
<item row="2" column="0">
<item row="2" column="1">
<widget class="QCheckBox" name="kcfg_AllowKDEAppsToRememberWindowPositions">
<property name="whatsThis">
<string>When turned on, KDE apps which are able to remember the positions of their windows are allowed to do so. This will override the window placement mode defined above.</string>
</property>
<property name="text">
<string>Allow KDE apps to remember the positions of their own windows</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="specialWindowsLabel">
<property name="text">
<string>&amp;Special windows:</string>
......@@ -122,7 +132,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QCheckBox" name="kcfg_HideUtilityWindowsForInactive">
<property name="whatsThis">
<string>When turned on, utility windows (tool windows, torn-off menus,...) of inactive applications will be hidden and will be shown only when the application becomes active. Note that applications have to mark the windows with the proper window type for this feature to work.</string>
......
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kdeglobals"/>
<group name="General">
<entry name="AllowKDEAppsToRememberWindowPositions" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>
File=kwinoptions_kdeglobals_settings.kcfg
ClassName=KWinOptionsKDEGlobalsSettings
IncludeFiles=options.h
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
......@@ -21,6 +21,7 @@
#include "mouse.h"
#include "windows.h"
#include "kwinoptions_settings.h"
#include "kwinoptions_kdeglobals_settings.h"
K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory)
......@@ -51,9 +52,9 @@ class KAdvancedConfigStandalone : public KAdvancedConfig
Q_OBJECT
public:
KAdvancedConfigStandalone(QWidget* parent, const QVariantList &)
: KAdvancedConfig(true, nullptr, parent)
: KAdvancedConfig(true, nullptr, nullptr, parent)
{
initialize(new KWinOptionsSettings(this));
initialize(new KWinOptionsSettings(this), new KWinOptionsKDEGlobalsSettings(this));
}
};
......@@ -99,7 +100,7 @@ KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
connect(mMoving, qOverload<bool>(&KCModule::defaulted), this, qOverload<bool>(&KCModule::defaulted));
connect(this, &KCModule::defaultsIndicatorsVisibleChanged, mMoving, &KCModule::setDefaultsIndicatorsVisible);
mAdvanced = new KAdvancedConfig(false, mSettings, this);
mAdvanced = new KAdvancedConfig(false, mSettings, new KWinOptionsKDEGlobalsSettings(this), this);
mAdvanced->setObjectName(QLatin1String("KWin Advanced"));
tab->addTab(mAdvanced, i18n("Adva&nced"));
connect(mAdvanced, qOverload<bool>(&KCModule::changed), this, qOverload<bool>(&KCModule::changed));
......
......@@ -17,6 +17,7 @@
#include <kcmodule.h>
class KWinOptionsSettings;
class KWinOptionsKDEGlobalsSettings;
class KFocusConfig;
class KTitleBarActionsConfig;
class KWindowActionsConfig;
......
......@@ -21,6 +21,7 @@
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KWindowSystem>
#include "windows.h"
#include "kwinoptions_settings.h"
......@@ -28,6 +29,7 @@
#include <kwin_effects_interface.h>
#include "kwinoptions_settings.h"
#include "kwinoptions_kdeglobals_settings.h"
#include <KConfigDialogManager>
#define CLICK_TO_FOCUS 0
......@@ -213,19 +215,20 @@ KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent)
setupUi(parent);
}
KAdvancedConfig::KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent)
KAdvancedConfig::KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, KWinOptionsKDEGlobalsSettings *globalSettings, QWidget *parent)
: KCModule(parent), standAlone(_standAlone)
, m_ui(new KWinAdvancedConfigForm(this))
{
if (settings) {
initialize(settings);
if (settings && globalSettings) {
initialize(settings, globalSettings);
}
}
void KAdvancedConfig::initialize(KWinOptionsSettings *settings)
void KAdvancedConfig::initialize(KWinOptionsSettings *settings, KWinOptionsKDEGlobalsSettings *globalSettings)
{
m_settings = settings;
addConfig(m_settings, this);
addConfig(globalSettings, this);
m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Smart, "Smart");
m_ui->kcfg_Placement->setItemData(KWinOptionsSettings::PlacementChoices::Maximizing, "Maximizing");
......@@ -234,6 +237,14 @@ void KAdvancedConfig::initialize(KWinOptionsSettings *settings)
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");
// 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());
load();
}
......
......@@ -30,6 +30,7 @@ class QSpinBox;
class KColorButton;
class KWinOptionsSettings;
class KWinOptionsKDEGlobalsSettings;
class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm
{
......@@ -107,12 +108,12 @@ class KAdvancedConfig : public KCModule
{
Q_OBJECT
public:
KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent);
KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, KWinOptionsKDEGlobalsSettings *globalSettings, QWidget *parent);
void save() override;
protected:
void initialize(KWinOptionsSettings *settings);
void initialize(KWinOptionsSettings *settings, KWinOptionsKDEGlobalsSettings *globalSettings);
void showEvent(QShowEvent *ev) override;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment