From 4843e71ab56f975da391840cba3aec0d8e26595b Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Mon, 31 Jul 2023 13:50:07 +0200 Subject: [PATCH 1/5] Separate taskbar icon for Open-Shell menu settings dialog It will be now separate from Explorer's icons in taskbar. Open-Shell icon will be displayed for better clarity. https://github.com/Open-Shell/Open-Shell-Menu/issues/31#issuecomment-1656611895 --- Src/Lib/Settings.cpp | 32 ++++++++++++++--------- Src/Lib/Settings.h | 2 +- Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Src/Lib/Settings.cpp b/Src/Lib/Settings.cpp index 54b3e273e..97674f319 100644 --- a/Src/Lib/Settings.cpp +++ b/Src/Lib/Settings.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -1108,7 +1109,7 @@ class CSettingsDlg: public CResizeableDlg { public: CSettingsDlg( void ); - void Init( CSetting *pSettings, ICustomSettings *pCustom, int tab ); + void Init( CSetting *pSettings, ICustomSettings *pCustom, int tab, const wchar_t* appId ); BEGIN_MSG_MAP( CSettingsDlg ) MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog ) @@ -1182,6 +1183,7 @@ class CSettingsDlg: public CResizeableDlg bool m_bIgnoreEdit; bool m_bDirty; CString m_FilterText; + const wchar_t* m_AppId; void AddTabs( int name, const CSetting *pSelect=NULL ); void SetCurTab( int index, bool bReset, const CSetting *pSelect=NULL ); @@ -1214,15 +1216,17 @@ CSettingsDlg::CSettingsDlg( void ) m_bOnTop=false; m_bIgnoreEdit=false; m_bDirty=false; + m_AppId=NULL; } -void CSettingsDlg::Init( CSetting *pSettings, ICustomSettings *pCustom, int tab ) +void CSettingsDlg::Init( CSetting *pSettings, ICustomSettings *pCustom, int tab, const wchar_t* appId ) { m_pSettings=pSettings; m_pCustom=pCustom; m_InitialTab=tab; m_FilterText.Empty(); m_bDirty=false; + m_AppId=appId; } // Subclass the tooltip to delay the tip when the mouse moves from one tree item to the next @@ -1246,17 +1250,19 @@ LRESULT CSettingsDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOO #ifdef _DEBUG g_bUIThread=true; #endif -/* - // attempt to make the dialog have its own icon. doesn't work though. the icon changes, but to the default folder icon - CComPtr pStore; - if (SUCCEEDED(SHGetPropertyStoreForWindow(m_hWnd,IID_IPropertyStore,(void**)&pStore))) + + if (m_AppId) { - PROPVARIANT val; - val.vt=VT_LPWSTR; - val.pwszVal=L"OpenShell.Settings.Dialog"; - pStore->SetValue(PKEY_AppUserModel_ID,val); + // attempt to make the dialog have its own icon + CComPtr pStore; + if (SUCCEEDED(SHGetPropertyStoreForWindow(m_hWnd,IID_IPropertyStore,(void**)&pStore))) + { + PROPVARIANT val; + InitPropVariantFromString(m_AppId,&val); + pStore->SetValue(PKEY_AppUserModel_ID,val); + } } -*/ + InitResize(MOVE_MODAL); HMENU menu=GetSystemMenu(FALSE); bool bAdded=false; @@ -1840,7 +1846,7 @@ bool CSettingsDlg::IsTabValid( void ) static CSettingsDlg g_SettingsDlg; -void EditSettings( const wchar_t *title, bool bModal, int tab ) +void EditSettings( const wchar_t *title, bool bModal, int tab, const wchar_t* appId ) { if (g_SettingsDlg.m_hWnd) { @@ -1858,7 +1864,7 @@ void EditSettings( const wchar_t *title, bool bModal, int tab ) } DLGTEMPLATE *pTemplate=LoadDialogEx(IDD_SETTINGS); g_SettingsManager.ResetImageList(); - g_SettingsDlg.Init(g_SettingsManager.GetSettings(),g_SettingsManager.GetCustom(),tab); + g_SettingsDlg.Init(g_SettingsManager.GetSettings(),g_SettingsManager.GetCustom(),tab,appId); g_SettingsDlg.Create(NULL,pTemplate); g_SettingsDlg.SetWindowText(title); g_SettingsDlg.SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|(g_SettingsDlg.GetOnTop()?0:SWP_NOZORDER)|SWP_SHOWWINDOW); diff --git a/Src/Lib/Settings.h b/Src/Lib/Settings.h index 01b8f42d8..92fa88f25 100644 --- a/Src/Lib/Settings.h +++ b/Src/Lib/Settings.h @@ -129,7 +129,7 @@ void InitSettings( CSetting *pSettings, TSettingsComponent component, ICustomSet void LoadSettings( void ); void SaveSettings( void ); void UpdateDefaultSettings( void ); -void EditSettings( const wchar_t *title, bool bModal, int tab ); +void EditSettings( const wchar_t *title, bool bModal, int tab, const wchar_t *appId = nullptr ); void CloseSettings( void ); void SetSettingsDirty( void ); void SelectSettingsTab( int tab, bool bAdvanced, const CSetting *pSelect ); diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index eb3af0494..49383601b 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -5272,7 +5272,7 @@ void EditSettings( bool bModal, int tab ) Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE_VER),ver>>24,(ver>>16)&0xFF,ver&0xFFFF); else Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE)); - EditSettings(title,bModal,tab); + EditSettings(title,bModal,tab,L"OpenShell.StartMenu.Settings"); } bool DllImportSettingsXml( const wchar_t *fname ) From 19a38f7317d5ba5547a31cace6b7a37c29e31149 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Mon, 31 Jul 2023 14:10:46 +0200 Subject: [PATCH 2/5] Allow negative horizontal/vertical menu offsets (#1629) Menu offsets were previously applied to s_MainMenuLimits. Though when deciding where to put start menu (CalculateCorner) we are now taking into account also position of start button (as since Win11 it may not be in corner of the screen). This broke negative menu offsets. We will fix it by applying menu offsets in CalculateCorner as a last step once we have determined start menu position. This should make even more sense than previous approach. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 28 +++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index a56e77be4..f75b0908f 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -7509,31 +7509,6 @@ RECT CMenuContainer::CalculateWorkArea( const RECT &taskbarRect ) } } - //calculate offsets - int xOff = GetSettingInt(L"HorizontalMenuOffset"); - int yOff = GetSettingInt(L"VerticalMenuOffset"); - if (s_TaskBarEdge == ABE_BOTTOM) - { - if (xOff != 0) - rc.left += xOff; - if (yOff != 0) - rc.bottom += yOff; - } - else if (s_TaskBarEdge == ABE_TOP || s_TaskBarEdge == ABE_LEFT) - { - if (xOff != 0) - rc.left += xOff; - if (yOff != 0) - rc.top += yOff; - } - else - { - if (xOff != 0) - rc.right += xOff; - if (yOff != 0) - rc.top += yOff; - } - return rc; } @@ -7560,6 +7535,9 @@ POINT CMenuContainer::CalculateCorner( void ) else corner.y=s_MainMenuLimits.bottom+margin.bottom; + corner.x+=GetSettingInt(L"HorizontalMenuOffset"); + corner.y+=GetSettingInt(L"VerticalMenuOffset"); + return corner; } From 89d7815925432fccb0a7fdb6eb10d3dce9e68ee8 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Tue, 1 Aug 2023 12:55:18 +0200 Subject: [PATCH 3/5] Fix checkboxes in settings dialog with custom themes (#1630) --- Src/Lib/Settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Lib/Settings.cpp b/Src/Lib/Settings.cpp index 97674f319..8937d4c39 100644 --- a/Src/Lib/Settings.cpp +++ b/Src/Lib/Settings.cpp @@ -979,7 +979,7 @@ void CSettingsManager::ResetSettings( void ) HIMAGELIST CSettingsManager::GetImageList( HWND tree ) { if (m_ImageList) return m_ImageList; - HTHEME theme=OpenThemeData(tree,L"button"); + HTHEME theme=OpenThemeData(GetParent(tree),L"button"); HDC hdc=CreateCompatibleDC(NULL); int iconSize=(TreeView_GetItemHeight(tree)<32)?16:32; int checkSize=16; From 9a3c4b92fd5d77aa39461a7307c417bc5b49550f Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sat, 5 Aug 2023 13:24:41 +0200 Subject: [PATCH 4/5] Fix search results overlapping (#1648) Changes in be8568 commit caused that under certain circumstances search results may overlap "Search the Internet" item. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index f75b0908f..37ac9b5e7 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -2769,8 +2769,8 @@ bool CMenuContainer::InitSearchItems( void ) itemHeight=s_Skin.ItemSettings[MenuSkin::LIST_ITEM].itemHeight; // total height minus the search box and the "more results"/"search internet", if present maxHeight=m_Items[m_SearchIndex].itemRect.top-s_Skin.Main_search_padding.top-s_Skin.Search_padding.top; - maxHeight-=itemHeight*(m_SearchItemCount-(s_bMoreResults?1:2)); - if (!s_SearchResults.bSearching && !HasMoreResults()) + maxHeight-=itemHeight*(m_SearchItemCount-1); + if (!s_bMoreResults || (!s_SearchResults.bSearching && !HasMoreResults())) maxHeight+=itemHeight; } if (bAutoComlpete) @@ -2983,7 +2983,7 @@ bool CMenuContainer::InitSearchItems( void ) else { m_ScrollCount=(int)m_Items.size(); - bool bInternet=GetSettingBool(L"SearchInternet"); + bool bInternet=GetSettingBool(L"SearchInternet"); if (s_bMoreResults && s_SearchResults.bSearching) { MenuItem item(MENU_SEARCH_EMPTY); From 19d5ab288a531c27c5f0a3549c6cbfaf827ef2c2 Mon Sep 17 00:00:00 2001 From: ge0rdi Date: Sat, 5 Aug 2023 14:14:41 +0200 Subject: [PATCH 5/5] Display "Searching..." progress always Commit be8568c that introduced option to disable "See more results" also changed behavior of "Searching..." item that indicates search in progress. We will now make sure that the search progress indicator is displayed always. No matter of options. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 37 +++++++++----------- Src/StartMenu/StartMenuDLL/MenuContainer.h | 1 - 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 37ac9b5e7..52ed2c738 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -335,7 +335,6 @@ bool CMenuContainer::s_bDragMovable; bool CMenuContainer::s_bRightDrag; bool CMenuContainer::s_bLockWorkArea; bool CMenuContainer::s_bPendingSearchEnter; -bool CMenuContainer::s_bMoreResults; std::vector CMenuContainer::s_Menus; volatile HWND CMenuContainer::s_FirstMenu, CMenuContainer::s_SearchMenu; CSearchManager::SearchResults CMenuContainer::s_SearchResults; @@ -2770,7 +2769,7 @@ bool CMenuContainer::InitSearchItems( void ) // total height minus the search box and the "more results"/"search internet", if present maxHeight=m_Items[m_SearchIndex].itemRect.top-s_Skin.Main_search_padding.top-s_Skin.Search_padding.top; maxHeight-=itemHeight*(m_SearchItemCount-1); - if (!s_bMoreResults || (!s_SearchResults.bSearching && !HasMoreResults())) + if (!s_SearchResults.bSearching && !HasMoreResults()) maxHeight+=itemHeight; } if (bAutoComlpete) @@ -2963,28 +2962,25 @@ bool CMenuContainer::InitSearchItems( void ) if (s_bWin7Style) { UpdateAccelerators(m_OriginalCount,(int)m_Items.size()); - if (s_bMoreResults) + MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; + if (s_SearchResults.bSearching) { - MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; - if (s_SearchResults.bSearching) - { - item.id=MENU_SEARCH_EMPTY; - item.name=FindTranslation(L"Menu.Searching",L"Searching..."); - item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,8",CItemManager::ICON_SIZE_TYPE_SMALL); - } - else - { - item.id=MENU_MORE_RESULTS; - item.name=FindTranslation(L"Menu.MoreResults",L"See more results"); - item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,177",CItemManager::ICON_SIZE_TYPE_SMALL); - } + item.id=MENU_SEARCH_EMPTY; + item.name=FindTranslation(L"Menu.Searching",L"Searching..."); + item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,8",CItemManager::ICON_SIZE_TYPE_SMALL); + } + else + { + item.id=MENU_MORE_RESULTS; + item.name=FindTranslation(L"Menu.MoreResults",L"See more results"); + item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,177",CItemManager::ICON_SIZE_TYPE_SMALL); } } else { m_ScrollCount=(int)m_Items.size(); bool bInternet=GetSettingBool(L"SearchInternet"); - if (s_bMoreResults && s_SearchResults.bSearching) + if (s_SearchResults.bSearching) { MenuItem item(MENU_SEARCH_EMPTY); item.name=FindTranslation(L"Menu.Searching",L"Searching..."); @@ -2999,7 +2995,7 @@ bool CMenuContainer::InitSearchItems( void ) item.name=FindTranslation(L"Menu.NoMatch",L"No items match your search."); m_Items.push_back(item); } - if (s_bMoreResults && HasMoreResults()) + if (HasMoreResults()) { { MenuItem item(MENU_SEPARATOR); @@ -5087,7 +5083,7 @@ void CMenuContainer::UpdateSearchResults( bool bForceShowAll ) g_SearchManager.BeginSearch(s_SearchResults.currentString); s_SearchResults.bSearching=true; s_bPendingSearchEnter=false; - if (s_bWin7Style && s_bMoreResults) + if (s_bWin7Style) { MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; item.id=MENU_SEARCH_EMPTY; @@ -7437,7 +7433,7 @@ static void CreateStartScreenFile( const wchar_t *fname ) bool CMenuContainer::HasMoreResults( void ) { if (s_HasMoreResults==-1) - s_HasMoreResults=(GetSettingBool(L"SearchFiles") && HasSearchService())?1:0; + s_HasMoreResults=(GetSettingBool(L"MoreResults") && GetSettingBool(L"SearchFiles") && HasSearchService())?1:0; return s_HasMoreResults!=0; } @@ -7713,7 +7709,6 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr s_bDisableHover=false; s_bDragClosed=false; s_bPendingSearchEnter=false; - s_bMoreResults=GetSettingBool(L"MoreResults"); InitTouchHelper(); bool bRemote=GetSystemMetrics(SM_REMOTESESSION)!=0; diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.h b/Src/StartMenu/StartMenuDLL/MenuContainer.h index 9b0bfe588..057982104 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.h +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.h @@ -896,7 +896,6 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub static bool s_bRightDrag; // dragging with the right mouse button static bool s_bLockWorkArea; // changes to the work area are ignored static bool s_bPendingSearchEnter; // Enter was pressed before the search results were ready - static bool s_bMoreResults; // shows the "Show More Results" item at the bottom of searches static RECT s_MenuLimits; // area of the main monitor accessible to all menus static RECT s_MainMenuLimits; // area of the main monitor accessible by the main menu static DWORD s_TaskbarState; // the state of the taskbar (ABS_AUTOHIDE and ABS_ALWAYSONTOP)