54 | 54 |
DEFINE_CONST_CHAR(setWindowProperty);
|
55 | 55 |
DEFINE_CONST_CHAR(pluginVersion);
|
56 | 56 |
DEFINE_CONST_CHAR(disableOverrideCursor);
|
|
57 |
DEFINE_CONST_CHAR(enableDxcb);
|
|
58 |
DEFINE_CONST_CHAR(isEnableDxcb);
|
57 | 59 |
|
58 | 60 |
static void setWindowProperty(QWindow *window, const char *name, const QVariant &value)
|
59 | 61 |
{
|
|
110 | 112 |
return reinterpret_cast<QString(*)()>(pv)();
|
111 | 113 |
}
|
112 | 114 |
|
113 | |
void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
|
114 | |
{
|
115 | |
if (!DApplication::isDXcbPlatform())
|
116 | |
return;
|
117 | |
|
|
115 |
static QWindow *ensureWindowHandle(QWidget *widget)
|
|
116 |
{
|
118 | 117 |
QWidget *window = widget->window();
|
119 | 118 |
QWindow *handle = window->windowHandle();
|
120 | 119 |
|
|
126 | 125 |
window->setAttribute(Qt::WA_NativeWindow, false);
|
127 | 126 |
|
128 | 127 |
// dxcb version >= 1.1.6
|
129 | |
if (!pluginVersion().isEmpty()) {
|
|
128 |
if (!DPlatformWindowHandle::pluginVersion().isEmpty()) {
|
130 | 129 |
/// TODO: Avoid call parentWidget()->enforceNativeChildren().
|
131 | 130 |
qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, save_flag);
|
132 | 131 |
}
|
133 | |
|
134 | |
Q_ASSERT_X(handle, "DPlatformWindowHandler:", "widget window handle is NULL.");
|
135 | |
|
136 | |
if (Q_UNLIKELY(!handle))
|
137 | |
return;
|
138 | |
}
|
139 | |
|
140 | |
if (handle->property(_useDxcb).toBool())
|
141 | |
return;
|
142 | |
|
143 | |
Q_ASSERT_X(!handle->handle(), "DPlatformWindowHandler:",
|
144 | |
"Must be called before window handle has been created. See also QWidget::windowHandle()");
|
145 | |
|
146 | |
handle->setProperty(_useDxcb, true);
|
147 | |
}
|
148 | |
|
149 | |
void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window)
|
|
132 |
}
|
|
133 |
|
|
134 |
return handle;
|
|
135 |
}
|
|
136 |
|
|
137 |
void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget)
|
150 | 138 |
{
|
151 | 139 |
if (!DApplication::isDXcbPlatform())
|
152 | 140 |
return;
|
153 | 141 |
|
154 | |
if (window->handle()) {
|
|
142 |
QWindow *handle = ensureWindowHandle(widget);
|
|
143 |
|
|
144 |
enableDXcbForWindow(handle);
|
|
145 |
}
|
|
146 |
|
|
147 |
void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window)
|
|
148 |
{
|
|
149 |
if (!DApplication::isDXcbPlatform())
|
|
150 |
return;
|
|
151 |
|
|
152 |
QFunctionPointer enable_dxcb = nullptr;
|
|
153 |
|
|
154 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
|
155 |
enable_dxcb = qApp->platformFunction(_enableDxcb);
|
|
156 |
#endif
|
|
157 |
|
|
158 |
if (enable_dxcb) {
|
|
159 |
(*reinterpret_cast<bool(*)(QWindow*)>(enable_dxcb))(window);
|
|
160 |
} else if (window->handle()) {
|
155 | 161 |
Q_ASSERT_X(window->property(_useDxcb).toBool(), "DPlatformWindowHandler:",
|
156 | 162 |
"Must be called before window handle has been created. See also QWindow::handle()");
|
157 | 163 |
} else {
|
|
161 | 167 |
|
162 | 168 |
void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget, bool redirectContent)
|
163 | 169 |
{
|
164 | |
enableDXcbForWindow(widget);
|
165 | |
|
166 | |
if (isEnabledDXcb(widget)) {
|
167 | |
widget->windowHandle()->setProperty(_redirectContent, redirectContent);
|
168 | |
}
|
|
170 |
enableDXcbForWindow(ensureWindowHandle(widget), redirectContent);
|
169 | 171 |
}
|
170 | 172 |
|
171 | 173 |
void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window, bool redirectContent)
|
172 | 174 |
{
|
|
175 |
window->setProperty(_redirectContent, redirectContent);
|
|
176 |
|
173 | 177 |
enableDXcbForWindow(window);
|
174 | |
|
175 | |
if (isEnabledDXcb(window)) {
|
176 | |
window->setProperty(_redirectContent, redirectContent);
|
177 | |
}
|
178 | 178 |
}
|
179 | 179 |
|
180 | 180 |
bool DPlatformWindowHandle::isEnabledDXcb(const QWidget *widget)
|
181 | 181 |
{
|
182 | |
return widget->windowHandle() && widget->windowHandle()->property(_useDxcb).toBool();
|
|
182 |
if (QWindow *handle = widget->windowHandle()) {
|
|
183 |
return isEnabledDXcb(handle);
|
|
184 |
}
|
|
185 |
|
|
186 |
return false;
|
183 | 187 |
}
|
184 | 188 |
|
185 | 189 |
bool DPlatformWindowHandle::isEnabledDXcb(const QWindow *window)
|
186 | 190 |
{
|
|
191 |
QFunctionPointer is_enable_dxcb = nullptr;
|
|
192 |
|
|
193 |
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
|
194 |
is_enable_dxcb = qApp->platformFunction(_isEnableDxcb);
|
|
195 |
#endif
|
|
196 |
|
|
197 |
if (is_enable_dxcb) {
|
|
198 |
return (*reinterpret_cast<bool(*)(const QWindow*)>(is_enable_dxcb))(window);
|
|
199 |
}
|
|
200 |
|
187 | 201 |
return window->property(_useDxcb).toBool();
|
188 | 202 |
}
|
189 | 203 |
|