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

feat: Implement BrowserWindow.getMediaSourceId() and BrowserWindow.moveAbove(mediaSourceId) #18926

Merged
merged 2 commits into from Aug 15, 2019

Conversation

CapOM
Copy link
Contributor

@CapOM CapOM commented Jun 21, 2019

Description of Change

BrowserWindow.{focus,blur,moveTop}() are not enough in some
situations. For example when implementing an overlay that
follows another window that can lose focus. In that case
it is useful to move the overlay above the tracked window.

sourceId is a string in the format of DesktopCapturerSource.id,
for example "window:1869:0".

Resolves #18922.

Checklist

Release Notes

Notes: Added BrowserWindow.getMediaSourceId() and BrowserWindow.moveAbove(mediaSourceId)

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 21, 2019
@CapOM
Copy link
Contributor Author

CapOM commented Jun 21, 2019

CC @MarshallOfSound @alexeykuzmin , Hi I am not sure who to add as reviewer, thx.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 22, 2019
@CapOM CapOM force-pushed the implement_moveAbove branch 2 times, most recently from fff8470 to 1141d12 Compare June 24, 2019 23:04
@CapOM CapOM changed the title feat: Implement BrowserWindow.moveAbove(mediaSourceId) feat: Implement BrowserWindow.getMediaSourceId() and BrowserWindow.moveAbove(mediaSourceId) Jun 24, 2019
@CapOM
Copy link
Contributor Author

CapOM commented Jun 24, 2019

I have added 5 unit tests

@CapOM CapOM force-pushed the implement_moveAbove branch 4 times, most recently from 485d2ce to 1e24458 Compare June 25, 2019 21:32
@CapOM
Copy link
Contributor Author

CapOM commented Jun 25, 2019

I am fighting with the unit tests (flakiness of API I am using in the tests but not the new API itself).
But the code is ready to be re-reviewed. Please take a look, thx!

spec-main/api-browser-window-spec.ts Show resolved Hide resolved
spec-main/api-browser-window-spec.ts Outdated Show resolved Hide resolved
spec-main/api-browser-window-spec.ts Show resolved Hide resolved
spec/api-browser-window-spec.js Outdated Show resolved Hide resolved
@CapOM CapOM force-pushed the implement_moveAbove branch 2 times, most recently from cf62392 to b5dc201 Compare June 26, 2019 18:24
@CapOM
Copy link
Contributor Author

CapOM commented Jun 26, 2019

I addressed remaining issues. The test failure seem unrelated to this change. Please take a look, thx!

@CapOM
Copy link
Contributor Author

CapOM commented Jul 2, 2019

Hi, gentle ping ?

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general structure and mac-specific implementation of this looks ok to me but i'd also like thoughts about linux and windows before merging this.

cc @zcbenz @ckerr @nornagon

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good to me.

shell/browser/native_window_views.cc Outdated Show resolved Hide resolved
@CapOM CapOM force-pushed the implement_moveAbove branch 5 times, most recently from 02953ce to 24dc332 Compare July 3, 2019 23:24
@CapOM
Copy link
Contributor Author

CapOM commented Jul 3, 2019

Hi, I have addressed all the remaining remarks, please take a look, thx!

@CapOM
Copy link
Contributor Author

CapOM commented Jul 9, 2019

Hi @nornagon , gentle ping ?

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally lgtm, just a few concerns with the tests.

shell/browser/native_window_views.cc Outdated Show resolved Hide resolved
spec-main/api-browser-window-spec.ts Outdated Show resolved Hide resolved
spec/api-browser-window-spec.js Outdated Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Outdated Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Outdated Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Outdated Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Outdated Show resolved Hide resolved
spec/api-desktop-capturer-spec.js Outdated Show resolved Hide resolved
@CapOM
Copy link
Contributor Author

CapOM commented Jul 10, 2019

Hi @nornagon I think I addressed all your remarks, let me know if I forgot something, thx!

spec/api-browser-window-spec.js Outdated Show resolved Hide resolved
@nornagon nornagon added the semver/minor backwards-compatible functionality label Jul 15, 2019
@CapOM CapOM force-pushed the implement_moveAbove branch 2 times, most recently from 9b55504 to 09b779b Compare July 15, 2019 16:58
@codebytere
Copy link
Member

BrowserWindow module window.getMediaSourceId() returns valid source id - returns valid source id

still seems to be failing @CapOM

@codebytere
Copy link
Member

codebytere commented Aug 5, 2019

@CapOM would you still like to move forward with this? it needs a rebase as well.

@CapOM
Copy link
Contributor Author

CapOM commented Aug 8, 2019

Back from vacations, I just rebased the 2 commits for now.

@codebytere
Copy link
Member

@CapOM test failure on macOS:

BrowserWindow module window.getMediaSourceId() returns valid source id - returns valid source id

AssertionError: expected 'window:-1:0' to match /^window:\d+:\d+$/

@CapOM
Copy link
Contributor Author

CapOM commented Aug 9, 2019

Thx, I will have a look.

Julien Isorce and others added 2 commits August 13, 2019 11:47
Return the Window id in the format of DesktopCapturerSource's id.
For example "window:1234:0".

electron#16460

Notes: Added BrowserWindow.getMediaSourceId
BrowserWindow.{focus,blur,moveTop}() are not enough in some
situations. For example when implementing an overlay that
follows another window that can lose focus. In that case
it is useful to move the overlay above the tracked window.

sourceId is a string in the format of DesktopCapturerSource.id,
for example "window:1869:0".

Notes: Added BrowserWindow.moveAbove(mediaSourceId)

electron#18922
@CapOM
Copy link
Contributor Author

CapOM commented Aug 13, 2019

@codebytere I fixed the test. The -1 was because [NSWindow windowNumber] returns the max value of uint64_t which is 18446744073709551615 (2^64 - 1) until the window is ordered to the screen for the first time. So the test now wait that the window is shown.

(the reason why it is translated to -1 in the string is because content:DesktopMediaID cast it to intptr_t instead of uintptr_t, so the conversion to string through content:DesktopMediaID.ToString selects the long long signature of the converting function. Instead of selecting the one that takes unsigned long long as parameter)

@codebytere
Copy link
Member

@CapOM great detective work 🕵

i'll get this merged as soon as CI is ✅

@CapOM
Copy link
Contributor Author

CapOM commented Aug 14, 2019

CI looks green, thx!

@zcbenz zcbenz merged commit 680399f into electron:master Aug 15, 2019
@release-clerk
Copy link

release-clerk bot commented Aug 15, 2019

Release Notes Persisted

Added BrowserWindow.getMediaSourceId() and BrowserWindow.moveAbove(mediaSourceId)

@deepak1556 deepak1556 mentioned this pull request Aug 20, 2019
3 tasks
@bynho
Copy link

bynho commented Jan 15, 2020

Has this been removed? I cant find the API to get the media source id mentioned in this PR

@CapOM
Copy link
Contributor Author

CapOM commented Jan 15, 2020

Commits are there:

9ca6bc0
64131e3

And it is shipped in electron starting from 8.0

@bynho
Copy link

bynho commented Jan 15, 2020

Fantastic. Thank you @CapOM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/minor backwards-compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a BrowserWindows.moveAbove(mediaSourceId) method
5 participants