97722d3efe
## Summary of the Pull Request Basically undoes #10988 in favour of implementing it as described in #11018 ## PR Checklist * [x] Closes #11018 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [X] Tests added/passed * [X] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [X] Schema updated. * [x] I work here ## Validation Steps Performed - alt+space opens the system menu by default - when alt+space is bound, the keys do not get send to terminal - right-click on the tab bar didn't break (still opens system menu at the location of the cursor)
91 lines
3.6 KiB
C++
91 lines
3.6 KiB
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Module Name:
|
|
- NonClientIslandWindow.h
|
|
|
|
Abstract:
|
|
- This class represents a window hosting two XAML Islands. One is in the client
|
|
area of the window, as it is in the base IslandWindow class. The second is in
|
|
the titlebar of the window, in the "non-client" area of the window. This
|
|
enables an app to place xaml content in the titlebar.
|
|
- Placing content in the frame is enabled with DwmExtendFrameIntoClientArea. See
|
|
https://docs.microsoft.com/en-us/windows/desktop/dwm/customframe
|
|
for information on how this is done.
|
|
|
|
Author(s):
|
|
Mike Griese (migrie) April-2019
|
|
--*/
|
|
|
|
#include "pch.h"
|
|
#include "IslandWindow.h"
|
|
#include "../../types/inc/Viewport.hpp"
|
|
#include <dwmapi.h>
|
|
#include <wil/resource.h>
|
|
|
|
class NonClientIslandWindow : public IslandWindow
|
|
{
|
|
public:
|
|
// this is the same for all DPIs
|
|
static constexpr const int topBorderVisibleHeight = 1;
|
|
|
|
NonClientIslandWindow(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme) noexcept;
|
|
virtual ~NonClientIslandWindow() override;
|
|
|
|
void MakeWindow() noexcept override;
|
|
virtual void OnSize(const UINT width, const UINT height) override;
|
|
|
|
[[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
|
|
|
|
virtual RECT GetNonClientFrame(UINT dpi) const noexcept override;
|
|
virtual SIZE GetTotalNonClientExclusiveSize(UINT dpi) const noexcept override;
|
|
|
|
void Initialize() override;
|
|
|
|
void OnAppInitialized() override;
|
|
void SetContent(winrt::Windows::UI::Xaml::UIElement content) override;
|
|
void SetTitlebarContent(winrt::Windows::UI::Xaml::UIElement content);
|
|
void OnApplicationThemeChanged(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme) override;
|
|
|
|
private:
|
|
std::optional<COORD> _oldIslandPos;
|
|
|
|
winrt::TerminalApp::TitlebarControl _titlebar{ nullptr };
|
|
winrt::Windows::UI::Xaml::UIElement _clientContent{ nullptr };
|
|
|
|
wil::unique_hbrush _backgroundBrush;
|
|
til::color _backgroundBrushColor;
|
|
|
|
winrt::Windows::UI::Xaml::Controls::Border _dragBar{ nullptr };
|
|
wil::unique_hwnd _dragBarWindow;
|
|
|
|
winrt::Windows::UI::Xaml::ElementTheme _theme;
|
|
|
|
bool _isMaximized;
|
|
|
|
[[nodiscard]] static LRESULT __stdcall _StaticInputSinkWndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
|
|
[[nodiscard]] LRESULT _InputSinkMessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
|
|
|
|
void _ResizeDragBarWindow() noexcept;
|
|
|
|
int _GetResizeHandleHeight() const noexcept;
|
|
RECT _GetDragAreaRect() const noexcept;
|
|
int _GetTopBorderHeight() const noexcept;
|
|
|
|
[[nodiscard]] LRESULT _OnNcCreate(WPARAM wParam, LPARAM lParam) noexcept override;
|
|
[[nodiscard]] LRESULT _OnNcCalcSize(const WPARAM wParam, const LPARAM lParam) noexcept;
|
|
[[nodiscard]] LRESULT _OnNcHitTest(POINT ptMouse) const noexcept;
|
|
[[nodiscard]] LRESULT _OnPaint() noexcept;
|
|
[[nodiscard]] LRESULT _OnSetCursor(WPARAM wParam, LPARAM lParam) const noexcept;
|
|
void _OnMaximizeChange() noexcept;
|
|
void _OnDragBarSizeChanged(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::SizeChangedEventArgs eventArgs);
|
|
|
|
void _SetIsBorderless(const bool borderlessEnabled) override;
|
|
void _SetIsFullscreen(const bool fullscreenEnabled) override;
|
|
bool _IsTitlebarVisible() const;
|
|
|
|
void _UpdateFrameMargins() const noexcept;
|
|
void _UpdateMaximizedState();
|
|
void _UpdateIslandPosition(const UINT windowWidth, const UINT windowHeight);
|
|
};
|