I would like to make a reservation in advance that I am not familiar with Java and I am interested in this question purely as a user of the Linux system, but all the answers related to technical details are still welcome.

In general, my friend wrote a simple snake under Windows on Java, gave me a chance to test it and I noticed that it slows me down (linux mint cinnamon). Under windows everything works stably for him. Then we started to try different options and found a problem: when the window redraws its contents, it skips frames if the cursor is not within it! We are talking about software rendering, with opengl most likely there is no such problem.

I asked him to make for example the simplest clock with milliseconds. Here is a short video of how it looks. Here is the source of the clock . Here are the watches themselves.

Tell me please, what could be the problem? Why does java, which was originally conceived as a cross-platform virtual machine, behave this way? It is very similar to the fact that the system considers that the window has lost focus when there is no cursor over it, in windows there is also a similar optimization, but in this case the window does not lose focus! Why does he need this cursor?

  • 3
    try adding a call to Toolkit.getDefaultToolkit().sync(); after drawing Toolkit.getDefaultToolkit().sync(); - zRrr
  • one
    @zRrr thanks, helped! Please explain in the form of an answer, how does this solve the problem? - Beast Winterwolf
  • 2
    I have no idea. most likely on the way, someone (x11, video card driver, maybe java2d) optimizes the process, postponing the rendering. sync() makes it display the current state. I hope someone will explain, this is due to the position of the cursor. - zRrr

0