From a51277f88aaa8024ce83699a5f277e6ffa3fbbf6 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 7 Sep 2023 13:56:54 +0300 Subject: [PATCH] wayland: Remove QPointer from public SurfaceInterface api QPointer is not meant for return values. There are also performance considerations to avoid returning QPointer. --- src/wayland/appmenu_interface.cpp | 1 + src/wayland/autotests/client/test_shadow.cpp | 2 +- src/wayland/autotests/client/test_wayland_blur.cpp | 4 ++-- .../autotests/client/test_wayland_contrast.cpp | 4 ++-- src/wayland/autotests/client/test_wayland_slide.cpp | 6 +++--- src/wayland/contenttype_v1_interface.h | 2 ++ .../keyboard_shortcuts_inhibit_v1_interface.cpp | 7 ++++--- src/wayland/plasmashell_interface.cpp | 2 ++ src/wayland/plasmawindowmanagement_interface.cpp | 1 + src/wayland/surface_interface.cpp | 13 ++++++++----- src/wayland/surface_interface.h | 9 ++++----- src/wayland/surface_interface_p.h | 1 + src/wayland/tablet_v2_interface.cpp | 2 ++ src/wayland/touch_interface_p.h | 2 ++ src/wayland/xdgactivation_v1_interface.cpp | 2 ++ 15 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/wayland/appmenu_interface.cpp b/src/wayland/appmenu_interface.cpp index 5e78cd76fa..f01787e27a 100644 --- a/src/wayland/appmenu_interface.cpp +++ b/src/wayland/appmenu_interface.cpp @@ -7,6 +7,7 @@ #include "display.h" #include "surface_interface.h" +#include #include #include "qwayland-server-appmenu.h" diff --git a/src/wayland/autotests/client/test_shadow.cpp b/src/wayland/autotests/client/test_shadow.cpp index 51e85bca83..6c96358a48 100644 --- a/src/wayland/autotests/client/test_shadow.cpp +++ b/src/wayland/autotests/client/test_shadow.cpp @@ -252,7 +252,7 @@ void ShadowTest::testSurfaceDestroy() // destroy the parent surface QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); - QSignalSpy shadowDestroyedSpy(serverShadow.data(), &QObject::destroyed); + QSignalSpy shadowDestroyedSpy(serverShadow, &QObject::destroyed); surface.reset(); QVERIFY(surfaceDestroyedSpy.wait()); QVERIFY(shadowDestroyedSpy.isEmpty()); diff --git a/src/wayland/autotests/client/test_wayland_blur.cpp b/src/wayland/autotests/client/test_wayland_blur.cpp index 72a3e776d0..8865c41a00 100644 --- a/src/wayland/autotests/client/test_wayland_blur.cpp +++ b/src/wayland/autotests/client/test_wayland_blur.cpp @@ -149,7 +149,7 @@ void TestBlur::testCreate() QCOMPARE(serverSurface->blur()->region(), QRegion(0, 0, 10, 20)); // and destroy - QSignalSpy destroyedSpy(serverSurface->blur().data(), &QObject::destroyed); + QSignalSpy destroyedSpy(serverSurface->blur(), &QObject::destroyed); delete blur; QVERIFY(destroyedSpy.wait()); } @@ -174,7 +174,7 @@ void TestBlur::testSurfaceDestroy() // destroy the parent surface QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); - QSignalSpy blurDestroyedSpy(serverSurface->blur().data(), &QObject::destroyed); + QSignalSpy blurDestroyedSpy(serverSurface->blur(), &QObject::destroyed); surface.reset(); QVERIFY(surfaceDestroyedSpy.wait()); QVERIFY(blurDestroyedSpy.isEmpty()); diff --git a/src/wayland/autotests/client/test_wayland_contrast.cpp b/src/wayland/autotests/client/test_wayland_contrast.cpp index 074e1d5b2f..3661466e6b 100644 --- a/src/wayland/autotests/client/test_wayland_contrast.cpp +++ b/src/wayland/autotests/client/test_wayland_contrast.cpp @@ -161,7 +161,7 @@ void TestContrast::testCreate() QCOMPARE(wl_fixed_from_double(serverSurface->contrast()->saturation()), wl_fixed_from_double(1.7)); // and destroy - QSignalSpy destroyedSpy(serverSurface->contrast().data(), &QObject::destroyed); + QSignalSpy destroyedSpy(serverSurface->contrast(), &QObject::destroyed); delete contrast; QVERIFY(destroyedSpy.wait()); } @@ -186,7 +186,7 @@ void TestContrast::testSurfaceDestroy() // destroy the parent surface QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); - QSignalSpy contrastDestroyedSpy(serverSurface->contrast().data(), &QObject::destroyed); + QSignalSpy contrastDestroyedSpy(serverSurface->contrast(), &QObject::destroyed); surface.reset(); QVERIFY(surfaceDestroyedSpy.wait()); QVERIFY(contrastDestroyedSpy.isEmpty()); diff --git a/src/wayland/autotests/client/test_wayland_slide.cpp b/src/wayland/autotests/client/test_wayland_slide.cpp index 74bbf93f4f..293b2d68f8 100644 --- a/src/wayland/autotests/client/test_wayland_slide.cpp +++ b/src/wayland/autotests/client/test_wayland_slide.cpp @@ -150,7 +150,7 @@ void TestSlide::testCreate() QCOMPARE(serverSurface->slideOnShowHide()->offset(), 15); // and destroy - QSignalSpy destroyedSpy(serverSurface->slideOnShowHide().data(), &QObject::destroyed); + QSignalSpy destroyedSpy(serverSurface->slideOnShowHide(), &QObject::destroyed); delete slide; QVERIFY(destroyedSpy.wait()); } @@ -170,11 +170,11 @@ void TestSlide::testSurfaceDestroy() surface->commit(KWayland::Client::Surface::CommitFlag::None); QVERIFY(slideChanged.wait()); auto serverSlide = serverSurface->slideOnShowHide(); - QVERIFY(!serverSlide.isNull()); + QVERIFY(serverSlide); // destroy the parent surface QSignalSpy surfaceDestroyedSpy(serverSurface, &QObject::destroyed); - QSignalSpy slideDestroyedSpy(serverSlide.data(), &QObject::destroyed); + QSignalSpy slideDestroyedSpy(serverSlide, &QObject::destroyed); surface.reset(); QVERIFY(surfaceDestroyedSpy.wait()); QVERIFY(slideDestroyedSpy.isEmpty()); diff --git a/src/wayland/contenttype_v1_interface.h b/src/wayland/contenttype_v1_interface.h index dd51ea979e..6b8d66148d 100644 --- a/src/wayland/contenttype_v1_interface.h +++ b/src/wayland/contenttype_v1_interface.h @@ -9,6 +9,8 @@ #include "qwayland-server-content-type-v1.h" +#include + namespace KWaylandServer { diff --git a/src/wayland/keyboard_shortcuts_inhibit_v1_interface.cpp b/src/wayland/keyboard_shortcuts_inhibit_v1_interface.cpp index 8d2b4b44c3..56c0a228fa 100644 --- a/src/wayland/keyboard_shortcuts_inhibit_v1_interface.cpp +++ b/src/wayland/keyboard_shortcuts_inhibit_v1_interface.cpp @@ -5,13 +5,14 @@ */ #include "keyboard_shortcuts_inhibit_v1_interface.h" - -#include - #include "display.h" #include "seat_interface.h" #include "surface_interface.h" +#include + +#include + static const int s_version = 1; namespace KWaylandServer diff --git a/src/wayland/plasmashell_interface.cpp b/src/wayland/plasmashell_interface.cpp index 6107261fb3..49b4f5d594 100644 --- a/src/wayland/plasmashell_interface.cpp +++ b/src/wayland/plasmashell_interface.cpp @@ -11,6 +11,8 @@ #include +#include + namespace KWaylandServer { static const quint32 s_version = 8; diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index 5b9e5337a9..88f365b7b8 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/wayland/surface_interface.cpp b/src/wayland/surface_interface.cpp index 9c9f03092f..d0991e8610 100644 --- a/src/wayland/surface_interface.cpp +++ b/src/wayland/surface_interface.cpp @@ -5,9 +5,10 @@ SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "surface_interface.h" +#include "blur_interface.h" #include "clientconnection.h" #include "compositor_interface.h" -#include "contenttype_v1_interface.h" +#include "contrast_interface.h" #include "display.h" #include "fractionalscale_v1_interface_p.h" #include "idleinhibit_v1_interface_p.h" @@ -15,6 +16,8 @@ #include "output_interface.h" #include "pointerconstraints_v1_interface_p.h" #include "region_interface_p.h" +#include "shadow_interface.h" +#include "slide_interface.h" #include "subcompositor_interface.h" #include "subsurface_interface_p.h" #include "surface_interface_p.h" @@ -920,22 +923,22 @@ QRectF SurfaceInterface::boundingRect() const return rect; } -QPointer SurfaceInterface::shadow() const +ShadowInterface *SurfaceInterface::shadow() const { return d->current->shadow; } -QPointer SurfaceInterface::blur() const +BlurInterface *SurfaceInterface::blur() const { return d->current->blur; } -QPointer SurfaceInterface::contrast() const +ContrastInterface *SurfaceInterface::contrast() const { return d->current->contrast; } -QPointer SurfaceInterface::slideOnShowHide() const +SlideInterface *SurfaceInterface::slideOnShowHide() const { return d->current->slide; } diff --git a/src/wayland/surface_interface.h b/src/wayland/surface_interface.h index 6a56a4be3f..c1cb78bdb3 100644 --- a/src/wayland/surface_interface.h +++ b/src/wayland/surface_interface.h @@ -10,7 +10,6 @@ #include #include -#include #include struct wl_resource; @@ -196,22 +195,22 @@ public: /** * @returns The Shadow for this Surface. */ - QPointer shadow() const; + ShadowInterface *shadow() const; /** * @returns The Blur for this Surface. */ - QPointer blur() const; + BlurInterface *blur() const; /** * @returns The Slide for this Surface. */ - QPointer slideOnShowHide() const; + SlideInterface *slideOnShowHide() const; /** * @returns The Contrast for this Surface. */ - QPointer contrast() const; + ContrastInterface *contrast() const; /** * Whether the SurfaceInterface is currently considered to be mapped. diff --git a/src/wayland/surface_interface_p.h b/src/wayland/surface_interface_p.h index f7a547b93d..34bd665895 100644 --- a/src/wayland/surface_interface_p.h +++ b/src/wayland/surface_interface_p.h @@ -11,6 +11,7 @@ #include "utils.h" // Qt #include +#include #include // Wayland #include "qwayland-server-wayland.h" diff --git a/src/wayland/tablet_v2_interface.cpp b/src/wayland/tablet_v2_interface.cpp index ba4459bc5e..31fa8b1f82 100644 --- a/src/wayland/tablet_v2_interface.cpp +++ b/src/wayland/tablet_v2_interface.cpp @@ -11,7 +11,9 @@ #include "utils.h" #include "qwayland-server-tablet-unstable-v2.h" + #include +#include namespace KWaylandServer { diff --git a/src/wayland/touch_interface_p.h b/src/wayland/touch_interface_p.h index ead40bc696..9ab9c69c50 100644 --- a/src/wayland/touch_interface_p.h +++ b/src/wayland/touch_interface_p.h @@ -10,6 +10,8 @@ #include "qwayland-server-wayland.h" +#include + namespace KWaylandServer { class ClientConnection; diff --git a/src/wayland/xdgactivation_v1_interface.cpp b/src/wayland/xdgactivation_v1_interface.cpp index e2d2147a77..8b16341b2c 100644 --- a/src/wayland/xdgactivation_v1_interface.cpp +++ b/src/wayland/xdgactivation_v1_interface.cpp @@ -11,6 +11,8 @@ #include "qwayland-server-xdg-activation-v1.h" +#include + namespace KWaylandServer { static const int s_version = 1;