|
1 |
| - |
2 | 1 | #include <pch.h>
|
3 | 2 | #include "Include/Theme.h"
|
4 | 3 | #include "Include/ContextMenu.h"
|
@@ -3588,7 +3587,7 @@ namespace Nilesoft
|
3588 | 3587 |
|
3589 | 3588 | //New feature "showdelay" to change the menu show delay time and it is applied immediately without saving the value in the registry.
|
3590 | 3589 | //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.
|
3591 |
| - //New-Item -Path “HKCU:\Software\Control Panel\Desktop” -Name MenuShowDelay -Force -Value 200 |
| 3590 | + //New-Item -Path "HKCU:\Software\Control Panel\Desktop" -Name MenuShowDelay -Force -Value 200 |
3592 | 3591 | if(_context.eval_number(sets->showdelay, obj))
|
3593 | 3592 | {
|
3594 | 3593 | ::SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &_showdelay[0], 0);
|
@@ -4911,78 +4910,59 @@ namespace Nilesoft
|
4911 | 4910 |
|
4912 | 4911 | WND *ContextMenu::OnMenuCreate(HWND hWnd)
|
4913 | 4912 | {
|
4914 |
| - auto wnd = &_map[hWnd]; |
4915 |
| - |
4916 |
| - wnd->ctx = this; |
| 4913 | + auto wnd = &_windows[hWnd]; |
4917 | 4914 | wnd->handle = hWnd;
|
4918 |
| - wnd->set_prop(); |
4919 |
| - set_prop(hWnd); |
4920 |
| - |
4921 |
| - /// auto hMenu = (HMENU)::SendMessageW(hWnd, MN_GETHMENU, 0, 0); |
4922 |
| - // wnd->hMenu = hMenu; |
4923 |
| - // map_menu_wnd[hMenu] = { hMenu, hWnd }; |
4924 |
| - |
4925 |
| - current.hWnd = hWnd; |
4926 |
| - _level.push_back(wnd); |
4927 |
| - |
4928 |
| - Flag<ULONG_PTR> cs_style = ::GetClassLongPtrW(hWnd, GCL_STYLE); |
4929 |
| - Flag<LONG_PTR> style = ::GetWindowLongPtrW(hWnd, GWL_STYLE); |
4930 |
| - Flag<LONG_PTR> ex_style = ::GetWindowLongPtrW(hWnd, GWL_EXSTYLE); |
4931 |
| - |
4932 |
| - auto cs_style_old = cs_style; |
4933 |
| - auto style_old = style; |
4934 |
| - auto ex_style_old = ex_style; |
4935 |
| - |
4936 |
| - //RECT r = { 0 }; |
4937 |
| - //AdjustWindowRectEx(&r, (DWORD)style.value, false, (DWORD)ex_style.value); |
4938 |
| - |
4939 |
| - cs_style.remove(CS_DROPSHADOW); |
4940 |
| - style.remove(WS_BORDER); |
4941 |
| - |
4942 |
| - ex_style.remove(WS_EX_WINDOWEDGE); |
4943 |
| - ex_style.remove(WS_EX_DLGMODALFRAME); |
| 4915 | + wnd->menu = current.menu; |
| 4916 | + wnd->layer.handle = nullptr; |
| 4917 | + wnd->blurry.handle = nullptr; |
4944 | 4918 |
|
4945 |
| - if(composition) |
4946 |
| - ex_style.add(WS_EX_COMPOSITED); |
4947 |
| - |
4948 |
| - //ex_style.add(WS_EX_LAYERED); |
4949 |
| - //ex_style.add(WS_EX_NOREDIRECTIONBITMAP); |
4950 |
| - |
4951 |
| - if(!cs_style.equals(cs_style_old)) |
4952 |
| - ::SetClassLongPtrW(hWnd, GCL_STYLE, cs_style); |
| 4919 | + bool composition = false; |
| 4920 | + ::DwmIsCompositionEnabled(&composition); |
4953 | 4921 |
|
4954 |
| - if(!style.equals(style_old)) |
4955 |
| - ::SetWindowLongPtrW(hWnd, GWL_STYLE, style); |
4956 |
| - |
4957 |
| - if(!ex_style.equals(ex_style_old)) |
4958 |
| - ::SetWindowLongPtrW(hWnd, GWL_EXSTYLE, ex_style); |
4959 |
| - |
4960 |
| - //::SetClassLongPtrW(hWnd, GCL_STYLE, 0); |
4961 |
| - //::SetWindowLongPtrW(hWnd, GWL_STYLE, WS_POPUP); |
4962 |
| - //::SetWindowLongPtrW(hWnd, GWL_EXSTYLE, WS_EX_NOREDIRECTIONBITMAP); |
4963 |
| - |
4964 |
| - ::PostMessageW(hWnd, WM_SETCURSOR, 0, 0); |
4965 |
| - |
4966 |
| - //int opacity = 100; |
4967 |
| - //SetLayeredWindowAttributes(hWnd, 0, (255 * 100) / 100, LWA_ALPHA); |
4968 |
| - //SetLayeredWindowAttributes(hWnd, 0x0ff00, 0, LWA_COLORKEY); |
| 4922 | + BOOL isGlass = FALSE; |
4969 | 4923 | if(composition)
|
4970 | 4924 | {
|
| 4925 | + // For Windows 11, apply rounded corners and mica effect |
| 4926 | + if(ver->IsWindows11OrGreater()) |
| 4927 | + { |
| 4928 | + DWM dwm(hWnd); |
| 4929 | + // Apply rounded corners for Windows 11 |
| 4930 | + dwm.SetCorner(DWM::Corner::Round); |
| 4931 | + |
| 4932 | + // Apply proper backdrop effect based on Windows 11 build |
| 4933 | + if(ver->Build >= 22523) |
| 4934 | + { |
| 4935 | + // For newer Windows 11 builds, use the proper backdrop type |
| 4936 | + if(_theme.enableTransparency) |
| 4937 | + { |
| 4938 | + dwm.SetBackdropType(_theme.mode ? DWM::BackdropType::Acrylic : DWM::BackdropType::Mica); |
| 4939 | + } |
| 4940 | + } |
| 4941 | + else if(ver->Build >= 22000) |
| 4942 | + { |
| 4943 | + // For older Windows 11 builds, use the Mica API |
| 4944 | + if(_theme.enableTransparency) |
| 4945 | + { |
| 4946 | + dwm.SetMica(TRUE); |
| 4947 | + } |
| 4948 | + } |
| 4949 | + |
| 4950 | + // Set dark mode appropriately |
| 4951 | + dwm.SetImmersiveDarkMode(_theme.mode ? TRUE : FALSE); |
| 4952 | + } |
| 4953 | + |
4971 | 4954 | AccentPolicy ap(hWnd);
|
4972 |
| - //ap.set(AccentPolicy::Disabled); |
4973 |
| - //ap.set(ap.AcrylicBlurBehind, ap.AllowSetWindowRgn, _theme.background.color.to_ABGR()); |
4974 |
| - |
4975 |
| - //if(_theme.transparent) |
4976 |
| - Compositor::TransparentArea(hWnd); |
| 4955 | + if(_theme.enableTransparency) |
| 4956 | + { |
| 4957 | + if(_theme.background.effect > 0) |
| 4958 | + { |
| 4959 | + ap.enable(_theme.background.effect, _theme.background.tintcolor.to_BGR()); |
| 4960 | + isGlass = TRUE; |
| 4961 | + } |
| 4962 | + } |
4977 | 4963 | }
|
4978 | 4964 |
|
4979 |
| - BOOL ENABLED = TRUE; |
4980 |
| - ::DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_ENABLED, &ENABLED, sizeof(BOOL)); |
4981 |
| - ::DwmSetWindowAttribute(hWnd, DWMWA_ALLOW_NCPAINT, &ENABLED, sizeof(BOOL)); |
4982 |
| - ::DwmSetWindowAttribute(hWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &ENABLED, sizeof(BOOL)); |
4983 |
| - |
4984 |
| - WindowSubclass::Set(hWnd, MenuSubClassProc, 0, this); |
4985 |
| - //::ShowWindowAsync(hWnd, SW_HIDE); |
| 4965 | + wnd->is_glass = isGlass; |
4986 | 4966 | return wnd;
|
4987 | 4967 | }
|
4988 | 4968 |
|
|
0 commit comments