Skip to content

Commit

Permalink
8231865: JFXPanel sends resize event with size 0x0 on HiDPI devices
Browse files Browse the repository at this point in the history
Reviewed-by: angorya
  • Loading branch information
prsadhuk committed Jul 10, 2023
1 parent 8635f81 commit 8fef6a3
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,15 @@ protected void processComponentEvent(ComponentEvent e) {
private void updateComponentSize() {
int oldWidth = pWidth;
int oldHeight = pHeight;
// It's quite possible to get negative values here, this is not
// what JavaFX embedded scenes/stages are ready to
pWidth = Math.max(0, getWidth());
pHeight = Math.max(0, getHeight());
if (getBorder() != null) {
Insets i = getBorder().getBorderInsets(this);
pWidth -= (i.left + i.right);
pHeight -= (i.top + i.bottom);
}
// It's quite possible to get negative values here, this is not
// what JavaFX embedded scenes/stages are ready to
pWidth = Math.max(0, getWidth());
pHeight = Math.max(0, getHeight());
double newScaleFactorX = scaleFactorX;
double newScaleFactorY = scaleFactorY;
Graphics g = getGraphics();
Expand All @@ -626,6 +626,9 @@ private void updateComponentSize() {
newScaleFactorY = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().
getDefaultTransform().getScaleY();
if (oldWidth == 0 && oldHeight == 0 && pWidth == 0 && pHeight == 0) {
return;
}
if (oldWidth != pWidth || oldHeight != pHeight ||
newScaleFactorX != scaleFactorX || newScaleFactorY != scaleFactorY)
{
Expand Down

0 comments on commit 8fef6a3

Please sign in to comment.