restore resulted in collapsed window when maximized = yes was used

This commit is contained in:
Frank Skare
2019-10-13 05:15:41 +02:00
parent 625dddcfbb
commit ea6a71b7c3
2 changed files with 34 additions and 14 deletions

View File

@@ -2,15 +2,15 @@
- new: the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell) was improved - new: the [scripting wiki page](https://github.com/stax76/mpv.net/wiki/Scripting#powershell) was improved
- new: Toggle Shuffle has been added to the menu defaults - new: Toggle Shuffle has been added to the menu defaults
- new: for URLs the media title is shown in the title bar and the info command - new: for URLs the media title is shown in the title bar and in the info command
instead of displaying the URL, mpv.conf defaults were changed to use instead of displaying the URL, mpv.conf defaults were changed to use
[protocol.https] osd-playing-msg = '${media-title}' [protocol.https] osd-playing-msg = '${media-title}'
- fix: on the very first start volume was set to 0 and mute was set to yes - fix: on the very first start volume was set to 0 and mute was set to yes
- fix: there was a issue fixed with the URL clipboard monitoring - fix: there was a sound when closed from taskbar
- fix: there was a sound when closed from taskbar due to a exception
- fix: the log feature was not working - fix: the log feature was not working
- fix: clipboard monitoring feature removed because it was causing to many issues - fix: clipboard monitoring removed because it was causing to many issues
- fix: restore resulted in collapsed window when maximized = yes was used
- update: libmpv shinchiro 2019-10-06 - update: libmpv shinchiro 2019-10-06
- update: youtube-dl 2019-10-01 - update: youtube-dl 2019-10-01

View File

@@ -49,7 +49,8 @@ namespace mpvnet
mp.observe_property_string("vid", PropChangeVid); mp.observe_property_string("vid", PropChangeVid);
mp.observe_property_int("edition", PropChangeEdition); mp.observe_property_int("edition", PropChangeEdition);
if (mp.GPUAPI != "vulkan") mp.ProcessCommandLine(false); if (mp.GPUAPI != "vulkan")
mp.ProcessCommandLine(false);
AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString()); AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString());
Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception); Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception);
@@ -68,11 +69,18 @@ namespace mpvnet
ContextMenu.Opened += ContextMenu_Opened; ContextMenu.Opened += ContextMenu_Opened;
ContextMenu.Opening += ContextMenu_Opening; ContextMenu.Opening += ContextMenu_Opening;
if (mp.Screen == -1) mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen); if (mp.Screen == -1)
mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
int targetIndex = mp.Screen; int targetIndex = mp.Screen;
Screen[] screens = Screen.AllScreens; Screen[] screens = Screen.AllScreens;
if (targetIndex < 0) targetIndex = 0;
if (targetIndex > screens.Length - 1) targetIndex = screens.Length - 1; if (targetIndex < 0)
targetIndex = 0;
if (targetIndex > screens.Length - 1)
targetIndex = screens.Length - 1;
Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])]; Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])];
Rectangle target = screen.Bounds; Rectangle target = screen.Bounds;
Left = target.X + (target.Width - Width) / 2; Left = target.X + (target.Width - Width) / 2;
@@ -87,7 +95,8 @@ namespace mpvnet
Top = posY - Height / 2; Top = posY - Height / 2;
} }
if (App.Maximized) WindowState = FormWindowState.Maximized; if (App.Maximized)
WindowState = FormWindowState.Maximized;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -205,8 +214,10 @@ namespace mpvnet
if (recent != null) if (recent != null)
{ {
recent.DropDownItems.Clear(); recent.DropDownItems.Clear();
foreach (string path in RecentFiles) foreach (string path in RecentFiles)
MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control))); MenuItem.Add(recent.DropDownItems, path, () => mp.Load(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
recent.DropDownItems.Add(new ToolStripSeparator()); recent.DropDownItems.Add(new ToolStripSeparator());
MenuItem mi = new MenuItem("Clear List"); MenuItem mi = new MenuItem("Clear List");
mi.Action = () => RecentFiles.Clear(); mi.Action = () => RecentFiles.Clear();
@@ -409,7 +420,7 @@ namespace mpvnet
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
//Debug.WriteLine(m); Debug.WriteLine(m);
switch (m.Msg) switch (m.Msg)
{ {
@@ -445,24 +456,31 @@ namespace mpvnet
} }
break; break;
case 0x02E0: // WM_DPICHANGED case 0x02E0: // WM_DPICHANGED
if (!WasShown) break; if (!WasShown)
break;
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam); var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0); Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
break; break;
case 0x112: // WM_SYSCOMMAND
if (m.WParam.ToInt32() == 0xf120) // SC_RESTORE
SetFormPosAndSize();
break;
case 0x0214: // WM_SIZING case 0x0214: // WM_SIZING
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam); var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
var r = rc; var r = rc;
NativeHelp.SubtractWindowBorders(Handle, ref r); NativeHelp.SubtractWindowBorders(Handle, ref r);
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top; int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
Size s = mp.VideoSize; Size s = mp.VideoSize;
if (s == Size.Empty) s = new Size(16, 9); if (s == Size.Empty)
s = new Size(16, 9);
float aspect = s.Width / (float)s.Height; float aspect = s.Width / (float)s.Height;
int d_w = Convert.ToInt32(c_h * aspect - c_w); int d_w = Convert.ToInt32(c_h * aspect - c_w);
int d_h = Convert.ToInt32(c_w / aspect - c_h); int d_h = Convert.ToInt32(c_w / aspect - c_h);
int[] d_corners = { d_w, d_h, -d_w, -d_h }; int[] d_corners = { d_w, d_h, -d_w, -d_h };
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom }; int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32()); int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
if (corner >= 0) corners[corner] -= d_corners[corner]; if (corner >= 0)
corners[corner] -= d_corners[corner];
Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false); Marshal.StructureToPtr<Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
m.Result = new IntPtr(1); m.Result = new IntPtr(1);
return; return;
@@ -580,7 +598,9 @@ namespace mpvnet
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
base.OnResize(e); base.OnResize(e);
if (mp.IsLogoVisible) mp.ShowLogo();
if (mp.IsLogoVisible)
mp.ShowLogo();
} }
protected override void OnFormClosing(FormClosingEventArgs e) protected override void OnFormClosing(FormClosingEventArgs e)