Skip to content
Open
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 @@ -132,7 +132,9 @@ Rectangle getBoundsInPixels () {
if (width == 0) {
int [] buffer = new int [1];
if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, buffer, 0)) {
return new Rectangle (getXInPixels(), getYInPixels(), buffer [0], getHeightInPixels());
int width = DPIUtil.pixelToPoint(buffer [0], getPrimaryMonitorZoomAtStartup());
int widthInPixels = Win32DPIUtils.pointToPixel(width, getNativeZoom());
return new Rectangle (getXInPixels(), getYInPixels(), widthInPixels, getHeightInPixels());
}
}
return new Rectangle (getXInPixels(), getYInPixels(), getWidthInPixels(), getHeightInPixels());
Expand Down Expand Up @@ -226,7 +228,9 @@ Point getSizeInPixels () {
if (width == 0) {
int [] buffer = new int [1];
if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, buffer, 0)) {
return new Point (buffer [0], getHeightInPixels());
int width = DPIUtil.pixelToPoint(buffer [0], getPrimaryMonitorZoomAtStartup());
int widthInPixels = Win32DPIUtils.pointToPixel(width, getNativeZoom());
return new Point (widthInPixels, getHeightInPixels());
}
}
return new Point (getWidthInPixels(), getHeightInPixels());
Expand Down Expand Up @@ -370,7 +374,8 @@ void resize () {
if (image == null && widthInPixels == 0) {
int [] buffer = new int [1];
if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, buffer, 0)) {
widthInPixels = buffer [0];
int width = DPIUtil.pixelToPoint(buffer [0], getPrimaryMonitorZoomAtStartup());
widthInPixels = Win32DPIUtils.pointToPixel(width, getNativeZoom());
}
}
OS.CreateCaret (hwnd, hBitmap, widthInPixels, getHeightInPixels());
Expand Down Expand Up @@ -449,7 +454,8 @@ void setFocus () {
if (image == null && widthInPixels == 0) {
int [] buffer = new int [1];
if (OS.SystemParametersInfo (OS.SPI_GETCARETWIDTH, 0, buffer, 0)) {
widthInPixels = buffer [0];
int width = DPIUtil.pixelToPoint(buffer [0], getPrimaryMonitorZoomAtStartup());
widthInPixels = Win32DPIUtils.pointToPixel(width, getNativeZoom());
}
}
OS.CreateCaret (hwnd, hBitmap, widthInPixels, getHeightInPixels());
Expand Down Expand Up @@ -646,6 +652,13 @@ public void setVisible (boolean visible) {
}
}

private int getPrimaryMonitorZoomAtStartup() {
long hDC = OS.GetDC(0);
int dpi = OS.GetDeviceCaps(hDC, OS.LOGPIXELSX);
OS.ReleaseDC(0, hDC);
return DPIUtil.mapDPIToZoom(dpi);
}

/**
* <b>IMPORTANT:</b> This method is not part of the public
* API for Image. It is marked public only so that it
Expand Down
Loading