有没有办法改变X11 ConfigureNotify事件频率是多少? [英] Is there a way to change ConfigureNotify event frequency in X11?

查看:325
本文介绍了有没有办法改变X11 ConfigureNotify事件频率是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了使用ConfigureNotify事件来检测窗口大小调整和重绘应用一个小图形程序。但是,调整大小事件似乎拖动窗口调整大小,这将导致重拉伸是生涩当进来有些缓慢。有没有配置此事件发生率的方法吗?除了上述,有什么方法来检测调整大小的开始/结束,直到最终的尺寸已经达到了我可以延迟重绘?

I've got a little graphical program that uses ConfigureNotify events to detect window resizing and to redraw the application. However, the resize events seem to come in somewhat slowly when dragging the window to resize, which causes the redraw to be jerky. Is there a way to configure this event rate? Barring that, is there a way to detect the start/end of a resize so I can defer redrawing until the final size has been reached?

推荐答案

没有,那是不可能的配置事件发生率;他们刚进来的X服务器认为合适。然而,上述颤抖的一部分可能是precisely,因为你是一个调整大小事件后立即更新窗口(我希望你不这样做的事件处理程序...)的原因是您立即保持X服务器忙你的画,给它一点时间来发送事件了。

No, it is not possible to configure the event rate; they just come in as the X server sees fit. However, part of the jerkiness may be precisely because you are updating the window immediately after an resize event (I hope you don't do it inside the event handler...) The reason is that you immediately keep the X server busy with your painting, giving it little time to send events back.

我对这种行为的标准的解决方案是:调整大小时,用一个定时器定期重绘(比如,每隔200毫秒左右)。使用的宽度和高度,因为它是在油漆程序开始(请记住,你可以得到调整,而绘画活动!)。如果没有发生过自上次计时器事件在宽度/高度的改变,停止计时。

My standard solution for this kind of behaviour is: while resizing, use a timer to repaint at regular intervals (say, every 200 ms or so). Use the width and height as it is at the start of the paint routine (remember that you can receive resize events while painting!). If there has not been a change in width/height since the last timer event, stop the timer.

我建议使用XT工具包来实现定时器等回调;这是一个容易得多比裸Xlib中使用的电话。

I suggest using the Xt toolkit to implement timers and other callbacks; it's a lot easier to use than bare Xlib calls.

这篇关于有没有办法改变X11 ConfigureNotify事件频率是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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