34 , m_settings(new Settings(kwinApp()->config()))
35 , m_focusPolicy(ClickToFocus)
36 , m_nextFocusPrefersMouse(false)
39 , m_autoRaiseInterval(0)
40 , m_delayFocusInterval(0)
42 , m_shadeHoverInterval(0)
43 , m_separateScreenFocus(false)
44 , m_activeMouseScreen(false)
46 , m_activationDesktopPolicy(
Options::defaultActivationDesktopPolicy())
50 , m_snapOnlyWhenOverlapping(false)
51 , m_rollOverDesktops(false)
52 , m_focusStealingPreventionLevel(0)
53 , m_killPingTimeout(0)
54 , m_hideUtilityWindowsForInactive(false)
55 , m_xwaylandCrashPolicy(
Options::defaultXwaylandCrashPolicy())
56 , m_xwaylandMaxCrashCount(
Options::defaultXwaylandMaxCrashCount())
57 , m_xwaylandEavesdrops(
Options::defaultXwaylandEavesdrops())
58 , m_compositingMode(
Options::defaultCompositingMode())
59 , m_useCompositing(
Options::defaultUseCompositing())
60 , m_hiddenPreviews(
Options::defaultHiddenPreviews())
61 , m_glSmoothScale(
Options::defaultGlSmoothScale())
62 , m_glStrictBinding(
Options::defaultGlStrictBinding())
63 , m_glStrictBindingFollowsDriver(
Options::defaultGlStrictBindingFollowsDriver())
64 , m_glPreferBufferSwap(
Options::defaultGlPreferBufferSwap())
65 , m_glPlatformInterface(
Options::defaultGlPlatformInterface())
66 , m_windowsBlockCompositing(true)
67 , OpTitlebarDblClick(
Options::defaultOperationTitlebarDblClick())
68 , CmdActiveTitlebar1(
Options::defaultCommandActiveTitlebar1())
69 , CmdActiveTitlebar2(
Options::defaultCommandActiveTitlebar2())
70 , CmdActiveTitlebar3(
Options::defaultCommandActiveTitlebar3())
71 , CmdInactiveTitlebar1(
Options::defaultCommandInactiveTitlebar1())
72 , CmdInactiveTitlebar2(
Options::defaultCommandInactiveTitlebar2())
73 , CmdInactiveTitlebar3(
Options::defaultCommandInactiveTitlebar3())
74 , CmdTitlebarWheel(
Options::defaultCommandTitlebarWheel())
75 , CmdWindow1(
Options::defaultCommandWindow1())
76 , CmdWindow2(
Options::defaultCommandWindow2())
77 , CmdWindow3(
Options::defaultCommandWindow3())
78 , CmdWindowWheel(
Options::defaultCommandWindowWheel())
79 , CmdAll1(
Options::defaultCommandAll1())
80 , CmdAll2(
Options::defaultCommandAll2())
81 , CmdAll3(
Options::defaultCommandAll3())
82 , CmdAllWheel(
Options::defaultCommandAllWheel())
83 , CmdAllModKey(
Options::defaultKeyCmdAllModKey())
84 , electric_border_maximize(false)
85 , electric_border_tiling(false)
86 , electric_border_corner_ratio(0.0)
87 , borderless_maximized_windows(false)
88 , condensed_title(false)
90 m_settings->setDefaults();
94 m_configWatcher = KConfigWatcher::create(m_settings->sharedConfig());
95 connect(m_configWatcher.data(), &KConfigWatcher::configChanged,
this, [
this](
const KConfigGroup &group,
const QByteArrayList &names) {
96 if (group.name() == QLatin1String(
"KDE") && names.contains(QByteArrayLiteral(
"AnimationDurationFactor"))) {
98 Q_EMIT animationSpeedChanged();
99 }
else if (group.name() == QLatin1String(
"Xwayland")) {
311void Options::setFocusStealingPreventionLevel(
int focusStealingPreventionLevel)
313 if (!focusPolicyIsReasonable()) {
314 focusStealingPreventionLevel = 0;
316 if (m_focusStealingPreventionLevel == focusStealingPreventionLevel) {
319 m_focusStealingPreventionLevel = std::max(0, std::min(4, focusStealingPreventionLevel));
320 Q_EMIT focusStealingPreventionLevelChanged();
636 const QByteArray envOpenGLInterface(qgetenv(
"KWIN_OPENGL_INTERFACE"));
637 if (!envOpenGLInterface.isEmpty()) {
638 if (qstrcmp(envOpenGLInterface,
"egl") == 0) {
639 qCDebug(KWIN_CORE) <<
"Forcing EGL native interface through environment variable";
641 }
else if (qstrcmp(envOpenGLInterface,
"glx") == 0) {
642 qCDebug(KWIN_CORE) <<
"Forcing GLX native interface through environment variable";
648 qCDebug(KWIN_CORE) <<
"Forcing EGL native interface for Wayland mode";
652 qCDebug(KWIN_CORE) <<
"Forcing EGL native interface as compiled without GLX support";
655 if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
656 qCDebug(KWIN_CORE) <<
"Forcing EGL native interface as Qt uses OpenGL ES";
658 }
else if (qstrcmp(qgetenv(
"KWIN_COMPOSE"),
"O2ES") == 0) {
659 qCDebug(KWIN_CORE) <<
"Forcing EGL native interface as OpenGL ES requested through KWIN_COMPOSE environment variable.";
663 if (m_glPlatformInterface == interface) {
666 m_glPlatformInterface = interface;
667 Q_EMIT glPlatformInterfaceChanged();
682void Options::loadConfig()
689 KConfigGroup config(m_settings->config(), QStringLiteral(
"Windows"));
690 OpTitlebarDblClick = windowOperation(config.readEntry(
"TitlebarDoubleClickCommand",
"Maximize"),
true);
691 setOperationMaxButtonLeftClick(windowOperation(config.readEntry(
"MaximizeButtonLeftClickCommand",
"Maximize"),
true));
692 setOperationMaxButtonMiddleClick(windowOperation(config.readEntry(
"MaximizeButtonMiddleClickCommand",
"Maximize (vertical only)"),
true));
693 setOperationMaxButtonRightClick(windowOperation(config.readEntry(
"MaximizeButtonRightClickCommand",
"Maximize (horizontal only)"),
true));
696 config = KConfigGroup(m_settings->config(), QStringLiteral(
"MouseBindings"));
698 CmdTitlebarWheel = mouseWheelCommand(config.readEntry(
"CommandTitlebarWheel",
"Nothing"));
699 CmdAllModKey = (config.readEntry(
"CommandAllKey",
"Meta") == QStringLiteral(
"Meta")) ? Qt::Key_Meta : Qt::Key_Alt;
700 CmdAllWheel = mouseWheelCommand(config.readEntry(
"CommandAllWheel",
"Nothing"));
701 setCommandActiveTitlebar1(mouseCommand(config.readEntry(
"CommandActiveTitlebar1",
"Raise"),
true));
702 setCommandActiveTitlebar2(mouseCommand(config.readEntry(
"CommandActiveTitlebar2",
"Nothing"),
true));
703 setCommandActiveTitlebar3(mouseCommand(config.readEntry(
"CommandActiveTitlebar3",
"Operations menu"),
true));
704 setCommandInactiveTitlebar1(mouseCommand(config.readEntry(
"CommandInactiveTitlebar1",
"Activate and raise"),
true));
705 setCommandInactiveTitlebar2(mouseCommand(config.readEntry(
"CommandInactiveTitlebar2",
"Nothing"),
true));
706 setCommandInactiveTitlebar3(mouseCommand(config.readEntry(
"CommandInactiveTitlebar3",
"Operations menu"),
true));
707 setCommandWindow1(mouseCommand(config.readEntry(
"CommandWindow1",
"Activate, raise and pass click"),
false));
708 setCommandWindow2(mouseCommand(config.readEntry(
"CommandWindow2",
"Activate and pass click"),
false));
709 setCommandWindow3(mouseCommand(config.readEntry(
"CommandWindow3",
"Activate and pass click"),
false));
710 setCommandWindowWheel(mouseCommand(config.readEntry(
"CommandWindowWheel",
"Scroll"),
false));
711 setCommandAll1(mouseCommand(config.readEntry(
"CommandAll1",
"Move"),
false));
712 setCommandAll2(mouseCommand(config.readEntry(
"CommandAll2",
"Toggle raise and lower"),
false));
713 setCommandAll3(mouseCommand(config.readEntry(
"CommandAll3",
"Resize"),
false));
716 config = KConfigGroup(m_settings->config(), QStringLiteral(
"ModifierOnlyShortcuts"));
717 m_modifierOnlyShortcuts.clear();
718 if (config.hasKey(
"Shift")) {
719 m_modifierOnlyShortcuts.insert(Qt::ShiftModifier, config.readEntry(
"Shift", QStringList()));
721 if (config.hasKey(
"Control")) {
722 m_modifierOnlyShortcuts.insert(Qt::ControlModifier, config.readEntry(
"Control", QStringList()));
724 if (config.hasKey(
"Alt")) {
725 m_modifierOnlyShortcuts.insert(Qt::AltModifier, config.readEntry(
"Alt", QStringList()));
727 m_modifierOnlyShortcuts.insert(Qt::MetaModifier, config.readEntry(
"Meta", QStringList{QStringLiteral(
"org.kde.plasmashell"), QStringLiteral(
"/PlasmaShell"), QStringLiteral(
"org.kde.PlasmaShell"), QStringLiteral(
"activateLauncherMenu")}));
730 config = KConfigGroup(m_settings->config(), QStringLiteral(
"Compositing"));
731 bool useCompositing =
false;
733 QString compositingBackend = config.readEntry(
"Backend",
"OpenGL");
734 if (compositingBackend ==
"QPainter") {
740 if (
const char *c = getenv(
"KWIN_COMPOSE")) {
743 qCDebug(KWIN_CORE) <<
"Compositing forced to OpenGL mode by environment variable";
745 useCompositing =
true;
748 qCDebug(KWIN_CORE) <<
"Compositing forced to QPainter mode by environment variable";
750 useCompositing =
true;
753 if (getenv(
"KDE_FAILSAFE")) {
754 qCDebug(KWIN_CORE) <<
"Compositing disabled forcefully by KDE failsafe mode";
756 qCDebug(KWIN_CORE) <<
"Compositing disabled forcefully by environment variable";
761 qCDebug(KWIN_CORE) <<
"Unknown KWIN_COMPOSE mode set, ignoring";
765 setCompositingMode(compositingMode);
766 setUseCompositing(useCompositing || config.readEntry(
"Enabled", Options::defaultUseCompositing()));
768 setGlSmoothScale(std::clamp(config.readEntry(
"GLTextureFilter", Options::defaultGlSmoothScale()), -1, 2));
769 setGlStrictBindingFollowsDriver(!config.hasKey(
"GLStrictBinding"));
770 if (!isGlStrictBindingFollowsDriver()) {
771 setGlStrictBinding(config.readEntry(
"GLStrictBinding", Options::defaultGlStrictBinding()));
775 const QString s = config.readEntry(
"GLPreferBufferSwap", QString(QLatin1Char(Options::defaultGlPreferBufferSwap())));
777 c = s.at(0).toLatin1();
779 if (c !=
'a' && c !=
'c' && c !=
'p' && c !=
'e') {
780 c = Options::defaultGlPreferBufferSwap();
782 setGlPreferBufferSwap(c);
786 int hps = config.readEntry(
"HiddenPreviews", 5);
789 }
else if (hps == 5) {
791 }
else if (hps == 6) {
794 setHiddenPreviews(previews);
799 return QStringLiteral(
"glx");
801 return QStringLiteral(
"egl");
806 auto keyToInterface = [](
const QString &key) {
807 if (key == QStringLiteral(
"glx")) {
809 }
else if (key == QStringLiteral(
"egl")) {
812 return defaultGlPlatformInterface();
814 setGlPlatformInterface(keyToInterface(config.readEntry(
"GLPlatformInterface", interfaceToKey(m_glPlatformInterface))));
885 QString lowerName = name.toLower();
886 if (lowerName == QStringLiteral(
"raise")) {
889 if (lowerName == QStringLiteral(
"lower")) {
892 if (lowerName == QStringLiteral(
"operations menu")) {
893 return MouseOperationsMenu;
895 if (lowerName == QStringLiteral(
"toggle raise and lower")) {
896 return MouseToggleRaiseAndLower;
898 if (lowerName == QStringLiteral(
"activate and raise")) {
899 return MouseActivateAndRaise;
901 if (lowerName == QStringLiteral(
"activate and lower")) {
902 return MouseActivateAndLower;
904 if (lowerName == QStringLiteral(
"activate")) {
905 return MouseActivate;
907 if (lowerName == QStringLiteral(
"activate, raise and pass click")) {
908 return MouseActivateRaiseAndPassClick;
910 if (lowerName == QStringLiteral(
"activate and pass click")) {
911 return MouseActivateAndPassClick;
913 if (lowerName == QStringLiteral(
"scroll")) {
916 if (lowerName == QStringLiteral(
"activate and scroll")) {
917 return MouseActivateAndPassClick;
919 if (lowerName == QStringLiteral(
"activate, raise and scroll")) {
920 return MouseActivateRaiseAndPassClick;
922 if (lowerName == QStringLiteral(
"activate, raise and move")) {
923 return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove;
925 if (lowerName == QStringLiteral(
"move")) {
926 return restricted ? MouseMove : MouseUnrestrictedMove;
928 if (lowerName == QStringLiteral(
"resize")) {
929 return restricted ? MouseResize : MouseUnrestrictedResize;
931 if (lowerName == QStringLiteral(
"shade")) {
934 if (lowerName == QStringLiteral(
"minimize")) {
935 return MouseMinimize;
937 if (lowerName == QStringLiteral(
"close")) {
940 if (lowerName == QStringLiteral(
"increase opacity")) {
941 return MouseOpacityMore;
943 if (lowerName == QStringLiteral(
"decrease opacity")) {
944 return MouseOpacityLess;
946 if (lowerName == QStringLiteral(
"nothing")) {
954 QString lowerName = name.toLower();
955 if (lowerName == QStringLiteral(
"raise/lower")) {
956 return MouseWheelRaiseLower;
958 if (lowerName == QStringLiteral(
"shade/unshade")) {
959 return MouseWheelShadeUnshade;
961 if (lowerName == QStringLiteral(
"maximize/restore")) {
962 return MouseWheelMaximizeRestore;
964 if (lowerName == QStringLiteral(
"above/below")) {
965 return MouseWheelAboveBelow;
967 if (lowerName == QStringLiteral(
"previous/next desktop")) {
968 return MouseWheelPreviousNextDesktop;
970 if (lowerName == QStringLiteral(
"change opacity")) {
971 return MouseWheelChangeOpacity;
973 if (lowerName == QStringLiteral(
"nothing")) {
974 return MouseWheelNothing;
976 return MouseWheelNothing;