1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the config.tests of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
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 void QWaylandShellSurface::resize(QWaylandInputDevice *inputDevice, enum wl_shell_surface_resize edges)
60 wl_shell_surface_resize(m_shell_surface,inputDevice->wl_seat(),
61 QWaylandDisplay::currentTimeMillisec(),
65 void QWaylandShellSurface::move(QWaylandInputDevice *inputDevice)
67 wl_shell_surface_move(m_shell_surface,
68 inputDevice->wl_seat(),
69 QWaylandDisplay::currentTimeMillisec());
72 void QWaylandShellSurface::setTopLevel()
74 wl_shell_surface_set_toplevel(m_shell_surface);
77 void QWaylandShellSurface::updateTransientParent(QWindow *parent)
79 QWaylandWindow *parent_wayland_window = static_cast<QWaylandWindow *>(parent->handle());
80 if (!parent_wayland_window || !parent_wayland_window->shellSurface())
83 // set_transient expects a position relative to the parent
84 QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
85 QWindow *parentWin = m_window->window()->transientParent();
86 transientPos -= parentWin->geometry().topLeft();
87 if (parent_wayland_window->decoration()) {
88 transientPos.setX(transientPos.x() + parent_wayland_window->decoration()->margins().left());
89 transientPos.setY(transientPos.y() + parent_wayland_window->decoration()->margins().top());
93 Qt::WindowFlags wf = m_window->window()->windowFlags();
94 if (wf.testFlag(Qt::ToolTip)
95 || wf.testFlag(Qt::WindowTransparentForInput))
96 flags |= WL_SHELL_SURFACE_TRANSIENT_INACTIVE;
98 wl_shell_surface_set_transient(m_shell_surface,
99 parent_wayland_window->shellSurface()->m_shell_surface,
105 void QWaylandShellSurface::setTitle(const char *title)
107 wl_shell_surface_set_title(m_shell_surface, title);
110 void QWaylandShellSurface::ping(void *data,
111 struct wl_shell_surface *wl_shell_surface,
115 wl_shell_surface_pong(wl_shell_surface, serial);
118 void QWaylandShellSurface::configure(void *data,
119 wl_shell_surface *wl_shell_surface,
124 Q_UNUSED(wl_shell_surface);
125 QWaylandShellSurface *shell_surface = static_cast<QWaylandShellSurface *>(data);
126 shell_surface->m_window->configure(edges, width, height);
129 void QWaylandShellSurface::popup_done(void *data,
130 struct wl_shell_surface *wl_shell_surface)
133 Q_UNUSED(wl_shell_surface);
136 const wl_shell_surface_listener QWaylandShellSurface::m_shell_surface_listener = {
137 QWaylandShellSurface::ping,
138 QWaylandShellSurface::configure,
139 QWaylandShellSurface::popup_done