QML 窗口调整大小/移动闪烁 [英] QML window resize/move flicker

查看:26
本文介绍了QML 窗口调整大小/移动闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在开发一个简单的 QML 应用程序,我注意到与 QtWidgets 相比,调整和移动 QML 窗口的大小和移动会产生难看的闪烁代码> 窗口,例如.

I'm developing a simple QML application right now and I noticed that resizing and moving a QML window generates an ugly flicker compared to a QtWidgets window, for instance.

所以我创建了 2 个测试应用程序来显示差异:

So I created 2 test applications to show the difference:

QWidgets:

QML:

正如您所见,应用程序的 QML 版本闪烁得很丑,而 QtWidgets 版本却很干净.现在,当您的 UI 变得越来越复杂时,这会变得非常难看.

As you can see the QML version of the application flickers pretty ugly while the QtWidgets one is clean. Now this gets pretty ugly when your UI grows in complexity.

你有这方面的知识吗?这是一个错误吗?此问题是否有任何修复/解决方法?

Do you have any knowledge about this? Is this a bug? Is there any fix/workaround for this issue?

推荐答案

QML 应用程序大小调整的问题在于更新具有过时几何形状的窗口.解决方法是同步更新和调整大小.

The issue with resizing of QML apps is about updating a window with outdated geometry. The fix would be to sync the updates and resizing.

由于更新计时器可能会突然更新到渲染场景图,它可以随时更新窗口,它会导致绘制带有过时几何图形的内容.https://bugreports.qt.io/browse/QTBUG-46074

Since there might be sudden updates from update timer to render scene graph, which can update the window at any time, it causes drawing of the content with outdated geometry. https://bugreports.qt.io/browse/QTBUG-46074

应使用基本同步或扩展同步来同步调整大小和窗口更新.目前在 Qt 中使用并实现了基本同步,但仍需要将窗口更新(来自计时器)与来自 Windows 管理器的调整大小事件同步.

Either Basic or Extended synchronization should be used to synchronize resizing and the window updates. Currently Basic sync is used and implemented in Qt, but still need to synchronize the window updates (from timer) with resizing events from Windows Manager.

但是,与往常一样,存在一系列问题:

But, as always, there is a list of issues:

当窗口大小调整过快时会出现问题.由于应该一致地发送同步事件(来自 WM),因此下一个在上一个之后:

The problem is observed when the window is being resizing too fast. Since sync events (from WM) should be sent consistently, next after previous:

  1. <= _NET_WM_SYNC_REQUEST 是从 WM 发送的,现在大小正在改变.

  1. <= _NET_WM_SYNC_REQUEST is sent from WM, the size is changing now.

_NET_WM_SYNC_REQUEST 由应用接收和处理.

_NET_WM_SYNC_REQUEST is received and handled by app.

<= 收到的其他一些事件,例如新几何体.

<= some other events received, like new geometry.

.. 更新内容,swapBuffers.

.. update the content, swapBuffers.

=> 将 _NET_WM_SYNC_REQUEST_COUNTER 发送回 WM.

=> Sent _NET_WM_SYNC_REQUEST_COUNTER back to WM.

<= _NET_WM_SYNC_REQUEST 从 WM 再次发送,大小正在变化.

<= _NET_WM_SYNC_REQUEST is sent again from WM, the size is changing.

.. swapBuffers//这里是问题所在,更新是在窗口改变其几何形状时执行的.

.. swapBuffers // here is the problem, the update is performed when the window is being changing its geometry.

_NET_WM_SYNC_REQUEST 已收到并再次处理.

_NET_WM_SYNC_REQUEST received and handled again.

因此,当 (7) swapBuffers 出现在 _NET_WM_SYNC_REQUEST 发送但尚未接收/处理之后,就会出现问题.

So the issue happens when (7) swapBuffers appears after _NET_WM_SYNC_REQUEST is sent but not received/processed yet.

最后的结论:

  • 窗口的实际大小调整是在 _NET_WM_SYNC_REQUEST 由窗口管理器发送后立即开始的. 而不是在应用收到它时.此时窗口甚至可以在发送同步请求时更新,但尚未由应用程序处理.这将使用过时的几何图形绘制内容.
  • _NET_WM_FRAME_DRAWN 可以帮助在调整大小和更新之间进行同步,但也可能不被窗口管理器支持(并且猜测它不支持).
  • Actual resizing of the window is started right after _NET_WM_SYNC_REQUEST is sent by The Window Manager. And not when the app receives it. The window could be even updated at this time, when sync request is sent, but not handled by the app yet. Which will draw the content with outdated geometry.
  • _NET_WM_FRAME_DRAWN could help to sync between resizing and updates, but also might not be supported (and guess it is not) by The Window Manager.

换句话说,无论是基本同步还是扩展同步都无济于事,(至少没有 _NET_WM_FRAME_DRAWN),因为无法知道实际调整大小的时间.

In other words, either basic or extended synchronization does not help, (at least without _NET_WM_FRAME_DRAWN), because there is no way to know when actual resizing is done.

扩展同步协议试图解决这个问题,但由于几何的实际更改是在没有与客户端同步的情况下完成的,正如我所见,没有 _NET_WM_FRAME_DRAWN 总是有机会用过时的几何更新窗口.

Extended sync protocol is a try to handle this, but since actual changing of geometry is done without syncing with the client, as I can see, without _NET_WM_FRAME_DRAWN there is always a chance to update the window with outdated geometry.

https://lists.freedesktop.org/archives/xcb/2019-2月/011280.html

这篇关于QML 窗口调整大小/移动闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆