mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-22 08:02:24 +08:00
18eb6b4ffd
* created a folder for settings and added an overview, hotkey information * basic structure for communication between settings and runner * Added information about the IPC communication between settings and runner * Added information about the communication between the settings process and modules * Added details on backward compatibility * brief overview on settings utils * added an overview of the viewmodels and anomalies * minor modifications * Settings v2 dev docs (#7334) * Added settings architecture and tech stack dev docs * Added telemetry and updated architecture docs for settings v2 * Fix image link in ui_architecture markdown * Added table of contents for settings v2 * Correct file path for ui architecture image * nit fix in table of contents heading * Add doc for xaml island tweaks Co-authored-by: Divyansh Srivastava <somm14divi@gmail.com>
47 lines
2.6 KiB
Markdown
47 lines
2.6 KiB
Markdown
# Inter-Process Communication with Runner
|
|
|
|
The Settings v2 process uses two way IPC to communicate with the runner process.
|
|
|
|
## Initialization
|
|
- On the settings' side, the two way IPC delegates are contained with the [`ShellPage.xaml.cs`](/src/core/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml.cs) file. The delegates are static and the views for all the powerToys send the ipc information to the viewmodels as `ShellPage.DefaultSndMSGCallBack`.
|
|
- These delegates are initialized within the [`Mainwindow.xaml.cs`](/src/core/Microsoft.PowerToys.Settings.UI.Runner/MainWindow.xaml.cs) file in the `Settings.Runner` project.
|
|
|
|
|
|
## Types of IPC delegates
|
|
- There are three types of delegates for the settings to communicate with the runner:
|
|
1. `SendDefaultMessage` - This is used by all the viewmodels to communicate changes in the UI to the runner so that the information can be dispatched to the modules.
|
|
2. `RestartAsAdmin`
|
|
3. `CheckForUpdates`
|
|
|
|
## Sending information to runner
|
|
- The settings process communicates with the runner by using the delegates defined within the [`ShellPage.xaml.cs`](/src/core/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml.cs) file.
|
|
- Depending on the type of object sending the information, the json is created accordingly.
|
|
- If any information has been modified by the user in the GeneralSettings page, then the json file sent to the runner has the name set to `general`, whereas if any information has been modified by the user in any powertoy related settings page, the name of the json file being communicated with the runner is set to `powertoy`.
|
|
|
|
## Receiving information from runner
|
|
- The `ShellPage`object has a `IPCResponseHandleList` which is a list of functions which handle IPC responses.
|
|
|
|
```csharp
|
|
// receive IPC Message
|
|
Program.IPCMessageReceivedCallback = (string msg) =>
|
|
{
|
|
if (ShellPage.ShellHandler.IPCResponseHandleList != null)
|
|
{
|
|
try
|
|
{
|
|
JsonObject json = JsonObject.Parse(msg);
|
|
foreach (Action<JsonObject> handle in ShellPage.ShellHandler.IPCResponseHandleList)
|
|
{
|
|
handle(json);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
};
|
|
```
|
|
|
|
- Whenever any information is sent from the runner each of the functions in the handle list perform their action on that json object.
|
|
- One example of where information sent from the runner is being processed by the settings is in [`GeneralPage.xaml.cs`](/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml.cs) when the user clicks the check for updates button. The information displayed after, such as the user has the latest version installed is a result of this handle.
|