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

With two or more application modal windows; windows deeper in the stack are receiving requestToFront when not enabled causes an NSBeep.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u60
    • 8u31
    • javafx
    • Any

      From the application's Stage #1 create a new Stage #2 with Modality.APPLICATION_MODAL and owner Stage #1. From Stage #2 create a new Stage #3 with Modality.APPLICATION_MODAL and owner Stage #2. So that there is a stack of 3 windows [Stage #1, Stage #2 and Stage #3] in the windows ArrayList in com.sun.javafx.tk.quantum.GlassStage.windows. With Stage #3 visible, Stage #1 will be disabled with a disableCount of 2 and Stage #2 will be disabled with a disableCount of 1.

      When Stage #3 is hidden GlassStage.windowsSetEnabled(true) will be called which will call com.sun.javafx.tk.quantum.WindowStage.setPlatformEnabled(true) which in turn will call platformWindow.setEnabled(true) which is in com.sun.glass.ui.Window for all the windows except for the one being hidden (Stage #3).

      The problem occurs occurs in the WindowStage.setPlatformEnabled code as below :-

          protected void setPlatformEnabled(boolean enabled) {
              super.setPlatformEnabled(enabled);
              platformWindow.setEnabled(enabled);
              if (enabled) {
                  requestToFront();
              } else {
                  removeActiveWindow(this);
              }
          }

      because after the call platformWindow.setEnabled for Stage #1 the disableCount goes from 2 to 1 and hence Stage #1 is still disabled. However because enabled is true it calls requestToFront() which then causes the NSBeep in the Mac implentation code in GlassWindow+Overrides.m function windowDidBecomeKey:(NSNotification *)notification.

      The easy fix is to just check if the window is enabled and only call requestToFront() if it is. The correct version of setPlatformEnabled is below :-

          protected void setPlatformEnabled(boolean enabled) {
              super.setPlatformEnabled(enabled);
              platformWindow.setEnabled(enabled);
              if (enabled) {
                  if (platformWindow.isEnabled()) { // Check if it is really enabled as might have been nested
                    requestToFront();
                  }
              } else {
                  removeActiveWindow(this);
              }
          }

            ckyang Chien Yang (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: