Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/ManagedShell.AppBar/AppBarWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,20 @@ protected virtual void OnAutoHideAnimationComplete(bool isHiding)
}
}

protected virtual void OnFullScreenEnter()
protected virtual void OnFullScreenEnter(FullScreenApp app)
{
if (AppBarMode != AppBarMode.Normal && app.fromTasksService)
{
// If we are not reserving space, then some maximized windows could be mistaken as full-screen.
// Use the same strict bounds checks as full-screen apps with fromTasksService=false.
if (!(app.rect.Top == app.screen.Bounds.Top && app.rect.Left == app.screen.Bounds.Left &&
app.rect.Bottom == app.screen.Bounds.Bottom && app.rect.Right == app.screen.Bounds.Right))
{
ShellLogger.Debug($"AppBarWindow: {Name} on {Screen.DeviceName} ignoring full-screen app");
return;
}
}

ShellLogger.Debug($"AppBarWindow: {Name} on {Screen.DeviceName} conceding to full-screen app");

Topmost = false;
Expand Down Expand Up @@ -369,23 +381,23 @@ private void OnClosing(object sender, CancelEventArgs e)

private void FullScreenApps_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
bool found = false;
FullScreenApp app = null;

foreach (FullScreenApp app in _fullScreenHelper.FullScreenApps)
foreach (FullScreenApp _app in _fullScreenHelper.FullScreenApps)
{
if (app.screen.DeviceName == Screen.DeviceName || app.screen.IsVirtualScreen)
if (_app.screen.DeviceName == Screen.DeviceName || _app.screen.IsVirtualScreen)
{
// we need to not be on top now
found = true;
// there is a full screen app on our screen
app = _app;
break;
}
}

if (found && Topmost)
if (app != null && Topmost)
{
OnFullScreenEnter();
OnFullScreenEnter(app);
}
else if (!found && !Topmost)
else if (app == null && !Topmost)
{
OnFullScreenLeave();
}
Expand Down
4 changes: 3 additions & 1 deletion src/ManagedShell.AppBar/FullScreenApp.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using ManagedShell.Interop;
using System;

namespace ManagedShell.AppBar
{
public class FullScreenApp
{
public IntPtr hWnd;
public ScreenInfo screen;
public NativeMethods.Rect rect;
public string title;
public bool fromTasksService;
}
Expand Down
16 changes: 8 additions & 8 deletions src/ManagedShell.AppBar/FullScreenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ private void TasksService_Event(object sender, EventArgs e)

private void TasksService_FullScreenChanged(object sender, FullScreenEventArgs e)
{
if (InactiveFullScreenApps.Count > 0 && InactiveFullScreenApps.Any(app => app.hWnd == e.Handle))
{
// If this window is in the inactive list, remove it--the message that triggered this event takes precedence
InactiveFullScreenApps.Remove(InactiveFullScreenApps.First(app => app.hWnd == e.Handle));
}

if (FullScreenApps.Any(app => app.hWnd == e.Handle) == e.IsEntering)
{
if (e.IsEntering)
Expand All @@ -63,12 +69,6 @@ private void TasksService_FullScreenChanged(object sender, FullScreenEventArgs e
return;
}

if (InactiveFullScreenApps.Count > 0 && InactiveFullScreenApps.Any(app => app.hWnd == e.Handle))
{
// If this window is in the inactive list, remove it because it is no longer needed
InactiveFullScreenApps.Remove(InactiveFullScreenApps.First(app => app.hWnd == e.Handle));
}

if (e.IsEntering)
{
// When TasksService gives us a full-screen window handle, trust that it is full-screen in terms of bounds
Expand Down Expand Up @@ -224,10 +224,10 @@ private void updateFullScreenWindows()
private FullScreenApp getFullScreenApp(IntPtr hWnd, bool fromTasksService = false)
{
ScreenInfo screenInfo = null;
Rect rect = GetEffectiveWindowRect(hWnd);

if (!fromTasksService)
{
Rect rect = GetEffectiveWindowRect(hWnd);
var allScreens = Screen.AllScreens.Select(ScreenInfo.Create).ToList();
if (allScreens.Count > 1) allScreens.Add(ScreenInfo.CreateVirtualScreen());

Expand Down Expand Up @@ -260,7 +260,7 @@ private FullScreenApp getFullScreenApp(IntPtr hWnd, bool fromTasksService = fals
}

// this is a full screen app
return new FullScreenApp { hWnd = hWnd, screen = screenInfo, title = win.Title, fromTasksService = fromTasksService };
return new FullScreenApp { hWnd = hWnd, screen = screenInfo, rect = rect, title = win.Title, fromTasksService = fromTasksService };
}

private Rect GetEffectiveWindowRect(IntPtr hWnd)
Expand Down