5

I am working on an application using getDisplayMedia. When the browser prompts me to share my screen/a window and I select a specific window to share, that window is now suddenly focused and in front of my other windows (in particular, in front of the browser window!). I tested this with Firefox and Chrome, each on Ubuntu and Windows 10. I used this page to test.

I personally find this behavior kind of unexpected and annoying. I also fear that the technically less-inclined users of my application get very confused by this. So I'd like the browser to stay focused even after selecting a window. Is it possible to change that behavior? I checked the MDN docs on getDisplayMedia but did not find anything regarding this. I also did not find any information about this elsewhere.

If it's not possible to adjust that behavior, I'd like to know: why? Is it a technical limitation? Is it a privacy/security feature to make it more clear to the user that this window is shared now? (Personally I don't really think it helps the user but OK.)

Lukas Kalbertodt
  • 55,166
  • 13
  • 173
  • 236
  • I read the entire documentation for the [MediaDevices.getDisplayMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) and the [MediaStreamContraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints). I see nothing about stopping the window from focusing on top. Looks like this is probably a feature request to add this to the constraints. – Kevin Hernandez Feb 11 '20 at 16:10
  • Also there doesnt seem to be anything in [the list of all supported contraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSupportedConstraints) – Kevin Hernandez Feb 11 '20 at 16:12

1 Answers1

2

No, it is generally not possible to change this behavior, since it is intentional.

While this behavior is not mandated by any specification, most browsers today will push a just-shared window to front.

The rationale is the typical use case is someone presenting a document in a web conference call. In that context, the assumption is that since this is a user-initiated action (it requires a user gesture), the user intends to interact with the surface that they just shared.

In the past, browsers used to not do this, and users got confused about what was happening and about which window was being shared.

If you have a compelling use case where this is problematic, consider describing it in a new issue on the specification.

jib
  • 34,243
  • 11
  • 80
  • 138