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

JavaFX menus far displaced (>200 pixels both x and y) with GTK3 and i3 tiling wm

    XMLWordPrintable

Details

    Description

      ADDITIONAL SYSTEM INFORMATION :
      CPU: Intel Xeon E3-1220 v3
      GPU: Nvidia GTX1060
      GPU Driver: Nvidia driver 470.129.06
      OS: Gentoo Linux as of 2022-08-10 with vanilla kernel 5.18.11
      Window System: X.org 21.1.4
      Window Manager: i3 4.20.1
      GTK+: 3.24.34
      JavaFX Release: 18.0.1
      Environment Variables: JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, CLASSPATH, JAVA_COMPILER, USERNAME, LD_LIBRARY_PATH, LD_PRELOAD all unset; SHELL=/bin/bash; DISPLAY=:0; HOSTTYPE=x86_64; OSTYPE=linux-gnu; MACHTYPE=x86_64-pc-linux-gnu

      A DESCRIPTION OF THE PROBLEM :
      On any system with a tiling window manager like i3 or dwm, JavaFX menus (the atual popups that contain the MenuItems) pop up far displaced, in my case (on a screen with 3840x2160 pixels) up to hundreds of pixels too far left and hundreds of pixels too far up.

      Six users reported the same issue for JavaFX 13 and JavaFX 15 on the tiling window managers i3 and dwm:
      https://github.com/javafxports/openjdk-jfx/issues/546



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      On any system with a tiling window manager like i3 or dwm, run a minimal JavaFX app that just shows a MenuBar with a Menu that contains any number of MenuItems, and try to select a MenuItem.
      Example source code is provided below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The MenuItems should always pop up just below the clicked item in the MenuBar.
      ACTUAL -
      The MenuItems always pop up displaced.

      With the JavaFX stage window in a window-manager-tile in the lower right corner, JavaFX menus (the atual popups that contain the MenuItems) pop up far displaced, in my case (on a screen with 3840x2160 pixels) up to hundreds of pixels too far left and hundreds of pixels too far up.

      The menus also behave in an unexpected way:
      Normally, when the user clicks on a menu bar item (pressing the mouse button down and then releasing it immediately, e.g. within 150 milliseconds), the menu pops up and stays up until the user clicks either on a menu item or somewhere beyond the menu.
      With a tiling window manager, when the user clicks on a menu bar item, the menu pops up in a displaced location and disappears as soon as the user releases the mouse button during that first click.
      To actually select a menu item, the user must press and hold the mouse button and "drag" the pointer to a location outside the menu bar item (although no gui element will be dragged with the pointer). After that "drag" motion the menu remains popped up even when the user releases the mouse button that they pressed during the click on the menu bar item. Now the menu reacts to mouse movements while no mouse button is down; that is, menu items get colored and pop up submenus (if associated with those) when the pointer enters their region, and get uncolored and hide submenus (if associated with those) when the pointer enters the region of another menu item. The whole menu hides when the user clicks somewhere outside the menu and any open submenus.

      In full screen mode, they pop up only about one like of text too low. It looks as if the position was calculated with the expectation that the MenuBar would be shown lower, below a window title bar. Tiling window managers like i3 or dwm (if so configured) omit window title bars to save screen real estate. Even with this smaller displacement, menus are still hard to use because of the changed behaviour described above.


      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Menu;
      import javafx.scene.control.MenuBar;
      import javafx.scene.control.MenuItem;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class Main extends Application {
          public static void main(String[] args) { launch(args); }
          public void start(Stage stage) throws Exception {
              MenuItem item1 = new MenuItem("a bug");
              MenuItem item2 = new MenuItem("a complaint");
              Menu menu = new Menu("File",null,item1,item2);
              MenuBar menubar = new MenuBar(menu);
              BorderPane pane = new BorderPane(null,menubar,null,null,null);
              Scene scene = new Scene(pane);
              stage.setScene(scene);
              stage.show();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Run the java vm with the command line option -Djdk.gtk.version=2.
      This makes JavaFX use GTK2 instead of GTK3. With GTK2 the menus behave fine. I can only guess that GTK3 has misbehaviour that GTK2 does not.
      Unfortunately, the release notes for JavaFX 18 say that the GTK2 support is deprecated and will be removed in a future version.
      Hence, later versions of JavaFX will be unusable on desktops with tiling window managers until this bug is fixed.

      FREQUENCY : always


      Attachments

        1. Capture.PNG
          Capture.PNG
          120 kB
        2. Main.java
          0.8 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: