Eclipse RCP 应用程序 - 如何检测应用程序何时空闲?
我正在编写一个 Eclipse RCP 应用程序,除了我自己的插件之外,该应用程序还将有其他插件贡献,并且需要确定应用程序何时空闲(即一段时间内没有活动、应用程序最小化等)以及何时发生变化(即应用程序返回前台、单击鼠标等)。
我遇到的问题是,我要捕获所有应用程序击键和鼠标移动/单击...使用它来重置计时器,当计时器被击中时,可能会发生一些空闲处理(即通知服务器闲散 - 然后当我们切换到活跃状态时 - 没有什么密集的)。但是,应用程序窗口 shell 不会接收各种视图的子事件等,因此要么我遗漏了某些内容,要么这是错误的方法。
谁能提供解决方案吗?我不是在寻找系统范围的空闲 - 只是应用程序的空闲。
谢谢。
I am writing an Eclipse RCP application that will have other plugin contributions besides my own, and need to determine when the application is idle (i.e. no activity for a period of time, application is minimized, etc.), and when that changes (i.e. application is brought back to the foreground, a mouse is clicked, etc.).
The problem I'm having is that I was going to capture all application keystrokes and mouse moves/clicks...using that to reset a timer, and when the timer is hit, then some idle processing can occur (i.e. informing a server of the idleness - and then again when we switch to active - nothing intensive). However, the application window shell does not receive child events for the various views, etc. so either I'm missing something, or this is the wrong approach.
Can anyone offer a solution? I'm not looking for system-wide idleness - just application idleness.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Eclipse IDE 已经有类似执行垃圾收集的功能,看一下 Bundle org.eclipse.ui.ide.application 中的 org.eclipse.ui.internal.ide.application.IDEIdleHelper 类
The Eclipse IDE already has something similar to perform Garbage Collection, take a look at the class org.eclipse.ui.internal.ide.application.IDEIdleHelper in Bundle org.eclipse.ui.ide.application
也许这
就是您正在寻找的(您也可以添加其他事件)?
这是在组件明智地完成事件处理之前执行的...
但是通常不建议使用它 - 它应该是一个非常有限的用例,所以。
Maybe that
is what you're looking for (you can add other events, too)?
This is executed before event handling is done component wise...
But its use is not generally recommended - it should be a very restricted use case, so.
您可以利用以下事实:当没有更多消息需要处理时,
readAndDispatch
方法将返回 false。像这样的事情:You can use the fact that the
readAndDispatch
method will return false when there are no more messages to process. Something like this: