This post was updated on .
Hello there,
I am facing problems when I updated Java on our application from version 8 to 11. I am aware of this HighDPI issues and that is why I also updated to newest JOGAMP libs (2.5.0). I have Eclipse E4 RCP application, which works fine with SWT widgets. My GLCanvas is inside AWT frame that is created inside SWT composite using SWT_AWT bridge. Here is code snippet, how it is created (it is simplified code, I removed stuff that I do not consider important. I can provide more code if needed): // Composite glComposite comes as argument to this method - parental composite GLProfile profile = GLProfile.getDefault(GLProfile.getDefaultDevice()); GLCapabilities capabilities = new GLCapabilities(profile); capabilities.setDoubleBuffered(true); capabilities.setStencilBits(8); com.jogamp.opengl.awt.GLCanvas glCanvasAWT = new com.jogamp.opengl.awt.GLCanvas(capabilities); glCanvasAWT.setAutoSwapBufferMode(false); Frame frame = SWT_AWT.new_Frame(glComposite); frame.setLayout(new java.awt.CardLayout()); frame.add(glCanvasAWT, "GL_RENDER"); frame.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent e) { Display.getDefault().syncExec(() -> { System.out.println("Composite bounds: " + glComposite.getBounds()); System.out.println("Frame bounds: " + frame.getBounds()); System.out.println("AWT canvas bounds: " + glCanvasAWT.getBounds()); } } // other ComponentListener methods }); frame.doLayout(); When I resize my application, componentResized(ComponentEvent) is called and bounds of each object is printed to console. For some reason, they are not all the same - AWT frame and AWT Canvas bounds are smaller than SWT composite bounds and ratio between those bounds is corresponding to current monitor zoom (e.g.: Monitor zoom is 125%, SWT Composite bounds are 1000x1000 -> AWT frame bounds are 800x800). This desynchronization happens only with zoom higher than 100% and it is of course causing my scene to "overlap" behind application. And of course, scene events are not working as expected when bounds are not correct. Am I missing something in my code, is it somehow possible to fix this? Same code works fine on java 8 - bounds are same for SWT and AWT widgets. Thank you for your answers in advance. My versions: JOGAMP 2.5.0 SWT 3.109 Adoptium Terumin jdk 11.0.20 |
Administrator
|
Hi Thomas,
the AWT GLCanvas inside an SWT scenario .. phew, indeed, this is probably not addressed as the zoom factor probably is not forwarded to the AWT component itself. Could you try our own SWT GLCanvas and/or NewtCancasSWT instead? Alternatively, if this is important .. we might need to think about forwarding the zoom factor .. or you must manually apply it. IMHO this is not on our turf, but AWT/SWT integration. |
Hi Sven,
yeah, you are right. I tested this with small app, where I used SWT - AWT Bridge. When rezooming this app, bounds are desynchronized. I tried to investigate, how to forward DPI settings to AWT but I was not successful. :/ What do you mean by manually applaying it? We also use SWT canvas in some cases and this one works fine. But for some performance stuff, AWT canvas used to be better. Thank you. |
I think I found solution - added -Dsun.java2d.uiScale=1 VM argument. Resizing of swt awt bridge scales correctly with this solution.
I got it from here: https://stackoverflow.com/questions/63144081/is-there-a-way-to-disable-native-dpi-scaling-in-swing-via-code-or-command-line Thanks. Best regards Tomas C. |
Administrator
|
It's a workaround that forces the scale in Java2D.
Julien Gouesse | Personal blog | Website
|
Administrator
|
One - if so desired - could file a bugreport with the SWT team and reference this thread?
We could collab on this - however, I believe our two other solutions SWT GLCanvas and NewtCanvasSWT should suffice. |
Free forum by Nabble | Edit this page |