mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 18:35:32 +00:00
[Mac] Use On* methods from base class
This commit is contained in:
parent
10939fcaec
commit
300203f73b
|
@ -45,6 +45,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
static readonly IntPtr selNextEventMatchingMask = Selector.Get("nextEventMatchingMask:untilDate:inMode:dequeue:");
|
static readonly IntPtr selNextEventMatchingMask = Selector.Get("nextEventMatchingMask:untilDate:inMode:dequeue:");
|
||||||
static readonly IntPtr selSendEvent = Selector.Get("sendEvent:");
|
static readonly IntPtr selSendEvent = Selector.Get("sendEvent:");
|
||||||
//static readonly IntPtr selUpdateWindows = Selector.Get("updateWindows");
|
//static readonly IntPtr selUpdateWindows = Selector.Get("updateWindows");
|
||||||
|
static readonly IntPtr selContentView = Selector.Get("contentView");
|
||||||
static readonly IntPtr selConvertRectFromScreen = Selector.Get("convertRectFromScreen:");
|
static readonly IntPtr selConvertRectFromScreen = Selector.Get("convertRectFromScreen:");
|
||||||
static readonly IntPtr selConvertRectToScreen = Selector.Get("convertRectToScreen:");
|
static readonly IntPtr selConvertRectToScreen = Selector.Get("convertRectToScreen:");
|
||||||
static readonly IntPtr selPerformClose = Selector.Get("performClose:");
|
static readonly IntPtr selPerformClose = Selector.Get("performClose:");
|
||||||
|
@ -243,7 +244,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
GraphicsContext.CurrentContext.Update(windowInfo);
|
GraphicsContext.CurrentContext.Update(windowInfo);
|
||||||
|
|
||||||
if (suppressResize == 0)
|
if (suppressResize == 0)
|
||||||
Resize(this, EventArgs.Empty);
|
OnResize(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplicationQuit(object sender, CancelEventArgs e)
|
private void ApplicationQuit(object sender, CancelEventArgs e)
|
||||||
|
@ -256,17 +257,17 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
// Problem: Called only when you stop moving for a brief moment,
|
// Problem: Called only when you stop moving for a brief moment,
|
||||||
// not each frame as it is on PC.
|
// not each frame as it is on PC.
|
||||||
Move(this, EventArgs.Empty);
|
OnMove(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WindowDidBecomeKey(IntPtr self, IntPtr cmd, IntPtr notification)
|
private void WindowDidBecomeKey(IntPtr self, IntPtr cmd, IntPtr notification)
|
||||||
{
|
{
|
||||||
FocusedChanged(this, EventArgs.Empty);
|
OnFocusedChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WindowDidResignKey(IntPtr self, IntPtr cmd, IntPtr notification)
|
private void WindowDidResignKey(IntPtr self, IntPtr cmd, IntPtr notification)
|
||||||
{
|
{
|
||||||
FocusedChanged(this, EventArgs.Empty);
|
OnFocusedChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WindowWillMiniaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
private void WindowWillMiniaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
||||||
|
@ -280,14 +281,14 @@ namespace OpenTK.Platform.MacOS
|
||||||
private void WindowDidMiniaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
private void WindowDidMiniaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
||||||
{
|
{
|
||||||
windowState = WindowState.Minimized;
|
windowState = WindowState.Minimized;
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
OnResize(false); // Don't set tracking area when we minimize
|
OnResize(false); // Don't set tracking area when we minimize
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WindowDidDeminiaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
private void WindowDidDeminiaturize(IntPtr self, IntPtr cmd, IntPtr notification)
|
||||||
{
|
{
|
||||||
windowState = WindowState.Normal;
|
windowState = WindowState.Normal;
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
OnResize(true);
|
OnResize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +306,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
InternalBounds = toFrame;
|
InternalBounds = toFrame;
|
||||||
windowState = WindowState.Maximized;
|
windowState = WindowState.Maximized;
|
||||||
|
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -313,11 +314,11 @@ namespace OpenTK.Platform.MacOS
|
||||||
private bool WindowShouldClose(IntPtr self, IntPtr cmd, IntPtr sender)
|
private bool WindowShouldClose(IntPtr self, IntPtr cmd, IntPtr sender)
|
||||||
{
|
{
|
||||||
var cancelArgs = new CancelEventArgs();
|
var cancelArgs = new CancelEventArgs();
|
||||||
Closing(this, cancelArgs);
|
OnClosing(cancelArgs);
|
||||||
|
|
||||||
if (!cancelArgs.Cancel)
|
if (!cancelArgs.Cancel)
|
||||||
{
|
{
|
||||||
Closed(this, EventArgs.Empty);
|
OnClosed(EventArgs.Empty);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +416,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
if (!isARepeat || InputDriver.Keyboard[0].KeyRepeat)
|
if (!isARepeat || InputDriver.Keyboard[0].KeyRepeat)
|
||||||
{
|
{
|
||||||
KeyDown(this, keyArgs);
|
OnKeyDown(keyArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = Cocoa.FromNSString(Cocoa.SendIntPtr(e, selCharactersIgnoringModifiers));
|
var s = Cocoa.FromNSString(Cocoa.SendIntPtr(e, selCharactersIgnoringModifiers));
|
||||||
|
@ -427,7 +428,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
// For some reason, arrow keys (mapped 63232-63235) are seen as non-control characters, so get rid of those.
|
// For some reason, arrow keys (mapped 63232-63235) are seen as non-control characters, so get rid of those.
|
||||||
|
|
||||||
keyPressArgs.KeyChar = c;
|
keyPressArgs.KeyChar = c;
|
||||||
KeyPress(this, keyPressArgs);
|
OnKeyPress(keyPressArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +442,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
GetKey(keyCode, modifierFlags, keyArgs);
|
GetKey(keyCode, modifierFlags, keyArgs);
|
||||||
InputDriver.Keyboard[0].SetKey(keyArgs.Key, keyArgs.ScanCode, false);
|
InputDriver.Keyboard[0].SetKey(keyArgs.Key, keyArgs.ScanCode, false);
|
||||||
|
|
||||||
KeyUp(this, keyArgs);
|
OnKeyUp(keyArgs);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -456,8 +457,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
//SetCursor(selectedCursor);
|
//SetCursor(selectedCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorInsideWindow = true;
|
OnMouseEnter(EventArgs.Empty);
|
||||||
MouseEnter(this, EventArgs.Empty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -473,8 +473,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
SetCursor(MouseCursor.Default);
|
SetCursor(MouseCursor.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursorInsideWindow = false;
|
OnMouseLeave(EventArgs.Empty);
|
||||||
MouseLeave(this, EventArgs.Empty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -507,8 +506,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
var dy = Cocoa.SendFloat(e, selDeltaY);
|
var dy = Cocoa.SendFloat(e, selDeltaY);
|
||||||
|
|
||||||
p = new Point(
|
p = new Point(
|
||||||
MathHelper.Clamp((int)Math.Round(p.X + dx)),
|
MathHelper.Clamp((int)Math.Round(p.X + dx), 0, Width),
|
||||||
MathHelper.Clamp((int)Math.Round(p.Y - dy)));
|
MathHelper.Clamp((int)Math.Round(p.Y - dy), 0, Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
InputDriver.Mouse[0].Position = p;
|
InputDriver.Mouse[0].Position = p;
|
||||||
|
@ -598,7 +597,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
IntPtr nsimg = Cocoa.ToNSImage(img);
|
IntPtr nsimg = Cocoa.ToNSImage(img);
|
||||||
Cocoa.SendVoid(NSApplication.Handle, selSetApplicationIconImage, nsimg);
|
Cocoa.SendVoid(NSApplication.Handle, selSetApplicationIconImage, nsimg);
|
||||||
}
|
}
|
||||||
IconChanged(this, EventArgs.Empty);
|
OnIconChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +630,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Cocoa.SendVoid(windowInfo.Handle, selSetIsVisible, value);
|
Cocoa.SendVoid(windowInfo.Handle, selSetIsVisible, value);
|
||||||
VisibleChanged(this, EventArgs.Empty);
|
OnVisibleChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,7 +734,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
InternalBounds = GetCurrentScreenFrame();
|
InternalBounds = GetCurrentScreenFrame();
|
||||||
|
|
||||||
windowState = value;
|
windowState = value;
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
else if (value == WindowState.Maximized)
|
else if (value == WindowState.Maximized)
|
||||||
{
|
{
|
||||||
|
@ -748,8 +747,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
else if (value == WindowState.Normal)
|
else if (value == WindowState.Normal)
|
||||||
{
|
{
|
||||||
windowState = value;
|
windowState = value;
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
Resize(this, EventArgs.Empty);
|
OnResize(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,7 +772,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetWindowBorder(value);
|
SetWindowBorder(value);
|
||||||
WindowBorderChanged(this, EventArgs.Empty);
|
OnWindowBorderChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,7 +825,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
var contentViewBounds = Cocoa.SendRect(windowInfo.ViewHandle, selBounds);
|
var contentViewBounds = Cocoa.SendRect(windowInfo.ViewHandle, selBounds);
|
||||||
var bounds = Cocoa.SendRect(windowInfo.Handle, selConvertRectToBacking, contentViewBounds);
|
var bounds = Cocoa.SendRect(windowInfo.Handle, selConvertRectToBacking, contentViewBounds);
|
||||||
return new Size(0, 0, (int)bounds.Width, (int)bounds.Height);
|
return new Size((int)bounds.Width, (int)bounds.Height);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -999,7 +998,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
Cocoa.SendVoid(windowInfo.Handle, Selector.Release);
|
Cocoa.SendVoid(windowInfo.Handle, Selector.Release);
|
||||||
}
|
}
|
||||||
|
|
||||||
Disposed(this, EventArgs.Empty);
|
OnDisposed(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr GetView(IntPtr windowHandle)
|
public static IntPtr GetView(IntPtr windowHandle)
|
||||||
|
@ -1072,7 +1071,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
Cocoa.SendIntPtr(windowInfo.Handle, selSetTitle, Cocoa.ToNSString(title));
|
Cocoa.SendIntPtr(windowInfo.Handle, selSetTitle, Cocoa.ToNSString(title));
|
||||||
if (callEvent)
|
if (callEvent)
|
||||||
{
|
{
|
||||||
TitleChanged(this, EventArgs.Empty);
|
OnTitleChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue