@@ -2303,6 +2303,37 @@ void overpaintMenuBorder () {
2303
2303
OS .ReleaseDC (handle , dc );
2304
2304
}
2305
2305
2306
+ /**
2307
+ * Fills the remaining area which are not painted by MenuBar and ClientArea
2308
+ * inside the shell window.
2309
+ */
2310
+ private void fillUnpaintedRegionInShellWindow () {
2311
+ if (menuBar == null ) return ;
2312
+ Rectangle clientArea = getClientRectInWindow ();
2313
+ Rectangle menuArea = menuBar .getBounds ();
2314
+ Rectangle windowBounds = getBoundsInPixels ();
2315
+ menuArea .x = menuArea .x - windowBounds .x ;
2316
+ menuArea .y = menuArea .y - windowBounds .y ;
2317
+ long windowRegion = OS .CreateRectRgn (0 , 0 , windowBounds .width , windowBounds .height );
2318
+ long menuRegion = OS .CreateRectRgn (menuArea .x , menuArea .y , menuArea .x + menuArea .width , menuArea .y + menuArea .height );
2319
+ long clientRegion = OS .CreateRectRgn (clientArea .x , clientArea .y , clientArea .x + clientArea .width , clientArea .y + clientArea .height );
2320
+ OS .CombineRgn (windowRegion , windowRegion , menuRegion , OS .RGN_DIFF );
2321
+ OS .CombineRgn (windowRegion , windowRegion , clientRegion , OS .RGN_DIFF );
2322
+ OS .DeleteObject (menuRegion );
2323
+ OS .DeleteObject (clientRegion );
2324
+ int dwRop = display .useDarkModeExplorerTheme ? OS .BLACKNESS : OS .PATCOPY ;
2325
+ long dc = OS .GetWindowDC (handle );
2326
+ POINT pt = null ;
2327
+ pt = new POINT ();
2328
+ OS .GetWindowOrgEx (dc , pt );
2329
+ OS .OffsetRgn (windowRegion , -pt .x , -pt .y );
2330
+ OS .SelectClipRgn (dc , windowRegion );
2331
+ OS .OffsetRgn (windowRegion , pt .x , pt .y );
2332
+ OS .PatBlt (dc , 0 , 0 , windowBounds .width , windowBounds .height , dwRop );
2333
+ OS .DeleteObject (windowRegion );
2334
+ OS .ReleaseDC (handle , dc );
2335
+ }
2336
+
2306
2337
@ Override
2307
2338
long windowProc (long hwnd , int msg , long wParam , long lParam ) {
2308
2339
if (handle == 0 ) return 0 ;
@@ -2347,6 +2378,7 @@ long windowProc (long hwnd, int msg, long wParam, long lParam) {
2347
2378
{
2348
2379
long ret = super .windowProc (hwnd , msg , wParam , lParam );
2349
2380
overpaintMenuBorder ();
2381
+ fillUnpaintedRegionInShellWindow ();
2350
2382
return ret ;
2351
2383
}
2352
2384
}
@@ -2534,6 +2566,16 @@ LRESULT WM_NCHITTEST (long wParam, long lParam) {
2534
2566
if (hittest == OS .HTMENU ) hittest = OS .HTBORDER ;
2535
2567
return new LRESULT (hittest );
2536
2568
}
2569
+ /*
2570
+ * In quarter zoom levels, sometimes the MenuItem in the MenuBar has more height
2571
+ * than the MenuBar, which leads to a gap between the client area and the menu
2572
+ * bar leaving it unpainted and unmanaged. On hovering over the MenuItem, it
2573
+ * leaves the gap area painted with remains of the MenuItem hover overlay. The
2574
+ * event WM_NCHITTEST is sent on hovering over MenuItem and hence the overlay
2575
+ * remains can be cleaned by calling
2576
+ * fillUnpaintedRegionBetweenMenuBarAndClientArea on this event.
2577
+ */
2578
+ fillUnpaintedRegionInShellWindow ();
2537
2579
return null ;
2538
2580
}
2539
2581
0 commit comments