2022-05-07 11:17:36 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2022-12-15 20:35:22 +00:00
|
|
|
#include "scene/dndiconitem.h"
|
|
|
|
#include "scene/surfaceitem_wayland.h"
|
2023-09-13 05:52:59 +00:00
|
|
|
#include "wayland/datadevice.h"
|
|
|
|
#include "wayland/surface.h"
|
2022-05-07 11:17:36 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
DragAndDropIconItem::DragAndDropIconItem(DragAndDropIcon *icon, Scene *scene, Item *parent)
|
2022-12-18 12:30:40 +00:00
|
|
|
: Item(scene, parent)
|
2022-05-07 11:17:36 +00:00
|
|
|
{
|
2022-12-18 12:30:40 +00:00
|
|
|
m_surfaceItem = std::make_unique<SurfaceItemWayland>(icon->surface(), scene, this);
|
2022-05-07 11:17:36 +00:00
|
|
|
m_surfaceItem->setPosition(icon->position());
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
connect(icon, &DragAndDropIcon::destroyed, this, [this]() {
|
2022-05-07 11:17:36 +00:00
|
|
|
m_surfaceItem.reset();
|
|
|
|
});
|
2023-09-13 17:59:29 +00:00
|
|
|
connect(icon, &DragAndDropIcon::changed, this, [this, icon]() {
|
2022-05-07 11:17:36 +00:00
|
|
|
m_surfaceItem->setPosition(icon->position());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DragAndDropIconItem::~DragAndDropIconItem()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-11-14 06:58:00 +00:00
|
|
|
SurfaceInterface *DragAndDropIconItem::surface() const
|
2022-05-07 11:17:36 +00:00
|
|
|
{
|
2023-11-14 06:58:00 +00:00
|
|
|
return m_surfaceItem ? m_surfaceItem->surface() : nullptr;
|
2023-10-19 14:35:14 +00:00
|
|
|
}
|
|
|
|
|
2023-08-02 12:01:02 +00:00
|
|
|
void DragAndDropIconItem::setOutput(Output *output)
|
|
|
|
{
|
|
|
|
if (m_surfaceItem && output) {
|
2023-10-19 14:35:14 +00:00
|
|
|
m_output = output;
|
2023-08-02 12:01:02 +00:00
|
|
|
m_surfaceItem->surface()->setPreferredBufferScale(output->scale());
|
2023-10-25 16:36:33 +00:00
|
|
|
m_surfaceItem->surface()->setPreferredColorDescription(output->colorDescription());
|
2023-08-02 12:01:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:17:36 +00:00
|
|
|
} // namespace KWin
|
2023-07-05 06:30:14 +00:00
|
|
|
|
|
|
|
#include "moc_dndiconitem.cpp"
|