feat: Implement BrowserWindow.getMediaSourceId() and BrowserWindow.moveAbove(mediaSourceId) (#18926)
* feat: Implement BrowserWindow.moveAbove(mediaSourceId) 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) https://github.com/electron/electron/issues/18922 * feat: Implement BrowserWindow.getMediaSourceId Return the Window id in the format of DesktopCapturerSource's id. For example "window🔢0". https://github.com/electron/electron/issues/16460 Notes: Added BrowserWindow.getMediaSourceId
This commit is contained in:
parent
d0c7a91a50
commit
680399f476
12 changed files with 320 additions and 4 deletions
|
@ -553,6 +553,11 @@ std::vector<int> TopLevelWindow::GetPosition() {
|
|||
result[1] = pos.y();
|
||||
return result;
|
||||
}
|
||||
void TopLevelWindow::MoveAbove(const std::string& sourceId,
|
||||
mate::Arguments* args) {
|
||||
if (!window_->MoveAbove(sourceId))
|
||||
args->ThrowError("Invalid media source id");
|
||||
}
|
||||
|
||||
void TopLevelWindow::MoveTop() {
|
||||
window_->MoveTop();
|
||||
|
@ -731,6 +736,11 @@ void TopLevelWindow::RemoveBrowserView(v8::Local<v8::Value> value) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string TopLevelWindow::GetMediaSourceId() const {
|
||||
return window_->GetDesktopMediaID().ToString();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> TopLevelWindow::GetNativeWindowHandle() {
|
||||
// TODO(MarshallOfSound): Replace once
|
||||
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
|
||||
|
@ -1077,6 +1087,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setMaximumSize", &TopLevelWindow::SetMaximumSize)
|
||||
.SetMethod("getMaximumSize", &TopLevelWindow::GetMaximumSize)
|
||||
.SetMethod("setSheetOffset", &TopLevelWindow::SetSheetOffset)
|
||||
.SetMethod("moveAbove", &TopLevelWindow::MoveAbove)
|
||||
.SetMethod("moveTop", &TopLevelWindow::MoveTop)
|
||||
.SetMethod("_setResizable", &TopLevelWindow::SetResizable)
|
||||
.SetMethod("_isResizable", &TopLevelWindow::IsResizable)
|
||||
|
@ -1136,6 +1147,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setBrowserView", &TopLevelWindow::SetBrowserView)
|
||||
.SetMethod("addBrowserView", &TopLevelWindow::AddBrowserView)
|
||||
.SetMethod("removeBrowserView", &TopLevelWindow::RemoveBrowserView)
|
||||
.SetMethod("getMediaSourceId", &TopLevelWindow::GetMediaSourceId)
|
||||
.SetMethod("getNativeWindowHandle",
|
||||
&TopLevelWindow::GetNativeWindowHandle)
|
||||
.SetMethod("setProgressBar", &TopLevelWindow::SetProgressBar)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue