Skip to content

Commit e4893b0

Browse files
authored
Merge pull request #128 from cairoshell/more-fullscreen-fixes
More full-screen fixes
2 parents 84b3085 + 616639f commit e4893b0

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

src/ManagedShell.AppBar/AppBarWindow.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,20 @@ protected virtual void OnAutoHideAnimationComplete(bool isHiding)
328328
}
329329
}
330330

331-
protected virtual void OnFullScreenEnter()
331+
protected virtual void OnFullScreenEnter(FullScreenApp app)
332332
{
333+
if (AppBarMode != AppBarMode.Normal && app.fromTasksService)
334+
{
335+
// If we are not reserving space, then some maximized windows could be mistaken as full-screen.
336+
// Use the same strict bounds checks as full-screen apps with fromTasksService=false.
337+
if (!(app.rect.Top == app.screen.Bounds.Top && app.rect.Left == app.screen.Bounds.Left &&
338+
app.rect.Bottom == app.screen.Bounds.Bottom && app.rect.Right == app.screen.Bounds.Right))
339+
{
340+
ShellLogger.Debug($"AppBarWindow: {Name} on {Screen.DeviceName} ignoring full-screen app");
341+
return;
342+
}
343+
}
344+
333345
ShellLogger.Debug($"AppBarWindow: {Name} on {Screen.DeviceName} conceding to full-screen app");
334346

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

370382
private void FullScreenApps_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
371383
{
372-
bool found = false;
384+
FullScreenApp app = null;
373385

374-
foreach (FullScreenApp app in _fullScreenHelper.FullScreenApps)
386+
foreach (FullScreenApp _app in _fullScreenHelper.FullScreenApps)
375387
{
376-
if (app.screen.DeviceName == Screen.DeviceName || app.screen.IsVirtualScreen)
388+
if (_app.screen.DeviceName == Screen.DeviceName || _app.screen.IsVirtualScreen)
377389
{
378-
// we need to not be on top now
379-
found = true;
390+
// there is a full screen app on our screen
391+
app = _app;
380392
break;
381393
}
382394
}
383395

384-
if (found && Topmost)
396+
if (app != null && Topmost)
385397
{
386-
OnFullScreenEnter();
398+
OnFullScreenEnter(app);
387399
}
388-
else if (!found && !Topmost)
400+
else if (app == null && !Topmost)
389401
{
390402
OnFullScreenLeave();
391403
}

src/ManagedShell.AppBar/FullScreenApp.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
using System;
1+
using ManagedShell.Interop;
2+
using System;
23

34
namespace ManagedShell.AppBar
45
{
56
public class FullScreenApp
67
{
78
public IntPtr hWnd;
89
public ScreenInfo screen;
10+
public NativeMethods.Rect rect;
911
public string title;
1012
public bool fromTasksService;
1113
}

src/ManagedShell.AppBar/FullScreenHelper.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ private void TasksService_Event(object sender, EventArgs e)
4949

5050
private void TasksService_FullScreenChanged(object sender, FullScreenEventArgs e)
5151
{
52+
if (InactiveFullScreenApps.Count > 0 && InactiveFullScreenApps.Any(app => app.hWnd == e.Handle))
53+
{
54+
// If this window is in the inactive list, remove it--the message that triggered this event takes precedence
55+
InactiveFullScreenApps.Remove(InactiveFullScreenApps.First(app => app.hWnd == e.Handle));
56+
}
57+
5258
if (FullScreenApps.Any(app => app.hWnd == e.Handle) == e.IsEntering)
5359
{
5460
if (e.IsEntering)
@@ -63,12 +69,6 @@ private void TasksService_FullScreenChanged(object sender, FullScreenEventArgs e
6369
return;
6470
}
6571

66-
if (InactiveFullScreenApps.Count > 0 && InactiveFullScreenApps.Any(app => app.hWnd == e.Handle))
67-
{
68-
// If this window is in the inactive list, remove it because it is no longer needed
69-
InactiveFullScreenApps.Remove(InactiveFullScreenApps.First(app => app.hWnd == e.Handle));
70-
}
71-
7272
if (e.IsEntering)
7373
{
7474
// When TasksService gives us a full-screen window handle, trust that it is full-screen in terms of bounds
@@ -224,10 +224,10 @@ private void updateFullScreenWindows()
224224
private FullScreenApp getFullScreenApp(IntPtr hWnd, bool fromTasksService = false)
225225
{
226226
ScreenInfo screenInfo = null;
227+
Rect rect = GetEffectiveWindowRect(hWnd);
227228

228229
if (!fromTasksService)
229230
{
230-
Rect rect = GetEffectiveWindowRect(hWnd);
231231
var allScreens = Screen.AllScreens.Select(ScreenInfo.Create).ToList();
232232
if (allScreens.Count > 1) allScreens.Add(ScreenInfo.CreateVirtualScreen());
233233

@@ -260,7 +260,7 @@ private FullScreenApp getFullScreenApp(IntPtr hWnd, bool fromTasksService = fals
260260
}
261261

262262
// this is a full screen app
263-
return new FullScreenApp { hWnd = hWnd, screen = screenInfo, title = win.Title, fromTasksService = fromTasksService };
263+
return new FullScreenApp { hWnd = hWnd, screen = screenInfo, rect = rect, title = win.Title, fromTasksService = fromTasksService };
264264
}
265265

266266
private Rect GetEffectiveWindowRect(IntPtr hWnd)

0 commit comments

Comments
 (0)