Skip to content

Commit a6cc969

Browse files
Update specs/WindowControlsOverlayConfiguration.md
1 parent 8ff7c9e commit a6cc969

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

specs/WindowControlsOverlayConfiguration.md

+30-17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The overlay Settings lives on the controller object.
1010

1111
This API is designed to be used in addition with the other non-client region APIs
1212
and features. These include `app-region: drag`, and `IsNonClientRegionSupportEnabled`.
13+
14+
# Conceptual pages (How To)
15+
Here is a concept doc on the window controls overlay: https://wicg.github.io/window-controls-overlay/#concepts. This was written for the PWA counterpart for this feature. From the perspective of HTML & Javascript layers, everything there applies in Webview2 as well.
16+
1317
# Examples
1418

1519
## Win32 C++
@@ -27,15 +31,19 @@ AppWindow::AppWindow() {
2731

2832
void AppWindow::OnCreateWebview2ControllerCompleted(HRESULT hr, ICoreWebview2Controller* controller)
2933
{
30-
wil::com_ptr<ICoreWebView2Controller5> controller5;
31-
CHECK_FAILURE(controller->QueryInterface(&controller5));
3234

33-
wil::com_ptr<ICoreWebView2WindowControlsOverlaySettings> wco_config;
34-
CHECK_FAILURE(controller5->get_WindowControlsOverlaySettings(&wco_config));
35+
wil::com_ptr<ICoreWebView2> coreWebView2;
36+
CHECK_FAILURE(m_controller->get_CoreWebView2(&coreWebView2));
37+
38+
wil::com_ptr<ICoreWebView2> coreWebView2_28;
39+
CHECK_FAILURE(coreWebView2->QueryInterface(&coreWebView2_28));
3540

36-
wco_config->put_IsEnabled(true);
41+
wil::com_ptr<ICoreWebView2WindowControlsOverlaySettings> windowControlsOverlaySettings;
42+
CHECK_FAILURE(coreWebView2_28->get_WindowControlsOverlaySettings(&wco_config));
43+
44+
CHECK_FAILURE(wco_config->put_IsEnabled(true));
3745
COREWEBVIEW2_COLOR color {1, 0, 0, 225};
38-
wco_config->put_TitleBarColor(color);
46+
CHECK_FAILURE(wco_config->put_TitleBarBackgroundColor(color));
3947
}
4048
```
4149
## .NET C#
@@ -47,7 +55,7 @@ public MainWindow()
4755
InitializeComponent();
4856
m_AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
4957
50-
CoreWebView2WindowControlsOverlaySettings config = _coreWebView2Controller.WindowControlsOverlaySettings;
58+
CoreWebView2WindowControlsOverlaySettings config = Webview2.CoreWebivew2.WindowControlsOverlaySettings;
5159
config.IsEnabled = true;
5260
config.color = Color.FromARGB(0, 0, 255);
5361
}
@@ -61,7 +69,7 @@ public MainWindow()
6169
/// initialization errors appropriately. Provide your users with a way to close the window
6270
/// or restart the App.
6371
[uuid(101e36ca-7f75-5105-b9be-fea2ba61a2fd), object, pointer_default(unique)]
64-
interface ICoreWebView2Controller5 : IUnknown {
72+
interface ICoreWebView2_28 : IUnknown {
6573
/// Gets the `WindowControlsOverlaySettings` object.
6674
[propget] HRESULT WindowControlsOverlaySettings([out, retval] ICoreWebView2WindowControlsOverlaySettings** value);
6775
}
@@ -74,7 +82,10 @@ interface ICoreWebView2WindowControlsOverlaySettings : IUnknown {
7482

7583

7684
/// The `Height` property in raw screen pixels, allows you to set the height of the overlay and
77-
/// title bar area. Defaults to 48px.
85+
/// title bar area. Defaults to 48px. There is no minimum height restriction for this API,
86+
/// so it is up to the developer to make sure that the height of your window controls overlay
87+
/// is enough that users can see and interact with it. We recommend using GetSystemMetrics(SM_CYCAPTION)
88+
// as you minimum height.
7889
///
7990
[propput] HRESULT Height([in] UINT32 value);
8091

@@ -97,22 +108,23 @@ interface ICoreWebView2WindowControlsOverlaySettings : IUnknown {
97108
///
98109
/// The Overlay buttons will sit on top of the HTML content, and will prevent mouse interactions
99110
/// with any elements directly below it, so you should avoid placing content there.
100-
/// To that end, there are four CSS environment vairables defined to help you
111+
/// To that end, there are four [CSS environment vairables](https://developer.mozilla.org/en-US/docs/Web/API/Window_Controls_Overlay_API#css_environment_variables)
112+
/// titlebar-area-x, titlebar-area-y, titlebar-area-width defined to help you
101113
/// get the dimensions of the available titlebar area to the left of the overlay.
102114
/// Similarly the navigator object wil contain a [WindowControlsOverlay property](https://developer.mozilla.org/en-US/docs/Web/API/WindowControlsOverlay)
103115
/// which can be used to get the titlebar area as a rect, and listen for changes
104116
/// to the size of that area.
105117
///
106118
[propput] HRESULT IsEnabled([in] BOOL value);
107119

108-
/// Gets the `TitleBarColor` property.
109-
[propget] HRESULT TitleBarColor([out, retval] COREWEBVIEW2_COLOR* value);
120+
/// Gets the `TitleBarBackgroundColor` property.
121+
[propget] HRESULT TitleBarBackgroundColor([out, retval] COREWEBVIEW2_COLOR* value);
110122

111-
/// The `TitleBarColor` property allows you to set a background color
123+
/// The `TitleBarBackgroundColor` property allows you to set a background color
112124
/// for the overlay. Based on the background color you choose, Webview2
113125
///will automatically calculate a foreground and hover color that will
114126
/// provide you the best contrast while maintaining accessibility.
115-
/// Defaults to #f3f3f3
127+
/// Defaults to #f3f3f3. This API supports transparency.
116128
[propput] HRESULT TitleBarBackgroundColor([in] COREWEBVIEW2_COLOR value);
117129
}
118130
```
@@ -121,9 +133,9 @@ interface ICoreWebView2WindowControlsOverlaySettings : IUnknown {
121133
```c#
122134
namespace Microsoft.Web.WebView2.Core
123135
{
124-
runtimeclass CoreWebView2Controller
136+
runtimeclass CoreWebView2
125137
{
126-
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Controller")]
138+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2_28")]
127139
{
128140
CoreWebView2WindowControlsOverlaySettings WindowControlsOverlaySettings { get; };
129141
}
@@ -135,8 +147,9 @@ namespace Microsoft.Web.WebView2.Core
135147
{
136148
Boolean IsEnabled { get; set; };
137149
UInt32 Height { get; set; };
138-
Windows.UI.Color TitleBarColor { get; set; }
150+
Windows.UI.Color TitleBarBackgroundColor { get; set; }
139151
}
140152
}
141153
}
142154
```
155+

0 commit comments

Comments
 (0)