30void QWaylandWlShellPrivate::shell_get_shell_surface(Resource *resource, uint32_t id,
struct ::wl_resource *surface_res)
33 QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res);
35 QWaylandResource shellSurfaceResource(wl_resource_create(resource->client(), &wl_shell_surface_interface,
36 wl_resource_get_version(resource->handle), id));
45 wl_resource *displayRes = wl_client_get_object(resource->client(), 1);
46 if (!surface->setRole(QWaylandWlShellSurface::role(), displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT))
49 emit q->wlShellSurfaceRequested(surface, shellSurfaceResource);
51 QWaylandWlShellSurface *shellSurface = QWaylandWlShellSurface::fromResource(shellSurfaceResource.resource());
55 shellSurface =
new QWaylandWlShellSurface(q, surface, shellSurfaceResource);
58 m_shellSurfaces.append(shellSurface);
59 emit q->wlShellSurfaceCreated(shellSurface);
82void QWaylandWlShellSurfacePrivate::setWindowType(Qt::WindowType windowType)
84 if (m_windowType == windowType)
86 m_windowType = windowType;
88 Q_Q(QWaylandWlShellSurface);
89 emit q->windowTypeChanged();
99void QWaylandWlShellSurfacePrivate::shell_surface_move(Resource *resource,
100 struct wl_resource *input_device_super,
106 Q_Q(QWaylandWlShellSurface);
107 QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
108 emit q->startMove(input_device);
111void QWaylandWlShellSurfacePrivate::shell_surface_resize(Resource *resource,
112 struct wl_resource *input_device_super,
118 Q_Q(QWaylandWlShellSurface);
120 QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
121 emit q->startResize(input_device, QWaylandWlShellSurface::ResizeEdge(edges));
132void QWaylandWlShellSurfacePrivate::shell_surface_set_transient(Resource *resource,
133 struct wl_resource *parent_surface_resource,
140 Q_Q(QWaylandWlShellSurface);
141 QWaylandSurface *parent_surface = QWaylandSurface::fromResource(parent_surface_resource);
142 setWindowType(Qt::WindowType::SubWindow);
143 emit q->setTransient(parent_surface, QPoint(x,y), flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
146void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resource,
149 struct wl_resource *output_resource)
154 Q_Q(QWaylandWlShellSurface);
155 QWaylandOutput *output = output_resource
156 ? QWaylandOutput::fromResource(output_resource)
158 setWindowType(Qt::WindowType::Window);
159 emit q->setFullScreen(QWaylandWlShellSurface::FullScreenMethod(method), framerate, output);
162void QWaylandWlShellSurfacePrivate::shell_surface_set_popup(Resource *resource, wl_resource *input_device, uint32_t serial, wl_resource *parent, int32_t x, int32_t y, uint32_t flags)
167 Q_Q(QWaylandWlShellSurface);
168 QWaylandSeat *input = QWaylandSeat::fromSeatResource(input_device);
169 QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent);
170 setWindowType(Qt::WindowType::Popup);
171 emit q->setPopup(input, parentSurface, QPoint(x,y));
175void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resource,
176 struct wl_resource *output_resource)
179 Q_Q(QWaylandWlShellSurface);
180 QWaylandOutput *output = output_resource
181 ? QWaylandOutput::fromResource(output_resource)
183 setWindowType(Qt::WindowType::Window);
184 emit q->setMaximized(output);
209void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource,
210 const QString &className)
213 if (className == m_className)
215 Q_Q(QWaylandWlShellSurface);
216 m_className = className;
217 emit q->classNameChanged();
279void QWaylandWlShell::initialize()
281 Q_D(QWaylandWlShell);
282 QWaylandShellTemplate::initialize();
283 QWaylandCompositor *compositor = qobject_cast<QWaylandCompositor *>(extensionContainer());
285 qWarning() <<
"Failed to find QWaylandCompositor when initializing QWaylandWlShell";
288 d->init(compositor->display(), 1);
297QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfacesForClient(QWaylandClient *client)
const
299 Q_D(
const QWaylandWlShell);
300 QList<QWaylandWlShellSurface *> surfsForClient;
301 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
302 if (shellSurface->surface() && shellSurface->surface()->client() == client)
303 surfsForClient.append(shellSurface);
305 return surfsForClient;
308QList<QWaylandWlShellSurface *> QWaylandWlShell::mappedPopups()
const
310 Q_D(
const QWaylandWlShell);
311 QList<QWaylandWlShellSurface *> popupSurfaces;
312 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
313 if (shellSurface->windowType() == Qt::WindowType::Popup
314 && shellSurface->surface() && shellSurface->surface()->hasContent()) {
315 popupSurfaces.append(shellSurface);
318 return popupSurfaces;
321QWaylandClient *QWaylandWlShell::popupClient()
const
323 Q_D(
const QWaylandWlShell);
324 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
325 if (shellSurface->windowType() == Qt::WindowType::Popup
326 && shellSurface->surface() && shellSurface->surface()->hasContent()) {
327 return shellSurface->surface()->client();
428QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface,
const QWaylandResource &res)
429 : QWaylandShellSurfaceTemplate<QWaylandWlShellSurface>(*
new QWaylandWlShellSurfacePrivate)
431 initialize(shell, surface, res);
450void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface *surface,
const QWaylandResource &resource)
452 Q_D(QWaylandWlShellSurface);
454 d->m_surface = surface;
455 d->init(resource.resource());
456 setExtensionContainer(surface);
457 emit surfaceChanged();
459 QWaylandCompositorExtension::initialize();
483QSize QWaylandWlShellSurface::sizeForResize(
const QSizeF &size,
const QPointF &delta, QWaylandWlShellSurface::ResizeEdge edge)
485 qreal width = size.width();
486 qreal height = size.height();
489 else if (edge & RightEdge)
494 else if (edge & BottomEdge)
497 QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0));
498 return newSize.toSize();
531void QWaylandWlShellSurface::sendConfigure(
const QSize &size, ResizeEdge edges)
533 Q_D(QWaylandWlShellSurface);
534 if (!size.isValid()) {
535 qWarning() <<
"Can't configure wl_shell_surface with an invalid size" << size;
538 d->send_configure(edges, size.width(), size.height());