Skip to content

Commit f7c42a7

Browse files
authored
Merge pull request #148 from cairoshell/fix-getworkarea
Fix AppBarManager.GetWorkArea
2 parents 1ff43fc + f77ca74 commit f7c42a7

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

.github/workflows/managedshell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
buildconfig: [ Release ]
1818

19-
runs-on: windows-latest
19+
runs-on: windows-2022
2020

2121
env:
2222
project: src\ManagedShell\ManagedShell.csproj

src/ManagedShell.AppBar/AppBarManager.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class AppBarManager : IDisposable
1919

2020
public List<AppBarWindow> AppBars { get; } = new List<AppBarWindow>();
2121
public List<AppBarWindow> AutoHideBars { get; } = new List<AppBarWindow>();
22+
public List<AppBarWindow> OverlappingBars { get; } = new List<AppBarWindow>();
2223

2324
public AppBarManager(ExplorerHelper explorerHelper)
2425
{
@@ -213,6 +214,26 @@ public void UnregisterAutoHideBar(AppBarWindow window)
213214
AutoHideBars.Remove(window);
214215
}
215216

217+
public void RegisterOverlappingBar(AppBarWindow window)
218+
{
219+
if (OverlappingBars.Contains(window))
220+
{
221+
return;
222+
}
223+
224+
OverlappingBars.Add(window);
225+
}
226+
227+
public void UnregisterOverlappingBar(AppBarWindow window)
228+
{
229+
if (!OverlappingBars.Contains(window))
230+
{
231+
return;
232+
}
233+
234+
OverlappingBars.Remove(window);
235+
}
236+
216237
public int RegisterBar(AppBarWindow abWindow)
217238
{
218239
lock (appBarLock)
@@ -409,6 +430,56 @@ public Rect GetWorkArea(AppBarScreen screen, bool edgeBarsOnly, bool enabledBars
409430
}
410431
}
411432

433+
if (!enabledBarsOnly)
434+
{
435+
foreach (var window in AutoHideBars)
436+
{
437+
if (window.Screen.DeviceName == screen.DeviceName &&
438+
window.Handle != hWndIgnore &&
439+
(window.RequiresScreenEdge || !edgeBarsOnly))
440+
{
441+
switch (window.AppBarEdge)
442+
{
443+
case AppBarEdge.Left:
444+
leftEdgeWindowWidth += window.WindowRect.Width;
445+
break;
446+
case AppBarEdge.Right:
447+
rightEdgeWindowWidth += window.WindowRect.Width;
448+
break;
449+
case AppBarEdge.Bottom:
450+
bottomEdgeWindowHeight += window.WindowRect.Height;
451+
break;
452+
case AppBarEdge.Top:
453+
topEdgeWindowHeight += window.WindowRect.Height;
454+
break;
455+
}
456+
}
457+
}
458+
foreach (var window in OverlappingBars)
459+
{
460+
if (window.Screen.DeviceName == screen.DeviceName &&
461+
window.Handle != hWndIgnore &&
462+
(window.RequiresScreenEdge || !edgeBarsOnly))
463+
{
464+
switch (window.AppBarEdge)
465+
{
466+
case AppBarEdge.Left:
467+
leftEdgeWindowWidth += window.WindowRect.Width;
468+
break;
469+
case AppBarEdge.Right:
470+
rightEdgeWindowWidth += window.WindowRect.Width;
471+
break;
472+
case AppBarEdge.Bottom:
473+
bottomEdgeWindowHeight += window.WindowRect.Height;
474+
break;
475+
case AppBarEdge.Top:
476+
topEdgeWindowHeight += window.WindowRect.Height;
477+
break;
478+
}
479+
}
480+
}
481+
}
482+
412483
rc.Top = screen.Bounds.Top + topEdgeWindowHeight;
413484
rc.Bottom = screen.Bounds.Bottom - bottomEdgeWindowHeight;
414485
rc.Left = screen.Bounds.Left + leftEdgeWindowWidth;

src/ManagedShell.AppBar/AppBarWindow.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@ private void AppBarWindow_PropertyChanged(object sender, PropertyChangedEventArg
194194
_appBarManager.UnregisterAutoHideBar(this);
195195
AnimateAutoHide(false, true);
196196
}
197+
198+
if (AppBarMode == AppBarMode.None)
199+
{
200+
_appBarManager.RegisterOverlappingBar(this);
201+
}
202+
else
203+
{
204+
_appBarManager.UnregisterOverlappingBar(this);
205+
}
197206
}
198207
}
199208

@@ -294,6 +303,10 @@ protected virtual void OnSourceInitialized(object sender, EventArgs e)
294303
{
295304
_appBarManager.RegisterAutoHideBar(this);
296305
}
306+
else
307+
{
308+
_appBarManager.RegisterOverlappingBar(this);
309+
}
297310

298311
// hide from alt-tab etc
299312
WindowHelper.HideWindowFromTasks(Handle);
@@ -363,6 +376,7 @@ private void OnClosing(object sender, CancelEventArgs e)
363376
{
364377
UnregisterAppBar();
365378
_appBarManager.UnregisterAutoHideBar(this);
379+
_appBarManager.UnregisterOverlappingBar(this);
366380
AutoHideElement?.RenderTransform?.BeginAnimation(TranslateTransform.YProperty, null);
367381
AutoHideElement?.RenderTransform?.BeginAnimation(TranslateTransform.XProperty, null);
368382

src/ManagedShell.UWPInterop/ManagedShell.UWPInterop.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
Windows.Globalization.DayOfWeek;
4343
Windows.Management.Deployment;
4444
Windows.Storage;
45+
Windows.Storage.Provider.FileUpdateStatus;
4546
Windows.System.IUser;
4647
Windows.System.ProcessorArchitecture;
4748
Windows.System.User;
@@ -50,6 +51,7 @@
5051
Windows.Foundation.Diagnostics;
5152
Windows.Foundation.PropertyType;
5253
Windows.Storage.BulkAccess;
54+
Windows.Storage.Provider;
5355
</CsWinRTExcludes>
5456
</PropertyGroup>
5557

0 commit comments

Comments
 (0)