Add a convenient API to query the windowing system/platform used by Qt

Review Request #128567 - Created Aug. 1, 2016 and submitted

Information
Martin Flöser
kwindowsystem
master
67b9522...
Reviewers
kdeframeworks
A common pattern for our applications which have to do platform specific
tasks is to query the used platform with code like:
if (QX11Info::isPlatformX11()) {
    // do X11 specific stuff
} else if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
    // do Wayland specific stuff
}

The problem with that is that it involves string comparisons and is easy
to get wrong. E.g. for X11 one should use the QX11Info helper, for
Wayland one has to compare with startsWith. There is lot of domain
specific knowledge going into it to make it work correctly and in an
efficient way.

This change introduces an enum based API which encapsulates the
knowledge: it does the proper comparisons and caches the result, so
that one does not need to do string comparisons again and again.

So far the implementation supports the platforms X11/XCB and Wayland.
In addition there are convenient methods to check for a specific
platform modelled after QX11Info::isPlatformX11.

Further platforms can be added by the maintainers of the respective
platforms.

  

Issues

  • 0
  • 3
  • 2
  • 5
Description From Last Updated
Ivan Čukić
Sune Vuorela
Martin Flöser
Sune Vuorela
Ivan Čukić
Martin Flöser
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 67b95225136ea540d2c2a9fe4bd74285f40fdc73 by Martin Gräßlin to branch master.
Loading...