Be compatible with older compositors
When binding globals take care of the version the compositor provides and don't call requests that the compositor doesn't implement. Change-Id: Iea0c534fb9e005720857e2778e380b6a9c22a6f3 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
parent
eac16a7b28
commit
77fd8f63c3
@ -226,13 +226,14 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
struct ::wl_registry *registry = object();
|
||||
|
||||
if (interface == QStringLiteral("wl_output")) {
|
||||
QWaylandScreen *screen = new QWaylandScreen(this, id);
|
||||
QWaylandScreen *screen = new QWaylandScreen(this, version, id);
|
||||
mScreens.append(screen);
|
||||
// We need to get the output events before creating surfaces
|
||||
forceRoundTrip();
|
||||
mWaylandIntegration->screenAdded(screen);
|
||||
} else if (interface == QStringLiteral("wl_compositor")) {
|
||||
mCompositor.init(registry, id, 3);
|
||||
mCompositorVersion = qMin((int)version, 3);
|
||||
mCompositor.init(registry, id, mCompositorVersion);
|
||||
} else if (interface == QStringLiteral("wl_shm")) {
|
||||
mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
|
||||
} else if (interface == QStringLiteral("xdg_shell")
|
||||
@ -241,7 +242,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
||||
} else if (interface == QStringLiteral("wl_shell")){
|
||||
mShell.reset(new QtWayland::wl_shell(registry, id, 1));
|
||||
} else if (interface == QStringLiteral("wl_seat")) {
|
||||
QWaylandInputDevice *inputDevice = new QWaylandInputDevice(this, id);
|
||||
QWaylandInputDevice *inputDevice = new QWaylandInputDevice(this, version, id);
|
||||
mInputDevices.append(inputDevice);
|
||||
} else if (interface == QStringLiteral("wl_data_device_manager")) {
|
||||
mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
|
||||
|
@ -116,6 +116,7 @@ public:
|
||||
|
||||
const struct wl_compositor *wl_compositor() const { return mCompositor.object(); }
|
||||
QtWayland::wl_compositor *compositor() { return &mCompositor; }
|
||||
int compositorVersion() const { return mCompositorVersion; }
|
||||
|
||||
QtWayland::wl_shell *shell() { return mShell.data(); }
|
||||
QtWayland::xdg_shell *shellXdg();
|
||||
@ -198,6 +199,7 @@ private:
|
||||
int mWritableNotificationFd;
|
||||
bool mScreensInitialized;
|
||||
QList<RegistryGlobal> mGlobals;
|
||||
int mCompositorVersion;
|
||||
|
||||
void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE;
|
||||
void registry_global_remove(uint32_t id) Q_DECL_OVERRIDE;
|
||||
|
@ -228,9 +228,9 @@ public:
|
||||
QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
|
||||
};
|
||||
|
||||
QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, uint32_t id)
|
||||
QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version, uint32_t id)
|
||||
: QObject()
|
||||
, QtWayland::wl_seat(display->wl_registry(), id, 2)
|
||||
, QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 2))
|
||||
, mQDisplay(display)
|
||||
, mDisplay(display->wl_display())
|
||||
, mCaps(0)
|
||||
|
@ -75,7 +75,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWaylandInputDevice(QWaylandDisplay *display, uint32_t id);
|
||||
QWaylandInputDevice(QWaylandDisplay *display, int version, uint32_t id);
|
||||
~QWaylandInputDevice();
|
||||
|
||||
uint32_t capabilities() const { return mCaps; }
|
||||
|
@ -53,9 +53,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id)
|
||||
QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
|
||||
: QPlatformScreen()
|
||||
, QtWayland::wl_output(waylandDisplay->wl_registry(), id, 2)
|
||||
, QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
|
||||
, m_outputId(id)
|
||||
, mWaylandDisplay(waylandDisplay)
|
||||
, mExtendedOutput(0)
|
||||
|
@ -56,7 +56,7 @@ class QWaylandExtendedOutput;
|
||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandScreen : public QPlatformScreen, QtWayland::wl_output
|
||||
{
|
||||
public:
|
||||
QWaylandScreen(QWaylandDisplay *waylandDisplay, uint32_t id);
|
||||
QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
|
||||
~QWaylandScreen();
|
||||
|
||||
QWaylandDisplay *display() const;
|
||||
|
@ -429,6 +429,9 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
|
||||
|
||||
void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
|
||||
{
|
||||
if (mDisplay->compositorVersion() < 2)
|
||||
return;
|
||||
|
||||
wl_output_transform transform;
|
||||
bool isPortrait = window()->screen() && window()->screen()->primaryOrientation() == Qt::PortraitOrientation;
|
||||
switch (orientation) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user