this is surprisingly close. Doesn't handle the mouse-exit-from-window case, but otherwize :primo:
This commit is contained in:
parent
6c9b399048
commit
487edb9071
|
@ -95,10 +95,20 @@ LRESULT NonClientIslandWindow::_dragBarNcHitTest(const til::point& pointer)
|
||||||
// I just didn't duplicate it here.
|
// I just didn't duplicate it here.
|
||||||
// TODO! this 130 shouldn't be hardcoded
|
// TODO! this 130 shouldn't be hardcoded
|
||||||
// TODO! other buttons too
|
// TODO! other buttons too
|
||||||
if ((rcParent.right - pointer.x()) < 130)
|
// TODO! Account for DPI scaling
|
||||||
|
// TODO! ask the titlebar for caption button size?
|
||||||
|
if ((rcParent.right - pointer.x()) < 46)
|
||||||
|
{
|
||||||
|
return HTCLOSE;
|
||||||
|
}
|
||||||
|
else if ((rcParent.right - pointer.x()) < (46 * 2))
|
||||||
{
|
{
|
||||||
return HTMAXBUTTON;
|
return HTMAXBUTTON;
|
||||||
}
|
}
|
||||||
|
else if ((rcParent.right - pointer.x()) < (46 * 3))
|
||||||
|
{
|
||||||
|
return HTMINBUTTON;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If we're not on a caption button, then check if we're on the top
|
// If we're not on a caption button, then check if we're on the top
|
||||||
|
@ -128,22 +138,46 @@ LRESULT NonClientIslandWindow::_InputSinkMessageHandler(UINT const message, WPAR
|
||||||
case WM_NCMOUSEMOVE:
|
case WM_NCMOUSEMOVE:
|
||||||
// Communicate state to the title bar control so that it can update its visuals.
|
// Communicate state to the title bar control so that it can update its visuals.
|
||||||
// TODO! other buttons too
|
// TODO! other buttons too
|
||||||
if (wparam == HTMAXBUTTON)
|
|
||||||
|
switch (wparam)
|
||||||
{
|
{
|
||||||
|
case HTMINBUTTON:
|
||||||
|
_titlebar.HoverButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
|
break;
|
||||||
|
case HTMAXBUTTON:
|
||||||
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
_titlebar.HoverButton(winrt::TerminalApp::CaptionButton::Maximize);
|
_titlebar.HoverButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
// _titlebar.MaxButtonEntered();
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
}
|
break;
|
||||||
else
|
case HTCLOSE:
|
||||||
{
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
// _titlebar.MaxButtonExited();
|
_titlebar.HoverButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (wparam == HTMAXBUTTON)
|
||||||
|
// {
|
||||||
|
// _titlebar.HoverButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
|
// // _titlebar.MaxButtonEntered();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
|
// // _titlebar.MaxButtonExited();
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NCMOUSELEAVE:
|
case WM_NCMOUSELEAVE:
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
// _titlebar.MaxButtonExited();
|
// _titlebar.MaxButtonExited();
|
||||||
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
|
// _titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
|
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// NB: *Shouldn't be forwarding these* when they're not over the caption because they can inadvertently take action using the system's default metrics instead of our own.
|
// NB: *Shouldn't be forwarding these* when they're not over the caption because they can inadvertently take action using the system's default metrics instead of our own.
|
||||||
|
@ -151,9 +185,22 @@ LRESULT NonClientIslandWindow::_InputSinkMessageHandler(UINT const message, WPAR
|
||||||
case WM_NCLBUTTONDBLCLK:
|
case WM_NCLBUTTONDBLCLK:
|
||||||
switch (wparam)
|
switch (wparam)
|
||||||
{
|
{
|
||||||
|
case HTCAPTION:
|
||||||
|
{
|
||||||
|
// Pass caption-related nonclient messages to the parent window.
|
||||||
|
// The buttons won't work as you'd expect; we need to handle those ourselves.
|
||||||
|
auto parentWindow{ GetHandle() };
|
||||||
|
return SendMessage(parentWindow, message, wparam, lparam);
|
||||||
|
}
|
||||||
|
case HTMINBUTTON:
|
||||||
|
_titlebar.PressButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
|
break;
|
||||||
case HTMAXBUTTON:
|
case HTMAXBUTTON:
|
||||||
_titlebar.PressButton(winrt::TerminalApp::CaptionButton::Maximize);
|
_titlebar.PressButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
break;
|
break;
|
||||||
|
case HTCLOSE:
|
||||||
|
_titlebar.PressButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
// TODO!: I think we only want WM_NCLBUTTONUP
|
// TODO!: I think we only want WM_NCLBUTTONUP
|
||||||
|
@ -169,16 +216,25 @@ LRESULT NonClientIslandWindow::_InputSinkMessageHandler(UINT const message, WPAR
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HTMAXBUTTON:
|
// Forward along to the button state machine.
|
||||||
|
// As a proof of concept just locally handle the maximize button.
|
||||||
|
// TODO!
|
||||||
case HTMINBUTTON:
|
case HTMINBUTTON:
|
||||||
|
// TODO! if we're maximized, restore down!
|
||||||
|
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Minimize);
|
||||||
|
ShowWindow(GetHandle(), SW_MINIMIZE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HTMAXBUTTON:
|
||||||
|
// TODO! if we're maximized, restore down!
|
||||||
|
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Maximize);
|
||||||
|
ShowWindow(GetHandle(), SW_MAXIMIZE);
|
||||||
|
break;
|
||||||
|
|
||||||
case HTCLOSE:
|
case HTCLOSE:
|
||||||
// Forward along to the button state machine.
|
// TODO! if we're maximized, restore down!
|
||||||
// As a proof of concept just locally handle the maximize button.
|
_titlebar.ReleaseButton(winrt::TerminalApp::CaptionButton::Close);
|
||||||
// TODO!
|
Close();
|
||||||
if ((wparam == HTMAXBUTTON) && (message == WM_NCLBUTTONUP))
|
|
||||||
{
|
|
||||||
ShowWindow(GetHandle(), SW_MAXIMIZE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue