Skip to content

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

Merged
yair100 merged 1 commit into
files-community:mainfrom
TRUINGLol:tr/MiddleClickNewTab
Aug 13, 2026
Merged

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

Conversation

@TRUINGLol

Copy link
Copy Markdown
Contributor

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
Contributor 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 added the ready for review Pull requests that are ready for review label Aug 9, 2026
@yair100
yair100 requested a review from 0x5bfa August 13, 2026 16:25
@yair100

yair100 commented Aug 13, 2026

Copy link
Copy Markdown
Member

I can confirm this works as expected.

@0x5bfa 0x5bfa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM codewise.

@yair100 yair100 added ready to merge Pull requests that are approved and ready to merge and removed ready for review Pull requests that are ready for review labels Aug 13, 2026
@yair100
yair100 merged commit c5026ae into files-community:main Aug 13, 2026
7 checks passed
@yair100

yair100 commented Aug 13, 2026

Copy link
Copy Markdown
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Pull requests that are approved and ready to merge

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

4 participants