<arg name="name" type="string"/>
<arg name="value" type="array"/>
</request>
+
+ <enum name="orientation">
+ <entry name="PrimaryOrientation" value="0"/>
+ <entry name="PortraitOrientation" value="1"/>
+ <entry name="LandscapeOrientation" value="2"/>
+ <entry name="InvertedPortraitOrientation" value="4"/>
+ <entry name="InvertedLandscapeOrientation" value="8"/>
+ </enum>
+
+ <request name="set_window_orientation">
+ <arg name="orientation" type="int"/>
+ </request>
+
+ <request name="set_content_orientation">
+ <arg name="orientation" type="int"/>
+ </request>
</interface>
</protocol>
d->surface->setSize(size);
}
+Qt::ScreenOrientation WaylandSurface::contentOrientation() const
+{
+ Q_D(const WaylandSurface);
+ return d->surface->contentOrientation();
+}
+
+Qt::ScreenOrientation WaylandSurface::windowOrientation() const
+{
+ Q_D(const WaylandSurface);
+ return d->surface->windowOrientation();
+}
+
QImage WaylandSurface::image() const
{
Q_D(const WaylandSurface);
QSize size() const;
void setSize(const QSize &size);
+ Qt::ScreenOrientation contentOrientation() const;
+ Qt::ScreenOrientation windowOrientation() const;
+
QImage image() const;
#ifdef QT_COMPOSITOR_WAYLAND_GL
GLuint texture(QOpenGLContext *context) const;
ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, Surface *surface)
: m_surface(surface)
+ , m_windowOrientation(Qt::PrimaryOrientation)
+ , m_contentOrientation(Qt::PrimaryOrientation)
{
Q_ASSERT(surface->extendedSurface() == 0);
surface->setExtendedSurface(this);
}
+static Qt::ScreenOrientation screenOrientationFromWaylandOrientation(int32_t orientation)
+{
+ switch (orientation) {
+ case WL_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION: return Qt::PortraitOrientation;
+ case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION: return Qt::InvertedPortraitOrientation;
+ case WL_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION: return Qt::LandscapeOrientation;
+ case WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION: return Qt::InvertedLandscapeOrientation;
+ default: return Qt::PrimaryOrientation;
+ }
+}
+
+Qt::ScreenOrientation ExtendedSurface::windowOrientation() const
+{
+ return m_windowOrientation;
+}
+
+Qt::ScreenOrientation ExtendedSurface::contentOrientation() const
+{
+ return m_contentOrientation;
+}
+
+void ExtendedSurface::set_window_orientation(struct wl_client *client,
+ struct wl_resource *extended_surface_resource,
+ int32_t orientation)
+{
+ Q_UNUSED(client);
+ ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+ extended_surface->m_windowOrientation = screenOrientationFromWaylandOrientation(orientation);
+}
+
+void ExtendedSurface::set_content_orientation(struct wl_client *client,
+ struct wl_resource *extended_surface_resource,
+ int32_t orientation)
+{
+ Q_UNUSED(client);
+ ExtendedSurface *extended_surface = static_cast<ExtendedSurface *>(extended_surface_resource->data);
+ extended_surface->m_contentOrientation = screenOrientationFromWaylandOrientation(orientation);
+}
+
const struct wl_extended_surface_interface ExtendedSurface::extended_surface_interface = {
- ExtendedSurface::update_generic_property
+ ExtendedSurface::update_generic_property,
+ ExtendedSurface::set_window_orientation,
+ ExtendedSurface::set_content_orientation
};
}
void setParent(ExtendedSurface *parent);
QLinkedList<WaylandSurface *> subSurfaces() const;
+ Qt::ScreenOrientation windowOrientation() const;
+ Qt::ScreenOrientation contentOrientation() const;
+
private:
struct wl_resource *m_extended_surface_resource;
Surface *m_surface;
+ Qt::ScreenOrientation m_windowOrientation;
+ Qt::ScreenOrientation m_contentOrientation;
+
static void update_generic_property(struct wl_client *client,
struct wl_resource *resource,
const char *name,
struct wl_array *value);
+ static void set_window_orientation(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t orientation);
+
+ static void set_content_orientation(struct wl_client *client,
+ struct wl_resource *resource,
+ int32_t orientation);
+
static const struct wl_extended_surface_interface extended_surface_interface;
};
}
}
+Qt::ScreenOrientation Surface::windowOrientation() const
+{
+ Q_D(const Surface);
+ return d->extendedSurface ? d->extendedSurface->windowOrientation() : Qt::PrimaryOrientation;
+}
+
+Qt::ScreenOrientation Surface::contentOrientation() const
+{
+ Q_D(const Surface);
+ return d->extendedSurface ? d->extendedSurface->contentOrientation() : Qt::PrimaryOrientation;
+}
+
QPoint Surface::lastMousePos() const
{
Q_D(const Surface);
QVariant windowProperty(const QString &propertyName) const;
void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true);
+ Qt::ScreenOrientation contentOrientation() const;
+ Qt::ScreenOrientation windowOrientation() const;
+
QPoint lastMousePos() const;
void setExtendedSurface(ExtendedSurface *extendedSurface);
nativeInterface->emitWindowPropertyChanged(m_window,name);
}
+static int32_t waylandRotationFromScreenOrientation(Qt::ScreenOrientation orientation)
+{
+ switch (orientation) {
+ case Qt::PortraitOrientation: return WL_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
+ case Qt::InvertedPortraitOrientation: return WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
+ case Qt::LandscapeOrientation: return WL_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
+ case Qt::InvertedLandscapeOrientation: return WL_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
+ default: return WL_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
+ }
+}
+
+void QWaylandExtendedSurface::setWindowOrientation(Qt::ScreenOrientation orientation)
+{
+ wl_extended_surface_set_window_orientation(m_extended_surface, waylandRotationFromScreenOrientation(orientation));
+}
+
+void QWaylandExtendedSurface::setContentOrientation(Qt::ScreenOrientation orientation)
+{
+ wl_extended_surface_set_content_orientation(m_extended_surface, waylandRotationFromScreenOrientation(orientation));
+}
+
QVariantMap QWaylandExtendedSurface::properties() const
{
return m_properties;
public:
QWaylandExtendedSurface(QWaylandWindow *window, struct wl_extended_surface *extended_surface);
+ void setWindowOrientation(Qt::ScreenOrientation orientation);
+ void setContentOrientation(Qt::ScreenOrientation orientation);
+
void updateGenericProperty(const QString &name, const QVariant &value);
QVariantMap properties() const;
QVariant property(const QString &name);
{
return mSubSurfaceWindow;
}
+
+void QWaylandWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
+{
+ if (mExtendedWindow)
+ mExtendedWindow->setContentOrientation(orientation);
+}
+
+Qt::ScreenOrientation QWaylandWindow::requestWindowOrientation(Qt::ScreenOrientation orientation)
+{
+ if (mExtendedWindow) {
+ mExtendedWindow->setWindowOrientation(orientation);
+ return orientation;
+ }
+
+ return Qt::PrimaryOrientation;
+}
QWaylandExtendedSurface *extendedWindow() const;
QWaylandSubSurface *subSurfaceWindow() const;
+ void handleContentOrientationChange(Qt::ScreenOrientation orientation);
+ Qt::ScreenOrientation requestWindowOrientation(Qt::ScreenOrientation orientation);
+
protected:
QWaylandDisplay *mDisplay;
struct wl_surface *mSurface;