Warning, file /plasma/kwin/src/xwaylandwindow.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include "xwaylandwindow.h"
0011 #include "wayland/surface_interface.h"
0012 
0013 using namespace KWaylandServer;
0014 
0015 namespace KWin
0016 {
0017 
0018 XwaylandWindow::XwaylandWindow()
0019 {
0020     // The wayland surface is associated with the Xwayland window asynchronously.
0021     connect(this, &Window::surfaceChanged, this, &XwaylandWindow::associate);
0022 }
0023 
0024 void XwaylandWindow::associate()
0025 {
0026     if (surface()->isMapped()) {
0027         initialize();
0028     } else {
0029         // Queued connection because we want to mark the window ready for painting after
0030         // the associated surface item has processed the new surface state.
0031         connect(surface(), &SurfaceInterface::mapped, this, &XwaylandWindow::initialize, Qt::QueuedConnection);
0032     }
0033 }
0034 
0035 void XwaylandWindow::initialize()
0036 {
0037     if (!readyForPainting()) { // avoid "setReadyForPainting()" function calling overhead
0038         if (syncRequest().counter == XCB_NONE) { // cannot detect complete redraw, consider done now
0039             setReadyForPainting();
0040         }
0041     }
0042 }
0043 
0044 bool XwaylandWindow::wantsSyncCounter() const
0045 {
0046     // When the frame window is resized, the attached buffer will be destroyed by
0047     // Xwayland, causing unexpected invalid previous and current window pixmaps.
0048     // With the addition of multiple window buffers in Xwayland 1.21, X11 clients
0049     // are no longer able to destroy the buffer after it's been committed and not
0050     // released by the compositor yet.
0051     static const quint32 xwaylandVersion = xcb_get_setup(kwinApp()->x11Connection())->release_number;
0052     return xwaylandVersion >= 12100000;
0053 }
0054 
0055 } // namespace KWin