From 6e60c30e3160d7d9357a700d66fcac88acbf678e Mon Sep 17 00:00:00 2001 From: palollo Date: Mon, 6 Jan 2025 14:03:40 +0100 Subject: [PATCH 1/2] Add "Move Tab to a New Window" in tab context menu And open new windows in the default bounds, not in the stored bounds, avoiding that confusing behavior when the new window is created in the same exact position of the previous one. The stored bounds are used for the first instance. --- Explorer++/Explorer++/Explorer++.cpp | 9 ++++++++- Explorer++/Explorer++/Explorer++.h | 1 + Explorer++/Explorer++/Explorer++.rc | Bin 183428 -> 183630 bytes Explorer++/Explorer++/TabContainerImpl.cpp | 11 +++++++++++ Explorer++/Explorer++/TabContainerImpl.h | 1 + Explorer++/Explorer++/resource.h | 1 + 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Explorer++/Explorer++/Explorer++.cpp b/Explorer++/Explorer++/Explorer++.cpp index a91fc49fa0..c39a86182c 100644 --- a/Explorer++/Explorer++/Explorer++.cpp +++ b/Explorer++/Explorer++/Explorer++.cpp @@ -97,6 +97,7 @@ Explorerplusplus::~Explorerplusplus() HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData) { + bool isFirstInstance = IsFirstInstance(); static bool mainWindowClassRegistered = false; if (!mainWindowClassRegistered) @@ -119,12 +120,18 @@ HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData) placement.showCmd = SW_HIDE; placement.rcNormalPosition = - storageData ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds(); + storageData && isFirstInstance ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds(); SetWindowPlacement(hwnd, &placement); return hwnd; } +bool Explorerplusplus::IsFirstInstance() +{ + HWND hPrev = FindWindow(WINDOW_CLASS_NAME, nullptr); + return (hPrev == nullptr); +} + ATOM Explorerplusplus::RegisterMainWindowClass(HINSTANCE instance) { WNDCLASSEX windowClass = {}; diff --git a/Explorer++/Explorer++/Explorer++.h b/Explorer++/Explorer++/Explorer++.h index 581fa9b281..dd802209ee 100644 --- a/Explorer++/Explorer++/Explorer++.h +++ b/Explorer++/Explorer++/Explorer++.h @@ -211,6 +211,7 @@ class Explorerplusplus : Explorerplusplus(App *app, const WindowStorageData *storageData); static HWND CreateMainWindow(const WindowStorageData *storageData); + static bool IsFirstInstance(); static ATOM RegisterMainWindowClass(HINSTANCE instance); LRESULT WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); diff --git a/Explorer++/Explorer++/Explorer++.rc b/Explorer++/Explorer++/Explorer++.rc index 2ce2972a718ae96f00932923991d112c33cbec53..53fb886c230f6b1e29de173e122b611b6272e0d4 100644 GIT binary patch delta 161 zcmZpf$$f4X_l7H4hOP_|48aT`43P{z46Y0c4B$ delta 41 zcmV+^0M`G`nhS)P3$WBGlT6uylMwU-gODq?kShV`O_!dV0Sbo}dI7fOpenItem(tab.GetShellBrowserImpl()->GetDirectoryIdl().get(), + OpenFolderDisposition::NewWindow); + CloseTab(tab); +} + int TabContainerImpl::GetDropTargetItem(const POINT &pt) { POINT ptClient = pt; diff --git a/Explorer++/Explorer++/TabContainerImpl.h b/Explorer++/Explorer++/TabContainerImpl.h index f5e3eabdee..4d98b12679 100644 --- a/Explorer++/Explorer++/TabContainerImpl.h +++ b/Explorer++/Explorer++/TabContainerImpl.h @@ -114,6 +114,7 @@ class TabContainerImpl : public TabContainer, public ShellDropTargetWindow int GetNumTabs() const; int MoveTab(const Tab &tab, int newIndex); void DuplicateTab(const Tab &tab); + void MoveTabToNewWindow(const Tab &tab); bool CloseTab(const Tab &tab); // Eventually, this should be removed. diff --git a/Explorer++/Explorer++/resource.h b/Explorer++/Explorer++/resource.h index f0d4caecd3..f57ca27c8a 100644 --- a/Explorer++/Explorer++/resource.h +++ b/Explorer++/Explorer++/resource.h @@ -753,6 +753,7 @@ #define IDM_VIEW_SORTBY 40285 #define IDM_TOOLBARS_MAINTOOLBAR 40291 #define IDM_TOOLBARS_BOOKMARKSTOOLBAR 40292 +#define IDM_TAB_MOVETABNEWWINDOW 40316 #define IDM_TAB_OPENPARENTINNEWTAB 40319 #define IDM_TAB_RENAMETAB 40321 #define IDM_VIEW_SETDEFAULTCOLUMNS 40323 From 6cfa47b197272f2bd63f5ff8f5549b37c691dd8c Mon Sep 17 00:00:00 2001 From: palollo Date: Sun, 27 Apr 2025 20:02:26 +0200 Subject: [PATCH 2/2] Do not change window bounds when enabled feature MultipleWindowsPerSession # Conflicts: # Explorer++/Explorer++/Explorer++.cpp --- Explorer++/Explorer++/Explorer++.cpp | 14 ++++++++++---- Explorer++/Explorer++/Explorer++.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Explorer++/Explorer++/Explorer++.cpp b/Explorer++/Explorer++/Explorer++.cpp index c39a86182c..d2ef47c397 100644 --- a/Explorer++/Explorer++/Explorer++.cpp +++ b/Explorer++/Explorer++/Explorer++.cpp @@ -43,7 +43,8 @@ Explorerplusplus *Explorerplusplus::Create(App *app, const WindowStorageData *st Explorerplusplus::Explorerplusplus(App *app, const WindowStorageData *storageData) : m_id(idCounter++), m_app(app), - m_hContainer(CreateMainWindow(storageData)), + m_hContainer(CreateMainWindow(storageData, + app->GetFeatureList()->IsEnabled(Feature::MultipleWindowsPerSession))), m_commandController(this), m_tabBarBackgroundBrush(CreateSolidBrush(TAB_BAR_DARK_MODE_BACKGROUND_COLOR)), m_pluginMenuManager(m_hContainer, MENU_PLUGIN_START_ID, MENU_PLUGIN_END_ID), @@ -95,7 +96,8 @@ Explorerplusplus::~Explorerplusplus() m_pDirMon->Release(); } -HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData) +HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData, + const bool multipleWindowsPerSession) { bool isFirstInstance = IsFirstInstance(); static bool mainWindowClassRegistered = false; @@ -119,8 +121,12 @@ HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData) CHECK(res); placement.showCmd = SW_HIDE; - placement.rcNormalPosition = - storageData && isFirstInstance ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds(); + if (multipleWindowsPerSession) + placement.rcNormalPosition = + storageData ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds(); + else + placement.rcNormalPosition = + storageData && isFirstInstance ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds(); SetWindowPlacement(hwnd, &placement); return hwnd; diff --git a/Explorer++/Explorer++/Explorer++.h b/Explorer++/Explorer++/Explorer++.h index dd802209ee..e5b2572ece 100644 --- a/Explorer++/Explorer++/Explorer++.h +++ b/Explorer++/Explorer++/Explorer++.h @@ -210,7 +210,8 @@ class Explorerplusplus : Explorerplusplus(App *app, const WindowStorageData *storageData); - static HWND CreateMainWindow(const WindowStorageData *storageData); + static HWND CreateMainWindow(const WindowStorageData *storageData, + const bool multipleWindowsPerSession); static bool IsFirstInstance(); static ATOM RegisterMainWindowClass(HINSTANCE instance);