Skip to content

Commit

Permalink
Pass wl_display to XdgExported and XdgActivationToken from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Apr 25, 2023
1 parent fd9adb3 commit a3c94a0
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions base/platform/linux/base_linux_wayland_integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,12 @@ class XdgExported
: public QObject
, public QtWayland::zxdg_exported_v2 {
public:
XdgExported(struct ::zxdg_exported_v2 *object, QObject *parent = nullptr)
XdgExported(
struct ::wl_display *display,
struct ::zxdg_exported_v2 *object,
QObject *parent = nullptr)
: QObject(parent)
, zxdg_exported_v2(object) {
const auto native = QGuiApplication::platformNativeInterface();
if (!native) {
return;
}

const auto display = reinterpret_cast<wl_display*>(
native->nativeResourceForIntegration(QByteArray("wl_display")));

if (!display) {
return;
}

wl_display_roundtrip(display);
}

Expand All @@ -100,6 +91,7 @@ class XdgExported
class XdgActivationToken : public QtWayland::xdg_activation_token_v1 {
public:
XdgActivationToken(
struct ::wl_display *display,
struct ::xdg_activation_token_v1 *object,
struct ::wl_surface *surface,
struct ::wl_seat *seat,
Expand All @@ -110,19 +102,6 @@ class XdgActivationToken : public QtWayland::xdg_activation_token_v1 {
set_serial(serial, seat);
set_app_id(appId);
commit();

const auto native = QGuiApplication::platformNativeInterface();
if (!native) {
return;
}

const auto display = reinterpret_cast<wl_display*>(
native->nativeResourceForIntegration(QByteArray("wl_display")));

if (!display) {
return;
}

wl_display_roundtrip(display);
}

Expand Down Expand Up @@ -261,14 +240,18 @@ QString WaylandIntegration::nativeHandle(QWindow *window) {
return {};
}

const auto display = reinterpret_cast<wl_display*>(
native->nativeResourceForIntegration(QByteArray("wl_display")));

const auto surface = reinterpret_cast<wl_surface*>(
native->nativeResourceForWindow(QByteArray("surface"), window));

if (!surface) {
if (!display || !surface) {
return {};
}

return (new XdgExported(
display,
_private->xdgExporter.export_toplevel(surface),
window))->handle();
}
Expand All @@ -288,6 +271,9 @@ QString WaylandIntegration::activationToken() {
return {};
}

const auto display = reinterpret_cast<wl_display*>(
native->nativeResourceForIntegration(QByteArray("wl_display")));

const auto surface = reinterpret_cast<wl_surface*>(
native->nativeResourceForWindow(QByteArray("surface"), window));

Expand All @@ -297,11 +283,12 @@ QString WaylandIntegration::activationToken() {
const auto serial = uint32_t(reinterpret_cast<quintptr>(
native->nativeResourceForIntegration(QByteArray("serial"))));

if (!surface || !seat) {
if (!display || !surface || !seat) {
return {};
}

return XdgActivationToken(
display,
_private->xdgActivation.get_activation_token(),
surface,
seat,
Expand Down

0 comments on commit a3c94a0

Please sign in to comment.