1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the config.tests of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #include "qwaylandshellsurface.h"
44 #include "qwaylanddisplay.h"
45 #include "qwaylandwindow.h"
46 #include "qwaylandinputdevice.h"
47 #include "qwaylanddecoration.h"
49 #include <QtCore/QDebug>
51 QWaylandShellSurface::QWaylandShellSurface(struct wl_shell_surface *shell_surface, QWaylandWindow *window)
52 : m_shell_surface(shell_surface)
55 wl_shell_surface_add_listener(m_shell_surface,&m_shell_surface_listener,this);
58 QWaylandShellSurface::~QWaylandShellSurface()
60 wl_shell_surface_destroy(m_shell_surface);
63 void QWaylandShellSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
65 wl_shell_surface_resize(m_shell_surface,inputDevice->wl_seat(),
66 QWaylandDisplay::currentTimeMillisec(),
70 void QWaylandShellSurface::move(QWaylandInputDevice *inputDevice)
72 wl_shell_surface_move(m_shell_surface,
73 inputDevice->wl_seat(),
74 QWaylandDisplay::currentTimeMillisec());
77 void QWaylandShellSurface::setTopLevel()
79 wl_shell_surface_set_toplevel(m_shell_surface);
82 void QWaylandShellSurface::updateTransientParent(QWindow *parent)
84 QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
85 if (!parent_wayland_window || !parent_wayland_window->shellSurface())
88 // set_transient expects a position relative to the parent
89 QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
90 QWindow *parentWin = m_window->window()->transientParent();
91 transientPos -= parentWin->geometry().topLeft();
92 if (parent_wayland_window->decoration()) {
93 transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
94 transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
98 Qt::WindowFlags wf = m_window->window()->windowFlags();
99 if (wf.testFlag(Qt::ToolTip)
100 || wf.testFlag(Qt::WindowTransparentForInput))
101 flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
103 wl_shell_surface_set_transient(m_shell_surface,
104 parent_wayland_window->wl_surface(),
110 void QWaylandShellSurface::setTitle(const char *title)
112 wl_shell_surface_set_title(m_shell_surface, title);
115 void QWaylandShellSurface::ping(void *data,
116 struct wl_shell_surface *wl_shell_surface,
120 wl_shell_surface_pong(wl_shell_surface, serial);
123 void QWaylandShellSurface::configure(void *data,
124 wl_shell_surface *wl_shell_surface,
129 Q_UNUSED(wl_shell_surface);
130 QWaylandShellSurface *shell_surface = static_cast<QWaylandShellSurface *>(data);
131 shell_surface->m_window->configure(edges, width, height);
134 void QWaylandShellSurface::popup_done(void *data,
135 struct wl_shell_surface *wl_shell_surface)
138 Q_UNUSED(wl_shell_surface);
141 const wl_shell_surface_listener QWaylandShellSurface::m_shell_surface_listener = {
142 QWaylandShellSurface::ping,
143 QWaylandShellSurface::configure,
144 QWaylandShellSurface::popup_done