PDA

View Full Version : Goofy fix(?) for windows not refreshing at start


djlucas
January 30th, 2008, 05:04 AM
I had a minor problem, but an annoying one to me. I've run across it a few times in various forums, but I haven't managed to find a real 'fix' for it yet. Anyway, upon starting compiz, windows do not refresh until I switch desktops once. So in my startup script I dropped in the keyboard commands to rotate the screen and rotate it back using the cube. Java was a perfect QnD choice. It's a dumb, 'beat it into submission' type of solution, but it works for me and I figured I'd share. :-P

Enjoy.

-- DJ
===============================================
Execute commands between dashed lines.
-----------------------------------------------------------------
cat > RobotRotate.java << "EOF"
// RobotRotate.java
// SendKeys for X in java ;-)
// Slightly modified from the example at:
// -http://www.java-tips.org/java-se-tips/java.awt/how-to-use-robot-class-in-java.html

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class RobotRotate {

public static void main(String[] args) {

try {

Robot robot = new Robot();
// Give 4 seconds for the compiz/emerald to start
robot.delay(4000);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_LEFT);
// Wait a half second for screen to rotate completely
robot.delay(500);
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_ALT);

} catch (AWTException e) {
e.printStackTrace();
}
}
}
EOF
javac RobotRotate.java
cp RobotRotate.class </path/to/some/dir/in/$CLASSPATH>
-----------------------------------------------------------
Now run 'java RobotRotate' immediately after starting compiz. You might have to adjust the delay if your system is slower..donno...it's a quick and dirty hack at best, but it works for me.
===============================================