< prev index next >

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

Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX

*** 601,611 **** } /* * Fix for 4046446. */ ! SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE); /* Set default colors. */ m_colorForeground = colorForeground; m_colorBackground = colorBackground; --- 601,611 ---- } /* * Fix for 4046446. */ ! Reshape(x, y, w, h); /* Set default colors. */ m_colorForeground = colorForeground; m_colorBackground = colorBackground;
*** 1085,1094 **** --- 1085,1095 ---- WIN_MSG(WM_NULL) WIN_MSG(WM_CREATE) WIN_MSG(WM_DESTROY) WIN_MSG(WM_MOVE) WIN_MSG(WM_SIZE) + WIN_MSG(WM_DPICHANGED) WIN_MSG(WM_ACTIVATE) WIN_MSG(WM_SETFOCUS) WIN_MSG(WM_KILLFOCUS) WIN_MSG(WM_ENABLE) WIN_MSG(WM_SETREDRAW)
*** 1503,1515 **** break; } case WM_SIZE: { RECT r; ! // fix 4128317 : use GetClientRect for full 32-bit int precision and // to avoid negative client area dimensions overflowing 16-bit params - robi ! ::GetClientRect( GetHWnd(), &r ); mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top); //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam)); SetCompositionWindow(r); break; } --- 1504,1516 ---- break; } case WM_SIZE: { RECT r; ! // fix 4128317 : use GetWindowRect for full 32-bit int precision and // to avoid negative client area dimensions overflowing 16-bit params - robi ! ::GetWindowRect(GetHWnd(), &r); mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top); //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam)); SetCompositionWindow(r); break; }
*** 3886,3897 **** if (!::IsWindowVisible(hWnd)) { return; } HWND hTop = GetTopLevelParentForWindow(hWnd); ::ClientToScreen(hTop, &p); ! int sx = ScaleUpX(x) - p.x; ! int sy = ScaleUpY(y) - p.y; if (!m_bitsCandType) { SetCandidateWindow(m_bitsCandType, sx, sy); return; } for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) { --- 3887,3898 ---- if (!::IsWindowVisible(hWnd)) { return; } HWND hTop = GetTopLevelParentForWindow(hWnd); ::ClientToScreen(hTop, &p); ! int sx = ScaleUpAbsX(x) - p.x; ! int sy = ScaleUpAbsY(y) - p.y; if (!m_bitsCandType) { SetCandidateWindow(m_bitsCandType, sx, sy); return; } for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
*** 4765,4802 **** ((BYTE*)(dest++))[3] = alpha; } } } int AwtComponent::ScaleUpX(int x) { ! int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? x : device->ScaleUpX(x); } int AwtComponent::ScaleUpY(int y) { ! int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? y : device->ScaleUpY(y); } int AwtComponent::ScaleDownX(int x) { ! int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? x : device->ScaleDownX(x); } int AwtComponent::ScaleDownY(int y) { ! int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? y : device->ScaleDownY(y); } jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); if (!::IsWindowVisible(GetHWnd())) { return NULL; --- 4766,4840 ---- ((BYTE*)(dest++))[3] = alpha; } } } + int AwtComponent::GetScreenImOn() { + HWND hWindow = GetAncestor(GetHWnd(), GA_ROOT); + AwtComponent *comp = AwtComponent::GetComponent(hWindow); + if (comp && comp->IsTopLevel()) { + return comp->GetScreenImOn(); + } + return AwtWin32GraphicsDevice::DeviceIndexForWindow(hWindow); + } + int AwtComponent::ScaleUpX(int x) { ! int screen = GetScreenImOn(); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? x : device->ScaleUpX(x); } + int AwtComponent::ScaleUpAbsX(int x) { + int screen = GetScreenImOn(); + Devices::InstanceAccess devices; + AwtWin32GraphicsDevice* device = devices->GetDevice(screen); + return device == NULL ? x : device->ScaleUpAbsX(x); + } + int AwtComponent::ScaleUpY(int y) { ! int screen = GetScreenImOn(); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? y : device->ScaleUpY(y); } + int AwtComponent::ScaleUpAbsY(int y) { + int screen = GetScreenImOn(); + Devices::InstanceAccess devices; + AwtWin32GraphicsDevice* device = devices->GetDevice(screen); + return device == NULL ? y : device->ScaleUpAbsY(y); + } + int AwtComponent::ScaleDownX(int x) { ! int screen = GetScreenImOn(); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? x : device->ScaleDownX(x); } + int AwtComponent::ScaleDownAbsX(int x) { + int screen = GetScreenImOn(); + Devices::InstanceAccess devices; + AwtWin32GraphicsDevice* device = devices->GetDevice(screen); + return device == NULL ? x : device->ScaleDownAbsX(x); + } + int AwtComponent::ScaleDownY(int y) { ! int screen = GetScreenImOn(); Devices::InstanceAccess devices; AwtWin32GraphicsDevice* device = devices->GetDevice(screen); return device == NULL ? y : device->ScaleDownY(y); } + int AwtComponent::ScaleDownAbsY(int y) { + int screen = GetScreenImOn(); + Devices::InstanceAccess devices; + AwtWin32GraphicsDevice* device = devices->GetDevice(screen); + return device == NULL ? y : device->ScaleDownAbsY(y); + } + jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); if (!::IsWindowVisible(GetHWnd())) { return NULL;
*** 5088,5098 **** jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst, target, id, when, modifiers, ScaleDownX(x + insets.left), ScaleDownY(y + insets.top), ! ScaleDownX(xAbs), ScaleDownY(yAbs), clickCount, popupTrigger, button); if (safe_ExceptionOccurred(env)) { env->ExceptionDescribe(); env->ExceptionClear(); --- 5126,5136 ---- jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst, target, id, when, modifiers, ScaleDownX(x + insets.left), ScaleDownY(y + insets.top), ! ScaleDownAbsX(xAbs), ScaleDownAbsY(yAbs), clickCount, popupTrigger, button); if (safe_ExceptionOccurred(env)) { env->ExceptionDescribe(); env->ExceptionClear();
*** 5161,5172 **** mouseWheelEventConst, target, id, when, modifiers, ScaleDownX(x + insets.left), ScaleDownY(y + insets.top), ! ScaleDownX(xAbs), ! ScaleDownY(yAbs), clickCount, popupTrigger, scrollType, scrollAmount, roundedWheelRotation, preciseWheelRotation); DASSERT(mouseWheelEvent != NULL); --- 5199,5210 ---- mouseWheelEventConst, target, id, when, modifiers, ScaleDownX(x + insets.left), ScaleDownY(y + insets.top), ! ScaleDownAbsX(xAbs), ! ScaleDownAbsY(yAbs), clickCount, popupTrigger, scrollType, scrollAmount, roundedWheelRotation, preciseWheelRotation); DASSERT(mouseWheelEvent != NULL);
*** 5672,5683 **** if (::IsWindow(p->GetHWnd())) { RECT rect; VERIFY(::GetWindowRect(p->GetHWnd(),&rect)); result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V", ! p->ScaleDownX(rect.left), ! p->ScaleDownY(rect.top)); } ret: env->DeleteGlobalRef(self); if (result != NULL) --- 5710,5721 ---- if (::IsWindow(p->GetHWnd())) { RECT rect; VERIFY(::GetWindowRect(p->GetHWnd(),&rect)); result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V", ! p->ScaleDownAbsX(rect.left), ! p->ScaleDownAbsY(rect.top)); } ret: env->DeleteGlobalRef(self); if (result != NULL)
< prev index next >