microsoft / microsoft/terminal
Click anywhere to drag window
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Description of the new feature
I find myself missing this subtle feature from ConsoleZ where you could ctrl+click to grab the window from anywhere instead of having to hit the (increasingly small) non-client area of the titlebar, eg:
https://github.com/user-attachments/assets/77227fbe-4187-4793-ac2b-109804735ebe
the feature was called "drag window" and by default ctrl+left activated it but being able to configure it as middle click no modifier seems cool too.
I propose ripping this feature off whole-hog 😁
### Proposed technical implementation details
besides plumbing the options, ~~I think the actual functionality could be as easy as copying [this old trick](https://github.com/gfody/console/blob/99d317e111267e3b18adcf287f9f70c7cb38a358/Console/MainFrame.cpp#L1862-L1863) I used in ConsoleZ, basically:~~
~~- on mouse down, if feature enabled and conditions met
- release the mouse capture
- send a `WM_NCLBUTTONDOWN` w/`HTCAPTION` to the main window handle~~
(assuming uwp apps still have main window handles and message pumps 🤷)
edit: it might be sylish to flip the pointer to "grab" and then "grabbing" on the modifier keydown and then the mousedown (assuming those pointers don't look/feel out of place, and only it's not problematic like #1441)
edit2: tried the easy thing and it did not work:
```diff
diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp
index b079dbbc3..42459713f 100644
--- a/src/cascadia/TerminalControl/TermControl.cpp
+++ b/src/cascadia/TerminalControl/TermControl.cpp
@@ -1954,6 +1954,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto contactRect = point.Properties().ContactRect();
_interactivity.TouchPressed({ contactRect.X, contactRect.Y });
}
+ else if (args.KeyModifiers() == Windows::System::VirtualKeyModifiers::Control)
+ {
+ ReleaseCapture();
+ SendMessage((HWND)OwningHwnd(), WM_NCLBUTTONDOWN, HTCAPTION, 0);
+ }
else
{
const auto cursorPosition = point.Position();
```
Contributor guide
Research direction
Start in src/cascadia/TerminalControl/TermControl.cpp at the mouse input handling and review the failed WM_NCLBUTTONDOWN experiment in the issue. Trace how the feature's options and window interaction should be connected, then verify that the configured modifier or mouse button can drag the window from the terminal content area without disrupting normal input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100