Skip to content

8340870: [WIN] Checkbox is not sized according to uiScale #26221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ protected void paintToImage(Component c, Image image, Graphics g,
ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
part.getControlName(c), part.getValue(),
State.getValue(part, state),
0, 0, w, h, w, dpi);
w, h, w, dpi);

SunWritableRaster.markDirty(dbi);
}
Expand Down
18 changes: 7 additions & 11 deletions src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,18 @@ private static Long getTheme(String widget, int dpi) {

private static native void paintBackground(int[] buffer, long theme,
int part, int state,
int rectRight, int rectBottom,
int w, int h, int stride);

public static void paintBackground(int[] buffer, String widget,
int part, int state, int x, int y, int w, int h, int stride, int dpi) {
int part, int state, int w, int h, int stride, int dpi) {
readLock.lock();
try {
/* For widgets and parts in the lists, we get the part size
for the current screen DPI to scale them better. */
Dimension d = (partSizeWidgets.contains(widget)
&& partSizeWidgetParts.contains(Integer.valueOf(part)))
? getPartSize(getTheme(widget, dpi), part, state)
: new Dimension(w, h);

paintBackground(buffer, getTheme(widget, dpi), part, state,
d.width, d.height, w, h, stride);
// getTheme is not guaranteed to retrieve the theme handle for the desired DPI
// if assets for it aren't already loaded by the theming system. In that case,
// the closest loaded asset will be used and scaled to fit the provided height
// and width by paintBackground. The resulting image won't be as crisp as the
// native resolution asset, but it will be the correct size.
paintBackground(buffer, getTheme(widget, dpi), part, state, w, h, stride);
} finally {
readLock.unlock();
}
Expand Down
11 changes: 3 additions & 8 deletions src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static void copyDIBToBufferedImage(int *pDstBits, int *pSrcBits,
*/
JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_paintBackground
(JNIEnv *env, jclass klass, jintArray array, jlong theme, jint part, jint state,
jint rectRight, jint rectBottom, jint w, jint h, jint stride) {
jint w, jint h, jint stride) {

int *pDstBits=NULL;
int *pSrcBits=NULL;
Expand Down Expand Up @@ -440,14 +440,9 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_paintBackground

rect.left = 0;
rect.top = 0;
rect.bottom = h;
rect.right = w;

if (OpenThemeDataForDpiFunc) {
rect.bottom = rectBottom;
rect.right = rectRight;
} else {
rect.bottom = h;
rect.right = w;
}
ZeroMemory(pSrcBits,(BITS_PER_PIXEL>>3)*w*h);

HRESULT hres = DrawThemeBackgroundFunc(hTheme, memDC, part, state, &rect, NULL);
Expand Down