From 4d161bec48355f2dbfef8ef8c5aa4888eb245caa Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 9 Jan 2020 14:19:34 +0200 Subject: [PATCH] Use less Toplevel::isClient() Summary: Prefer qobject_cast<> over Toplevel::isClient() because it's more type safer and makes code a bit more readable. Hopefully, one day we will be able to get rid of isClient() altogether. Test Plan: Compiles. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D26541 --- layers.cpp | 6 ++++-- plugins/scenes/qpainter/scene_qpainter.cpp | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/layers.cpp b/layers.cpp index 151ff9dfc5..a15a8c7126 100644 --- a/layers.cpp +++ b/layers.cpp @@ -222,8 +222,10 @@ void Workspace::propagateClients(bool propagate_new_clients) cl = new xcb_window_t[ manual_overlays.count() + stacking_order.count()]; pos = 0; for (auto it = stacking_order.constBegin(); it != stacking_order.constEnd(); ++it) { - if ((*it)->isClient()) - cl[pos++] = (*it)->window(); + X11Client *client = qobject_cast(*it); + if (client) { + cl[pos++] = client->window(); + } } for (const auto win : manual_overlays) { cl[pos++] = win; diff --git a/plugins/scenes/qpainter/scene_qpainter.cpp b/plugins/scenes/qpainter/scene_qpainter.cpp index 93b6c49c1e..5f77465558 100644 --- a/plugins/scenes/qpainter/scene_qpainter.cpp +++ b/plugins/scenes/qpainter/scene_qpainter.cpp @@ -243,6 +243,19 @@ static void paintSubSurface(QPainter *painter, const QPoint &pos, QPainterWindow } } +static bool isXwaylandClient(Toplevel *toplevel) +{ + X11Client *client = qobject_cast(toplevel); + if (client) { + return true; + } + Deleted *deleted = qobject_cast(toplevel); + if (deleted) { + return deleted->wasX11Client(); + } + return false; +} + void SceneQPainter::Window::performPaint(int mask, QRegion region, WindowPaintData data) { if (!(mask & (PAINT_WINDOW_TRANSFORMED | PAINT_SCREEN_TRANSFORMED))) @@ -289,7 +302,7 @@ void SceneQPainter::Window::performPaint(int mask, QRegion region, WindowPaintDa // render content QRect source; QRect target; - if (toplevel->isClient()) { + if (isXwaylandClient(toplevel)) { // special case for XWayland windows source = QRect(toplevel->clientPos(), toplevel->clientSize()); target = source;