Skip to content

Commit

Permalink
Always populate list of screens even if multi-mon features disabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dremin committed Mar 10, 2020
1 parent 41fd33e commit 5b836be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
40 changes: 18 additions & 22 deletions Cairo Desktop/Cairo Desktop/MenuBar.xaml.cs
Expand Up @@ -360,15 +360,7 @@ public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bo
}
else if (msg == NativeMethods.WM_DPICHANGED)
{
if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens)
{
Startup.ScreenSetup(); // update Cairo window list based on new screen setup
}
else if (!(Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon))
{
Startup.ResetScreenCache();
Screen = System.Windows.Forms.Screen.PrimaryScreen;
}
setScreenProperties();

if (Screen.Primary)
{
Expand All @@ -381,25 +373,14 @@ public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bo
}
else if (msg == NativeMethods.WM_DISPLAYCHANGE)
{
if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
{
Startup.ScreenSetup(); // update Cairo window list based on new screen setup
}
else if (!(Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon))
{
Startup.ResetScreenCache();
Screen = System.Windows.Forms.Screen.PrimaryScreen;
}
setScreenProperties();

setPosition(((uint)lParam & 0xffff), ((uint)lParam >> 16));
handled = true;
}
else if (msg == NativeMethods.WM_DEVICECHANGE && (int)wParam == 0x0007)
{
if ((Settings.Instance.EnableMenuBarMultiMon || Configuration.Settings.Instance.EnableTaskbarMultiMon) && !Startup.IsSettingScreens && Screen.Primary)
{
Startup.ScreenSetup(); // update Cairo window list based on new screen setup
}
setScreenProperties();
}

return IntPtr.Zero;
Expand Down Expand Up @@ -429,6 +410,21 @@ private void FullScreenApps_CollectionChanged(object sender, System.Collections.
}
}

private void setScreenProperties()
{
if (!Startup.IsSettingScreens && Screen.Primary)
{
Startup.ScreenSetup(); // update Cairo window list based on new screen setup
}

if (!(Settings.Instance.EnableMenuBarMultiMon || Settings.Instance.EnableTaskbarMultiMon))
{
// Update our screen here since if multi-mon features are disabled it doesn't happen in screensetup
// Should this really be handled here or shold screensetup just use primaryscreen in this situation?
Screen = System.Windows.Forms.Screen.PrimaryScreen;
}
}

private void setFullScreenMode(bool entering)
{
if (entering)
Expand Down
20 changes: 14 additions & 6 deletions Cairo Desktop/Cairo Desktop/Startup.cs
Expand Up @@ -163,11 +163,8 @@ public static void Main(string[] args)
TaskbarWindows.Add(TaskbarWindow);
}

// Future: This should be moved to whatever plugin is responsible for Taskbar/MennuBart stuff
if (Settings.Instance.EnableMenuBarMultiMon || Settings.Instance.EnableTaskbarMultiMon)
ScreenSetup(true);
else if (IsCairoRunningAsShell) // Set desktop work area for when Explorer isn't running
AppBarHelper.SetWorkArea(System.Windows.Forms.Screen.PrimaryScreen);
// Future: This should be moved to whatever plugin is responsible for Taskbar/MenuBar stuff
ScreenSetup(true);

// Future: This should be moved to whatever plugin is responsible for SystemTray stuff. Possibly Core with no UI, then have a plugin that gives the UI?
// Don't allow showing both the Windows taskbar and the Cairo tray
Expand Down Expand Up @@ -499,13 +496,24 @@ public static void ScreenSetup(bool skipChecks = false)
else
screenState = System.Windows.Forms.Screen.AllScreens;

if (!Settings.Instance.EnableMenuBarMultiMon && !Settings.Instance.EnableTaskbarMultiMon)
{
// skip screen setup since no multi-mon features enabled
CairoLogger.Instance.Debug("Skipping screen setup due to no multi-mon features enabled");
shouldSetScreens = false;

// also set work area for when Explorer isn't running, since screen setup code isn't running
if (IsCairoRunningAsShell)
AppBarHelper.SetWorkArea(System.Windows.Forms.Screen.PrimaryScreen);
}

if (shouldSetScreens)
{
if (!skipChecks)
{
// enumerate screens

if (Settings.Instance.EnableMenuBarMultiMon || !Configuration.Settings.Instance.EnableTaskbar)
if (Settings.Instance.EnableMenuBarMultiMon || !Settings.Instance.EnableTaskbar)
{
foreach (MenuBar bar in MenuBarWindows)
{
Expand Down

0 comments on commit 5b836be

Please sign in to comment.