Bug 454569 - window snapping might snap to invisible windows during resize
Summary: window snapping might snap to invisible windows during resize
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: core (other bugs)
Version First Reported In: 5.24.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-29 12:25 UTC by Flupp
Modified: 2022-06-01 17:52 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Flupp 2022-05-29 12:25:08 UTC
When resizing a window with window snapping enabled, KWin considers, e.g., windows from other activities as snapping target although they are currently invisible. This does not occur when a window is repositioned instead of resized.

In the source code, AFAIS, the snapping implementations for repositioning and resizing employ very different filters to determine potential snapping targets (see `src/workspace.cpp`):

```C++
QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unrestricted, double snapAdjust)
{
    // […]
            for (auto l = m_allClients.constBegin(); l != m_allClients.constEnd(); ++l) {
                if ((*l) == c)
                    continue;
                if ((*l)->isMinimized() || (*l)->isShade())
                    continue;
                if (!(*l)->isShown())
                    continue;
                if (!(*l)->isOnCurrentDesktop())
                    continue; // wrong virtual desktop
                if (!(*l)->isOnCurrentActivity())
                    continue; // wrong activity
                if ((*l)->isDesktop() || (*l)->isSplash() || (*l)->isNotification() ||
                        (*l)->isCriticalNotification() || (*l)->isOnScreenDisplay())
                    continue;

                // [adapt position] […]


QRect Workspace::adjustClientSize(AbstractClient* c, QRect moveResizeGeom, Gravity gravity)
{
    // […]
            for (auto l = m_allClients.constBegin(); l != m_allClients.constEnd(); ++l) {
                if ((*l)->isOnCurrentDesktop() &&
                        !(*l)->isMinimized()
                        && (*l) != c) {
                    // [adapt size] […]
```
Comment 1 Nate Graham 2022-06-01 17:52:49 UTC
Nice catch, feel free to submit a merge request to fix this.