summaryrefslogtreecommitdiff
path: root/examples/wayland/custom-shell/client-plugin/examplesurface.cpp
blob: eb17331c3ff4f8c6c5d5248ca51139a2b6e98be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "examplesurface.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>

ExampleShellSurface::ExampleShellSurface(struct ::qt_example_shell_surface *shell_surface, QWaylandWindow *window)
    : QWaylandShellSurface(window)
    , QtWayland::qt_example_shell_surface(shell_surface)
{
}

ExampleShellSurface::~ExampleShellSurface()
{
}

bool ExampleShellSurface::wantsDecorations() const
{
    return true;
}

//! [setTitle]
void ExampleShellSurface::setTitle(const QString &windowTitle)
{
    set_window_title(windowTitle);
}
//! [setTitle]

void ExampleShellSurface::requestWindowStates(Qt::WindowStates states)
{
    set_minimized(states & Qt::WindowMinimized);
}

//! [applyConfigure]
void ExampleShellSurface::applyConfigure()
{
    if (m_stateChanged)
        QWindowSystemInterface::handleWindowStateChanged(platformWindow()->window(), m_pendingStates);
    m_stateChanged = false;
}
//! [applyConfigure]

void ExampleShellSurface::example_shell_surface_minimize(uint32_t minimized)
{
    m_pendingStates = minimized ? Qt::WindowMinimized : Qt::WindowNoState;
    m_stateChanged = true;
    applyConfigureWhenPossible();
}