Skip to content

Feature: Open a new tab by middle clicking the empty space in the tab strip - #18804

Open
TRUINGLol wants to merge 1 commit into
files-community:mainfrom
TRUINGLol:tr/MiddleClickNewTab
Open

Feature: Open a new tab by middle clicking the empty space in the tab strip#18804
TRUINGLol wants to merge 1 commit into
files-community:mainfrom
TRUINGLol:tr/MiddleClickNewTab

Conversation

@TRUINGLol

Copy link
Copy Markdown

Resolved / Related Issues

Steps used to test these changes

  1. Opened Files, middle-clicked the empty strip between the "+" button and the caption buttons — a new tab opens and is selected. Repeated with several tabs open and with the window maximized.
  2. Dragged the window by that same empty area, including snapping to the top and side edges.
  3. Double-clicked it (maximize/restore), right-clicked it (system menu), used the minimize/maximize/close buttons.
  4. Middle-clicked a tab (still closes it), the "+" button, the toolbar, the Omnibar and the file list — no stray tabs.
  5. Repeated steps 1–2 with the app language set to an RTL language.

The empty tab strip area is registered as a Caption region, so middle clicks there never reach the XAML tree. The non-client messages don't reach the main window either: WinUI routes them to a dedicated InputNonClientPointerSource child window and forwards only WM_NCLBUTTONDOWN and WM_NCRBUTTONUP up to the top level.

So this PR subclasses that child window via WinUIEx.WindowMessageMonitor and handles WM_NCMBUTTONDOWN / WM_NCMBUTTONDBLCLK with wParam == HTCAPTION, invoking the same Commands.NewTab the "+" button uses.

@CLAassistant

CLAassistant commented Aug 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@TRUINGLol

Copy link
Copy Markdown
Author

If anyone is interested here is a summary of the resources that helped me understand how to solve this correctly (also alot chatgpt chats xD)

non client area
mouse
window n procedures
subclassing win
title bar winui

@yair100

yair100 commented Aug 9, 2026

Copy link
Copy Markdown
Member

I can confirm this works as expected. That being said, I won't be able to review the code changes until next week.

@yair100 yair100 added the ready for review Pull requests that are ready for review label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Open a new tab by middle clicking the empty space in the horizontal tab control

3 participants