Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qandroidplatformforeignwindow.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qandroidplatformforeignwindow.h"
6
#
include
"androidjnimain.h"
7
#
include
<
QtCore
/
qvariant
.
h
>
8
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
9
#
include
<
QtCore
/
private
/
qjnihelpers_p
.
h
>
10
#
include
<
QtCore
/
qjnitypes
.
h
>
11
12
QT_BEGIN_NAMESPACE
13
14
QAndroidPlatformForeignWindow::QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle)
15
: QAndroidPlatformWindow(window)
16
, m_view(
reinterpret_cast
<jobject>(nativeHandle))
17
, m_nativeViewInserted(
false
)
18
{
19
}
20
21
void
QAndroidPlatformForeignWindow::initialize()
22
{
23
QAndroidPlatformWindow::initialize();
24
25
if
(isEmbeddingContainer()) {
26
m_nativeViewId = m_view.callMethod<jint>(
"getId"
);
27
return
;
28
}
29
30
if
(m_view.isValid())
31
QtAndroid::setViewVisibility(m_view.object(),
false
);
32
}
33
34
QAndroidPlatformForeignWindow::~QAndroidPlatformForeignWindow()
35
{
36
if
(isEmbeddingContainer())
37
return
;
38
39
if
(m_view.isValid())
40
QtAndroid::setViewVisibility(m_view.object(),
false
);
41
42
m_nativeQtWindow.callMethod<
void
>(
"removeNativeView"
);
43
44
}
45
46
void
QAndroidPlatformForeignWindow::setVisible(
bool
visible)
47
{
48
if
(isEmbeddingContainer()) {
49
QAndroidPlatformWindow::setVisible(visible);
50
return
;
51
}
52
53
if
(!m_view.isValid())
54
return
;
55
56
QtAndroid::setViewVisibility(m_view.object(), visible);
57
updateNativeWindow(visible);
58
59
if
(!visible && m_nativeViewInserted) {
60
m_nativeQtWindow.callMethod<
void
>(
"removeNativeView"
);
61
m_nativeViewInserted =
false
;
62
}
else
if
(!m_nativeViewInserted) {
63
addViewToWindow();
64
}
65
sendChildExposeEvents();
66
}
67
68
bool
QAndroidPlatformForeignWindow::isExposed()
const
69
{
70
// A native view is on screen while shown, it has no Surface of Qt's.
71
const
auto
state = qApp->applicationState();
72
return
window()->isVisible()
73
&& (state == Qt::ApplicationInactive || state == Qt::ApplicationActive);
74
}
75
76
void
QAndroidPlatformForeignWindow::applicationStateChanged(Qt::ApplicationState state)
77
{
78
if
(!isEmbeddingContainer()) {
79
if
((state == Qt::ApplicationHidden || state == Qt::ApplicationSuspended)
80
&& m_nativeViewInserted) {
81
m_nativeQtWindow.callMethod<
void
>(
"removeNativeView"
);
82
m_nativeViewInserted =
false
;
83
}
else
if
(m_view.isValid() && !m_nativeViewInserted){
84
addViewToWindow();
85
}
86
}
87
88
QAndroidPlatformWindow::applicationStateChanged(state);
89
}
90
91
WId QAndroidPlatformForeignWindow::winId()
const
92
{
93
if
(isEmbeddingContainer() && m_view.isValid())
94
return
reinterpret_cast
<WId>(m_view.object());
95
if
(m_nativeQtWindow.isValid())
96
return
reinterpret_cast
<WId>(m_nativeQtWindow.object());
97
return
0L;
98
}
99
100
void
QAndroidPlatformForeignWindow::addViewToWindow()
101
{
102
if
(isEmbeddingContainer())
103
return
;
104
105
m_nativeQtWindow.callMethod<
void
>(
"setNativeView"
, m_view);
106
m_nativeViewInserted =
true
;
107
}
108
109
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
plugins
platforms
android
qandroidplatformforeignwindow.cpp
Generated on
for Qt by
1.18.0