# Creating a QML window that doesn't steal mouse focus

**URL:** <https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440>\
**Category:** Development\
**Tags:** kwin, qt, kwin-scripting\
**Created:** [May 31, 2026, 5:08pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440 "2026-05-31T17:08:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![flurry](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/flurry/32/10442_2.png) [@flurry](https://discuss.kde.org/u/flurry)\
**Post date:** [May 31, 2026, 5:08pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/1 "2026-05-31T17:08:54Z")

</div>

I’ve been working on a clone of oneko for KWin, which involves creating an always-on-top QML window. Though, when the window “runs” under the cursor, it steals the mouse input: for example, if I’m scrolling and the cat runs by, scrolling abruptly stops.

These are the WindowFlags I currently have set:

```auto
flags: Qt.X11BypassWindowManagerHint |
    Qt.FramelessWindowHint |
    Qt.WindowTransparentForInput |
    Qt.WindowDoesNotAcceptFocus |
    Qt.WindowStaysOnTopHint

```

I assumed `WindowTransparentForInput` or `WindowDoesNotAcceptFocus`would do the trick, but neither seem to affect how mouse inputs are treated.

Is there something else I need to do, or is this a limitation of KWin (or Qt)? I was wondering if this was a security concern in the vein of clickjacking, but I didn’t find anything in the KWin sources.

---

<div class="post-metadata">

**Author:** ![flurry](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/flurry/32/10442_2.png) [@flurry](https://discuss.kde.org/u/flurry)\
**Post date:** [June 2, 2026, 1:53am UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/2 "2026-06-02T01:53:02Z")

</div>

Aha, I think I figured something out. Unfortunately in working this out, I’ve found this isn’t quite what I need. But curiosity got the better of me, so I hope it helps someone!

In the KWin sources, `InternalWindow::hitTest()` (of which a KWin declarative script is an instance of) checks for one of the following, on top of the standard window hit test:

- If the QWindow mask is set, whether the cursor is outside the given mask\[1\]
- Whether the flag `Qt::WindowTransparentForInput` is set
- Whether the QWindow property `outputOnly` is truthy

If any of those cases are true, the input is ignored and passed to the lower window. And while technically the last one is deprecated and meant for use with org.kde.plasma.core.Dialog, you _can_ use it on any old window:

```auto
import QtQuick

Window {
    id: scriptWindow
    visible: true

    readonly property bool outputOnly: true // This works!

    Rectangle {
        color: "blue"
    }
}

```

That said, I imagine setting `Qt.WindowTransparentForInput` is the more correct way of tackling this. So why doesn’t it seem to work here?

**Edit:** My theory was wrong, it was just an issue of looking at code for the wrong version.

~~I’m not clear on how a `QQuickWindow` becomes an `InternalWindow`, so this is a bit of a wild guess. I’m wondering if the window flags are somehow populated in `InternalWindow::m_handle` after it’s constructed, and since there’s nothing listening for `QWindow::setFlags()`, that state never gets updated. If that’s the case, I’d assume this less feature and more bug. But I haven’t tested that hypothesis yet.~~

* * *

1. This is actually what I want, but I don’t think it can be set via QML. If there’s a workaround, please let me know!

---

<div class="post-metadata">

**Author:** ![jinliu](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/jinliu/32/2414_2.png) [@jinliu](https://discuss.kde.org/u/jinliu)\
**Post date:** [June 2, 2026, 2:42am UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/3 "2026-06-02T02:42:48Z")

</div>

You are doing a KWin script or effect?

---

<div class="post-metadata">

**Author:** ![flurry](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/flurry/32/10442_2.png) [@flurry](https://discuss.kde.org/u/flurry)\
**Post date:** [June 2, 2026, 3:41am UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/4 "2026-06-02T03:41:23Z")

</div>

Oh oops, forgot to mention that! This is for a KWin script.

---

<div class="post-metadata">

**Author:** ![jinliu](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/jinliu/32/2414_2.png) [@jinliu](https://discuss.kde.org/u/jinliu)\
**Post date:** [June 2, 2026, 3:43am UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/5 "2026-06-02T03:43:27Z")

</div>

`WindowTransparentForInput` should work.

Example:

> **[GitHub - jinliu/kwin-effect-overlayclock](https://github.com/jinliu/kwin-effect-overlayclock)**
>
> Contribute to jinliu/kwin-effect-overlayclock development by creating an account on GitHub.

(Ignore the repo name, it’s a script.)

---

<div class="post-metadata">

**Author:** ![flurry](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/flurry/32/10442_2.png) [@flurry](https://discuss.kde.org/u/flurry)\
**Post date:** [June 2, 2026, 3:02pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/6 "2026-06-02T15:02:48Z")

</div>

Interesting! Which KDE version are you on? On 6.6.5, `Qt.WindowTransparentForInput` doesn’t seem to work for me.

---

<div class="post-metadata">

**Author:** ![jinliu](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/jinliu/32/2414_2.png) [@jinliu](https://discuss.kde.org/u/jinliu)\
**Post date:** [June 2, 2026, 3:28pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/7 "2026-06-02T15:28:53Z")

</div>

I’m on 6.7beta2

---

<div class="post-metadata">

**Author:** ![jinliu](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/jinliu/32/2414_2.png) [@jinliu](https://discuss.kde.org/u/jinliu)\
**Post date:** [June 2, 2026, 3:31pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/8 "2026-06-02T15:31:25Z")

</div>

BTW, no problem using outputOnly. Plasma’s own OSD uses it too. You are writing a kwin script, so what’s wrong using a kwin only property.

---

<div class="post-metadata">

**Author:** ![flurry](https://discuss-cdn.kde.org/user_avatar/discuss.kde.org/flurry/32/10442_2.png) [@flurry](https://discuss.kde.org/u/flurry)\
**Post date:** [June 2, 2026, 4:01pm UTC](https://discuss.kde.org/t/creating-a-qml-window-that-doesnt-steal-mouse-focus/47440/9 "2026-06-02T16:01:00Z")

</div>

Oh yep, and there it is (diff between v6.6.5 and v6.6.90). Thank you!

```diff
diff --git a/src/internalwindow.cpp b/src/internalwindow.cpp
index c03d03696b..0b1322aa1b 100644
--- a/src/internalwindow.cpp
+++ b/src/internalwindow.cpp
@@ -76,7 +76,9 @@ bool InternalWindow::hitTest(const QPointF &point) const
     const QRegion mask = m_handle->mask();
     if (!mask.isEmpty() && !mask.contains(mapToLocal(point).toPoint())) {
         return false;
- } else if (m_handle->property("outputOnly").toBool()) {
+ } else if (m_internalWindowFlags.testFlag(Qt::WindowTransparentForInput)) {
+ return false;
+ } else if (m_handle->property("outputOnly").toBool()) { // from Dialog, this is being deprecated in Plasma but still used by lots of kwin scripts
         return false;
     }

```

For why I was avoiding `outputOnly`, this comment from the InternalWindow definition was what made me hesitant:

```cpp
// from Dialog, this is being deprecated in Plasma but still used by lots of kwin scripts

```

I guess the deprecation is new, but I’d rather avoid relying on it if there’s a preferred way to handle it.
