Add InteractiveWindowMoveEnabled option

We need a way of disabling interactive window moving in Plasma Mobile
(see: https://invent.kde.org/plasma/plasma-mobile/-/issues/340).

This adds a property on the window that lets us toggle interactive
window moving from a config setting.
wilder/Plasma/6.3
Devin Lin 1 year ago
parent ffc6305a78
commit fd8083df22
  1. 3
      src/internalwindow.cpp
  2. 3
      src/kwin.kcfg
  3. 14
      src/options.cpp
  4. 5
      src/options.h
  5. 6
      src/x11window.cpp
  6. 6
      src/xdgshellwindow.cpp

@ -186,6 +186,9 @@ bool InternalWindow::isCloseable() const
bool InternalWindow::isMovable() const
{
if (!options->interactiveWindowMoveEnabled()) {
return false;
}
return !m_internalWindowFlags.testFlag(Qt::BypassWindowManagerHint) && !m_internalWindowFlags.testFlag(Qt::Popup);
}

@ -217,6 +217,9 @@
<entry name="BorderlessMaximizedWindows" type="Bool">
<default>false</default>
</entry>
<entry name="InteractiveWindowMoveEnabled" type="Bool">
<default>true</default>
</entry>
</group>
<group name="EdgeBarrier">
<entry name="CornerBarrier" type="Bool">

@ -640,6 +640,19 @@ void Options::setAllowTearing(bool allow)
}
}
bool Options::interactiveWindowMoveEnabled() const
{
return m_interactiveWindowMoveEnabled;
}
void Options::setInteractiveWindowMoveEnabled(bool set)
{
if (set != m_interactiveWindowMoveEnabled) {
m_interactiveWindowMoveEnabled = set;
Q_EMIT interactiveWindowMoveEnabledChanged();
}
}
void Options::setGlPlatformInterface(OpenGLPlatformInterface interface)
{
// check environment variable
@ -845,6 +858,7 @@ void Options::syncFromKcfgc()
setElectricBorderCornerRatio(m_settings->electricBorderCornerRatio());
setWindowsBlockCompositing(m_settings->windowsBlockCompositing());
setAllowTearing(m_settings->allowTearing());
setInteractiveWindowMoveEnabled(m_settings->interactiveWindowMoveEnabled());
}
// restricted should be true for operations that the user may not be able to repeat

@ -201,6 +201,7 @@ class KWIN_EXPORT Options : public QObject
Q_PROPERTY(KWin::OpenGLPlatformInterface glPlatformInterface READ glPlatformInterface WRITE setGlPlatformInterface NOTIFY glPlatformInterfaceChanged)
Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged)
Q_PROPERTY(bool allowTearing READ allowTearing WRITE setAllowTearing NOTIFY allowTearingChanged)
Q_PROPERTY(bool interactiveWindowMoveEnabled READ interactiveWindowMoveEnabled WRITE setInteractiveWindowMoveEnabled NOTIFY interactiveWindowMoveEnabledChanged)
public:
explicit Options(QObject *parent = nullptr);
~Options() override;
@ -696,6 +697,7 @@ public:
}
bool allowTearing() const;
bool interactiveWindowMoveEnabled() const;
// setters
void setFocusPolicy(FocusPolicy focusPolicy);
@ -755,6 +757,7 @@ public:
void setGlPlatformInterface(OpenGLPlatformInterface interface);
void setWindowsBlockCompositing(bool set);
void setAllowTearing(bool allow);
void setInteractiveWindowMoveEnabled(bool set);
// default values
static WindowOperation defaultOperationTitlebarDblClick()
@ -958,6 +961,7 @@ Q_SIGNALS:
void animationSpeedChanged();
void configChanged();
void allowTearingChanged();
void interactiveWindowMoveEnabledChanged();
private:
void setElectricBorders(int borders);
@ -1031,6 +1035,7 @@ private:
bool condensed_title;
bool m_allowTearing = true;
bool m_interactiveWindowMoveEnabled = true;
MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const;
};

@ -4281,6 +4281,9 @@ bool X11Window::isMovable() const
if (rules()->checkPosition(invalidPoint) != invalidPoint) { // forced position
return false;
}
if (!options->interactiveWindowMoveEnabled()) {
return false;
}
return true;
}
@ -4298,6 +4301,9 @@ bool X11Window::isMovableAcrossScreens() const
if (rules()->checkPosition(invalidPoint) != invalidPoint) { // forced position
return false;
}
if (!options->interactiveWindowMoveEnabled()) {
return false;
}
return true;
}

@ -554,6 +554,9 @@ bool XdgToplevelWindow::isMovable() const
if (rules()->checkPosition(invalidPoint) != invalidPoint) {
return false;
}
if (!options->interactiveWindowMoveEnabled()) {
return false;
}
return true;
}
@ -565,6 +568,9 @@ bool XdgToplevelWindow::isMovableAcrossScreens() const
if (rules()->checkPosition(invalidPoint) != invalidPoint) {
return false;
}
if (!options->interactiveWindowMoveEnabled()) {
return false;
}
return true;
}

Loading…
Cancel
Save