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

setLocationRelativeTo() places the window incorrectly on multi-mon-xinerama when comp is invisible

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b27
    • CPU:
      generic, x86
    • OS:
      generic, linux_redhat_9.0
    • Verification:
      Verified

      Description

      I am calling window.setLocationRelativeTo() with a component that is invisible. According to the specification, this method is supposed to place the window at the center of the screen when the given component is null or invisible. This actually behaves differently on different platforms, on a multi-monitor system.

      On Windows with virtual screen, the window is getting placed at the center of the primary display.
      On Linux with xinerama (virtual screen), the window is getting placed at the center of the virtual screen. The specification does not say anything about how this would work on a virtual screen setup.

      This behavioral difference is due to the code given below:
      setLocation((screenSize.width - paneSize.width) / 2,
                 (screenSize.height - paneSize.height) / 2);
      Here the screen size is obtained by calling Toolkit.getScreenSize(). This method behaves differently on win32 and xinerama. on Win32, it returns the size of the prim display but on xinerama it returns the size of the virtual screen. Hence the window also gets centered accordingly. (A bug is filed against this method: 5100801 which is evaluated as a doc bug)

      What i am expecting here is to have a uniform approach across all virtual screen setups, be it xinerama or win32.
      1. If the intention is to place with window at the center of the virtual screen, it must be done for both the cases - win32 as well as xinerama.

      2. Alternatively setLocationRelativeTo() can use Window centering APIs (GraphicsEnv.getCenterPoint()) to center the window within the primary display. This method works consistently across all setups.

      3. Another option is, the 2 cases such as component being null and component being invisible can be handled differently. When the component is null, it can use option-2. If the component is invisible, GraphicsConfig can be obtained from the invisible component and the window can be centered within the monitor where the invisible component is located.

      The specification must be enhanced to clarify this for a multi-monitor scenario (virtual screen as well as independent screens).

      I have attached a sample test which shows a message dialog using JOptionPane. It covers both the cases where the component is null and the component is invisible. Run it on a win32 - virtual screen setup as well as on a linux-xinerama setup. If the window is placed at the center of the virtual screen on xinerama, the bug is reproduced.
      ###@###.### 10/12/04 06:45 GMT

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              art Artem Ananiev (Inactive)
              Reporter:
              pmohansunw Praveen Mohan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: