diff --git a/src/dll/src/ContextMenu.cpp b/src/dll/src/ContextMenu.cpp index f8d2ef7..b9310c9 100644 --- a/src/dll/src/ContextMenu.cpp +++ b/src/dll/src/ContextMenu.cpp @@ -1,4 +1,3 @@ - #include #include "Include/Theme.h" #include "Include/ContextMenu.h" @@ -3588,7 +3587,7 @@ namespace Nilesoft //New feature "showdelay" to change the menu show delay time and it is applied immediately without saving the value in the registry. //Gets or sets the time, in milliseconds, that the system waits before displaying a shortcut menu when the mouse cursor is over a submenu item. - //New-Item -Path “HKCU:\Software\Control Panel\Desktop” -Name MenuShowDelay -Force -Value 200 + //New-Item -Path "HKCU:\Software\Control Panel\Desktop" -Name MenuShowDelay -Force -Value 200 if(_context.eval_number(sets->showdelay, obj)) { ::SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &_showdelay[0], 0); @@ -4911,78 +4910,59 @@ namespace Nilesoft WND *ContextMenu::OnMenuCreate(HWND hWnd) { - auto wnd = &_map[hWnd]; - - wnd->ctx = this; + auto wnd = &_windows[hWnd]; wnd->handle = hWnd; - wnd->set_prop(); - set_prop(hWnd); - - /// auto hMenu = (HMENU)::SendMessageW(hWnd, MN_GETHMENU, 0, 0); - // wnd->hMenu = hMenu; - // map_menu_wnd[hMenu] = { hMenu, hWnd }; - - current.hWnd = hWnd; - _level.push_back(wnd); - - Flag cs_style = ::GetClassLongPtrW(hWnd, GCL_STYLE); - Flag style = ::GetWindowLongPtrW(hWnd, GWL_STYLE); - Flag ex_style = ::GetWindowLongPtrW(hWnd, GWL_EXSTYLE); - - auto cs_style_old = cs_style; - auto style_old = style; - auto ex_style_old = ex_style; - - //RECT r = { 0 }; - //AdjustWindowRectEx(&r, (DWORD)style.value, false, (DWORD)ex_style.value); - - cs_style.remove(CS_DROPSHADOW); - style.remove(WS_BORDER); - - ex_style.remove(WS_EX_WINDOWEDGE); - ex_style.remove(WS_EX_DLGMODALFRAME); + wnd->menu = current.menu; + wnd->layer.handle = nullptr; + wnd->blurry.handle = nullptr; - if(composition) - ex_style.add(WS_EX_COMPOSITED); - - //ex_style.add(WS_EX_LAYERED); - //ex_style.add(WS_EX_NOREDIRECTIONBITMAP); - - if(!cs_style.equals(cs_style_old)) - ::SetClassLongPtrW(hWnd, GCL_STYLE, cs_style); + bool composition = false; + ::DwmIsCompositionEnabled(&composition); - if(!style.equals(style_old)) - ::SetWindowLongPtrW(hWnd, GWL_STYLE, style); - - if(!ex_style.equals(ex_style_old)) - ::SetWindowLongPtrW(hWnd, GWL_EXSTYLE, ex_style); - - //::SetClassLongPtrW(hWnd, GCL_STYLE, 0); - //::SetWindowLongPtrW(hWnd, GWL_STYLE, WS_POPUP); - //::SetWindowLongPtrW(hWnd, GWL_EXSTYLE, WS_EX_NOREDIRECTIONBITMAP); - - ::PostMessageW(hWnd, WM_SETCURSOR, 0, 0); - - //int opacity = 100; - //SetLayeredWindowAttributes(hWnd, 0, (255 * 100) / 100, LWA_ALPHA); - //SetLayeredWindowAttributes(hWnd, 0x0ff00, 0, LWA_COLORKEY); + BOOL isGlass = FALSE; if(composition) { + // For Windows 11, apply rounded corners and mica effect + if(ver->IsWindows11OrGreater()) + { + DWM dwm(hWnd); + // Apply rounded corners for Windows 11 + dwm.SetCorner(DWM::Corner::Round); + + // Apply proper backdrop effect based on Windows 11 build + if(ver->Build >= 22523) + { + // For newer Windows 11 builds, use the proper backdrop type + if(_theme.enableTransparency) + { + dwm.SetBackdropType(_theme.mode ? DWM::BackdropType::Acrylic : DWM::BackdropType::Mica); + } + } + else if(ver->Build >= 22000) + { + // For older Windows 11 builds, use the Mica API + if(_theme.enableTransparency) + { + dwm.SetMica(TRUE); + } + } + + // Set dark mode appropriately + dwm.SetImmersiveDarkMode(_theme.mode ? TRUE : FALSE); + } + AccentPolicy ap(hWnd); - //ap.set(AccentPolicy::Disabled); - //ap.set(ap.AcrylicBlurBehind, ap.AllowSetWindowRgn, _theme.background.color.to_ABGR()); - - //if(_theme.transparent) - Compositor::TransparentArea(hWnd); + if(_theme.enableTransparency) + { + if(_theme.background.effect > 0) + { + ap.enable(_theme.background.effect, _theme.background.tintcolor.to_BGR()); + isGlass = TRUE; + } + } } - BOOL ENABLED = TRUE; - ::DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &ENABLED, sizeof(BOOL)); - ::DwmSetWindowAttribute(hWnd, DWMWA_ALLOW_NCPAINT, &ENABLED, sizeof(BOOL)); - ::DwmSetWindowAttribute(hWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &ENABLED, sizeof(BOOL)); - - WindowSubclass::Set(hWnd, MenuSubClassProc, 0, this); - //::ShowWindowAsync(hWnd, SW_HIDE); + wnd->is_glass = isGlass; return wnd; } diff --git a/src/dll/src/Include/Theme.h b/src/dll/src/Include/Theme.h index 5b22866..1bc6613 100644 --- a/src/dll/src/Include/Theme.h +++ b/src/dll/src/Include/Theme.h @@ -565,20 +565,21 @@ namespace Nilesoft } else if(isw11) { + // Updated Windows 11 light theme colors and styling th.separator.color = 0xFFD7D7D7; th.border.color = 0xFFE5E5E5; th.background.color = 0xFFF9F9F9; th.text.color = { 0xFF000000, 0xFFFFFFFF, 0xFF9F9F9F, 0xFF9F9F9F }; th.back.color = { 0xFFF9F9F9, Color::Swap(0xFF0078D4), 0xFFF9F9F9, 0xFFF0F0F0 }; + // Improved Windows 11 styling for borders and padding th.border.padding.left = 4; th.border.padding.right = 4; - th.border.radius = th.radius(2); - th.back.radius = th.radius(1); - th.back.padding.top = 0; - th.back.padding.bottom = 0; - th.back.margin = { 0, 4, 0, 4 }; - th.shadow.size = 3; + th.border.radius = 8; // Windows 11 uses 8px border radius + th.back.radius = 4; // Inner selection radius + th.back.padding = { 8, 6, 8, 6 }; // Better padding for menu items + th.back.margin = { 4, 4, 4, 4 }; // Better margin for menu items + th.shadow.size = 4; // Slightly larger shadow if(enableTransparency) { @@ -613,7 +614,6 @@ namespace Nilesoft } th.shadow.color.a = 0x10; - //th.back.border = th.back.color.nor; th.set_symbols_as_text(0); return th; } @@ -637,20 +637,21 @@ namespace Nilesoft } else if(isw11) { + // Updated Windows 11 dark theme colors and styling th.separator.color = 0xFF3E3E3E; th.border.color = 0xFF3E3E3E; th.background.color = 0xFF2B2B2B; th.text.color = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFF6D6D6D, 0xFF6D6D6D }; th.back.color = { 0xFF2B2B2B, Color::Swap(0xFF0078D4), 0xFF2B2B2B, 0xFF353535 }; + // Improved Windows 11 styling for borders and padding th.border.padding.left = 4; th.border.padding.right = 4; - th.border.radius = th.radius(2); - th.back.radius = th.radius(1); - th.back.padding.top = 0; - th.back.padding.bottom = 0; - th.back.margin = { 0, 4, 0, 4 }; - th.shadow.size = 3; + th.border.radius = 8; // Windows 11 uses 8px border radius + th.back.radius = 4; // Inner selection radius + th.back.padding = { 8, 6, 8, 6 }; // Better padding for menu items + th.back.margin = { 4, 4, 4, 4 }; // Better margin for menu items + th.shadow.size = 4; // Slightly larger shadow if(enableTransparency) { @@ -689,7 +690,6 @@ namespace Nilesoft } th.shadow.color.opacity(25); - //th.back.border = th.back.color.nor; th.set_symbols_as_text(1); return th;