mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-1351 Borderless UI: Bold frame around IDEA window appears on non-HiDPI display
(cherry picked from commit 06d35de069)
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
56cb1a3e82
commit
443adee080
@@ -52,6 +52,8 @@ typedef enum _PROCESS_DPI_AWARENESS {
|
||||
} PROCESS_DPI_AWARENESS;
|
||||
#endif
|
||||
|
||||
typedef BOOL(WINAPI AdjustWindowRectExForDpiFunc)(LPRECT, DWORD, BOOL, DWORD, UINT);
|
||||
|
||||
class AwtObject;
|
||||
typedef AwtObject* PDATA;
|
||||
|
||||
|
||||
@@ -1676,12 +1676,18 @@ BOOL AwtFrame::HasCustomDecoration()
|
||||
|
||||
void GetSysInsets(RECT* insets, AwtFrame* pFrame) {
|
||||
if (pFrame->IsUndecorated()) {
|
||||
::SetRect(insets, 0, 0, 0, 0);
|
||||
::SetRectEmpty(insets);
|
||||
return;
|
||||
}
|
||||
insets->left = insets->right = ::GetSystemMetrics(pFrame->IsResizable() ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME);
|
||||
insets->top = insets->bottom = ::GetSystemMetrics(pFrame->IsResizable() ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME);
|
||||
insets->top += ::GetSystemMetrics(SM_CYCAPTION);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(AwtWin32GraphicsDevice::DeviceIndexForWindow(pFrame->GetHWnd()));
|
||||
int dpi = device ? device->GetScaleX() * 96 : 96;
|
||||
|
||||
// GetSystemMetricsForDpi gives incorrect values, use AdjustWindowRectExForDpi for border metrics instead
|
||||
RECT rect = {};
|
||||
DWORD style = pFrame->IsResizable() ? WS_OVERLAPPEDWINDOW : WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME;
|
||||
AwtToolkit::AdjustWindowRectExForDpi(&rect, style, FALSE, NULL, dpi);
|
||||
::SetRect(insets, -rect.left, -rect.top, rect.right, rect.bottom);
|
||||
}
|
||||
|
||||
LRESULT HitTestNCA(AwtFrame* frame, int x, int y) {
|
||||
@@ -1692,7 +1698,7 @@ LRESULT HitTestNCA(AwtFrame* frame, int x, int y) {
|
||||
GetWindowRect(frame->GetHWnd(), &rcWindow);
|
||||
|
||||
// Get the frame rectangle, adjusted for the style without a caption.
|
||||
RECT rcFrame = {0};
|
||||
RECT rcFrame = {};
|
||||
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
|
||||
|
||||
USHORT uRow = 1;
|
||||
|
||||
@@ -141,6 +141,8 @@ extern "C" JNIEXPORT jboolean JNICALL AWTIsHeadless() {
|
||||
|
||||
#define IDT_AWT_MOUSECHECK 0x101
|
||||
|
||||
AdjustWindowRectExForDpiFunc* AwtToolkit::lpAdjustWindowRectExForDpi = NULL;
|
||||
|
||||
static LPCTSTR szAwtToolkitClassName = TEXT("SunAwtToolkit");
|
||||
|
||||
static const int MOUSE_BUTTONS_WINDOWS_SUPPORTED = 5; //three standard buttons + XBUTTON1 + XBUTTON2.
|
||||
@@ -671,6 +673,12 @@ BOOL AwtToolkit::Initialize(BOOL localPump) {
|
||||
|
||||
awt_dnd_initialize();
|
||||
|
||||
HMODULE hLibUser32Dll = JDK_LoadSystemLibrary("User32.dll");
|
||||
if (hLibUser32Dll != NULL) {
|
||||
lpAdjustWindowRectExForDpi = (AdjustWindowRectExForDpiFunc*)GetProcAddress(hLibUser32Dll, "AdjustWindowRectExForDpi");
|
||||
::FreeLibrary(hLibUser32Dll);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialization of the touch keyboard related variables.
|
||||
*/
|
||||
|
||||
@@ -439,6 +439,12 @@ public:
|
||||
static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg);
|
||||
static BOOL activateKeyboardLayout(HKL hkl);
|
||||
|
||||
static INLINE BOOL AdjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi)
|
||||
{
|
||||
return lpAdjustWindowRectExForDpi != NULL ?
|
||||
lpAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi) : ::AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
|
||||
}
|
||||
|
||||
HANDLE m_waitEvent;
|
||||
volatile DWORD eventNumber;
|
||||
volatile BOOL isInDoDragDropLoop;
|
||||
@@ -505,6 +511,8 @@ private:
|
||||
HANDLE m_inputMethodWaitEvent;
|
||||
LRESULT m_inputMethodData;
|
||||
|
||||
static AdjustWindowRectExForDpiFunc *lpAdjustWindowRectExForDpi;
|
||||
|
||||
/* track display changes - used by palette-updating code.
|
||||
This is a workaround for a windows bug that prevents
|
||||
WM_PALETTECHANGED event from occurring immediately after
|
||||
|
||||
Reference in New Issue
Block a user