Skip to content

Commit e24df7e

Browse files
benhillisBen Hillis
andauthored
Resolve issue with buttons on notifications not working correctly (#13921)
* Resolve issue with buttons on notifications not working correctly * pr feedback --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
1 parent 180d811 commit e24df7e

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

src/windows/common/notifications.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ try
8686
</binding>
8787
</visual>
8888
<actions>
89-
<action arguments='--{}' content='{}'/>
90-
<action arguments='--{}' content='{}'/>
89+
<action arguments='{}' content='{}'/>
90+
<action arguments='{}' content='{}'/>
9191
</actions>
9292
</toast>)",
9393
Localization::MessageNewWslVersionAvailable(Localization::Options::DontImpersonate),
@@ -118,8 +118,8 @@ try
118118
</binding>
119119
</visual>
120120
<actions>
121-
<action arguments='--{} {}' content='{}'/>
122-
<action arguments='--{} {}' content="{}"/>
121+
<action arguments='{} {}' content='{}'/>
122+
<action arguments='{} {}' content="{}"/>
123123
</actions>
124124
</toast>)",
125125
Localization::MessagePerformanceTip(Localization::Options::DontImpersonate),
@@ -151,7 +151,7 @@ try
151151
</binding>
152152
</visual>
153153
<actions>
154-
<action arguments='--{}' content='{}'/>
154+
<action arguments='{}' content='{}'/>
155155
</actions>
156156
</toast>)",
157157
Localization::MessageWarningDuringStartup(),
@@ -176,7 +176,7 @@ try
176176
</binding>
177177
</visual>
178178
<actions>
179-
<action arguments='--{}' content='{}'/>
179+
<action arguments='{}' content='{}'/>
180180
</actions>
181181
</toast>)",
182182
Localization::MessageMissingOptionalComponents(),

src/windows/inc/wslhost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ LPCWSTR const handle_option = L"--handle";
3333
LPCWSTR const event_option = L"--event";
3434
LPCWSTR const parent_option = L"--parent";
3535
LPCWSTR const vm_id_option = L"--vm-id";
36-
LPCWSTR const embedding_option = L"--Embedding";
36+
LPCWSTR const embedding_option = L"-Embedding";
3737
} // namespace wslhost

src/windows/service/exe/LxssUserSession.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,13 +2172,22 @@ HRESULT LxssUserSessionImpl::Shutdown(_In_ bool PreventNewInstances, ShutdownBeh
21722172
return S_OK;
21732173
}
21742174

2175-
void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const
2175+
void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket) const
21762176
try
21772177
{
21782178
wsl::windows::common::wslutil::SetThreadDescription(L"Telemetry");
21792179

21802180
wsl::shared::SocketChannel channel(std::move(socket), "Telemetry", m_vmTerminating.get());
21812181

2182+
// Check if drvfs notifications are enabled for the user.
2183+
bool drvFsNotifications{};
2184+
{
2185+
auto impersonate = wil::impersonate_token(m_userToken.get());
2186+
const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
2187+
drvFsNotifications =
2188+
wsl::windows::common::registry::ReadDword(lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
2189+
}
2190+
21822191
// Aggregate information about what is running inside the VM. This is logged
21832192
// periodically because logging each event individually would be too noisy.
21842193
for (;;)
@@ -2852,17 +2861,9 @@ void LxssUserSessionImpl::_CreateVm()
28522861
// If the telemetry is enabled, launch the telemetry agent inside the VM.
28532862
if (m_utilityVm->GetConfig().EnableTelemetry && TraceLoggingProviderEnabled(g_hTraceLoggingProvider, WINEVENT_LEVEL_INFO, 0))
28542863
{
2855-
bool drvFsNotifications = false;
2856-
{
2857-
auto impersonate = wil::impersonate_token(m_userToken.get());
2858-
const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
2859-
drvFsNotifications = wsl::windows::common::registry::ReadDword(
2860-
lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
2861-
}
2862-
28632864
LPCSTR Arguments[] = {LX_INIT_TELEMETRY_AGENT, nullptr};
28642865
auto socket = m_utilityVm->CreateRootNamespaceProcess(LX_INIT_PATH, Arguments);
2865-
m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket), drvFsNotifications);
2866+
m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket));
28662867
}
28672868

28682869
m_pluginManager.OnVmStarted(&m_session, &userSettings);

src/windows/service/exe/LxssUserSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class LxssUserSessionImpl
503503
/// <summary>
504504
/// Worker thread for logging telemetry about processes running inside of WSL.
505505
/// </summary>
506-
void TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const;
506+
void TelemetryWorker(_In_ wil::unique_socket&& socket) const;
507507

508508
/// <summary>
509509
/// Terminates a distribution by it's client identifier.

src/windows/wslhost/main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ class DECLSPEC_UUID("2B9C59C3-98F1-45C8-B87B-12AE3C7927E8") NotificationActivato
7474
// Log telemetry when a WSL notification is activated, used to determine user engagement for notifications
7575
WSL_LOG_TELEMETRY("NotificationActivate", PDT_ProductAndServicePerformance, TraceLoggingValue(invokedArgs, "Arguments"));
7676

77-
// Prepend the executable name to the arguments so getopt can be used to parse the arguments.
78-
auto commandLine = wil::GetModuleFileNameW<std::wstring>(wil::GetModuleInstanceHandle());
79-
commandLine += L" ";
80-
commandLine += invokedArgs;
81-
82-
ArgumentParser parser(GetCommandLineW(), wslhost::binary_name);
77+
ArgumentParser parser(invokedArgs, wslhost::binary_name, 0);
8378
parser.AddArgument(
8479
[]() {
8580
std::wstring path;

0 commit comments

Comments
 (0)