Advertisement
Guest User

set-focusable.patch

a guest
Mar 22nd, 2017
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.92 KB | None | 0 0
  1. diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java b/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java
  2. --- a/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java
  3. +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java
  4. @@ -115,6 +115,8 @@
  5.      public void setMaximumSize(int maxWidth, int maxHeight);
  6.  
  7.      public void setFullScreen(boolean fullScreen);
  8. +    
  9. +    public void setFocusable(boolean isFocusable);
  10.  
  11.      // =================================================================================================================
  12.      // Functions
  13. diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java
  14. --- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java
  15. +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java
  16. @@ -176,6 +176,10 @@
  17.      @Override public void ungrabFocus() {
  18.          host.ungrabFocus();
  19.      }
  20. +    
  21. +    @Override public void setFocusable(boolean isFocusable) {
  22. +        throw new UnsupportedOperationException("Not supported yet.");
  23. +    }
  24.  
  25.      private void notifyStageListener(final Runnable r) {
  26.          AccessControlContext acc = getAccessControlContext();
  27. diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
  28. --- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
  29. +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java
  30. @@ -76,6 +76,7 @@
  31.      private boolean isAppletStage = false; // true if this is an embedded applet window
  32.      private boolean isPopupStage = false;
  33.      private boolean isInFullScreen = false;
  34. +    private boolean isFocusable = true;
  35.  
  36.      // A flag to indicate whether a call was generated from
  37.      // an input event handler.
  38. @@ -133,6 +134,7 @@
  39.  
  40.      final void setIsPopup() {
  41.          isPopupStage = true;
  42. +        isFocusable = false;
  43.      }
  44.  
  45.      // Called by QuantumToolkit, so we can override initPlatformWindow in subclasses
  46. @@ -157,14 +159,12 @@
  47.                      ownerWindow = ((WindowStage)owner).platformWindow;
  48.                  }
  49.                  boolean resizable = false;
  50. -                boolean focusable = true;
  51.                  int windowMask = rtl ? Window.RIGHT_TO_LEFT : 0;
  52.                  if (isPopupStage) { // TODO: make it a stage style?
  53.                      windowMask |= Window.POPUP;
  54.                      if (style == StageStyle.TRANSPARENT) {
  55.                          windowMask |= Window.TRANSPARENT;
  56.                      }
  57. -                    focusable = false;
  58.                  } else {
  59.                      switch (style) {
  60.                          case UNIFIED:
  61. @@ -189,7 +189,7 @@
  62.                  platformWindow =
  63.                          app.createWindow(ownerWindow, Screen.getMainScreen(), windowMask);
  64.                  platformWindow.setResizable(resizable);
  65. -                platformWindow.setFocusable(focusable);
  66. +                platformWindow.setFocusable(isFocusable);
  67.              }
  68.          }
  69.          platformWindows.put(platformWindow, this);
  70. @@ -510,6 +510,13 @@
  71.          setFullScreen(false);
  72.      }
  73.      
  74. +    @Override public void setFocusable(boolean isFocusable) {
  75. +        this.isFocusable = isFocusable;
  76. +        if (platformWindow != null) {
  77. +            platformWindow.setFocusable(isFocusable);
  78. +        }
  79. +    }
  80. +    
  81.      boolean isApplet() {
  82.          return isPrimaryStage && null != appletWindow;
  83.      }
  84. diff --git a/modules/graphics/src/main/java/javafx/stage/Window.java b/modules/graphics/src/main/java/javafx/stage/Window.java
  85. --- a/modules/graphics/src/main/java/javafx/stage/Window.java
  86. +++ b/modules/graphics/src/main/java/javafx/stage/Window.java
  87. @@ -418,6 +418,10 @@
  88.      }
  89.      public final boolean isFocused() { return focused.get(); }
  90.      public final ReadOnlyBooleanProperty focusedProperty() { return focused.getReadOnlyProperty(); }
  91. +    
  92. +    public void setFocusable(boolean isFocusable) {
  93. +        return impl_getPeer().setFocusable(isFocusable);
  94. +    }
  95.  
  96.      /**
  97.       * The {@code Scene} to be rendered on this {@code Stage}. There can only
  98. diff --git a/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java b/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java
  99. --- a/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java
  100. +++ b/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java
  101. @@ -191,7 +191,11 @@
  102.      public void setFullScreen(boolean fullScreen) {
  103.          notificationSender.changedFullscreen(fullScreen);
  104.      }
  105. -
  106. +    
  107. +    @Override
  108. +    public void setFocusable(boolean isFocusable) {
  109. +    }
  110. +    
  111.      @Override
  112.      public void requestFocus() {
  113.          notificationSender.changedFocused(true, FocusCause.ACTIVATED);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement