Skip to content

Commit 6e60c30

Browse files
committed
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.
1 parent 7e6b2b4 commit 6e60c30

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

Explorer++/Explorer++/Explorer++.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Explorerplusplus::~Explorerplusplus()
9797

9898
HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData)
9999
{
100+
bool isFirstInstance = IsFirstInstance();
100101
static bool mainWindowClassRegistered = false;
101102

102103
if (!mainWindowClassRegistered)
@@ -119,12 +120,18 @@ HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData)
119120

120121
placement.showCmd = SW_HIDE;
121122
placement.rcNormalPosition =
122-
storageData ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds();
123+
storageData && isFirstInstance ? storageData->bounds : LayoutDefaults::GetDefaultMainWindowBounds();
123124
SetWindowPlacement(hwnd, &placement);
124125

125126
return hwnd;
126127
}
127128

129+
bool Explorerplusplus::IsFirstInstance()
130+
{
131+
HWND hPrev = FindWindow(WINDOW_CLASS_NAME, nullptr);
132+
return (hPrev == nullptr);
133+
}
134+
128135
ATOM Explorerplusplus::RegisterMainWindowClass(HINSTANCE instance)
129136
{
130137
WNDCLASSEX windowClass = {};

Explorer++/Explorer++/Explorer++.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class Explorerplusplus :
211211
Explorerplusplus(App *app, const WindowStorageData *storageData);
212212

213213
static HWND CreateMainWindow(const WindowStorageData *storageData);
214+
static bool IsFirstInstance();
214215
static ATOM RegisterMainWindowClass(HINSTANCE instance);
215216

216217
LRESULT WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
202 Bytes
Binary file not shown.

Explorer++/Explorer++/TabContainerImpl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ void TabContainerImpl::ProcessTabCommand(UINT uMenuID, Tab &tab)
443443
DuplicateTab(tab);
444444
break;
445445

446+
case IDM_TAB_MOVETABNEWWINDOW:
447+
MoveTabToNewWindow(tab);
448+
break;
449+
446450
case IDM_TAB_OPENPARENTINNEWTAB:
447451
OnOpenParentInNewTab(tab);
448452
break;
@@ -1309,6 +1313,13 @@ void TabContainerImpl::DuplicateTab(const Tab &tab)
13091313
CreateNewTab(navigateParams, {}, &folderSettings, &folderColumns);
13101314
}
13111315

1316+
void TabContainerImpl::MoveTabToNewWindow(const Tab &tab)
1317+
{
1318+
tab.GetBrowser()->OpenItem(tab.GetShellBrowserImpl()->GetDirectoryIdl().get(),
1319+
OpenFolderDisposition::NewWindow);
1320+
CloseTab(tab);
1321+
}
1322+
13121323
int TabContainerImpl::GetDropTargetItem(const POINT &pt)
13131324
{
13141325
POINT ptClient = pt;

Explorer++/Explorer++/TabContainerImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class TabContainerImpl : public TabContainer, public ShellDropTargetWindow<int>
114114
int GetNumTabs() const;
115115
int MoveTab(const Tab &tab, int newIndex);
116116
void DuplicateTab(const Tab &tab);
117+
void MoveTabToNewWindow(const Tab &tab);
117118
bool CloseTab(const Tab &tab);
118119

119120
// Eventually, this should be removed.

Explorer++/Explorer++/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@
753753
#define IDM_VIEW_SORTBY 40285
754754
#define IDM_TOOLBARS_MAINTOOLBAR 40291
755755
#define IDM_TOOLBARS_BOOKMARKSTOOLBAR 40292
756+
#define IDM_TAB_MOVETABNEWWINDOW 40316
756757
#define IDM_TAB_OPENPARENTINNEWTAB 40319
757758
#define IDM_TAB_RENAMETAB 40321
758759
#define IDM_VIEW_SETDEFAULTCOLUMNS 40323

0 commit comments

Comments
 (0)