Skip to content

Commit

Permalink
Revert "chore: refine logic for tab preservation during fullscreen mode"
Browse files Browse the repository at this point in the history
This reverts commit edb99af
  • Loading branch information
Bush2021 committed Apr 10, 2024
1 parent 60d7815 commit 536f959
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
42 changes: 17 additions & 25 deletions src/tabbookmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ bool IsNeedKeep(HWND hwnd, int32_t* ptr = nullptr) {
if (tick > 0 && tick <= 250 && tab_count <= 2) {
is_only_one_tab = true;
}
if (tab_count == 0) { // 处理全屏等状态
is_only_one_tab = false;
}

keep_tab = is_only_one_tab;

Expand Down Expand Up @@ -283,30 +286,6 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
return CallNextHookEx(mouse_hook, nCode, wParam, lParam);
}

bool handleTabPreserve(WPARAM wParam) {

if (!(wParam == 'W' && IsPressed(VK_CONTROL) && !IsPressed(VK_SHIFT)) &&
!(wParam == VK_F4 && IsPressed(VK_CONTROL))) {
return 0;
}

HWND hwnd = GetFocus();

// if (!GetTopContainerView(hwnd)) {
// keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // 先释放用户按住的 Ctrl
// SendKeys(VK_ESCAPE);
// }

if (!IsNeedKeep(hwnd)) {
return 0;
}

ExecuteCommand(IDC_NEW_TAB);
ExecuteCommand(IDC_SELECT_PREVIOUS_TAB);
ExecuteCommand(IDC_CLOSE_TAB);
return 1;
}

bool IsNeedOpenUrlInNewTab() {
bool open_url_ing = false;

Expand All @@ -326,8 +305,21 @@ HHOOK keyboard_hook = nullptr;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION && !(lParam & 0x80000000)) // pressed
{
bool keep_tab = false;

if (handleTabPreserve(wParam)) {}
if (wParam == 'W' && IsPressed(VK_CONTROL) && !IsPressed(VK_SHIFT)) {
keep_tab = IsNeedKeep(GetForegroundWindow());
}
if (wParam == VK_F4 && IsPressed(VK_CONTROL)) {
keep_tab = IsNeedKeep(GetForegroundWindow());
}

if (keep_tab) {
ExecuteCommand(IDC_NEW_TAB);
ExecuteCommand(IDC_SELECT_PREVIOUS_TAB);
ExecuteCommand(IDC_CLOSE_TAB);
return 1;
}

bool open_url_ing = false;

Expand Down
1 change: 0 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ void DebugLog(const wchar_t* format, ...) {
#define IDC_SELECT_TAB_6 34024
#define IDC_SELECT_TAB_7 34025
#define IDC_SELECT_LAST_TAB 34026
#define IDC_FULLSCREEN 34030
#define IDC_SHOW_TRANSLATE 35009

#define IDC_UPGRADE_DIALOG 40024
Expand Down

0 comments on commit 536f959

Please sign in to comment.