Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Move Tab to a New Window" in tab context menu #509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Explorer++/Explorer++/Explorer++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Explorerplusplus::~Explorerplusplus()

HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData)
{
bool isFirstInstance = IsFirstInstance();
static bool mainWindowClassRegistered = false;

if (!mainWindowClassRegistered)
Expand All @@ -121,12 +122,19 @@ HWND Explorerplusplus::CreateMainWindow(const WindowStorageData *storageData)
CHECK(res);

placement.showCmd = SW_HIDE;
placement.rcNormalPosition = storageData ? storageData->bounds : GetDefaultMainWindowBounds();
placement.rcNormalPosition =
storageData && isFirstInstance ? storageData->bounds : 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 = {};
Expand Down
1 change: 1 addition & 0 deletions Explorer++/Explorer++/Explorer++.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class Explorerplusplus :
Explorerplusplus(App *app, const WindowStorageData *storageData);

static HWND CreateMainWindow(const WindowStorageData *storageData);
static bool IsFirstInstance();
static ATOM RegisterMainWindowClass(HINSTANCE instance);
static RECT GetDefaultMainWindowBounds();

Expand Down
Binary file modified Explorer++/Explorer++/Explorer++.rc
Binary file not shown.
11 changes: 11 additions & 0 deletions Explorer++/Explorer++/TabContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ void TabContainer::ProcessTabCommand(UINT uMenuID, Tab &tab)
DuplicateTab(tab);
break;

case IDM_TAB_MOVETABNEWWINDOW:
MoveTabToNewWindow(tab);
break;

case IDM_TAB_OPENPARENTINNEWTAB:
OnOpenParentInNewTab(tab);
break;
Expand Down Expand Up @@ -1339,6 +1343,13 @@ void TabContainer::DuplicateTab(const Tab &tab)
CreateNewTab(navigateParams, {}, &folderSettings, &folderColumns);
}

void TabContainer::MoveTabToNewWindow(const Tab &tab)
{
tab.GetBrowser()->OpenItem(tab.GetShellBrowserImpl()->GetDirectoryIdl().get(),
OpenFolderDisposition::NewWindow);
CloseTab(tab);
}

int TabContainer::GetDropTargetItem(const POINT &pt)
{
POINT ptClient = pt;
Expand Down
1 change: 1 addition & 0 deletions Explorer++/Explorer++/TabContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class TabContainer : public ShellDropTargetWindow<int>
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.
Expand Down
1 change: 1 addition & 0 deletions Explorer++/Explorer++/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,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
Expand Down