use a native event filter to notice the screen was swapped
ClosedPublic

Authored by mart on Dec 27 2016, 11:55 AM.

Details

Summary

this replaces the approach with the expose event in
20b439a4f4a by directly monitoring the xcb screen change
notify native event

Test Plan

attaching and detaching the external screen on a laptop
configured to deactivate the internal screen upon connection
same behavior as D3777

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.
mart retitled this revision from to use a native event filter to notice the screen was swapped.Dec 27 2016, 11:55 AM
mart updated this object.
mart edited the test plan for this revision. (Show Details)
mart added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptDec 27 2016, 11:55 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mart edited the test plan for this revision. (Show Details)Dec 27 2016, 11:57 AM
mart added reviewers: davidedmundson, sebas.
sebas added a comment.Dec 27 2016, 4:31 PM

Code-wise, it looks good. let's get it into master quickly, and if we get no complaints, backport to 5.8?

shell/shellcorona.h
117

whitespace between * and var name

Given the only member variable we use is m_screenPool-> shouldn't this just be in ScreenPool?

Also I don't understand how this is works:

qxcbconnection::handleXcbEvent

calls ::filterNativeEvent
before ::handleScreenChange

which means this code is running before qGuiApp->primaryScreen has updated.

mart added a comment.Dec 28 2016, 10:54 AM

Given the only member variable we use is m_screenPool-> shouldn't this just be in ScreenPool?

Also I don't understand how this is works:

qxcbconnection::handleXcbEvent

calls ::filterNativeEvent
before ::handleScreenChange

which means this code is running before qGuiApp->primaryScreen has updated.

the weird thing is that i'm getting a lot of screen change events, so that's probably why it works even if it's called in the wrong order.

putting a bit of debug i get this:

Name of current primary screen "eDP-1" stored name in screenpool "eDP-1"
Name of current primary screen "eDP-1" stored name in screenpool "eDP-1"
Name of current primary screen ":0.0" stored name in screenpool "eDP-1"
Name of current primary screen "HDMI-1" stored name in screenpool ":0.0"
Name of current primary screen "HDMI-1" stored name in screenpool "HDMI-1"

can be seen going from the internal screen to the fake one, then from the fake one to the external one

mart updated this revision to Diff 9409.Dec 28 2016, 11:07 AM
  • move in screenpool
pmuralidharan added inline comments.
shell/screenpool.cpp
203

Wondering whether returning false always is correct. It feels wrong but I may be missing something.

mart added inline comments.Dec 29 2016, 11:25 AM
shell/screenpool.cpp
203

always returning false means you don't want to ever block such events from further management, which is correct.

davidedmundson accepted this revision.Dec 29 2016, 11:25 AM
This revision is now accepted and ready to land.Dec 29 2016, 11:25 AM
mart added a comment.Dec 29 2016, 11:29 AM

so, landing in both master and 5.8

This revision was automatically updated to reflect the committed changes.

so, landing in both master and 5.8

Master yes, 5.8 it's up to you.

broulik added a subscriber: broulik.Jan 1 2017, 4:37 PM
broulik added inline comments.
shell/screenpool.cpp
37

No need to install if not on X?

broulik added inline comments.Jan 8 2017, 2:33 PM
shell/screenpool.cpp
188

Is that call to X really neccessary everytime? It's called constantly for all kinds of events. Also at least cache the QX11Info::connection() ...