File indexing completed on 2024-05-19 16:34:45

0001 /*
0002     SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "scene/dndiconitem.h"
0008 #include "scene/surfaceitem_wayland.h"
0009 #include "wayland/datadevice_interface.h"
0010 #include "wayland/surface_interface.h"
0011 
0012 namespace KWin
0013 {
0014 
0015 DragAndDropIconItem::DragAndDropIconItem(KWaylandServer::DragAndDropIcon *icon, Scene *scene, Item *parent)
0016     : Item(scene, parent)
0017 {
0018     m_surfaceItem = std::make_unique<SurfaceItemWayland>(icon->surface(), scene, this);
0019     m_surfaceItem->setPosition(icon->position());
0020 
0021     connect(icon, &KWaylandServer::DragAndDropIcon::destroyed, this, [this]() {
0022         m_surfaceItem.reset();
0023     });
0024     connect(icon, &KWaylandServer::DragAndDropIcon::changed, this, [this, icon]() {
0025         m_surfaceItem->setPosition(icon->position());
0026     });
0027 }
0028 
0029 DragAndDropIconItem::~DragAndDropIconItem()
0030 {
0031 }
0032 
0033 void DragAndDropIconItem::frameRendered(quint32 timestamp)
0034 {
0035     if (m_surfaceItem) {
0036         m_surfaceItem->surface()->frameRendered(timestamp);
0037     }
0038 }
0039 
0040 } // namespace KWin