We have a full screen java program running on a Linux box. The program is always running, and is the primary reason for the Linux box existing.
We have a bunch of PDF Help files for the program that can be opened through a dropdown menu. When a user clicks one of the help menu items we open XPDF through
final Runtime rt = Runtime.getRuntime();
final String cmd = "runxpdf.sh";
rt.exec(cmd);
This all works fine except that if the user clicks on our program while the XPDF viewer is running it will fall behind our full screen program display.
What we'd like to be able to do is to keep the XPDF program always on top until it is closed. Is this possible to do through executing a program from Java?
The problem is that you need to communicate to a different program, the window manager, to direct that program to keep the window raised.
In X window based systems, there used to be a tool called wmctrl
which would make requests and queries to the current window manager, provided that it was a compliant window manager. I had mixed results using such a tool. Of the 20 or so Linux window managers, the most popular ones do a better job of handling requests (perhaps that's why they are popular?).
The command to switch desktop to the window, raise and focus is
wmctrl -i -a <Window Id>
To get a list of windows managed by the window manager
wmctrl -l
While this won't guaranteed "always on top", you could write a Thread
looping to check and re-raise a window.
As far as a windows solution, someone else will have to comment on that.