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
|
@ -89,6 +89,10 @@ bool ShouldUseGlobalMenuBar() {
|
|||
}
|
||||
|
||||
void MoveWindowToForeground(::Window xwindow) {
|
||||
MoveWindowAbove(xwindow, 0);
|
||||
}
|
||||
|
||||
void MoveWindowAbove(::Window xwindow, ::Window other_xwindow) {
|
||||
XDisplay* xdisplay = gfx::GetXDisplay();
|
||||
XEvent xclient;
|
||||
memset(&xclient, 0, sizeof(xclient));
|
||||
|
@ -99,7 +103,7 @@ void MoveWindowToForeground(::Window xwindow) {
|
|||
xclient.xclient.message_type = GetAtom("_NET_RESTACK_WINDOW");
|
||||
xclient.xclient.format = 32;
|
||||
xclient.xclient.data.l[0] = 2;
|
||||
xclient.xclient.data.l[1] = 0;
|
||||
xclient.xclient.data.l[1] = other_xwindow;
|
||||
xclient.xclient.data.l[2] = Above;
|
||||
xclient.xclient.data.l[3] = 0;
|
||||
xclient.xclient.data.l[4] = 0;
|
||||
|
@ -109,4 +113,9 @@ void MoveWindowToForeground(::Window xwindow) {
|
|||
XFlush(xdisplay);
|
||||
}
|
||||
|
||||
bool IsWindowValid(::Window xwindow) {
|
||||
XWindowAttributes attrs;
|
||||
return XGetWindowAttributes(gfx::GetXDisplay(), xwindow, &attrs);
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue