Skip to content

Commit

Permalink
Fix FFM to apply only if tab is focused (#9198)
Browse files Browse the repository at this point in the history
In the FFM mode, hovering on the pane might dismiss renamer.
To address this we want to make sure that FFM is applied
only if the Terminal Tab is focused.
  • Loading branch information
Don-Vito authored Feb 18, 2021
1 parent eb34993 commit 90699da
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,19 @@ namespace winrt::TerminalApp::implementation
tab->_RecalculateAndApplyReadOnly();
}
});

control.FocusFollowMouseRequested([weakThis](auto&& sender, auto&&) {
if (const auto tab{ weakThis.get() })
{
if (tab->_focusState != FocusState::Unfocused)
{
if (const auto termControl{ sender.try_as<winrt::Microsoft::Terminal::TerminalControl::TermControl>() })
{
termControl.Focus(FocusState::Pointer);
}
}
}
});
}

// Method Description:
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

if (!_focused && _settings.FocusFollowMouse())
{
Focus(FocusState::Pointer);
_FocusFollowMouseRequestedHandlers(*this, nullptr);
}

if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
TYPED_EVENT(HidePointerCursor, IInspectable, IInspectable);
TYPED_EVENT(RestorePointerCursor, IInspectable, IInspectable);
TYPED_EVENT(ReadOnlyChanged, IInspectable, IInspectable);
TYPED_EVENT(FocusFollowMouseRequested, IInspectable, IInspectable);
// clang-format on

private:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ namespace Microsoft.Terminal.TerminalControl
Boolean ReadOnly { get; };
void ToggleReadOnly();
event Windows.Foundation.TypedEventHandler<Object, Object> ReadOnlyChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> FocusFollowMouseRequested;
}
}

0 comments on commit 90699da

Please sign in to comment.