[Flyout][Hotfix]Appear next to the tray icon position (#23772)

* [Flyout]Appear next to the tray icon position

* fix spellchecker
This commit is contained in:
Jaime Bernardo
2023-02-03 15:10:14 +00:00
committed by GitHub
parent 2e047e04de
commit fc8ee435e6
8 changed files with 153 additions and 48 deletions

View File

@@ -316,7 +316,7 @@ BOOL run_settings_non_elevated(LPCWSTR executable_path, LPWSTR executable_args,
DWORD g_settings_process_id = 0;
void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::optional<std::wstring> settings_window, bool show_flyout = false)
void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::optional<std::wstring> settings_window, bool show_flyout = false, const std::optional<POINT>& flyout_position = std::nullopt)
{
g_isLaunchInProgress = true;
@@ -389,21 +389,31 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
// Arg 10: should flyout be shown
std::wstring settings_showFlyout = show_flyout ? L"true" : L"false";
// Arg 11: contains if there's a settings window argument. If true, will add one extra argument with the value to the call.
std::wstring settings_containsSettingsWindow = settings_window.has_value() ? L"true" : L"false";
// Arg 12: contains if there's flyout coordinates. If true, will add two extra arguments to the call containing the x and y coordinates.
std::wstring settings_containsFlyoutPosition = flyout_position.has_value() ? L"true" : L"false";
// Args 13, .... : Optional arguments depending on the options presented before. All by the same value.
// create general settings file to initialize the settings file with installation configurations like :
// 1. Run on start up.
PTSettingsHelper::save_general_settings(save_settings.to_json());
std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {} {}",
executable_path,
powertoys_pipe_name,
settings_pipe_name,
std::to_wstring(powertoys_pid),
settings_theme,
settings_elevatedStatus,
settings_isUserAnAdmin,
settings_showOobe,
settings_showScoobe,
settings_showFlyout);
std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {} {} {} {}",
executable_path,
powertoys_pipe_name,
settings_pipe_name,
std::to_wstring(powertoys_pid),
settings_theme,
settings_elevatedStatus,
settings_isUserAnAdmin,
settings_showOobe,
settings_showScoobe,
settings_showFlyout,
settings_containsSettingsWindow,
settings_containsFlyoutPosition);
if (settings_window.has_value())
{
@@ -411,6 +421,14 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
executable_args.append(settings_window.value());
}
if (flyout_position)
{
executable_args.append(L" ");
executable_args.append(std::to_wstring(flyout_position.value().x));
executable_args.append(L" ");
executable_args.append(std::to_wstring(flyout_position.value().y));
}
BOOL process_created = false;
// Commented out to fix #22659
@@ -550,7 +568,7 @@ void bring_settings_to_front()
EnumWindows(callback, 0);
}
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout = false)
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout = false, const std::optional<POINT>& flyout_position)
{
if (g_settings_process_id != 0)
{
@@ -558,7 +576,14 @@ void open_settings_window(std::optional<std::wstring> settings_window, bool show
{
if (current_settings_ipc)
{
current_settings_ipc->send(L"{\"ShowYourself\":\"flyout\"}");
if (!flyout_position.has_value())
{
current_settings_ipc->send(L"{\"ShowYourself\":\"flyout\"}");
}
else
{
current_settings_ipc->send(fmt::format(L"{{\"ShowYourself\":\"flyout\", \"x_position\":{}, \"y_position\":{} }}", std::to_wstring(flyout_position.value().x), std::to_wstring(flyout_position.value().y)));
}
}
}
else
@@ -575,8 +600,8 @@ void open_settings_window(std::optional<std::wstring> settings_window, bool show
{
if (!g_isLaunchInProgress)
{
std::thread([settings_window, show_flyout]() {
run_settings_window(false, false, settings_window, show_flyout);
std::thread([settings_window, show_flyout, flyout_position]() {
run_settings_window(false, false, settings_window, show_flyout, flyout_position);
}).detach();
}
}
@@ -608,13 +633,6 @@ void open_scoobe_window()
}).detach();
}
void open_flyout()
{
std::thread([]() {
run_settings_window(false, false, std::nullopt, true);
}).detach();
}
std::string ESettingsWindowNames_to_string(ESettingsWindowNames value)
{
switch (value)