context menu issue fix #396
This commit is contained in:
@@ -53,6 +53,7 @@ namespace mpvnet
|
||||
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
|
||||
case "show-keys": ShowStrings(Core.GetPropertyString("input-key-list").Split(',')); break;
|
||||
case "show-media-info": ShowMediaInfo(args); break;
|
||||
case "show-menu": ShowMenu(); break;
|
||||
case "show-playlist": ShowPlaylist(); break;
|
||||
case "show-profiles": Msg.ShowInfo(mpvHelp.GetProfiles()); break;
|
||||
case "show-progress": ShowProgress(); break;
|
||||
@@ -661,5 +662,7 @@ namespace mpvnet
|
||||
MainForm.Instance.ShowCommandPalette();
|
||||
CommandPalette.Instance.SelectFirst();
|
||||
});
|
||||
|
||||
public static void ShowMenu() => Core.RaiseShowMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace mpvnet
|
||||
|
||||
public event Action Initialized;
|
||||
public event Action InitializedAsync;
|
||||
public event Action ShowMenu;
|
||||
public event Action<float> ScaleWindow;
|
||||
public event Action<float> WindowScale;
|
||||
public event Action<int> PlaylistPosChanged;
|
||||
@@ -81,7 +82,7 @@ namespace mpvnet
|
||||
public string ConfPath { get => ConfigFolder + "mpv.conf"; }
|
||||
public string GPUAPI { get; set; } = "auto";
|
||||
public string VO { get; set; } = "gpu";
|
||||
public string InputConfPath { get => ConfigFolder + "input.conf"; }
|
||||
public string InputConfPath => ConfigFolder + "input.conf";
|
||||
|
||||
public string VID { get; set; } = "";
|
||||
public string AID { get; set; } = "";
|
||||
@@ -109,6 +110,8 @@ namespace mpvnet
|
||||
|
||||
public void Init()
|
||||
{
|
||||
ApplyShowMenuFix();
|
||||
|
||||
Handle = mpv_create();
|
||||
|
||||
if (Handle == IntPtr.Zero)
|
||||
@@ -168,23 +171,40 @@ namespace mpvnet
|
||||
InvokeAsync(InitializedAsync);
|
||||
}
|
||||
|
||||
void ApplyCompatibilityFixes()
|
||||
void ApplyShowMenuFix()
|
||||
{
|
||||
if (!App.Settings.InputDefaultBindingsFixApplied)
|
||||
if (App.Settings.ShowMenuFixApplied)
|
||||
return;
|
||||
|
||||
if (File.Exists(InputConfPath))
|
||||
{
|
||||
if (File.Exists(ConfPath))
|
||||
{
|
||||
string content = File.ReadAllText(ConfPath);
|
||||
string content = File.ReadAllText(InputConfPath);
|
||||
|
||||
if (content.Contains("input-default-bindings = no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings = no", ""));
|
||||
|
||||
if (content.Contains("input-default-bindings=no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings=no", ""));
|
||||
}
|
||||
|
||||
App.Settings.InputDefaultBindingsFixApplied = true;
|
||||
if (!content.Contains("script-message mpv.net show-menu"))
|
||||
File.WriteAllText(InputConfPath, BR + content.Trim() + BR +
|
||||
"MBTN_Right script-message mpv.net show-menu" + BR);
|
||||
}
|
||||
|
||||
App.Settings.ShowMenuFixApplied = true;
|
||||
}
|
||||
|
||||
void ApplyInputDefaultBindingsFix()
|
||||
{
|
||||
if (App.Settings.InputDefaultBindingsFixApplied)
|
||||
return;
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
{
|
||||
string content = File.ReadAllText(ConfPath);
|
||||
|
||||
if (content.Contains("input-default-bindings = no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings = no", ""));
|
||||
|
||||
if (content.Contains("input-default-bindings=no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings=no", ""));
|
||||
}
|
||||
|
||||
App.Settings.InputDefaultBindingsFixApplied = true;
|
||||
}
|
||||
|
||||
public void ProcessProperty(string name, string value)
|
||||
@@ -264,7 +284,7 @@ namespace mpvnet
|
||||
get {
|
||||
if (_Conf == null)
|
||||
{
|
||||
ApplyCompatibilityFixes();
|
||||
ApplyInputDefaultBindingsFix();
|
||||
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
@@ -1352,6 +1372,8 @@ KP1 script-binding delete_current_file/confirm
|
||||
public void RaiseScaleWindow(float value) => ScaleWindow(value);
|
||||
|
||||
public void RaiseWindowScale(float value) => WindowScale(value);
|
||||
|
||||
public void RaiseShowMenu() => ShowMenu();
|
||||
|
||||
void ReadMetaData()
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace mpvnet
|
||||
Core.Init();
|
||||
|
||||
Core.Shutdown += Core_Shutdown;
|
||||
Core.ShowMenu += Core_ShowMenu;
|
||||
Core.VideoSizeChanged += Core_VideoSizeChanged;
|
||||
Core.ScaleWindow += Core_ScaleWindow;
|
||||
Core.WindowScale += Core_WindowScale;
|
||||
@@ -135,6 +136,18 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
private void Core_ShowMenu()
|
||||
{
|
||||
BeginInvoke(new Action(() => {
|
||||
if (IsMouseInOSC())
|
||||
return;
|
||||
|
||||
CursorHelp.Show();
|
||||
UpdateMenu();
|
||||
ContextMenu.IsOpen = true;
|
||||
}));
|
||||
}
|
||||
|
||||
void Core_ScaleWindow(float scale) {
|
||||
BeginInvoke(new Action(() => {
|
||||
int w, h;
|
||||
@@ -791,30 +804,17 @@ namespace mpvnet
|
||||
case 0x105: // WM_SYSKEYUP
|
||||
case 0x201: // WM_LBUTTONDOWN
|
||||
case 0x202: // WM_LBUTTONUP
|
||||
case 0x204: // WM_RBUTTONDOWN
|
||||
case 0x205: // WM_RBUTTONUP
|
||||
case 0x207: // WM_MBUTTONDOWN
|
||||
case 0x208: // WM_MBUTTONUP
|
||||
case 0x20a: // WM_MOUSEWHEEL
|
||||
case 0x20e: // WM_MOUSEHWHEEL
|
||||
case 0x20b: // WM_XBUTTONDOWN
|
||||
case 0x20c: // WM_XBUTTONUP
|
||||
case 0x20c: // WM_XBUTTONUP
|
||||
case 0x20e: // WM_MOUSEHWHEEL
|
||||
if (Core.WindowHandle != IntPtr.Zero)
|
||||
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x0204: // WM_RBUTTONDOWN
|
||||
if (IsMouseInOSC() && Core.WindowHandle != IntPtr.Zero)
|
||||
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x0205: // WM_RBUTTONUP
|
||||
if (!IsMouseInOSC())
|
||||
{
|
||||
CursorHelp.Show();
|
||||
UpdateMenu();
|
||||
ContextMenu.IsOpen = true;
|
||||
}
|
||||
else
|
||||
if (Core.WindowHandle != IntPtr.Zero)
|
||||
m.Result = SendMessage(Core.WindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x319: // WM_APPCOMMAND
|
||||
{
|
||||
string value = Input.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mpvnet
|
||||
public class AppSettings
|
||||
{
|
||||
public bool InputDefaultBindingsFixApplied;
|
||||
public int LastUpdateCheck;
|
||||
public bool ShowMenuFixApplied;
|
||||
public int Volume = 70;
|
||||
public List<string> RecentFiles = new List<string>();
|
||||
public Point WindowLocation;
|
||||
|
||||
Reference in New Issue
Block a user