Is there a way to change ConfigureNotify event frequency in X11?

我的梦境 提交于 2019-12-02 02:03:37

问题


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?


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/14161264/is-there-a-way-to-change-configurenotify-event-frequency-in-x11

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!