MCPcopy Create free account
hub / github.com/KDE/kwin / DragAndDropInputFilter

Class DragAndDropInputFilter

src/input.cpp:2564–2914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2562}
2563
2564class DragAndDropInputFilter : public QObject, public InputEventFilter
2565{
2566 Q_OBJECT
2567
2568public:
2569 DragAndDropInputFilter()
2570 : InputEventFilter(InputFilterOrder::DragAndDrop)
2571 {
2572 connect(waylandServer()->seat(), &SeatInterface::dragRequested, this, [](AbstractDataSource *source, SurfaceInterface *origin, quint32 serial, DragAndDropIcon *dragIcon) {
2573 if (auto window = waylandServer()->findWindow(origin->mainSurface())) {
2574 QMatrix4x4 transformation = window->inputTransformation();
2575 transformation.translate(-QVector3D(origin->mapToMainSurface(QPointF(0, 0))));
2576
2577 if (waylandServer()->seat()->hasImplicitPointerGrab(serial)) {
2578 if (waylandServer()->seat()->startPointerDrag(source, origin, waylandServer()->seat()->pointerPos(), transformation, serial, dragIcon)) {
2579 return;
2580 }
2581 }
2582
2583 if (const auto touchPoint = waylandServer()->seat()->touchPointByImplicitGrabSerial(serial)) {
2584 if (waylandServer()->seat()->startTouchDrag(source, origin, touchPoint->position, transformation, serial, dragIcon)) {
2585 return;
2586 }
2587 }
2588
2589 if (waylandServer()->tabletManagerV2()->seat(waylandServer()->seat())->hasImplicitGrab(serial)) {
2590 if (waylandServer()->seat()->startTabletDrag(source, origin, input()->tablet()->position(), transformation, serial, dragIcon)) {
2591 return;
2592 }
2593 }
2594 }
2595
2596 if (source) {
2597 source->dndCancelled();
2598 }
2599 });
2600
2601 connect(waylandServer()->seat(), &SeatInterface::dragStarted, this, [this]() {
2602 AbstractDataSource *dragSource = waylandServer()->seat()->dragSource();
2603 if (!dragSource) {
2604 return;
2605 }
2606
2607 dragSource->setKeyboardModifiers(input()->keyboardModifiers());
2608 connect(input(), &InputRedirection::keyboardModifiersChanged, dragSource, [dragSource](Qt::KeyboardModifiers mods) {
2609 dragSource->setKeyboardModifiers(mods);
2610 });
2611 auto toplevelDrag = waylandServer()->seat()->xdgTopleveldrag();
2612 if (!toplevelDrag) {
2613 return;
2614 }
2615 setupDraggedToplevel();
2616 connect(toplevelDrag, &XdgToplevelDragV1Interface::toplevelChanged, this, &DragAndDropInputFilter::setupDraggedToplevel);
2617 });
2618
2619 connect(waylandServer()->seat(), &SeatInterface::dragEnded, this, [this] {
2620 m_dragTarget = nullptr;
2621 m_lastPos.reset();

Callers

nothing calls this directly

Calls 15

InputEventFilterClass · 0.85
waylandServerFunction · 0.85
QPointFClass · 0.85
inputFunction · 0.85
workspaceFunction · 0.85
inputTransformationMethod · 0.80
mapToMainSurfaceMethod · 0.80
startPointerDragMethod · 0.80
pointerPosMethod · 0.80
startTouchDragMethod · 0.80

Tested by

no test coverage detected