Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5#include "androidjnimain.h"
6#include <QtCore/qvariant.h>
7#include <qpa/qwindowsysteminterface.h>
8#include <QtCore/private/qjnihelpers_p.h>
9#include <QtCore/qjnitypes.h>
10
12
14 : QAndroidPlatformWindow(window), m_view(nullptr), m_nativeViewInserted(false)
15{
16 m_view = reinterpret_cast<jobject>(nativeHandle);
18 m_nativeViewId = m_view.callMethod<jint>("getId");
19 return;
20 }
21
22 if (m_view.isValid())
23 QtAndroid::setViewVisibility(m_view.object(), false);
24}
25
27{
29 return;
30
31 if (m_view.isValid())
32 QtAndroid::setViewVisibility(m_view.object(), false);
33
34 m_nativeQtWindow.callMethod<void>("removeNativeView");
35
36}
37
39{
41
43 return;
44
45 if (m_nativeViewInserted)
47}
48
50{
53 return;
54 }
55
56 if (!m_view.isValid())
57 return;
58
59 QtAndroid::setViewVisibility(m_view.object(), visible);
60
61 if (!visible && m_nativeViewInserted) {
62 m_nativeQtWindow.callMethod<void>("removeNativeView");
63 m_nativeViewInserted = false;
64 } else if (!m_nativeViewInserted) {
65 addViewToWindow();
66 }
67}
68
70{
71 if (!isEmbeddingContainer()) {
73 && m_nativeViewInserted) {
74 m_nativeQtWindow.callMethod<void>("removeNativeView");
75 m_nativeViewInserted = false;
76 } else if (m_view.isValid() && !m_nativeViewInserted){
77 addViewToWindow();
78 }
79 }
80
82}
83
85{
86 if (isEmbeddingContainer() && m_view.isValid())
87 return reinterpret_cast<WId>(m_view.object());
88 if (m_nativeQtWindow.isValid())
89 return reinterpret_cast<WId>(m_nativeQtWindow.object());
90 return 0L;
91}
92
93void QAndroidPlatformForeignWindow::addViewToWindow()
94{
96 return;
97
98 jint x = 0, y = 0, w = -1, h = -1;
99 if (!geometry().isNull())
100 geometry().getRect(&x, &y, &w, &h);
101
102 m_nativeQtWindow.callMethod<void>("setNativeView", m_view, x, y, qMax(w, 1), qMax(h, 1));
103 m_nativeViewInserted = true;
104}
105
void applicationStateChanged(Qt::ApplicationState state) override
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle)
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void setNativeGeometry(const QRect &geometry)
virtual void applicationStateChanged(Qt::ApplicationState)
QtJniTypes::QtWindow m_nativeQtWindow
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
void setViewVisibility(jobject view, bool visible)
ApplicationState
Definition qnamespace.h:262
@ ApplicationHidden
Definition qnamespace.h:264
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint y
GLfloat GLfloat GLfloat GLfloat h
QObject::connect nullptr
aWidget window() -> setWindowTitle("New Window Title")
[2]