File indexing completed on 2024-11-10 04:57:14

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.h"
0010 #include "wayland/surface.h"
0011 
0012 namespace KWin
0013 {
0014 
0015 DragAndDropIconItem::DragAndDropIconItem(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, &DragAndDropIcon::destroyed, this, [this]() {
0022         m_surfaceItem.reset();
0023     });
0024     connect(icon, &DragAndDropIcon::changed, this, [this, icon]() {
0025         m_surfaceItem->setPosition(icon->position());
0026     });
0027 }
0028 
0029 DragAndDropIconItem::~DragAndDropIconItem()
0030 {
0031 }
0032 
0033 SurfaceInterface *DragAndDropIconItem::surface() const
0034 {
0035     return m_surfaceItem ? m_surfaceItem->surface() : nullptr;
0036 }
0037 
0038 void DragAndDropIconItem::setOutput(Output *output)
0039 {
0040     if (m_surfaceItem && output) {
0041         m_output = output;
0042         m_surfaceItem->surface()->setPreferredBufferScale(output->scale());
0043         m_surfaceItem->surface()->setPreferredColorDescription(output->colorDescription());
0044     }
0045 }
0046 
0047 } // namespace KWin
0048 
0049 #include "moc_dndiconitem.cpp"