mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
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:1234:0".
https://github.com/electron/electron/issues/16460
Notes: Added BrowserWindow.getMediaSourceId
This commit is contained in:
committed by
Cheng Zhao
parent
d0c7a91a50
commit
680399f476
@@ -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
|
||||
|
||||
@@ -23,9 +23,15 @@ void SetWindowType(::Window xwindow, const std::string& type);
|
||||
// Returns true if the bus name "com.canonical.AppMenu.Registrar" is available.
|
||||
bool ShouldUseGlobalMenuBar();
|
||||
|
||||
// Bring the given window to the front and give it the focus.
|
||||
// Bring the given window to the front regardless of focus.
|
||||
void MoveWindowToForeground(::Window xwindow);
|
||||
|
||||
// Move a given window above the other one.
|
||||
void MoveWindowAbove(::Window xwindow, ::Window other_xwindow);
|
||||
|
||||
// Return true is the given window exists, false otherwise.
|
||||
bool IsWindowValid(::Window xwindow);
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_BROWSER_UI_X_X_WINDOW_UTILS_H_
|
||||
|
||||
Reference in New Issue
Block a user