Skip to content

Commit

Permalink
I suppose this works for the titlebar in fomo
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Sep 8, 2021
1 parent c5518d4 commit f97efcc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void IslandWindow::SetTaskbarProgress(const size_t state, const size_t progress)
}

// From GdiEngine::s_SetWindowLongWHelper
void _SetWindowLongWHelper(const HWND hWnd, const int nIndex, const LONG dwNewLong) noexcept
void SetWindowLongWHelper(const HWND hWnd, const int nIndex, const LONG dwNewLong) noexcept
{
// SetWindowLong has strange error handling. On success, it returns the
// previous Window Long value and doesn't modify the Last Error state. To
Expand Down Expand Up @@ -933,14 +933,14 @@ void IslandWindow::_SetIsBorderless(const bool borderlessEnabled)

// First, modify regular window styles as appropriate
auto windowStyle = _getDesiredWindowStyle();
_SetWindowLongWHelper(hWnd, GWL_STYLE, windowStyle);
SetWindowLongWHelper(hWnd, GWL_STYLE, windowStyle);

// Now modify extended window styles as appropriate
// When moving to fullscreen, remove the window edge style to avoid an
// ugly border when not focused.
auto exWindowStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
WI_UpdateFlag(exWindowStyle, WS_EX_WINDOWEDGE, !_fullscreen);
_SetWindowLongWHelper(hWnd, GWL_EXSTYLE, exWindowStyle);
SetWindowLongWHelper(hWnd, GWL_EXSTYLE, exWindowStyle);

// Resize the window, with SWP_FRAMECHANGED, to trigger user32 to
// recalculate the non/client areas
Expand Down Expand Up @@ -1078,14 +1078,14 @@ void IslandWindow::_SetIsFullscreen(const bool fullscreenEnabled)

// First, modify regular window styles as appropriate
auto windowStyle = _getDesiredWindowStyle();
_SetWindowLongWHelper(hWnd, GWL_STYLE, windowStyle);
SetWindowLongWHelper(hWnd, GWL_STYLE, windowStyle);

// Now modify extended window styles as appropriate
// When moving to fullscreen, remove the window edge style to avoid an
// ugly border when not focused.
auto exWindowStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
WI_UpdateFlag(exWindowStyle, WS_EX_WINDOWEDGE, !_fullscreen);
_SetWindowLongWHelper(hWnd, GWL_EXSTYLE, exWindowStyle);
SetWindowLongWHelper(hWnd, GWL_EXSTYLE, exWindowStyle);

// Only change the window position if changing fullscreen state.
if (fChangingFullscreen)
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <winrt/TerminalApp.h>
#include "../../cascadia/inc/cppwinrt_utils.h"

void SetWindowLongWHelper(const HWND hWnd, const int nIndex, const LONG dwNewLong) noexcept;

class IslandWindow :
public BaseWindow<IslandWindow>
{
Expand Down
18 changes: 16 additions & 2 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,13 @@ SIZE NonClientIslandWindow::GetTotalNonClientExclusiveSize(UINT dpi) const noexc
// - the HRESULT returned by DwmExtendFrameIntoClientArea.
void NonClientIslandWindow::_UpdateFrameMargins() const noexcept
{
MARGINS margins = {};
MARGINS margins = { 0, 0, 0, 0 };

if (_GetTopBorderHeight() != 0)
if (_borderless)
{
margins.cyTopHeight = 1;
}
else if (_GetTopBorderHeight() != 0)
{
RECT frame = {};
winrt::check_bool(::AdjustWindowRectExForDpi(&frame, GetWindowStyle(_window.get()), FALSE, 0, _currentDpi));
Expand Down Expand Up @@ -896,6 +900,16 @@ void NonClientIslandWindow::_SetIsBorderless(const bool borderlessEnabled)
_titlebar.Visibility(_IsTitlebarVisible() ? Visibility::Visible : Visibility::Collapsed);
}

// These are all useless.
// auto windowStyle = GetWindowLongW(GetHandle(), GWL_STYLE);
// WI_ClearAllFlags(windowStyle, WS_OVERLAPPEDWINDOW);
// WI_SetFlag(windowStyle, WS_SIZEBOX);
// // WI_SetFlag(windowStyle, WS_BORDER);
// WI_SetFlag(windowStyle, WS_POPUP);
// SetWindowLongWHelper(GetHandle(), GWL_STYLE, windowStyle);

_UpdateFrameMargins();

// GH#4224 - When the auto-hide taskbar setting is enabled, then we don't
// always get another window message to trigger us to remove the drag bar.
// So, make sure to update the size of the drag region here, so that it
Expand Down

0 comments on commit f97efcc

Please sign in to comment.