fix: can not click popup menu

also remove useless code in popup
sync: https://github.com/vioken/waylib/pull/265/
This commit is contained in:
rewine 2024-01-16 15:37:48 +08:00 committed by zccrs
parent 649f6177b1
commit eba72f766e
3 changed files with 10 additions and 13 deletions

View File

@ -217,7 +217,7 @@ Item {
}
padding: 0
background: null
closePolicy: Popup.CloseOnPressOutside
closePolicy: Popup.NoAutoClose
XdgSurface {
id: popupSurfaceItem
@ -237,11 +237,6 @@ Item {
}
}
}
onClosed: {
if (waylandSurface)
waylandSurface.surface.unmap()
}
}
}

View File

@ -180,7 +180,7 @@ Item {
}
padding: 0
background: null
closePolicy: Popup.CloseOnPressOutside
closePolicy: Popup.NoAutoClose
XdgSurface {
id: popupSurfaceItem
@ -200,11 +200,6 @@ Item {
}
}
}
onClosed: {
if (waylandSurface)
waylandSurface.surface.unmap()
}
}
}

View File

@ -6,6 +6,7 @@
#include <WServer>
#include <WOutput>
#include <WSurfaceItem>
#include <wxdgsurface.h>
#include <qwbackend.h>
#include <qwdisplay.h>
@ -383,10 +384,16 @@ bool Helper::afterHandleEvent(WSeat *seat, WSurface *watched, QObject *surfaceIt
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::TouchBegin) {
// surfaceItem is qml type: XdgSurfaceItem or LayerSurfaceItem
auto toplevelSurface = qvariant_cast<WToplevelSurface*>(surfaceItem->property("surface"));
auto *toplevelSurface = qvariant_cast<WToplevelSurface*>(surfaceItem->property("surface"));
if (!toplevelSurface)
return false;
Q_ASSERT(toplevelSurface->surface() == watched);
if (auto *xdgSurface = qvariant_cast<WXdgSurface*>(surfaceItem->property("surface"))) {
// TODO(waylib): popupSurface should not inherit WToplevelSurface
if (xdgSurface->isPopup()) {
return false;
}
}
setActivateSurface(toplevelSurface);
}