diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-03-11 14:02:12 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-03-14 14:37:51 +0000 |
commit | 617b0b063155523aa7affcdaa5aa3effac646124 (patch) | |
tree | b9fc8490501dbb793d274006772bcef667199f05 /src/plugins | |
parent | 1607b8bb38e57d9d5ebdd075a9b1f3f992c5cfde (diff) |
Client: Make QWaylandWindow's wl_surface inheritance private
QWaylandWindow inheriting wl_surface is a leftover from the old days, and today
it is sometimes causing great problems. Especially on xdg_shell and other
shells where the wl_surface needs to recreated with a different role if the
QWindow::type changes.
This is currently worked around by calling reset() on the surface, which will
destroy the wl_surface, and emit some necessary events and signals.
However, much of the rest of the code still assumes that a QWaylandWindow maps
directly to a single wl_surface which won't change over the lifetime of the
QWaylandWindow.
Today, it would make sense to implement this with composition rather than
inheritance. This is a major undertaking and so this is the first small step;
hide the inheritance in QWaylandWindow's public API. This makes it much more
visible when and where the rest of the QPA plugin is using it, so we can
eventually move it into its own class later.
Task-number: QTBUG-74373
Change-Id: I257729e33c3a5368cef4bb1e16148ba392e65bd2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'src/plugins')
8 files changed, 17 insertions, 18 deletions
diff --git a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp index 9a829f6e9..26f598895 100644 --- a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp +++ b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.cpp @@ -51,7 +51,7 @@ QWaylandFullScreenShellV1Surface::QWaylandFullScreenShellV1Surface(QtWayland::zw , m_window(window) { auto screen = static_cast<QWaylandScreen *>(m_window->screen()); - m_shell->present_surface(m_window->object(), + m_shell->present_surface(m_window->wlSurface(), QtWayland::zwp_fullscreen_shell_v1::present_method_default, screen->output()); } diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp index efb61dc9f..9309faccd 100644 --- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp +++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp @@ -132,7 +132,7 @@ QWaylandShellSurface *QWaylandIviShellIntegration::createShellSurface(QWaylandWi if (surfaceId == 0) return nullptr; - struct ivi_surface *surface = m_iviApplication->surface_create(surfaceId, window->object()); + struct ivi_surface *surface = m_iviApplication->surface_create(surfaceId, window->wlSurface()); if (!m_iviController) return new QWaylandIviSurface(surface, window); diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp index 1edb24b3c..f396e8402 100644 --- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp +++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp @@ -70,7 +70,7 @@ bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) QWaylandShellSurface *QWaylandWlShellIntegration::createShellSurface(QWaylandWindow *window) { - return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->object()), window); + return new QWaylandWlShellSurface(m_wlShell->get_shell_surface(window->wlSurface()), window); } void *QWaylandWlShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp index 4506c312a..48e14c753 100644 --- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp +++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp @@ -62,9 +62,9 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_ Qt::WindowType type = window->window()->type(); auto *transientParent = window->transientParent(); - if (type == Qt::Popup && transientParent && transientParent->object()) + if (type == Qt::Popup && transientParent && transientParent->wlSurface()) setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial()); - else if (transientParent && transientParent->object()) + else if (transientParent && transientParent->wlSurface()) updateTransientParent(transientParent->window()); else setTopLevel(); @@ -234,11 +234,9 @@ void QWaylandWlShellSurface::updateTransientParent(QWindow *parent) || testShowWithoutActivating(m_window->window())) flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE; - Q_ASSERT(parent_wayland_window->object()); - set_transient(parent_wayland_window->object(), - transientPos.x(), - transientPos.y(), - flags); + auto *parentSurface = parent_wayland_window->wlSurface(); + Q_ASSERT(parentSurface); + set_transient(parentSurface, transientPos.x(), transientPos.y(), flags); } void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial) @@ -261,9 +259,10 @@ void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevic transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top()); } - Q_ASSERT(parent_wayland_window->object()); - set_popup(device->wl_seat(), serial, parent_wayland_window->object(), - transientPos.x(), transientPos.y(), 0); + auto *parentSurface = parent_wayland_window->wlSurface(); + Q_ASSERT(parentSurface); + uint flags = 0; + set_popup(device->wl_seat(), serial, parentSurface, transientPos.x(), transientPos.y(), flags); } void QWaylandWlShellSurface::shell_surface_ping(uint32_t serial) diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp index 4cbafbd71..fa9d0d8cf 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp @@ -71,7 +71,7 @@ QWaylandXdgSurfaceV5 *QWaylandXdgShellV5::createXdgSurface(QWaylandWindow *windo QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice) { QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last(); - ::wl_surface *parentSurface = parentWindow->object(); + ::wl_surface *parentSurface = parentWindow->wlSurface(); if (m_popupSerial == 0) m_popupSerial = inputDevice->serial(); @@ -81,7 +81,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q int x = position.x() + parentWindow->frameMargins().left(); int y = position.y() + parentWindow->frameMargins().top(); - auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->object(), parentSurface, seat, m_popupSerial, x, y), window); + auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window); m_popups.append(window); QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){ m_popups.removeOne(window); diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp index e9f64e2e6..e8bff9193 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp @@ -54,7 +54,7 @@ namespace QtWaylandClient { QWaylandXdgSurfaceV5::QWaylandXdgSurfaceV5(QWaylandXdgShellV5 *shell, QWaylandWindow *window) : QWaylandShellSurface(window) - , QtWayland::xdg_surface_v5(shell->get_xdg_surface(window->object())) + , QtWayland::xdg_surface_v5(shell->get_xdg_surface(window->wlSurface())) , m_window(window) , m_shell(shell) { diff --git a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index 60540fb0c..9e2c8e6d2 100644 --- a/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp @@ -418,7 +418,7 @@ QWaylandXdgShellV6::~QWaylandXdgShellV6() QWaylandXdgSurfaceV6 *QWaylandXdgShellV6::getXdgSurface(QWaylandWindow *window) { - return new QWaylandXdgSurfaceV6(this, get_xdg_surface(window->object()), window); + return new QWaylandXdgSurfaceV6(this, get_xdg_surface(window->wlSurface()), window); } void QWaylandXdgShellV6::zxdg_shell_v6_ping(uint32_t serial) diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 78b7b45c8..acce08b5a 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -455,7 +455,7 @@ QWaylandXdgShell::~QWaylandXdgShell() QWaylandXdgSurface *QWaylandXdgShell::getXdgSurface(QWaylandWindow *window) { - return new QWaylandXdgSurface(this, get_xdg_surface(window->object()), window); + return new QWaylandXdgSurface(this, get_xdg_surface(window->wlSurface()), window); } void QWaylandXdgShell::xdg_wm_base_ping(uint32_t serial) |