Search code examples
javaeclipseeclipse-rcprcp

Eclipse RCP application - how to detect when application is idle?


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.


Solution

  • Maybe that

        display.addFilter(SWT.MouseDown, new Listener() {
            @Override
            public void handleEvent(Event event) {
            }
        });
    

    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.