DesktopView: Don't call ensureWindowType on FocusIn event
ClosedPublic

Authored by drosca on Jul 8 2016, 4:40 PM.

Details

Summary

Fixes desktop window losing the keep-below flag.

BUG: 365014

Test Plan

The real issue is probably some race between KWindowSystem and Qt xcb,
but this fixes the issue and it really seems unnecessary to refresh the window flags
on each focus in event.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
drosca updated this revision to Diff 5026.Jul 8 2016, 4:40 PM
drosca retitled this revision from to DesktopView: Don't call ensureWindowType on FocusIn event.
drosca updated this object.
drosca edited the test plan for this revision. (Show Details)
drosca added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptJul 8 2016, 4:40 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript

Fixes desktop window losing the keep-below flag

Just saying: this doesn't make sense. Keep-below doesn't matter for a desktop window. I just checked KWin's source code and the layer of the desktop window is only determined by the window type. Keep above/below has no influence on desktop windows. (For those interested kwin.git file abstract_client.cpp method belongsToLayer())

Overall the proposed change worries me. I totally believe you that it fixes the problem and also think that the current code is wrong. What worries me is that we don't understand what's going on here in a very central part of our desktop application. We don't know when we set the window type. That's urgh.

I would say the ensurePlatformWindow needs to be called from the QPlatformSurfaceEvent::SurfaceCreated event. But we should test that whole thing.

What's really important to know is that KWin does not support changes of window type once a window is mapped. This makes the existing code pointless - it cannot update. But it also means that somewhere there is a race that the window type is not properly set.

snip from xprop -spy on desktop window when clicking on desktop window and other windows:

_NET_WM_USER_TIME(CARDINAL) = 894873
_NET_WM_USER_TIME(CARDINAL) = 894853
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x1, 0x0, 0x0, 0x0
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_NET_WM_STATE(ATOM) = 
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_CHANGE_DESKTOP
_NET_WM_USER_TIME(CARDINAL) = 896471
_NET_WM_USER_TIME(CARDINAL) = 896471
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x1, 0x0, 0x0, 0x0
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_CLOSE
_NET_WM_STATE(ATOM) = _NET_WM_STATE_BELOW
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x1, 0x0, 0x0, 0x0
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DESKTOP
_NET_WM_STATE(ATOM) = 
_NET_WM_USER_TIME(CARDINAL) = 898190
mart added a subscriber: mart.Jul 11 2016, 8:35 AM

it's probably due from the xcb platformintegration setting window type only after the window has been shown?

In D2121#39399, @drosca wrote:

snip from xprop -spy on desktop window when clicking on desktop window and other windows:

can you try that with starting plasmashell? My gut feeling is that it's first a different type and changed afterwards.

hmm xprop won't do that (lalala), maybe we can see it in xev, though

Patch for setting through surface event:

diff --git a/shell/desktopview.cpp b/shell/desktopview.cpp
index 14a25af..38c6621 100644
--- a/shell/desktopview.cpp
+++ b/shell/desktopview.cpp
@@ -226,6 +226,7 @@ bool DesktopView::event(QEvent *e)
             switch (pe->surfaceEventType()) {
             case QPlatformSurfaceEvent::SurfaceCreated:
                 setupWaylandIntegration();
+                ensureWindowType();
                 break;
             case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
                 delete m_shellSurface;

Patch for setting through surface event:

No, that doesn't help, nor does calling ensureWindowType in QEvent::Expose.

As it is now, calling ensureWindowType in QEvent::FocusIn is pointless (and causes this bug), as proper window type is already set *after* QEvent::Show (ensureWindowType is called in showEvent) - that is after native window was created and exposed.

graesslin accepted this revision.Aug 12 2016, 11:52 AM
graesslin added a reviewer: graesslin.
This revision is now accepted and ready to land.Aug 12 2016, 11:52 AM
This revision was automatically updated to reflect the committed changes.