Skip to content

Commit

Permalink
Still trying to figure this out exactly. For linking: #653
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jan 28, 2021
1 parent 1dcb4cb commit fee6473
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,40 +870,35 @@ void IslandWindow::SetGlobalHotkey(const winrt::Microsoft::Terminal::TerminalCon

winrt::fire_and_forget IslandWindow::SummonWindow()
{
// A SC_HOTKEY WM_SYSCOMMAND that's _not_ processed my a wndproc will summon
// the window exactly the way we want. So send that yo ourselves.
// On the foreground thread:
// * Restore the window from minimized
// * Activate the window
// * focus the window
// * IMPORTANT: MAKE THE WINDOW THE FOREGROUND WINDOW
// - If you forget this last one, you'll start blinking the cursor for the
// Terminal, but it WON'T ACTUALLY BE THE FOREGROUND WINDOW. It won't
// recieve keyboard input. Crazy.

// TODO: This isn't right either. This just causes the window to blink. Hmm.
// I wonder if this is because we're doing it from an RPC thread (likely).

// Does the mysterious "cursor starts blinking but doesn't accept keyboard focus"
// SendMessage(_window.get(), WM_SYSCOMMAND, SC_HOTKEY, (LPARAM)(_window.get()));

// Does the mysterious "cursor starts blinking but doesn't accept keyboard focus"
// ShowWindow(_window.get(), SW_RESTORE);
// SetActiveWindow(_window.get());
// SetFocus(_window.get());

// Does nothing at all
// ShowWindow(_window.get(), SW_SHOWNORMAL);

// The co_await didn't help here
// co_await winrt::resume_foreground(_rootGrid.Dispatcher());
// ShowWindow(_window.get(), SW_RESTORE);
// SetActiveWindow(_window.get());
// SetFocus(_window.get());
co_await winrt::resume_foreground(_rootGrid.Dispatcher());
ShowWindow(_window.get(), SW_RESTORE); // TODO: Frick this will restore down too. We don't want that.
// This doesn't _really_ help, but it might help put the window on top of the Z order.

// This (even with a co_await didn't work, and it doesn't restore a minimized window)
// SetWindowPos(_window.get(),
// HWND_TOP,
// 0,
// 0,
// 0,
// 0,
// SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);

co_await winrt::resume_foreground(_rootGrid.Dispatcher());
ShowWindow(_window.get(), SW_RESTORE);
SetActiveWindow(_window.get());
SetFocus(_window.get());
SetForegroundWindow(_window.get());

// TODO: Why doesn't this work if the window is _not_ minimized? If the
// window is minimized, this works like a charm. W E I R D
}

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

1 comment on commit fee6473

@github-actions

This comment was marked as outdated.

Please sign in to comment.