From 40a4f4c90bf4c0a5c54640db652afda1286bce6b Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Sat, 28 Oct 2023 13:52:53 -0600 Subject: [PATCH] kcms/options: set focus policy strings on load, not just on change Right now the string is only set when the option is changed to anything else. That's fine, but we need to set it on load too, or else the user will see a placeholder string instead of the real text if they don't change anything. BUG: 456718 FIXED-IN: 6.0 --- src/kcms/options/windows.cpp | 34 ++++++++++++++++++++++++++++------ src/kcms/options/windows.h | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/kcms/options/windows.cpp b/src/kcms/options/windows.cpp index 3096955544..7f91f3c428 100644 --- a/src/kcms/options/windows.cpp +++ b/src/kcms/options/windows.cpp @@ -85,38 +85,59 @@ void KFocusConfig::updateDefaultIndicator() m_ui->windowFocusPolicy->update(); } +void KFocusConfig::updateFocusPolicyExplanatoryText() +{ + const int focusPolicy = m_ui->windowFocusPolicy->currentIndex(); + switch (focusPolicy) { + case CLICK_TO_FOCUS: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus: A window becomes active when you click into it. This behavior is common on other operating systems and likely what you want.")); + break; + case CLICK_TO_FOCUS_MOUSE_PRECEDENT: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus (mouse precedence): Mostly the same as Click to focus. 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 Click to focus.")); + break; + case FOCUS_FOLLOWS_MOUSE: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus follows mouse: Moving the mouse onto a window will activate it. Eg. windows randomly appearing under the mouse will not gain the focus. Focus stealing prevention takes place as usual. Think as Click to focus just without having to actually click.")); + break; + case FOCUS_FOLLOWS_MOUSE_PRECEDENT: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("This is mostly the same as Focus follows mouse. 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.")); + break; + case FOCUS_UNDER_MOUSE: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus under mouse: The focus always remains on the window under the mouse.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); + break; + case FOCUS_STRICTLY_UNDER_MOUSE: + m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus strictly under mouse: 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.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); + break; + } +} + void KFocusConfig::focusPolicyChanged() { int selectedFocusPolicy = 0; bool selectedNextFocusPrefersMouseItem = false; const bool loadedNextFocusPrefersMouseItem = m_settings->nextFocusPrefersMouse(); + updateFocusPolicyExplanatoryText(); + int focusPolicy = m_ui->windowFocusPolicy->currentIndex(); switch (focusPolicy) { case CLICK_TO_FOCUS: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus: A window becomes active when you click into it. This behavior is common on other operating systems and likely what you want.")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::ClickToFocus; break; case CLICK_TO_FOCUS_MOUSE_PRECEDENT: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Click to focus (mouse precedence): Mostly the same as Click to focus. 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 Click to focus.")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::ClickToFocus; selectedNextFocusPrefersMouseItem = true; break; case FOCUS_FOLLOWS_MOUSE: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus follows mouse: Moving the mouse onto a window will activate it. Eg. windows randomly appearing under the mouse will not gain the focus. Focus stealing prevention takes place as usual. Think as Click to focus just without having to actually click.")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse; break; case FOCUS_FOLLOWS_MOUSE_PRECEDENT: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("This is mostly the same as Focus follows mouse. 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.")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusFollowsMouse; selectedNextFocusPrefersMouseItem = true; break; case FOCUS_UNDER_MOUSE: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus under mouse: The focus always remains on the window under the mouse.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusUnderMouse; break; case FOCUS_STRICTLY_UNDER_MOUSE: - m_ui->windowFocusPolicyDescriptionLabel->setText(i18n("Focus strictly under mouse: 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.
Warning: Focus stealing prevention and the tabbox ('Alt+Tab') contradict the activation policy and will not work. You very likely want to use Focus follows mouse (mouse precedence) instead!")); selectedFocusPolicy = KWinOptionsSettings::EnumFocusPolicy::FocusStrictlyUnderMouse; break; } @@ -159,6 +180,7 @@ void KFocusConfig::load(void) m_ui->windowFocusPolicy->setCurrentIndex(focusPolicy + 2); break; } + updateFocusPolicyExplanatoryText(); } void KFocusConfig::save(void) diff --git a/src/kcms/options/windows.h b/src/kcms/options/windows.h index a53d585808..55ba293030 100644 --- a/src/kcms/options/windows.h +++ b/src/kcms/options/windows.h @@ -82,6 +82,8 @@ private: KWinFocusConfigForm *m_ui; KWinOptionsSettings *m_settings; + + void updateFocusPolicyExplanatoryText(); }; class KMovingConfig : public KCModule