mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: unify BrowserWindow.isVisible() logic cross-platform (#38315)
fix: unify BrowserWindow.isVisible() logic cross-platform Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -491,10 +491,6 @@ void NativeWindowMac::Hide() {
|
||||
|
||||
bool NativeWindowMac::IsVisible() {
|
||||
bool occluded = [window_ occlusionState] == NSWindowOcclusionStateVisible;
|
||||
|
||||
// For a window to be visible, it must be visible to the user in the
|
||||
// foreground of the app, which means that it should not be minimized or
|
||||
// occluded
|
||||
return [window_ isVisible] && !occluded && !IsMinimized();
|
||||
}
|
||||
|
||||
|
||||
@@ -535,7 +535,17 @@ void NativeWindowViews::Hide() {
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsVisible() {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// widget()->IsVisible() calls ::IsWindowVisible, which returns non-zero if a
|
||||
// window or any of its parent windows are visible. We want to only check the
|
||||
// current window.
|
||||
bool visible =
|
||||
::GetWindowLong(GetAcceleratedWidget(), GWL_STYLE) & WS_VISIBLE;
|
||||
// WS_VISIBLE is true even if a window is miminized - explicitly check that.
|
||||
return visible && !IsMinimized();
|
||||
#else
|
||||
return widget()->IsVisible();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool NativeWindowViews::IsEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user