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

Quickaccess systemtray launcher #22408

Merged
merged 55 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c59e0d5
Init
niels9001 Sep 1, 2022
baf9774
Fix running settings
stefansjfw Sep 2, 2022
1830a97
UI design
niels9001 Sep 2, 2022
f62d01e
Left click trigger
stefansjfw Sep 6, 2022
a282848
Wire up others
stefansjfw Sep 6, 2022
35c83b0
Update FlyoutWindow.xaml.cs
niels9001 Sep 9, 2022
3f1a304
Removed comments
niels9001 Sep 9, 2022
1231ec7
Update FlyoutWindow.xaml
niels9001 Sep 14, 2022
46c4c53
Merge branch 'main' into feature/sytrayflyoutpoc
niels9001 Nov 19, 2022
b1b5e05
More work
niels9001 Nov 20, 2022
72aa1b5
Open Settings page
niels9001 Nov 21, 2022
d73b837
Merge branch 'main' into feature/sytrayflyoutpoc
niels9001 Nov 23, 2022
6de8f58
Merge branch 'main' into feature/sytrayflyoutpoc
niels9001 Nov 23, 2022
1f97768
Merge branch 'main' into feature/sytrayflyoutpoc
niels9001 Nov 29, 2022
8fee8c1
Migrate spelling-0.0.21 changes from main
DHowett Nov 29, 2022
6389d0b
More UI work
niels9001 Dec 1, 2022
544ce00
Merge branch 'feature/sytrayflyoutpoc' of https://github.com/microsof…
niels9001 Dec 1, 2022
1af8d62
Merge branch 'main' into feature/sytrayflyoutpoc
niels9001 Jan 11, 2023
3efa848
Resolve conflicts
niels9001 Jan 11, 2023
3b9cf42
[General] SystemTray Flyout: Add update on tray items' visibility whe…
donlaci Jan 12, 2023
b152272
Adding app list
niels9001 Jan 12, 2023
19a76e4
Merge branch 'feature/sytrayflyoutpoc' of https://github.com/microsof…
niels9001 Jan 12, 2023
aecc160
Adding more buttons, resolving conflicts
niels9001 Jan 12, 2023
8f7ed67
[General] Flyout: improving opening, closing flyout/settings window. …
donlaci Jan 18, 2023
e7608ff
[General] FlyoutWindow: proceed with implementation. GPO works. Main …
donlaci Jan 20, 2023
02baf2b
[general] flyout: fix exit button
donlaci Jan 21, 2023
0592ca6
[general] flyout: implement double click handling
donlaci Jan 21, 2023
2b48a36
Localization
niels9001 Jan 24, 2023
5d63406
[Generel] Flyout: Re-implement flyout launching, add workaround: disa…
donlaci Jan 25, 2023
a260523
[general] flyout: restore the context menu when right clicking on sys…
donlaci Jan 25, 2023
3d7aa1c
Merge branch 'main' into feature/sytrayflyoutpoc
donlaci Jan 26, 2023
8f04df2
Fix spellchecker
jaimecbernardo Jan 26, 2023
f012466
[installer] fixing missing dll files + suppress error on not signed s…
donlaci Jan 26, 2023
5c8cc23
Fix spell checker
donlaci Jan 26, 2023
854615b
Fix flyout not focusing when activated
jaimecbernardo Jan 26, 2023
a230dc6
Refresh Settings UI enabled state when flyout changes
jaimecbernardo Jan 26, 2023
28e455d
fix spellcheck
jaimecbernardo Jan 26, 2023
c56885a
Remove VCM from the list
jaimecbernardo Jan 26, 2023
fad9252
[General] flyout: fix settings window opening. Switch to general page…
donlaci Jan 27, 2023
7182f7b
[general] flyout: add launching hosts app
donlaci Jan 27, 2023
a6f86e7
Fix CI build
jaimecbernardo Jan 27, 2023
c59683c
adding check on elevation when launching hosts
donlaci Jan 27, 2023
d200852
Use localization strings that already exist
jaimecbernardo Jan 27, 2023
f390b86
Remove dll not present in arm64 build
jaimecbernardo Jan 27, 2023
1341def
Adding GPO policy check for the launcher page items
donlaci Jan 27, 2023
0a8d74e
fix hosts launching
donlaci Jan 27, 2023
3be3239
Add telemetry
jaimecbernardo Jan 27, 2023
24f10b8
Also hide from all apps list when gpo is force enabling
jaimecbernardo Jan 27, 2023
0625f25
fix spellchecker
jaimecbernardo Jan 27, 2023
3721737
Improve focus issues
jaimecbernardo Jan 30, 2023
6f3f346
Merge branch 'main' into feature/sytrayflyoutpoc
jaimecbernardo Jan 30, 2023
402a203
Fix flickering Bitmap Icons
jaimecbernardo Jan 30, 2023
f9dde03
Fix telemetry error
jaimecbernardo Jan 30, 2023
1f0fb52
Fix telemetry call
jaimecbernardo Jan 30, 2023
0fe619f
Fix wrong comment
jaimecbernardo Jan 30, 2023
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
4 changes: 3 additions & 1 deletion .github/actions/spell-check/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ CHILDACTIVATE
CHILDWINDOW
Choibalsan
chrdavis
chromaticities
Chrzan
cht
Chukotka
Expand Down Expand Up @@ -995,6 +996,7 @@ Markovic
Marquesas
martinchrzan
martinmoene
Masure
Mato
Maximizable
MAXIMIZEBOX
Expand Down Expand Up @@ -2156,4 +2158,4 @@ Zoneszonabletester
Zonev
zopfli
Zykova
zzz
zzz
12 changes: 12 additions & 0 deletions src/common/interop/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ public
return gcnew String(CommonSharedConstants::FZE_EXIT_EVENT);
}

static String ^ FZEToggleEvent() {
return gcnew String(CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT);
}

static String ^ ColorPickerSendSettingsTelemetryEvent() {
return gcnew String(CommonSharedConstants::COLOR_PICKER_SEND_SETTINGS_TELEMETRY_EVENT);
}
Expand All @@ -207,6 +211,14 @@ public
return gcnew String(CommonSharedConstants::POWERACCENT_EXIT_EVENT);
}

static String ^ ShortcutGuideTriggerEvent() {
return gcnew String(CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT);
}

static String
^ MasureToolTriggerEvent() {
return gcnew String(CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT);
}
static String ^ GcodePreviewResizeEvent() {
return gcnew String(CommonSharedConstants::GCODE_PREVIEW_RESIZE_EVENT);
}
Expand Down
5 changes: 5 additions & 0 deletions src/common/interop/shared_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace CommonSharedConstants
// Path to the event used to show Color Picker
const wchar_t SHOW_COLOR_PICKER_SHARED_EVENT[] = L"Local\\ShowColorPickerEvent-8c46be2a-3e05-4186-b56b-4ae986ef2525";

const wchar_t SHORTCUT_GUIDE_TRIGGER_EVENT[] = L"Local\\ShortcutGuide-TriggerEvent-d4275ad3-2531-4d19-9252-c0becbd9b496";

const wchar_t SHORTCUT_GUIDE_EXIT_EVENT[] = L"Local\\ShortcutGuide-ExitEvent-35697cdd-a3d2-47d6-a246-34efcc73eac0";

const wchar_t FANCY_ZONES_EDITOR_TOGGLE_EVENT[] = L"Local\\FancyZones-ToggleEditorEvent-1e174338-06a3-472b-874d-073b21c62f14";
Expand All @@ -44,6 +46,9 @@ namespace CommonSharedConstants
// Path to the event used by PowerOCR
const wchar_t SHOW_POWEROCR_SHARED_EVENT[] = L"Local\\PowerOCREvent-dc864e06-e1af-4ecc-9078-f98bee745e3a";

// Path to the event used by MeasureTool
const wchar_t MEASURE_TOOL_TRIGGER_EVENT[] = L"Local\\MeasureToolEvent-3d46745f-09b3-4671-a577-236be7abd199";

// Path to the event used by GcodePreviewHandler
const wchar_t GCODE_PREVIEW_RESIZE_EVENT[] = L"Local\\PowerToysGcodePreviewResizeEvent-6ff1f9bd-ccbd-4b24-a79f-40a34fb0317d";

Expand Down
10 changes: 10 additions & 0 deletions src/modules/MeasureTool/MeasureToolModuleInterface/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <interface/powertoy_module_interface.h>
#include <common/SettingsAPI/settings_objects.h>
#include "trace.h"
#include <common/interop/shared_constants.h>
#include <common/utils/string_utils.h>
#include <common/utils/winapi_error.h>
#include <common/utils/logger_helper.h>
#include <common/utils/EventWaiter.h>

extern "C" IMAGE_DOS_HEADER __ImageBase;

Expand Down Expand Up @@ -49,6 +51,9 @@ class MeasureTool : public PowertoyModuleIface
Hotkey m_hotkey;
HANDLE m_hProcess;

HANDLE triggerEvent;
EventWaiter triggerEventWaiter;

void parse_hotkey(PowerToysSettings::PowerToyValues& settings)
{
auto settingsObject = settings.get_raw_json();
Expand Down Expand Up @@ -142,6 +147,11 @@ class MeasureTool : public PowertoyModuleIface
{
LoggerHelpers::init_logger(L"Measure Tool", L"ModuleInterface", "Measure Tool");
init_settings();

triggerEvent = CreateEvent(nullptr, false, false, CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT);
triggerEventWaiter = EventWaiter(CommonSharedConstants::MEASURE_TOOL_TRIGGER_EVENT, [this](int) {
on_hotkey(0);
});
}

~MeasureTool()
Expand Down
2 changes: 1 addition & 1 deletion src/modules/MeasureTool/MeasureToolUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="using:PowerToys.MeasureToolUI.Properties"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="using:PowerToys.MeasureToolUI.Properties"
xmlns:winuiex="using:WinUIEx"
IsAlwaysOnTop="True"
IsMaximizable="False"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../interface/powertoy_module_interface.h"
#include "Generated Files/resource.h"
#include <common/SettingsAPI/settings_objects.h>
#include <common/utils/EventWaiter.h>

BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD /*ul_reason_for_call*/, LPVOID /*lpReserved*/)
{
Expand All @@ -35,6 +36,11 @@ class ShortcutGuideModule : public PowertoyModuleIface
Logger::warn(L"Failed to create {} event. {}", CommonSharedConstants::SHORTCUT_GUIDE_EXIT_EVENT, get_last_error_or_default(GetLastError()));
}

triggerEvent = CreateEvent(nullptr, false, false, CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT);
triggerEventWaiter = EventWaiter(CommonSharedConstants::SHORTCUT_GUIDE_TRIGGER_EVENT, [this](int) {
OnHotkeyEx();
});

InitSettings();
}

Expand Down Expand Up @@ -191,7 +197,9 @@ class ShortcutGuideModule : public PowertoyModuleIface
UINT m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS;
UINT m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS;

HANDLE triggerEvent;
HANDLE exitEvent;
EventWaiter triggerEventWaiter;

bool StartProcess(std::wstring args = L"")
{
Expand Down
2 changes: 1 addition & 1 deletion src/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow
{
window = winrt::to_hstring(settingsWindow);
}
open_settings_window(window);
open_settings_window(window, false);
}

if (openOobe)
Expand Down
66 changes: 55 additions & 11 deletions src/runner/settings_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
#include "restart_elevated.h"
#include "UpdateUtils.h"
#include "centralized_kb_hook.h"
#include "Generated files/resource.h"

#include <common/utils/json.h>
#include <common/SettingsAPI/settings_helpers.cpp>
#include <common/version/version.h>
#include <common/version/helper.h>
#include <common/logger/logger.h>
#include <common/utils/resources.h>
#include <common/utils/elevation.h>
#include <common/utils/process_path.h>
#include <common/utils/timeutil.h>
Expand Down Expand Up @@ -175,7 +177,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
{
std::unique_lock lock{ ipc_mutex };
if(current_settings_ipc)
if (current_settings_ipc)
current_settings_ipc->send(settings_string);
}
}
Expand All @@ -185,7 +187,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
{
std::unique_lock lock{ ipc_mutex };
if(current_settings_ipc)
if (current_settings_ipc)
current_settings_ipc->send(settings_string);
}
}
Expand All @@ -194,7 +196,7 @@ void dispatch_received_json(const std::wstring& json_to_parse)
const std::wstring settings_string{ get_all_settings().Stringify().c_str() };
{
std::unique_lock lock{ ipc_mutex };
if(current_settings_ipc)
if (current_settings_ipc)
current_settings_ipc->send(settings_string);
}
}
Expand All @@ -205,11 +207,27 @@ void dispatch_received_json(const std::wstring& json_to_parse)
{
{
std::unique_lock lock{ ipc_mutex };
if(current_settings_ipc)
if (current_settings_ipc)
current_settings_ipc->send(result.value());
}
}
}
else if (name == L"bugreport")
{
// std::wstring bug_report_path = get_module_folderpath();
// bug_report_path += L"\\Tools\\PowerToys.BugReportTool.exe";
// SHELLEXECUTEINFOW sei{ sizeof(sei) };
// sei.fMask = { SEE_MASK_FLAG_NO_UI | SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NO_CONSOLE };
// sei.lpFile = bug_report_path.c_str();
// sei.nShow = SW_HIDE;
// if (ShellExecuteExW(&sei))
// {
// WaitForSingleObject(sei.hProcess, INFINITE);
// CloseHandle(sei.hProcess);
// static const std::wstring bugreport_success = GET_RESOURCE_STRING(IDS_BUGREPORT_SUCCESS);
// MessageBoxW(nullptr, bugreport_success.c_str(), L"PowerToys", MB_OK);
// }
}
}
return;
}
Expand Down Expand Up @@ -290,7 +308,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)
void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::optional<std::wstring> settings_window, bool show_flyout = false)
{
g_isLaunchInProgress = true;

Expand Down Expand Up @@ -360,11 +378,14 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
// Arg 9: should scoobe window be shown
std::wstring settings_showScoobe = show_scoobe_window ? L"true" : L"false";

// Arg 10: should flyout be shown
std::wstring settings_showFlyout = show_flyout ? L"true" : L"false";

// 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"\"{}\" {} {} {} {} {} {} {} {}",
std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {} {}",
executable_path,
powertoys_pipe_name,
settings_pipe_name,
Expand All @@ -373,7 +394,8 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op
settings_elevatedStatus,
settings_isUserAnAdmin,
settings_showOobe,
settings_showScoobe);
settings_showScoobe,
settings_showFlyout);

if (settings_window.has_value())
{
Expand Down Expand Up @@ -520,18 +542,33 @@ void bring_settings_to_front()
EnumWindows(callback, 0);
}

void open_settings_window(std::optional<std::wstring> settings_window)
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout = false)
{
if (g_settings_process_id != 0)
{
bring_settings_to_front();
if (show_flyout)
{
if (current_settings_ipc)
{
current_settings_ipc->send(L"{\"ShowYourself\":\"flyout\"}");
}
}
else
{
// nl instead of showing the window, send message to it (flyout might need to be hidden, main setting window activated)
// bring_settings_to_front();
if (current_settings_ipc)
{
current_settings_ipc->send(L"{\"ShowYourself\":\"mainpage\"}");
}
}
}
else
{
if (!g_isLaunchInProgress)
{
std::thread([settings_window]() {
run_settings_window(false, false, settings_window);
std::thread([settings_window, show_flyout]() {
run_settings_window(false, false, settings_window, show_flyout);
}).detach();
}
}
Expand Down Expand Up @@ -563,6 +600,13 @@ 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)
Expand Down
3 changes: 2 additions & 1 deletion src/runner/settings_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ enum class ESettingsWindowNames
std::string ESettingsWindowNames_to_string(ESettingsWindowNames value);
ESettingsWindowNames ESettingsWindowNames_from_string(std::string value);

void open_settings_window(std::optional<std::wstring> settings_window);
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout);
void close_settings_window();

void open_oobe_window();
void open_scoobe_window();
void open_flyout();
35 changes: 6 additions & 29 deletions src/runner/tray_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam)
case ID_SETTINGS_MENU_COMMAND:
{
std::wstring settings_window{ winrt::to_hstring(ESettingsWindowNames_to_string(static_cast<ESettingsWindowNames>(lparam))) };
open_settings_window(settings_window);
open_settings_window(settings_window, false);
}
break;
case ID_EXIT_MENU_COMMAND:
Expand Down Expand Up @@ -168,38 +168,15 @@ LRESULT __stdcall tray_icon_window_proc(HWND window, UINT message, WPARAM wparam
{
switch (lparam)
{
case WM_LBUTTONDBLCLK:
case WM_LBUTTONUP:
{
open_settings_window(std::nullopt);
open_settings_window(std::nullopt, true);
break;
}
case WM_RBUTTONUP:
case WM_CONTEXTMENU:
case WM_LBUTTONDBLCLK:
{
if (!h_menu)
{
h_menu = LoadMenu(reinterpret_cast<HINSTANCE>(&__ImageBase), MAKEINTRESOURCE(ID_TRAY_MENU));
}
if (h_menu)
{
static std::wstring settings_menuitem_label = GET_RESOURCE_STRING(IDS_SETTINGS_MENU_TEXT);
static std::wstring exit_menuitem_label = GET_RESOURCE_STRING(IDS_EXIT_MENU_TEXT);
static std::wstring submit_bug_menuitem_label = GET_RESOURCE_STRING(IDS_SUBMIT_BUG_TEXT);
static std::wstring documentation_menuitem_label = GET_RESOURCE_STRING(IDS_DOCUMENTATION_MENU_TEXT);

change_menu_item_text(ID_SETTINGS_MENU_COMMAND, settings_menuitem_label.data());
change_menu_item_text(ID_EXIT_MENU_COMMAND, exit_menuitem_label.data());
change_menu_item_text(ID_REPORT_BUG_COMMAND, submit_bug_menuitem_label.data());
change_menu_item_text(ID_DOCUMENTATION_MENU_COMMAND, documentation_menuitem_label.data());
}
if (!h_sub_menu)
{
h_sub_menu = GetSubMenu(h_menu, 0);
}
POINT mouse_pointer;
GetCursorPos(&mouse_pointer);
SetForegroundWindow(window); // Needed for the context menu to disappear.
TrackPopupMenu(h_sub_menu, TPM_CENTERALIGN | TPM_BOTTOMALIGN, mouse_pointer.x, mouse_pointer.y, 0, window, nullptr);
open_settings_window(std::nullopt, false);
break;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/runner/tray_icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void start_tray_icon();
// Stop the Tray Icon
void stop_tray_icon();
// Open the Settings Window
void open_settings_window(std::optional<std::wstring> settings_window);
void open_settings_window(std::optional<std::wstring> settings_window, bool show_flyout);
// Callback type to be called by the tray icon loop
typedef void (*main_loop_callback_function)(PVOID);
// Calls a callback in _callback
Expand Down
Loading