Skip to content

Commit

Permalink
This animates the window, but it's weird
Browse files Browse the repository at this point in the history
  We've got to do a SW_HIDE first if we want the window to appear. That causes
  the taskbar icon to flash if we're already open. Then, the border is visible
  always. That's certainly a little weird. It also doesn't work with restoring
  from minimized, but I haven't played with that much.

  It _feels_ like a hack, so I don't want to ship this. I'm gonna have to see if
  the win32 programming discussion alias has ideas.
  • Loading branch information
zadjii-msft committed Apr 23, 2021
1 parent 045a8db commit a6cd981
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,15 @@ winrt::fire_and_forget IslandWindow::SummonWindow()
// restore-down the window.
if (IsIconic(_window.get()))
{
LOG_IF_WIN32_BOOL_FALSE(ShowWindow(_window.get(), SW_RESTORE));
// LOG_IF_WIN32_BOOL_FALSE(ShowWindow(_window.get(), SW_RESTORE));

// auto success = AnimateWindow(_window.get(), 200, AW_SLIDE | AW_VER_POSITIVE);
// auto success = AnimateWindow(_window.get(), 200, AW_ACTIVATE | AW_SLIDE | AW_VER_POSITIVE);
// if (!success)
// {
// auto gle = GetLastError();
// gle;
// }
}
const DWORD windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), nullptr);
const DWORD currentThreadId = GetCurrentThreadId();
Expand All @@ -992,11 +1000,22 @@ winrt::fire_and_forget IslandWindow::SummonWindow()
LOG_IF_WIN32_BOOL_FALSE(AttachThreadInput(windowThreadProcessId, currentThreadId, false));
});
LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window.get()));
LOG_IF_WIN32_BOOL_FALSE(ShowWindow(_window.get(), SW_SHOW));

// Activate the window too. This will force us to the virtual desktop this
// window is on, if it's on another virtual desktop.
LOG_LAST_ERROR_IF_NULL(SetActiveWindow(_window.get()));
// LOG_IF_WIN32_BOOL_FALSE(ShowWindow(_window.get(), SW_SHOW));
LOG_IF_WIN32_BOOL_FALSE(ShowWindow(_window.get(), SW_HIDE));

// // Activate the window too. This will force us to the virtual desktop this
// // window is on, if it's on another virtual desktop.
// LOG_LAST_ERROR_IF_NULL(SetActiveWindow(_window.get()));
// AnimateWindow(_window.get(), 200, AW_ACTIVATE | AW_SLIDE | AW_VER_POSITIVE);
// LOG_IF_WIN32_BOOL_FALSE(AnimateWindow(_window.get(), 200, AW_ACTIVATE | AW_SLIDE | AW_VER_POSITIVE));
// auto success = AnimateWindow(_window.get(), 200, AW_SLIDE | AW_VER_POSITIVE);
auto success = AnimateWindow(_window.get(), 200, AW_SLIDE | AW_VER_POSITIVE);
// auto success = AnimateWindow(_window.get(), 200, AW_BLEND); // Hey this actually worked with a SW_HIDE right before it
if (!success)
{
auto gle = GetLastError();
gle;
}
}

DEFINE_EVENT(IslandWindow, DragRegionClicked, _DragRegionClickedHandlers, winrt::delegate<>);
Expand Down

0 comments on commit a6cd981

Please sign in to comment.