29void QWaylandWlShellPrivate::shell_get_shell_surface(Resource *resource, uint32_t id,
struct ::wl_resource *surface_res)
32 QWaylandSurface *surface = QWaylandSurface::fromResource(surface_res);
34 QWaylandResource shellSurfaceResource(wl_resource_create(resource->client(), &wl_shell_surface_interface,
35 wl_resource_get_version(resource->handle), id));
44 wl_resource *displayRes = wl_client_get_object(resource->client(), 1);
45 if (!surface->setRole(QWaylandWlShellSurface::role(), displayRes, WL_DISPLAY_ERROR_INVALID_OBJECT))
48 emit q->wlShellSurfaceRequested(surface, shellSurfaceResource);
50 QWaylandWlShellSurface *shellSurface = QWaylandWlShellSurface::fromResource(shellSurfaceResource.resource());
54 shellSurface =
new QWaylandWlShellSurface(q, surface, shellSurfaceResource);
57 m_shellSurfaces.append(shellSurface);
58 emit q->wlShellSurfaceCreated(shellSurface);
81void QWaylandWlShellSurfacePrivate::setWindowType(Qt::WindowType windowType)
83 if (m_windowType == windowType)
85 m_windowType = windowType;
87 Q_Q(QWaylandWlShellSurface);
88 emit q->windowTypeChanged();
98void QWaylandWlShellSurfacePrivate::shell_surface_move(Resource *resource,
99 struct wl_resource *input_device_super,
105 Q_Q(QWaylandWlShellSurface);
106 QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
107 emit q->startMove(input_device);
110void QWaylandWlShellSurfacePrivate::shell_surface_resize(Resource *resource,
111 struct wl_resource *input_device_super,
117 Q_Q(QWaylandWlShellSurface);
119 QWaylandSeat *input_device = QWaylandSeat::fromSeatResource(input_device_super);
120 emit q->startResize(input_device, QWaylandWlShellSurface::ResizeEdge(edges));
131void QWaylandWlShellSurfacePrivate::shell_surface_set_transient(Resource *resource,
132 struct wl_resource *parent_surface_resource,
139 Q_Q(QWaylandWlShellSurface);
140 QWaylandSurface *parent_surface = QWaylandSurface::fromResource(parent_surface_resource);
141 setWindowType(Qt::WindowType::SubWindow);
142 emit q->setTransient(parent_surface, QPoint(x,y), flags & WL_SHELL_SURFACE_TRANSIENT_INACTIVE);
145void QWaylandWlShellSurfacePrivate::shell_surface_set_fullscreen(Resource *resource,
148 struct wl_resource *output_resource)
153 Q_Q(QWaylandWlShellSurface);
154 QWaylandOutput *output = output_resource
155 ? QWaylandOutput::fromResource(output_resource)
157 setWindowType(Qt::WindowType::Window);
158 emit q->setFullScreen(QWaylandWlShellSurface::FullScreenMethod(method), framerate, output);
161void 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)
166 Q_Q(QWaylandWlShellSurface);
167 QWaylandSeat *input = QWaylandSeat::fromSeatResource(input_device);
168 QWaylandSurface *parentSurface = QWaylandSurface::fromResource(parent);
169 setWindowType(Qt::WindowType::Popup);
170 emit q->setPopup(input, parentSurface, QPoint(x,y));
174void QWaylandWlShellSurfacePrivate::shell_surface_set_maximized(Resource *resource,
175 struct wl_resource *output_resource)
178 Q_Q(QWaylandWlShellSurface);
179 QWaylandOutput *output = output_resource
180 ? QWaylandOutput::fromResource(output_resource)
182 setWindowType(Qt::WindowType::Window);
183 emit q->setMaximized(output);
208void QWaylandWlShellSurfacePrivate::shell_surface_set_class(Resource *resource,
209 const QString &className)
212 if (className == m_className)
214 Q_Q(QWaylandWlShellSurface);
215 m_className = className;
216 emit q->classNameChanged();
278void QWaylandWlShell::initialize()
280 Q_D(QWaylandWlShell);
281 QWaylandShellTemplate::initialize();
282 QWaylandCompositor *compositor = qobject_cast<QWaylandCompositor *>(extensionContainer());
284 qWarning() <<
"Failed to find QWaylandCompositor when initializing QWaylandWlShell";
287 d->init(compositor->display(), 1);
296QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfacesForClient(QWaylandClient *client)
const
298 Q_D(
const QWaylandWlShell);
299 QList<QWaylandWlShellSurface *> surfsForClient;
300 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
301 if (shellSurface->surface() && shellSurface->surface()->client() == client)
302 surfsForClient.append(shellSurface);
304 return surfsForClient;
307QList<QWaylandWlShellSurface *> QWaylandWlShell::mappedPopups()
const
309 Q_D(
const QWaylandWlShell);
310 QList<QWaylandWlShellSurface *> popupSurfaces;
311 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
312 if (shellSurface->windowType() == Qt::WindowType::Popup
313 && shellSurface->surface() && shellSurface->surface()->hasContent()) {
314 popupSurfaces.append(shellSurface);
317 return popupSurfaces;
320QWaylandClient *QWaylandWlShell::popupClient()
const
322 Q_D(
const QWaylandWlShell);
323 for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) {
324 if (shellSurface->windowType() == Qt::WindowType::Popup
325 && shellSurface->surface() && shellSurface->surface()->hasContent()) {
326 return shellSurface->surface()->client();
427QWaylandWlShellSurface::QWaylandWlShellSurface(QWaylandWlShell *shell, QWaylandSurface *surface,
const QWaylandResource &res)
428 : QWaylandShellSurfaceTemplate<QWaylandWlShellSurface>(*
new QWaylandWlShellSurfacePrivate)
430 initialize(shell, surface, res);
449void QWaylandWlShellSurface::initialize(QWaylandWlShell *shell, QWaylandSurface *surface,
const QWaylandResource &resource)
451 Q_D(QWaylandWlShellSurface);
453 d->m_surface = surface;
454 d->init(resource.resource());
455 setExtensionContainer(surface);
456 emit surfaceChanged();
458 QWaylandCompositorExtension::initialize();
482QSize QWaylandWlShellSurface::sizeForResize(
const QSizeF &size,
const QPointF &delta, QWaylandWlShellSurface::ResizeEdge edge)
484 qreal width = size.width();
485 qreal height = size.height();
488 else if (edge & RightEdge)
493 else if (edge & BottomEdge)
496 QSizeF newSize(qMax(width, 1.0), qMax(height, 1.0));
497 return newSize.toSize();
530void QWaylandWlShellSurface::sendConfigure(
const QSize &size, ResizeEdge edges)
532 Q_D(QWaylandWlShellSurface);
533 if (!size.isValid()) {
534 qWarning() <<
"Can't configure wl_shell_surface with an invalid size" << size;
537 d->send_configure(edges, size.width(), size.height());