return 0;
}
+QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+{
+ for (int i = 0; i < mScreens.size(); ++i) {
+ QWaylandScreen *screen = static_cast<QWaylandScreen *>(mScreens.at(i));
+ if (screen->output() == output)
+ return screen;
+ }
+ return 0;
+}
+
void QWaylandDisplay::outputHandleGeometry(void *data,
wl_output *output,
int32_t x, int32_t y,
~QWaylandDisplay(void);
QList<QPlatformScreen *> screens() const { return mScreens; }
+
+ QWaylandScreen *screenForOutput(struct wl_output *output) const;
+
struct wl_surface *createSurface(void *handle);
struct wl_buffer *createShmBuffer(int fd, int width, int height,
uint32_t stride,
#include "qwaylanddisplay.h"
#include "qwaylandcursor.h"
+#include <QWindowSystemInterface>
+
QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry)
: QPlatformScreen()
, mWaylandDisplay(waylandDisplay)
, mGeometry(geometry)
, mDepth(32)
, mFormat(QImage::Format_ARGB32_Premultiplied)
+ , mOrientation(primaryOrientation())
, mWaylandCursor(new QWaylandCursor(this))
{
}
return mFormat;
}
+Qt::ScreenOrientation QWaylandScreen::currentOrientation() const
+{
+ return mOrientation;
+}
+
+void QWaylandScreen::setOrientation(const Qt::ScreenOrientation orientation)
+{
+ mOrientation = orientation;
+ QWindowSystemInterface::handleScreenOrientationChange(screen());
+}
+
QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{
QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window);
int depth() const;
QImage::Format format() const;
+ Qt::ScreenOrientation currentOrientation() const;
+ void setOrientation(const Qt::ScreenOrientation orientation);
+
wl_visual *visual() const;
+ wl_output *output() const { return mOutput; }
static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
int mDepth;
QImage::Format mFormat;
QSize mPhysicalSize;
+ Qt::ScreenOrientation mOrientation;
QWaylandCursor *mWaylandCursor;
};
#include "qwaylandwindowmanagerintegration.h"
#include "wayland-windowmanager-client-protocol.h"
+#include "qwaylandscreen.h"
#include "qwaylandwindow.h"
#include <stdint.h>
QCoreApplication::sendEvent(QCoreApplication::instance(), &evt);
}
-void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation)
+void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager,
+ struct wl_output *wl_output, int screenOrientation)
{
- Q_UNUSED(data);
- Q_UNUSED(wl_windowmanager);
- QScreenOrientationChangeEvent event(screenOrientation);
- QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
+ QWaylandWindowManagerIntegration *integration = QWaylandWindowManagerIntegration::instance();
+ QWaylandScreen *screen = integration->d_ptr->m_waylandDisplay->screenForOutput(wl_output);
+ if (screen)
+ screen->setOrientation(Qt::ScreenOrientation(screenOrientation));
}
void QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
const char *interface, uint32_t version, void *data);
static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible);
- static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation);
+ static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager,
+ struct wl_output *wl_output, int screenOrientation);
static void wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
struct wl_surface *surface,
const char *propertyName, struct wl_array *propertyValue);
struct wl_windowmanager_listener {
void (*client_onscreen_visibility)(void *data,
struct wl_windowmanager *wl_windowmanager,
- int32_t visible);
+ int visible);
void (*set_screen_rotation)(void *data,
struct wl_windowmanager *wl_windowmanager,
- int32_t rotation);
+ struct wl_output *output,
+ int rotation);
void (*set_generic_property)(void *data,
struct wl_windowmanager *wl_windowmanager,
struct wl_surface *surface,
#include <stdint.h>
#include "wayland-util.h"
-extern const struct wl_interface wl_surface_interface;
-
-static const struct wl_interface *types[] = {
- NULL,
- &wl_surface_interface,
- NULL,
- NULL,
- &wl_surface_interface,
- NULL,
- NULL,
-};
-
static const struct wl_message wl_windowmanager_requests[] = {
- { "map_client_to_process", "u", types + 0 },
- { "authenticate_with_token", "s", types + 0 },
- { "update_generic_property", "osa", types + 1 },
+ { "map_client_to_process", "u", NULL },
+ { "authenticate_with_token", "s", NULL },
+ { "update_generic_property", "osa", NULL },
};
static const struct wl_message wl_windowmanager_events[] = {
- { "client_onscreen_visibility", "i", types + 0 },
- { "set_screen_rotation", "i", types + 0 },
- { "set_generic_property", "osa", types + 4 },
+ { "client_onscreen_visibility", "i", NULL },
+ { "set_screen_rotation", "oi", NULL },
+ { "set_generic_property", "osa", NULL },
};
WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
return m_socket_name.constData();
}
-void WaylandCompositor::setScreenOrientation(qint32 orientationInDegrees)
+/*!
+ Set the screen orientation based on accelerometer data or similar.
+*/
+void WaylandCompositor::setScreenOrientation(Qt::ScreenOrientation orientation)
{
- m_compositor->setScreenOrientation(orientationInDegrees);
+ m_compositor->setScreenOrientation(orientation);
}
void WaylandCompositor::setOutputGeometry(const QRect &geometry)
const char *socketName() const;
- void setScreenOrientation(qint32 orientationInDegrees);
+ void setScreenOrientation(Qt::ScreenOrientation orientation);
void setOutputGeometry(const QRect &outputGeometry);
bool isDragging() const;
, m_current_frame(0)
, m_last_queued_buf(-1)
, m_qt_compositor(qt_compositor)
+ , m_orientation(Qt::UnknownOrientation)
, m_pointerFocusSurface(0)
, m_keyFocusSurface(0)
, m_directRenderSurface(0)
addClientResource(client, &surface->base()->resource, id, &wl_surface_interface,
&surface_interface, destroy_surface);
- m_windowManagerWaylandProtocol->updateOrientation(client);
- m_qt_compositor->surfaceCreated(surface->handle());
-
QList<struct wl_client *> prevClientList = clients();
m_surfaces << surface;
- if (!prevClientList.contains(client))
+ if (!prevClientList.contains(client)) {
+ m_windowManagerWaylandProtocol->setScreenOrientation(client, m_output.base(), m_orientation);
emit clientAdded(client);
+ }
+
+ m_qt_compositor->surfaceCreated(surface->handle());
}
struct wl_client *Compositor::getClientFromWinId(uint winId) const
return list;
}
-void Compositor::setScreenOrientation(qint32 orientationInDegrees)
+void Compositor::setScreenOrientation(Qt::ScreenOrientation orientation)
{
+ m_orientation = orientation;
+
QList<struct wl_client*> clientList = clients();
for (int i = 0; i < clientList.length(); ++i) {
struct wl_client *client = clientList.at(i);
- m_windowManagerWaylandProtocol->setScreenOrientation(client, orientationInDegrees);
+ m_windowManagerWaylandProtocol->setScreenOrientation(client, m_output.base(), orientation);
}
}
QList<struct wl_client *> clients() const;
- void setScreenOrientation(qint32 orientationInDegrees);
+ void setScreenOrientation(Qt::ScreenOrientation orientation);
void setOutputGeometry(const QRect &geometry);
bool isDragging() const;
wl_event_loop *m_loop;
WaylandCompositor *m_qt_compositor;
+ Qt::ScreenOrientation m_orientation;
Surface *m_pointerFocusSurface;
Surface *m_keyFocusSurface;
#include <stdint.h>
#include "wayland-util.h"
-extern const struct wl_interface wl_surface_interface;
-
-static const struct wl_interface *types[] = {
- NULL,
- &wl_surface_interface,
- NULL,
- NULL,
- &wl_surface_interface,
- NULL,
- NULL,
-};
-
static const struct wl_message wl_windowmanager_requests[] = {
- { "map_client_to_process", "u", types + 0 },
- { "authenticate_with_token", "s", types + 0 },
- { "update_generic_property", "osa", types + 1 },
+ { "map_client_to_process", "u", NULL },
+ { "authenticate_with_token", "s", NULL },
+ { "update_generic_property", "osa", NULL },
};
static const struct wl_message wl_windowmanager_events[] = {
- { "client_onscreen_visibility", "i", types + 0 },
- { "set_screen_rotation", "i", types + 0 },
- { "set_generic_property", "osa", types + 4 },
+ { "client_onscreen_visibility", "i", NULL },
+ { "set_screen_rotation", "oi", NULL },
+ { "set_generic_property", "osa", NULL },
};
WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
WindowManagerServerIntegration::WindowManagerServerIntegration(QObject *parent)
: QObject(parent)
- , m_orientationInDegrees(0)
{
m_instance = this;
}
WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY, visible ? 1 : 0);
}
-void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, qint32 orientationInDegrees)
+void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, wl_object *output, Qt::ScreenOrientation orientation)
{
- m_orientationInDegrees = orientationInDegrees;
wl_client_post_event(client, m_windowManagerObject->base(),
- WL_WINDOWMANAGER_SET_SCREEN_ROTATION, orientationInDegrees);
-}
-
-void WindowManagerServerIntegration::updateOrientation(wl_client *client)
-{
- setScreenOrientation(client, m_orientationInDegrees);
+ WL_WINDOWMANAGER_SET_SCREEN_ROTATION, output, qint32(orientation));
}
// client -> server
#include <QVariant>
struct wl_client;
+struct wl_object;
namespace Wayland {
class Display;
WaylandManagedClient *managedClient(wl_client *client) const;
void setVisibilityOnScreen(wl_client *client, bool visible);
- void setScreenOrientation(wl_client *client, qint32 orientationInDegrees);
+ void setScreenOrientation(wl_client *client, wl_object *output, Qt::ScreenOrientation orientationInDegrees);
void updateOrientation(wl_client *client);
void updateWindowProperty(wl_client *client, struct wl_surface *surface, const char *name, struct wl_array *value);
static WindowManagerServerIntegration *m_instance;
WindowManagerObject *m_windowManagerObject;
- qint32 m_orientationInDegrees;
friend class WindowManagerObject;
};
<!-- Sets screen rotation, typically based on accelerometer/orientation sensor reading data -->
<event name="set_screen_rotation">
+ <arg name="output" type="object" interface="wl_output"/>
<arg name="rotation" type="int"/>
</event>