From 9d0823038e20c373aa864a07d383b80af1cbafd6 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 23 Apr 2021 18:14:00 +0200 Subject: [PATCH] Native window decorations: fixed occasional double window title bar when creating many frames or dialogs (issue #315) --- CHANGELOG.md | 2 ++ .../flatlaf-natives-windows/src/main/cpp/HWNDMap.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 327a4aa2..8ed1b298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ FlatLaf Change Log `FlatPopupFactory.fixToolTipLocation()`. (issue #305) - IntelliJ Themes: Fixed background colors of DesktopPane and DesktopIcon in all themes. +- Native window decorations: Fixed occasional double window title bar when + creating many frames or dialogs. (issue #315) ## 1.1.2 diff --git a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/HWNDMap.cpp b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/HWNDMap.cpp index ae909ee1..8f9ae24a 100644 --- a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/HWNDMap.cpp +++ b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/HWNDMap.cpp @@ -102,17 +102,17 @@ void HWNDMap::remove( HWND key ) { } int HWNDMap::binarySearch( HWND key ) { + __int64 ikey = reinterpret_cast<__int64>( key ); int low = 0; int high = size - 1; while( low <= high ) { int mid = (low + high) >> 1; - HWND midKey = table[mid].key; - int cmp = midKey - key; - if( cmp < 0 ) + __int64 midKey = reinterpret_cast<__int64>( table[mid].key ); + if( midKey < ikey ) low = mid + 1; - else if( cmp > 0 ) + else if( midKey > ikey ) high = mid - 1; else return mid;