I want to simulate a Windows-Snap feature for my application for Linux working under multiple-monitor setups and virtual-desktop setups. Why? I just do, for kicks. If it comes down to it I can use some native C++ code in Linux to achieve this also, and link to it with JNI.
Goal:
- Press Super key + Right arrow, the JFrame is now maximized on the right.
- Press Super key + Right arrow again, the JFrame is now maximized on the left on the next monitor.
Problems:
- Virtual desktops are my problem--I don't know how to detect them in Java. Does anyone know a useful way to achieve this?
- I need to be able to move the JFrame to the next virtual desktop upon snapping right the second time.
Code:
This code successfully detects which physical monitor the window is on, but it does not work with virtual desktops. I did not add any snapping code here, this is for monitor detection only. In case you want to have a look: (use space and enter to swap monitors)
The code showed me the same GraphicsDevice when changing virtual desktop. I'm running Lubuntu x64 15.10 and running Java x64 version 8u25.