blob: bb954e8e737f55dde453b8495a1845f18661f83a (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
#include <QtCore/QObject>
#include <QtCore/QVariantMap>
#include <QtCore/QPointer>
#include <QtQuick/QQuickItem>
#include <QtCore/QSet>
#include <QtAppManCommon/global.h>
#include <QtAppManManager/application.h>
QT_BEGIN_NAMESPACE_AM
class WindowItem;
// A Window object exists for every application window that is managed by the application manager
// and has been shown (mapped) at least once.
// In the Wayland case, every Window is a surface, but not every surface is a Window. That's why
// there is a separate WindowSurface class in waylandcompositor.h.
class Window : public QObject
{
Q_OBJECT
Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/WindowObject 2.0 UNCREATABLE")
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
Q_PROPERTY(ContentState contentState READ contentState NOTIFY contentStateChanged)
Q_PROPERTY(Application* application READ application CONSTANT)
Q_PROPERTY(bool popup READ isPopup CONSTANT)
Q_PROPERTY(QPoint requestedPopupPosition READ requestedPopupPosition NOTIFY requestedPopupPositionChanged)
public:
enum ContentState {
SurfaceWithContent,
SurfaceNoContent,
NoSurface
};
Q_ENUM(ContentState)
Window(Application *app);
virtual ~Window();
virtual bool isInProcess() const = 0;
virtual Application *application() const;
// Controls how many items (which are views from a model-view perspective) are currently rendering this window
void registerItem(WindowItem *item);
void unregisterItem(WindowItem *item);
const QSet<WindowItem*> &items() const { return m_items; }
void setPrimaryItem(WindowItem *item);
WindowItem *primaryItem() const { return m_primaryItem; }
// This really depends on the windowing system - currently only Wayland with xdg-shell 6
// supports popups natively
virtual bool isPopup() const = 0;
virtual QPoint requestedPopupPosition() const = 0;
// Whether there's any view (WindowItem) holding a reference to this window
bool isBeingDisplayed() const;
virtual ContentState contentState() const = 0;
Q_INVOKABLE virtual bool setWindowProperty(const QString &name, const QVariant &value) = 0;
Q_INVOKABLE virtual QVariant windowProperty(const QString &name) const = 0;
Q_INVOKABLE virtual QVariantMap windowProperties() const = 0;
Q_INVOKABLE virtual void close() = 0;
virtual QSize size() const = 0;
Q_INVOKABLE virtual void resize(const QSize &size) = 0;
signals:
void sizeChanged();
void windowPropertyChanged(const QString &name, const QVariant &value);
void isBeingDisplayedChanged();
void contentStateChanged();
void requestedPopupPositionChanged();
protected:
QPointer<Application> m_application;
QSet<WindowItem*> m_items;
WindowItem *m_primaryItem{nullptr};
};
QT_END_NAMESPACE_AM
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE_AM(Window*))
|