[FIXED] Minor: Linux Center Problem

Started by jediTofu, December 13, 2010, 02:20:18

Previous topic - Next topic

jediTofu

Minor bug (if you can even call it that).  On Windows, the window is centered with location set to (-1,-1).  On Linux, it just places it at the top left corner.
cool story, bro

kappa

Basically what is LWJGL's Default behaviour when using Display.setLocation(-1, -1)?

The JavaDoc says if no location is set or if it is set to (-1,-1) the window will be centred.

Accordingly, I'll have a look soon to see if it can be changed and made the default behaviour on Linux.

kappa

I finally got a chance to have a look at this bug. The issue is that the Display window isn't centered when created on linux although Display.setLocation() works fine.

The LWJGL code seems to be providing the correct values and probably worked as expected when it was written. The correct window position values are fed on window creation to XCreateWindow (window centered). However it seems some "modern" window managers override this behaviour and prefer to set their own window positions thus creating the window at (0, 0). Haven't come across an elegant solution to fix this problem without manually moving the window when its created. Quoting someone from the xorg channel when enquiring about a workaround:

QuoteYou don't. If I (as a user) have set a specific window manager policy for where windows go, I'm going to be very annoyed at you for even attempting to work round it.

Once the window is created though it can be moved to where you want using Display.setLocation() and you can even center it using the (-1, -1) values. So users who want to center the Display on linux can do it manually.

Did attempt an initial fix, by adding a line of code at the end of the window creation method that moved it to the center. This works nicely but has a small quirk in that the contents of the desktop from 0,0 appears for a second or so on it before the Display fully initialises (i.e. the window background not being cleared), can be reproduced by creating a Display and then immediately calling Display.setLocation(-1,-1). Not sure if this is acceptable but will try see if it can be ironed out.

kappa


jediTofu

cool story, bro