Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply a GDI region to the top level Island window to allow dragging with a single Xaml Island #929

Merged
merged 49 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2c7e4e8
Use a region to cut off the dragable region
ocalvo May 21, 2019
d1af4bd
It works
ocalvo May 21, 2019
7b34187
Adjust Slipt button for Title Bar
ocalvo May 21, 2019
80c6b93
Use proper measurements for the draggable area
ocalvo May 21, 2019
d56afcf
Remove dead code
ocalvo May 22, 2019
567a833
Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
ocalvo May 22, 2019
dc8213c
Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
ocalvo May 22, 2019
6a7ea45
Apply PR feedback
ocalvo May 22, 2019
fab0bc8
Apply PR feedback
ocalvo May 22, 2019
0d34b8f
Fix build break ARM64
ocalvo May 28, 2019
59260b1
Merge branch 'master' of https://github.com/microsoft/terminal
ocalvo May 28, 2019
754e843
Merge branch 'master' of https://github.com/microsoft/terminal
ocalvo May 28, 2019
14a8604
Something working
ocalvo May 30, 2019
8dabdb0
Merge branch 'master' of https://github.com/microsoft/terminal
ocalvo May 30, 2019
cd9185d
Apply PR feedback
ocalvo May 30, 2019
163b37c
Remove comment
ocalvo May 30, 2019
de9cbfa
Add comment
ocalvo May 30, 2019
d3fb2a6
Merge branch 'master' of https://github.com/ocalvo/terminal into NCPaint
ocalvo May 30, 2019
0a9570c
Almost working
ocalvo Jun 3, 2019
f41c866
Working a little more
ocalvo Jun 3, 2019
43d54a6
Working better, paint works most of the time
ocalvo Jun 3, 2019
f6ac3c4
Fix a bug where paint is incomplete when double clicking the dragbar
ocalvo Jun 3, 2019
2eb1f9b
Draw Edge
ocalvo Jun 3, 2019
2c4763d
Works end to end, window border is of incorrect color
ocalvo Jun 4, 2019
45e2c61
Fix bug
ocalvo Jun 4, 2019
50bc312
Deal with GDI objects
ocalvo Jun 6, 2019
3fd8482
Fix crash at shutdown
ocalvo Jun 6, 2019
f571c76
Force close
ocalvo Jun 6, 2019
c1ec4b1
Remove dead code
ocalvo Jun 6, 2019
3add2ee
Fix a bug where windows are not Destroyed
ocalvo Jun 6, 2019
0daa857
Close island when shuttding down
ocalvo Jun 6, 2019
83f9779
Delete dead code
ocalvo Jun 7, 2019
505624e
Remove not needed code
ocalvo Jun 7, 2019
024f478
Update src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
ocalvo Jun 19, 2019
525bbcf
Remove old fork on XamlApplication
ocalvo Jun 19, 2019
16cd22f
Merge branch 'master' of https://github.com/ocalvo/terminal
ocalvo Jun 19, 2019
d2ac3b4
Apply PR comments
ocalvo Jun 19, 2019
8b6e856
Merge branch 'master' of https://github.com/microsoft/terminal
ocalvo Jun 19, 2019
23d3765
Fix bad merge
ocalvo Jun 19, 2019
d5327ff
Fix code format
ocalvo Jun 19, 2019
0e1ea77
Upgrade to XamlApp preview6.2
ocalvo Jun 24, 2019
f831b76
Merge branch 'master' of https://github.com/microsoft/terminal
ocalvo Jun 24, 2019
c6703c3
Apply PR feedback
ocalvo Jun 24, 2019
2c3fd76
Fix build break (but not sure why or how)
ocalvo Jun 24, 2019
18dfcf4
Fix build break in ARM64
ocalvo Jun 24, 2019
db846ba
Add Microsoft.VCRTForwarders to make it easy to dogfood
ocalvo Jun 25, 2019
f9a311c
Apply PR feedback
ocalvo Jun 25, 2019
fdf0962
App,ly PR feedback
ocalvo Jun 25, 2019
e704ace
Fix code format
ocalvo Jun 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/cascadia/TerminalApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ namespace winrt::TerminalApp::implementation
// another for the settings button.
auto tabsColDef = Controls::ColumnDefinition();
auto newTabBtnColDef = Controls::ColumnDefinition();

newTabBtnColDef.Width(GridLengthHelper::Auto());

_tabRow.ColumnDefinitions().Append(tabsColDef);
Expand All @@ -112,11 +111,9 @@ namespace winrt::TerminalApp::implementation
_root.RowDefinitions().Append(tabBarRowDef);
_root.RowDefinitions().Append(Controls::RowDefinition{});

if (_settings->GlobalSettings().GetShowTabsInTitlebar() == false)
{
_root.Children().Append(_tabRow);
Controls::Grid::SetRow(_tabRow, 0);
}
_root.Children().Append(_tabRow);
Controls::Grid::SetRow(_tabRow, 0);

_root.Children().Append(_tabContent);
Controls::Grid::SetRow(_tabContent, 1);
Controls::Grid::SetColumn(_tabView, 0);
Expand All @@ -140,6 +137,8 @@ namespace winrt::TerminalApp::implementation
_CreateNewTabFlyout();

_tabRow.Children().Append(_tabView);

_newTabButton.Margin({ 0, 0, NON_CLIENT_DRAGBAR_WIDTH, 0 });
ocalvo marked this conversation as resolved.
Show resolved Hide resolved
_tabRow.Children().Append(_newTabButton);

_tabContent.VerticalAlignment(VerticalAlignment::Stretch);
Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace winrt::TerminalApp::implementation
{
const float NON_CLIENT_DRAGBAR_WIDTH = 300.0;

// We dont use AppT as it does not provide access to protected constructors
template <typename D, typename... I>
Expand All @@ -38,6 +39,11 @@ namespace winrt::TerminalApp::implementation
Windows::Foundation::Point GetLaunchDimensions(uint32_t dpi);
bool GetShowTabsInTitlebar();

float GetNonClientAreaDragBarWidth() const noexcept
ocalvo marked this conversation as resolved.
Show resolved Hide resolved
{
return NON_CLIENT_DRAGBAR_WIDTH;
}

~App();

hstring GetTitle();
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/App.idl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace TerminalApp

String GetTitle();

FLOAT GetNonClientAreaDragBarWidth();
ocalvo marked this conversation as resolved.
Show resolved Hide resolved

// IXamlMetadataProvider, Xaml.Application:
// Application's composing initializer will register the composing class
// as the toplevel "active" Xaml application. This Application (through IXamlMetadataProvider)
Expand Down
18 changes: 2 additions & 16 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,18 @@ using namespace winrt::Windows::UI::Xaml::Hosting;
using namespace winrt::Windows::Foundation::Numerics;
using namespace ::Microsoft::Console::Types;

// The tabs are 34.8px tall. This is their default height - we're not
// controlling the styling of the tabs at all currently. If we change the size
// of those, we'll need to change the size here, too. We can't get this size
// from the tab control until the control is added to a XAML element, and we
// can't create any XAML elements until we have a window, and we need to know
// this size before we can create a window, so unfortunately we're stuck
// hardcoding this.
const int NON_CLIENT_CONTENT_HEIGHT = static_cast<int>(std::round(34.8));
double NON_CLIENT_DRAGBAR_WIDTH = 0.0;

AppHost::AppHost() noexcept :
_app{},
_window{ nullptr }
{
_useNonClientArea = _app.GetShowTabsInTitlebar();
NON_CLIENT_DRAGBAR_WIDTH = _app.GetNonClientAreaDragBarWidth();
ocalvo marked this conversation as resolved.
Show resolved Hide resolved

if (_useNonClientArea)
{
_window = std::make_unique<NonClientIslandWindow>();
auto pNcWindow = static_cast<NonClientIslandWindow*>(_window.get());

pNcWindow->SetNonClientHeight(NON_CLIENT_CONTENT_HEIGHT);
}
else
{
Expand Down Expand Up @@ -75,11 +66,6 @@ void AppHost::Initialize()
AppTitleChanged(_app.GetTitle());

_window->SetRootContent(_app.GetRoot());
if (_useNonClientArea)
{
auto pNcWindow = static_cast<NonClientIslandWindow*>(_window.get());
pNcWindow->SetNonClientContent(_app.GetTabs());
}
}

// Method Description:
Expand Down
6 changes: 3 additions & 3 deletions src/cascadia/WindowsTerminal/BaseWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ class BaseWindow
//// https://docs.microsoft.com/en-us/windows/desktop/hidpi/high-dpi-desktop-application-development-on-windows#per-monitor-and-per-monitor-v2-dpi-awareness
winrt::Windows::Foundation::Size GetLogicalSize(const SIZE physicalSize) const noexcept
{
const auto dpi = GetCurrentDpiScale();
const auto scale = GetCurrentDpiScale();
// 0.5 is to ensure that we pixel snap correctly at the edges, this is necessary with odd DPIs like 1.25, 1.5, 1, .75
const auto logicalWidth = (physicalSize.cx / dpi) + 0.5f;
const auto logicalHeigth = (physicalSize.cy / dpi) + 0.5f;
const auto logicalWidth = (physicalSize.cx / scale) + 0.5f;
const auto logicalHeigth = (physicalSize.cy / scale) + 0.5f;
return winrt::Windows::Foundation::Size(logicalWidth, logicalHeigth);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IslandWindow : public BaseWindow<IslandWindow>
void OnRestore() override;
void SetRootContent(winrt::Windows::UI::Xaml::UIElement content);

virtual void Initialize();
void Initialize();

void SetCreateCallback(std::function<void(const HWND, const RECT)> pfn) noexcept;

Expand Down
Loading