Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8218677

Embedded frame is sized incorrectly on GTK3 with HiDPI scaling

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      ADDITIONAL SYSTEM INFORMATION :
      CentOS 7.3
      JDK11.0.2, also reproduces on JDK12ea28

      A DESCRIPTION OF THE PROBLEM :
      In an SWT application with embedded AWT frame (using SWT_AWT) running with HiDPI scaling (say, GDK_SCALE=2)
      if you resize the container, the size of an embedded AWT frame jumps between the correct and half size.

      My guess is that scaling incorrectly handled in XEmbeddedFramePeer.handleConfigureNotifyEvent

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the snippet on Linux with environment variable GDK_SCALE=2 with SWT 4.10 on the classpath (https://archive.eclipse.org/eclipse/downloads/drops4/R-4.10-201812060815/download.php?dropFile=swt-4.10-gtk-linux-x86_64.zip).
      Resize the application window with the mouse.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      SWT and Swing buttons resize with the application window taking equal sizes
      ACTUAL -
      The size of Swing button fights between normal and half size

      ---------- BEGIN SOURCE ----------
      public static void main(String[] args) {
          
              final Display display = new Display();
              final Shell shell = new Shell(display, SWT.RESIZE | SWT.CLOSE);
              final GridLayout layout = new GridLayout(2, false);
              shell.setLayout(layout);
              
              final org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
              swtButton.setText("SWT");
              swtButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
              
              Composite swingBox = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
              swingBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
              java.awt.Frame frame = SWT_AWT.new_Frame(swingBox);
              JButton jButton = new JButton("Swing");
           frame.add(jButton,java.awt.BorderLayout.CENTER);
          
       
              shell.open();
              shell.pack();
              while (!shell.isDisposed()) {
                  if (!display.readAndDispatch()) {
                      display.sleep();
                  }
              }
              display.dispose();
          }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              pardesha Pardeep Sharma
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: