Skip to content

Commit

Permalink
8270874: JFrame paint artifacts when dragged from standard monitor to…
Browse files Browse the repository at this point in the history
… HiDPI monitor

Reviewed-by: jdv
  • Loading branch information
mrserb committed Nov 18, 2021
1 parent ce0f00f commit 03473b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
26 changes: 18 additions & 8 deletions src/java.desktop/windows/native/libawt/windows/awt_Component.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -47,6 +47,7 @@
#include "awt_Win32GraphicsDevice.h"
#include "Hashtable.h"
#include "ComCtl32Util.h"
#include "math.h"

#include <Region.h>

Expand Down Expand Up @@ -2234,8 +2235,8 @@ void AwtComponent::PaintUpdateRgn(const RECT *insets)
*/
RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
RECT* un[2] = {0, 0};
DWORD i;
for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
DWORD i;
for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
int width = r->right-r->left;
int height = r->bottom-r->top;
if (width > 0 && height > 0) {
Expand All @@ -2247,13 +2248,22 @@ void AwtComponent::PaintUpdateRgn(const RECT *insets)
}
}
}
// The Windows may request to update the small region of pixels that
// cannot be represented in the user's space, in this case, we will
// request to repaint the smallest non-empty bounding box in the user's
// space
int screen = GetScreenImOn();
Devices::InstanceAccess devices;
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
float scaleX = (device == NULL) ? 1 : device->GetScaleX();
float scaleY = (device == NULL) ? 1 : device->GetScaleY();
for(i = 0; i < 2; i++) {
if (un[i] != 0) {
DoCallback("handleExpose", "(IIII)V",
ScaleDownX(un[i]->left),
ScaleDownY(un[i]->top),
ScaleDownX(un[i]->right - un[i]->left),
ScaleDownY(un[i]->bottom - un[i]->top));
int x1 = floor(un[i]->left / scaleX);
int y1 = floor(un[i]->top / scaleY);
int x2 = ceil(un[i]->right / scaleX);
int y2 = ceil(un[i]->bottom / scaleY);
DoCallback("handleExpose", "(IIII)V", x1, y1, x2 - x1, y2 - y1);
}
}
delete [] buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import javax.swing.SwingUtilities;

/* @test
* @bug 8147440 8147016
* @bug 8147440 8147016 8270874
* @summary HiDPI (Windows): Swing components have incorrect sizes after
* changing display resolution
* @run main/manual/othervm WindowResizingOnMovingToAnotherDisplay
Expand Down

11 comments on commit 03473b4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 03473b4 Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on 03473b4 Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-03473b4c in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 03473b4c from the openjdk/jdk repository.

The commit being backported was authored by Sergey Bylokhov on 18 Nov 2021 and was reviewed by Jayathirth D V.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u mrserb-backport-03473b4c:mrserb-backport-03473b4c
$ git checkout mrserb-backport-03473b4c
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u mrserb-backport-03473b4c

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 03473b4 Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 03473b4 Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb Could not automatically backport 03473b4c to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b mrserb-backport-03473b4c
$ git fetch --no-tags https://git.openjdk.java.net/jdk 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ git cherry-pick --no-commit 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d.

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 03473b4 Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 03473b4 Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb Could not automatically backport 03473b4c to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b mrserb-backport-03473b4c
$ git fetch --no-tags https://git.openjdk.java.net/jdk 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ git cherry-pick --no-commit 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d.

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 03473b4 Dec 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 03473b4 Dec 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb the backport was successfully created on the branch mrserb-backport-03473b4c in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 03473b4c from the openjdk/jdk repository.

The commit being backported was authored by Sergey Bylokhov on 18 Nov 2021 and was reviewed by Jayathirth D V.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-03473b4c:mrserb-backport-03473b4c
$ git checkout mrserb-backport-03473b4c
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-03473b4c

@mrserb
Copy link
Member Author

@mrserb mrserb commented on 03473b4 Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 03473b4 Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrserb Could not automatically backport 03473b4c to openjdk/jdk11u-dev due to conflicts in the following files:

  • src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

To manually resolve these conflicts run the following commands in your personal fork of openjdk/jdk11u-dev:

$ git checkout -b mrserb-backport-03473b4c
$ git fetch --no-tags https://git.openjdk.java.net/jdk 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ git cherry-pick --no-commit 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d
$ # Resolve conflicts
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk11u-dev with the title Backport 03473b4c271b2ec7f0ebdb0edabadf7f36816b9d.

Please sign in to comment.