[rfc][icedtea-web] centre of dialogues to centre of active monitor
Jiri Vanek
jvanek at redhat.com
Thu Jan 10 00:31:01 PST 2013
On 01/09/2013 08:08 PM, Adam Domurad wrote:
> On 01/09/2013 01:53 PM, Adam Domurad wrote:
>> On 01/08/2013 10:54 AM, Jiri Vanek wrote:
>>> All dialogues in ITW are centred into middle of ALL monitors, which is really nasty.
>>> During splashscreen development I have centred into middle of default screen. Well better but not
>>> perfect.
>>> That time Omair suggested to centr into middle of active screen - active here is the one where is
>>> cursor.
>>> Well I have finally come with something like this:)
>>>
>>>
>> This looks OK to me, although I still get the dialog pop-ups flashing on the wrong screen
>> sometimes, before appearing on the correct one.
>>
>> Comments on impl class:
>>> +public class ScreenFinder {
>>> +
>>> + public static GraphicsDevice getCurrentScreen() {
>>> + Point p = MouseInfo.getPointerInfo().getLocation();
>>> + return getScreenOnCoords(p);
>>> +
>>> + }
>>> + public static Rectangle getCurrentScreenSizeWithoutBounds() {
>>> + Point p = MouseInfo.getPointerInfo().getLocation();
>>> + return getScreenOnCoordsWithutBounds(p);
>>> +
>>> + }
>>> +
>>> + public static void centerWindowsToCurrentScreen(Window w) {
>>> + Rectangle bounds = getCurrentScreenSizeWithoutBounds();
>>> + w.setLocation(bounds.x + (bounds.width - w.getWidth())/2,
>>> + bounds.y + (bounds.height - w.getHeight())/2);
>>> +
>>> + }
>>> +
>>> + public static GraphicsDevice getScreenOnCoords(Point point) {
>>> + GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
>>> + GraphicsDevice[] devices = e.getScreenDevices();
>>> + GraphicsDevice result = null;
>>> + //now get the configuration(s) for each device
>>> + for (GraphicsDevice device : devices) {
>>> + //GraphicsConfiguration[] configurations = device.getConfigurations();
>>> + //or?
>>
>> If you've settled on default device, I'd prefer to just simply use it.
>>
>>> + GraphicsConfiguration[] configurations = new
>>> GraphicsConfiguration[]{device.getDefaultConfiguration()};
>>> + for (GraphicsConfiguration config : configurations) {
>>> + Rectangle gcBounds = config.getBounds();
>>> + if (gcBounds.contains(point)) {
>>> + result = device;
>>> + }
>>> + }
>>> + }
>>> + if (result == null) {
>>> + //not found, get the default display
>>> + result = e.getDefaultScreenDevice();
>>> + }
>>> + return result;
>>> + }
>>> +
>>> + public static Rectangle getScreenOnCoordsWithutBounds(Point p) {
>>> + GraphicsDevice device = getScreenOnCoords(p);
>>> + Rectangle screenSize = device.getDefaultConfiguration().getBounds();
>>> + Insets insets =
>>> Toolkit.getDefaultToolkit().getScreenInsets(device.getDefaultConfiguration());
>>> + return new Rectangle((int)screenSize.getX()+insets.left,
>>> (int)screenSize.getY()+insets.top, (int)screenSize.getWidth()-insets.left,
>>> (int)screenSize.getHeight()-insets.bottom);
>>
>> I'd prefer 4 temporary variables for these coordinates.
>>
>>> + }
>>> +
>>> +
>>> +}
>>
>> OK to push otherwise, though.
>>
>> Thanks,
>> -Adam
>
> Hmm actually as well, the "Fatal: Launch Error: " shows up for me on wrong monitor.
Yap, that is true. There are(were) three types of dialogues in icedtea web.
Classical dialogues centerd by internal java implementation. Imho nothing we should touch. (but yes,
they can confuse usser by waiting on different screen).
I guess those dialogues are centred to middle of default screen.
Our dialogues, which were centred into middle of all screens. Nasty, fixed by above patch.
Our dialogues, however centred to somewhere else. Those should be probably found and fixed too.
Waiting with push to future IRC discussion.
Thanx, J.
More information about the distro-pkg-dev
mailing list