summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/qwaylanddisplay.cpp14
-rw-r--r--src/client/qwaylanddisplay_p.h2
-rw-r--r--src/client/qwaylandeventthread.cpp8
-rw-r--r--src/client/qwaylandnativeinterface.cpp2
-rw-r--r--src/client/qwaylandwindow.cpp30
-rw-r--r--src/client/qwaylandwindowmanagerintegration.cpp31
-rw-r--r--src/client/qwaylandwindowmanagerintegration_p.h4
-rw-r--r--src/client/qwaylandwlshellsurface.cpp3
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp56
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard_p.h1
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp8
11 files changed, 89 insertions, 70 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index ab69bca32..2d1c81a75 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -154,12 +154,7 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
mEventThreadObject->displayConnect();
mDisplay = mEventThreadObject->display(); //blocks until display is available
- //Create a new even queue for the QtGui thread
- mEventQueue = wl_display_create_queue(mDisplay);
-
struct ::wl_registry *registry = wl_display_get_registry(mDisplay);
- wl_proxy_set_queue((struct wl_proxy *)registry, mEventQueue);
-
init(registry);
connect(mEventThreadObject, SIGNAL(newEventsRead()), this, SLOT(flushRequests()));
@@ -187,7 +182,7 @@ QWaylandDisplay::~QWaylandDisplay(void)
void QWaylandDisplay::flushRequests()
{
- if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) {
+ if (wl_display_dispatch_pending(mDisplay) < 0) {
mEventThreadObject->checkError();
exitWithError();
}
@@ -198,7 +193,7 @@ void QWaylandDisplay::flushRequests()
void QWaylandDisplay::blockingReadEvents()
{
- if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) {
+ if (wl_display_dispatch(mDisplay) < 0) {
mEventThreadObject->checkError();
exitWithError();
}
@@ -348,17 +343,16 @@ void QWaylandDisplay::forceRoundTrip()
int ret = 0;
bool done = false;
wl_callback *callback = wl_display_sync(mDisplay);
- wl_proxy_set_queue((struct wl_proxy *)callback, mEventQueue);
wl_callback_add_listener(callback, &sync_listener, &done);
flushRequests();
if (QThread::currentThread()->eventDispatcher()) {
while (!done && ret >= 0) {
QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
- ret = wl_display_dispatch_queue_pending(mDisplay, mEventQueue);
+ ret = wl_display_dispatch_pending(mDisplay);
}
} else {
while (!done && ret >= 0)
- ret = wl_display_dispatch_queue(mDisplay, mEventQueue);
+ ret = wl_display_dispatch(mDisplay);
}
if (ret == -1 && !done)
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index 96d79ddbd..84c79d70d 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -109,7 +109,6 @@ public:
void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image);
struct wl_display *wl_display() const { return mDisplay; }
- struct wl_event_queue *wl_event_queue() const { return mEventQueue; }
struct ::wl_registry *wl_registry() { return object(); }
const struct wl_compositor *wl_compositor() const { return mCompositor.object(); }
@@ -174,7 +173,6 @@ private:
};
struct wl_display *mDisplay;
- struct wl_event_queue *mEventQueue;
QtWayland::wl_compositor mCompositor;
struct wl_shm *mShm;
QThread *mEventThread;
diff --git a/src/client/qwaylandeventthread.cpp b/src/client/qwaylandeventthread.cpp
index e2e21c9e7..e0a3edcb8 100644
--- a/src/client/qwaylandeventthread.cpp
+++ b/src/client/qwaylandeventthread.cpp
@@ -80,13 +80,9 @@ void QWaylandEventThread::checkError() const
void QWaylandEventThread::readWaylandEvents()
{
- if (wl_display_dispatch(m_display) < 0) {
- checkError();
- m_readNotifier->setEnabled(false);
- emit fatalError();
- return;
+ if (wl_display_prepare_read(m_display) == 0) {
+ wl_display_read_events(m_display);
}
-
emit newEventsRead();
}
diff --git a/src/client/qwaylandnativeinterface.cpp b/src/client/qwaylandnativeinterface.cpp
index 8170c39f1..0d20075f0 100644
--- a/src/client/qwaylandnativeinterface.cpp
+++ b/src/client/qwaylandnativeinterface.cpp
@@ -58,8 +58,6 @@ void *QWaylandNativeInterface::nativeResourceForIntegration(const QByteArray &re
if (lowerCaseResource == "display" || lowerCaseResource == "wl_display" || lowerCaseResource == "nativedisplay")
return m_integration->display()->wl_display();
- if (lowerCaseResource == "wl_event_queue")
- return m_integration->display()->wl_event_queue();
if (lowerCaseResource == "compositor")
return const_cast<wl_compositor *>(m_integration->display()->wl_compositor());
if (lowerCaseResource == "server_buffer_integration")
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index a54979a2f..ed7b656d9 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -156,7 +156,8 @@ void QWaylandWindow::initWindow()
mShellSurface->updateTransientParent(window()->transientParent());
}
} else {
- mShellSurface->setTopLevel();
+ if (window()->type() != Qt::ToolTip)
+ mShellSurface->setTopLevel();
}
}
@@ -266,17 +267,18 @@ void QWaylandWindow::setGeometry(const QRect &rect)
void QWaylandWindow::setVisible(bool visible)
{
if (visible) {
- if (window()->type() == Qt::Popup) {
- QWaylandWindow *parent = transientParent();
- if (!parent) {
- // Try with the current focus window. It should be the right one and anyway
- // better than having no parent at all.
- parent = mDisplay->lastInputWindow();
- }
- if (parent) {
- QWaylandWlShellSurface *wlshellSurface = qobject_cast<QWaylandWlShellSurface*>(mShellSurface);
- if (wlshellSurface)
- wlshellSurface->setPopup(parent, mDisplay->lastInputDevice(), mDisplay->lastInputSerial());
+ if (mShellSurface) {
+ if (window()->type() == Qt::Popup) {
+ QWaylandWindow *parent = transientParent();
+ if (parent) {
+ QWaylandWlShellSurface *wlshellSurface = qobject_cast<QWaylandWlShellSurface*>(mShellSurface);
+ if (wlshellSurface)
+ wlshellSurface->setPopup(parent, mDisplay->lastInputDevice(), mDisplay->lastInputSerial());
+ }
+ } else if (window()->type() == Qt::ToolTip) {
+ if (QWaylandWindow *parent = transientParent()) {
+ mShellSurface->updateTransientParent(parent->window());
+ }
}
}
@@ -643,7 +645,9 @@ QWaylandWindow *QWaylandWindow::transientParent() const
// events.
return static_cast<QWaylandWindow *>(topLevelWindow(window()->transientParent())->handle());
}
- return 0;
+ // Try with the current focus window. It should be the right one and anyway
+ // better than having no parent at all.
+ return mDisplay->lastInputWindow();
}
void QWaylandWindow::handleMouse(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e)
diff --git a/src/client/qwaylandwindowmanagerintegration.cpp b/src/client/qwaylandwindowmanagerintegration.cpp
index 56fe7c5a3..5e8a628bf 100644
--- a/src/client/qwaylandwindowmanagerintegration.cpp
+++ b/src/client/qwaylandwindowmanagerintegration.cpp
@@ -127,28 +127,33 @@ QByteArray QWaylandWindowManagerIntegration::desktopEnvironment() const
void QWaylandWindowManagerIntegration::openUrl_helper(const QUrl &url)
{
- if (isInitialized()) {
- QByteArray data = url.toString().toUtf8();
-
- static const int chunkSize = 128;
- while (!data.isEmpty()) {
- QByteArray chunk = data.left(chunkSize);
- data = data.mid(chunkSize);
- open_url(!data.isEmpty(), QString::fromUtf8(chunk));
- }
+ Q_ASSERT(isInitialized());
+ QByteArray data = url.toString().toUtf8();
+
+ static const int chunkSize = 128;
+ while (!data.isEmpty()) {
+ QByteArray chunk = data.left(chunkSize);
+ data = data.mid(chunkSize);
+ open_url(!data.isEmpty(), QString::fromUtf8(chunk));
}
}
bool QWaylandWindowManagerIntegration::openUrl(const QUrl &url)
{
- openUrl_helper(url);
- return true;
+ if (isInitialized()) {
+ openUrl_helper(url);
+ return true;
+ }
+ return QGenericUnixServices::openUrl(url);
}
bool QWaylandWindowManagerIntegration::openDocument(const QUrl &url)
{
- openUrl_helper(url);
- return true;
+ if (isInitialized()) {
+ openUrl_helper(url);
+ return true;
+ }
+ return QGenericUnixServices::openDocument(url);
}
}
diff --git a/src/client/qwaylandwindowmanagerintegration_p.h b/src/client/qwaylandwindowmanagerintegration_p.h
index 612cda43e..c5ceb6d5b 100644
--- a/src/client/qwaylandwindowmanagerintegration_p.h
+++ b/src/client/qwaylandwindowmanagerintegration_p.h
@@ -38,7 +38,7 @@
#include <QtCore/QScopedPointer>
#include <wayland-client.h>
-#include <qpa/qplatformservices.h>
+#include <QtPlatformSupport/private/qgenericunixservices_p.h>
#include <QtWaylandClient/private/qwayland-windowmanager.h>
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
@@ -52,7 +52,7 @@ class QWaylandDisplay;
class QWaylandWindowManagerIntegrationPrivate;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandWindowManagerIntegration : public QObject, public QPlatformServices, public QtWayland::qt_windowmanager
+class Q_WAYLAND_CLIENT_EXPORT QWaylandWindowManagerIntegration : public QObject, public QGenericUnixServices, public QtWayland::qt_windowmanager
{
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration)
diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp
index 8888dbf4d..f7bdc2c99 100644
--- a/src/client/qwaylandwlshellsurface.cpp
+++ b/src/client/qwaylandwlshellsurface.cpp
@@ -159,8 +159,7 @@ void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
// set_transient expects a position relative to the parent
QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
- QWindow *parentWin = m_window->window()->transientParent();
- transientPos -= parentWin->geometry().topLeft();
+ transientPos -= parent->geometry().topLeft();
if (parent_wayland_window->decoration()) {
transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index bcee40fb4..060965663 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -72,6 +72,7 @@ Keyboard::Keyboard(Compositor *compositor, InputDevice *seat)
, m_group()
, m_pendingKeymap(false)
#ifndef QT_NO_WAYLAND_XKB
+ , m_keymap_fd(-1)
, m_state(0)
#endif
{
@@ -349,42 +350,57 @@ void Keyboard::initXKB()
createXKBKeymap();
}
-void Keyboard::createXKBKeymap()
+void Keyboard::createXKBState(xkb_keymap *keymap)
{
- if (!m_context)
- return;
-
- if (m_state)
- xkb_state_unref(m_state);
-
- struct xkb_rule_names rule_names = { strdup(qPrintable(m_keymap.rules())),
- strdup(qPrintable(m_keymap.model())),
- strdup(qPrintable(m_keymap.layout())),
- strdup(qPrintable(m_keymap.variant())),
- strdup(qPrintable(m_keymap.options())) };
- struct xkb_keymap *keymap = xkb_keymap_new_from_names(m_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0));
-
char *keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1);
- if (!keymap_str)
- qFatal("Failed to compile global XKB keymap");
+ if (!keymap_str) {
+ qWarning("Failed to compile global XKB keymap");
+ return;
+ }
m_keymap_size = strlen(keymap_str) + 1;
+ if (m_keymap_fd >= 0)
+ close(m_keymap_fd);
m_keymap_fd = createAnonymousFile(m_keymap_size);
- if (m_keymap_fd < 0)
- qFatal("Failed to create anonymous file of size %lu", static_cast<unsigned long>(m_keymap_size));
+ if (m_keymap_fd < 0) {
+ qWarning("Failed to create anonymous file of size %lu", static_cast<unsigned long>(m_keymap_size));
+ return;
+ }
m_keymap_area = static_cast<char *>(mmap(0, m_keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_keymap_fd, 0));
if (m_keymap_area == MAP_FAILED) {
close(m_keymap_fd);
- qFatal("Failed to map shared memory segment");
+ m_keymap_fd = -1;
+ qWarning("Failed to map shared memory segment");
+ return;
}
strcpy(m_keymap_area, keymap_str);
free(keymap_str);
+ if (m_state)
+ xkb_state_unref(m_state);
m_state = xkb_state_new(keymap);
+}
+
+void Keyboard::createXKBKeymap()
+{
+ if (!m_context)
+ return;
- xkb_keymap_unref(keymap);
+ struct xkb_rule_names rule_names = { strdup(qPrintable(m_keymap.rules())),
+ strdup(qPrintable(m_keymap.model())),
+ strdup(qPrintable(m_keymap.layout())),
+ strdup(qPrintable(m_keymap.variant())),
+ strdup(qPrintable(m_keymap.options())) };
+ struct xkb_keymap *keymap = xkb_keymap_new_from_names(m_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0));
+
+ if (keymap) {
+ createXKBState(keymap);
+ xkb_keymap_unref(keymap);
+ } else {
+ qWarning("Failed to load the '%s' XKB keymap.", qPrintable(m_keymap.layout()));
+ }
free((char *)rule_names.rules);
free((char *)rule_names.model);
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard_p.h b/src/compositor/wayland_wrapper/qwlkeyboard_p.h
index d394aad1b..c4df31266 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard_p.h
+++ b/src/compositor/wayland_wrapper/qwlkeyboard_p.h
@@ -127,6 +127,7 @@ private:
#ifndef QT_NO_WAYLAND_XKB
void initXKB();
void createXKBKeymap();
+ void createXKBState(xkb_keymap *keymap);
#endif
Compositor *m_compositor;
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index 9b3789087..d23c6aeb0 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -436,6 +436,14 @@ void Surface::surface_destroy_resource(Resource *)
m_extendedSurface = 0;
}
+ if (transientParent()) {
+ foreach (Surface *surface, compositor()->surfaces()) {
+ if (surface->transientParent() == this) {
+ surface->setTransientParent(0);
+ }
+ }
+ }
+
m_destroyed = true;
m_waylandSurface->destroy();
emit m_waylandSurface->surfaceDestroyed();