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:
/**
* 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.
@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.