Add a way to attach popups to layer surfaces

This commit is contained in:
Vlad Zahorodnii 2023-03-08 12:27:49 +02:00
parent 7d1fb40d07
commit 92e4bfda61
2 changed files with 26 additions and 0 deletions

View File

@ -6,6 +6,9 @@
#include "window.h"
#include "../qwaylandlayershellintegration_p.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
#include "../qwaylandlayersurface_p.h"
#endif
#include <layershellqt_logging.h>
@ -121,6 +124,21 @@ void Window::setDesiredOutput(QScreen *output)
d->desiredOutput = output;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
void Window::attachPopup(QWindow *window, xdg_popup *popup)
{
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
if (!waylandWindow) {
return;
}
auto shellSurface = dynamic_cast<QWaylandLayerSurface *>(waylandWindow->shellSurface());
if (shellSurface) {
shellSurface->get_popup(popup);
}
}
#endif
Window::Window(QWindow *window)
: QObject(window)
, d(new WindowPrivate(window))

View File

@ -14,6 +14,10 @@
#include "layershellqt_export.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
struct xdg_popup;
#endif
namespace LayerShellQt
{
class WindowPrivate;
@ -93,6 +97,10 @@ public:
*/
static Window *get(QWindow *window);
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
static void attachPopup(QWindow *window, xdg_popup *popup);
#endif
Q_SIGNALS:
void anchorsChanged();
void exclusionZoneChanged();