simplify ensure_onscreen code (since end of cycle approaches, disable by default with config)

This commit is contained in:
John Colvin committed 2019-04-27 12:03:13 -05:00
1 parent 6d4ece0667
commit fbe6b38edc
2 files changed
+26 -10

No files matched your search

@@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using mbts.ui.native;
using mbts.ui.shell;
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using mbts.ui.native;
using mbts.ui.shell;
namespace mbts.ui
{
public static class WindowExtensions
{
namespace mbts.ui {
static class WindowExtensions {
static readonly bool _ensure_onscreen_with_work_area_rect = config.Configuration.get<bts.config.toggles.EnsureOnScreenWithWorkAreaRect>().enabled;
public static Rect bounds(this Window window) {
return new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight);
}
@@ -111,6 +108,18 @@ namespace mbts.ui
MONITORINFO minfo = new MONITORINFO();
minfo.cbSize = Marshal.SizeOf(minfo);
if (NativeMethods.GetMonitorInfo(hmonitor, ref minfo)) {
if (_ensure_onscreen_with_work_area_rect) {
var work_area_rect = new Rect(minfo.rcWork.Left, minfo.rcWork.Top, minfo.rcWork.Width, minfo.rcWork.Height);
var transform = get_transform_from_device(window);
work_area_rect.Transform(transform);
double y_off = (window.Top + window.Height) - work_area_rect.Bottom;
if (y_off > 0)
window.Top -= y_off;
double x_off = (window.Left + window.Width) - work_area_rect.Right;
if (x_off > 0)
window.Left -= x_off;
return;
}
// if the screen and workarea upper left and lower right coords are the same, there is no
// taskbar on this screen
var no_taskbar_on_screen = (minfo.rcMonitor.Top == minfo.rcWork.Top && minfo.rcMonitor.Left == minfo.rcWork.Left &&
+7
View File
@@ -34,4 +34,11 @@ message VolumeAtPrice{
message FixNestedScrolling {
optional bool enabled = 1 [default = true];
}
message EnsureOnScreenWithWorkAreaRect {
// Defaulting to false bc this is near the end of the cycle (04/27/2019),
// and the new ensure_onscreen code has only been tested with a single monitor arrangement.
// Should verify that the code works with every monitor arrangement before enabling by default.
optional bool enabled = 1 [default = false];
}