LWJGL
May 22, 2012, 14:50:57 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: 1 [2]
  Print  
Author Topic: Full Screen on Linux/Ubuntu/Gnome  (Read 5991 times)
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #15 on: July 07, 2010, 05:38:38 »

I just committed an implementation using Dbus. You can try it with the next build.
Logged

Ciardhubh
Talks Too Much
***
Posts: 159


« Reply #16 on: July 07, 2010, 08:08:43 »

Ah, I'll take a look tomorrow. Just finished my own implementation. I basically wrapped the Display class in my own. If the OS is Linux and Compiz is running, it automatically activates and deactivates the workaround if you go fullscreen or return from fullscreen. Source of my implementation if you're interested.
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #17 on: July 07, 2010, 10:26:15 »

Great, thanks. I'll add your code that detects compiz/dbus availability tomorrow. Wasn't sure how to do that.

<- linux noob.
Logged

spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #18 on: July 09, 2010, 11:48:03 »

The next build will have the improved implementation, including support for gconftool. Btw, I noticed that goconftool doesn't apply the workaround immediately. I had to add a Thread.sleep(200) to get consistent results. Could you verify that this happens with your implementation too?
Logged

Ciardhubh
Talks Too Much
***
Posts: 159


« Reply #19 on: July 09, 2010, 14:16:50 »

Could you verify that this happens with your implementation too?

Unfortunately it does happen with my implementation too.

Gconftool immediately and consistently reports the correct value after setting it, i.e. the following JUnit test runs fine:
Code:
    /**
     * Test whether gconftool takes some time to apply the change.
     */
    @Test
    public void testGconfDelay() throws Exception {
        System.out.println("testGconfDelay");

        LegacyDisplay.setProvider(new GconfProvider());
        LegacyDisplay.setFullscreen(true);

        // Try with non-existing display.
        testGconfDelayRun();

        // Try with existing display
        LegacyDisplay.create();
        testGconfDelayRun();

        LegacyDisplay.destroy();
    }

    /**
     * Activates the workaround. Queries the state to make sure it's on. Then deactivates the
     * workaround and checks again. This is repeated several times.
     */
    private void testGconfDelayRun() {
        boolean expResult;
        boolean result;
        final int testRuns = 200;
        for (int i = 0; i < testRuns; i++) {
            LegacyDisplay.activateLegacyFullscreen();
            expResult = true;
            result = LegacyDisplay.isLegacyFullscreen();
            assertEquals(expResult, result);

            LegacyDisplay.deactivateLegacyFullscreen();
            expResult = false;
            result = LegacyDisplay.isLegacyFullscreen();
            assertEquals(expResult, result);
        }
    }

However, if I take a look at the resulting fullscreen window, in about 50% of the cases of the following test I get the bug.
Code:
    @Test
    public void testVisualDelay() throws Exception {
        System.out.println("testVisualDelay");

        LegacyDisplay.setProvider(new GconfProvider());
        LegacyDisplay.setFullscreen(true);

        final int restRuns = 10;

        for (int i = 0; i < restRuns; i++) {
            LegacyDisplay.create();
            Thread.sleep(1000);
            LegacyDisplay.destroy();
        }
    }

If I add a delay of 100 ms between setting the workaround and creating the display, it drops to 10%-ish (just a ballpark figure). 200ms looks good for about 40 tests. This does not happen when I use DBus.
Logged
Ciardhubh
Talks Too Much
***
Posts: 159


« Reply #20 on: July 12, 2010, 07:43:36 »

I tested your code and it works as expected. Of course it suffers from the same issue as mine: If the VM crashes, it won't deactivate the workaround in Compiz.

For example, this leaves the workaround active if it was deactivated:
Code:
    public static void main(final String[] args) throws LWJGLException, InterruptedException {
        Display.setDisplayMode(Display.getDesktopDisplayMode());
        Display.setFullscreen(true);
        Display.create();

        while (!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
            Display.update();
            Thread.sleep(50);
        }

        // Crash Java VM
        Object[] o = null;
        while (true) {
            o = new Object[]{o};
        }
    }

I considered writing the state to disk before changing it, to be able to recover in case of a crash. However that's not exactly reliable either (Will the program in question ever run properly again? Has the user changed his mind, i.e. does he now want the workaround to stay active? etc.). Plus it's hard to tell how long the workaround will stay in Compiz.
Logged
princec
Nerdus Imperius
*****
Posts: 1782



WWW
« Reply #21 on: July 12, 2010, 11:55:15 »

Can we not find out from the Compiz guys what we should be doing?

Cas Smiley
Logged

Ciardhubh
Talks Too Much
***
Posts: 159


« Reply #22 on: July 13, 2010, 02:54:52 »

Can we not find out from the Compiz guys what we should be doing?

Where's the fun in that? Wink

Call me jaded but that will likely result in a post in a forum or mailing list, never to be answered. This workaround might not be the best solution, but it works, now. At the least, it bridges the time until a more robust solution can be found.
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!