Commit graph

233 commits

Author SHA1 Message Date
thefiddler f799530575 [Mac] Do not use autorelease pool
Avoids a potential crash on shutdown.
2014-07-23 23:22:00 +02:00
thefiddler bb882fe700 [Mac] Correctly release mach port
The event tap is released automatically along with the mach port. Fixes
crash on shutdown.
2014-07-23 23:21:04 +02:00
thefiddler 29af70274d [Mac] Removed stored delegate list
The stored delegate list would store delegates indefinitely, causing a
memory leak. It is now the responsibility of each class to maintain
references to any callback functions it defines.
2014-07-23 21:23:25 +02:00
thefiddler 57c2f89038 [Mac] Explicitly close removed devices
Devices are now explicitly closed when they a DeviceRemoved event is
received. Additionally, exceptions are no longer allowed to escape into
unmanaged code, where they might crash the runtime.
2014-07-23 21:19:46 +02:00
thefiddler d12643cf44 [Mac] Mark callback calling convention
Callbacks are now explicitly marked as unmanaged pointers with the
correct (platform-defined) calling convention. Exceptions raised inside
these callbacks are no longer allowed to escape into unmanaged code,
where they will crash the runtime.

Additionally, the window is now only closed on the UI thread, and only
if it is actually open.
2014-07-23 21:18:34 +02:00
thefiddler a6c4a7c9b5 [Mac] Only dispose context on UI thread 2014-07-23 21:15:16 +02:00
thefiddler e5e9ae0929 [Mac]] Add NSApplication.IsUIThread property
This can be used to check whether it is safe to access UI components in
the calling thread.
2014-07-23 21:14:47 +02:00
thefiddler 050a93d4af [Mac] Resource registration moved to the facades 2014-07-23 14:36:09 +02:00
thefiddler ac2ae4a4bb [Mac] Ensure Cocoa bindings are initialized first 2014-07-23 14:35:51 +02:00
thefiddler 5d66aaa034 [Mac] Do not set callback delegates to null
This is done automatically by the GC once they are eligible for
collection.
2014-07-23 10:10:37 +02:00
thefiddler 4093b39fac [Mac] Store a reference to callback delegates
This avoids a potential crashes by the GC reclaiming the delegates
prematurely.
2014-07-23 10:10:08 +02:00
thefiddler e81d8da068 [OpenTK] Reduce duplication in GraphicsContextBase
Inheritors now take advantage of base class functionality to avoid
duplicating finalizers and warning messages.
2014-07-23 10:08:57 +02:00
thefiddler 8f03b09dad [Mac] Register platform resources for disposal 2014-07-23 09:21:28 +02:00
thefiddler 864cc84019 [Mac] Do not execute run loop prematurely
Fixes a potential crash when destroying and recreating OpenTK.Toolkit.
2014-07-23 09:20:51 +02:00
thefiddler 0a0a5d0af7 [Mac] More defensive programming
CocoaNativeWindow now checks for and reports failures to allocate
resources in its constructor. Additionally, it no longer calls UI
methods in the finalizer thread, as those methods will crash on Cocoa.
2014-07-23 09:05:01 +02:00
thefiddler 9d6b6891e6 [Mac] CursorVisible should only apply when changed
This fixes an issue where `NativeWindow.Dispose()` would move the mouse
cursor.
2014-07-22 21:02:33 +02:00
thefiddler 0c4081f6ef [Mac] Do not use Autorelease pool 2014-07-22 16:29:52 +02:00
thefiddler 5501689d37 [Mac] Added objc_disposeClassPair binding 2014-07-22 16:29:37 +02:00
thefiddler 0e40f63cf2 [Mac] Close CocoaNativeWindow in Dispose()
Also fix various memory management issues regarding the `MouseCursor`
and `Icon` properties.
2014-07-22 16:29:21 +02:00
thefiddler 7956126c8d [Mac] Retain CFRunLoop while it is in use 2014-07-22 16:20:46 +02:00
thefiddler 42e4e0b27e [Mac] Added CFRetain binding 2014-07-22 16:19:43 +02:00
thefiddler a047c08d3d [Mac] Correctly shutdown HID input driver 2014-07-22 14:28:48 +02:00
thefiddler 00b531fdef Fixed compilation warnings on Mono 3.4.0 2014-07-21 17:46:39 +02:00
thefiddler 461fbce45f Cleaned up a number of obsolete warnings 2014-07-21 16:39:58 +02:00
thefiddler c1c6b4269b Merge pull request #149 from thefiddler/mac_stability
[Mac] Improved stability for NSOpenGLPixelFormat
2014-07-15 06:06:41 +00:00
thefiddler 32958ffcce [Mac] Improved stability for NSOpenGLPixelFormat
Non-accelerated contexts are now considered iff no accelerated contexts
are available. Additionally, a GraphicsException will be thrown if
context construction fails for any reason, instead of causing a runtime
crash.
2014-07-14 12:27:28 +02:00
thefiddler 8373782fad [Mac] Fix Mouse.GetState() h-wheel
External mice will now report horizontal scrolling in the low-level
`Mouse.GetState()` API. The touchpad apparently creates an emulated
mouse device that does not report horizontal wheel scrolling events.

Touchpad support probably requires a proper multitouch implementation.
2014-06-10 17:43:31 +02:00
thefiddler 5e63c5fa5c [Mac] Add note for higher precision pixel scroll 2014-06-10 16:41:09 +02:00
thefiddler 2a4f634848 [Mac] Match win32 scrolling coordinates 2014-06-10 16:40:44 +02:00
thefiddler 5b529647c9 [Mac] Fixed NRE and initial position on 64bit 2014-05-20 01:00:54 +02:00
thefiddler c65e2a4d9e [Mac] Added NSFloat implementation 2014-05-20 00:14:57 +02:00
thefiddler 1419c1e3a0 [Mac] Explicitly retain/release CocoaWindowInfo instances 2014-05-14 18:01:08 +02:00
thefiddler 96aaef9b37 [Mac] Implemented Mouse.GetCursorState() 2014-05-12 02:20:53 +02:00
thefiddler f4a3cab0e0 [Input] Added Mouse.GetCursorPos() (WIP) 2014-05-12 02:20:52 +02:00
thefiddler d7e0373852 [Platform] Fixed keys getting stuck on focus loss
NativeWindowBase will now clear all keyboard keys when losing focus.
This prevents keys from getting stuck when refocusing the window.

[Win] Also fixed WindowState.Maximized when WindowBorder is Hidden and
the window is minimized.
2014-05-09 16:45:45 +02:00
thefiddler b1f627893b [Mac] Fixed PointTo* calculations
On HiDPI displays, the client rectangle is using a pixel-based
coordinate system, while the screen is using a point-based coordinate
system. PointToClient/PointToScreen now correctly accounts for that.
2014-05-06 09:03:13 +02:00
thefiddler 41276361fb [Mac] Report KeyDown/Up events for modifier flags 2014-05-05 09:14:14 +02:00
thefiddler 8b7d5bc7e4 [Input] Implement key repeat 2014-05-05 00:43:45 +02:00
thefiddler d968281a1b [OpenTK] Refactor keyboard and mouse handling
A lot of duplicated code is now moved to NativeWindowBase and
LegacyInputDriver.
2014-05-04 17:05:08 +02:00
thefiddler 28a1849a72 [Mac] Moved MacOSKeys to MacOS namespace
They are used by both Carbon and Cocoa, so there is little reason to
keep them in MacOS.Carbon
2014-05-04 17:02:37 +02:00
thefiddler 4b115c443b [Mac] Add horizontal scrolling 2014-05-04 15:24:02 +02:00
thefiddler 9dab96c5c1 [Mac] Disable momentum scrolling and key pop-ups
We might wish to add an option to re-enable momentum scrolling, as this
might be useful to some applications for a more native feel.
2014-05-04 15:23:24 +02:00
thefiddler e093fd23f6 [Mac] Avoid calling into LegacyInputDriver 2014-05-04 08:32:26 +02:00
thefiddler 94fdf1881c [Platform] Improved mouse interface
- The complete mouse state is now available in mouse events
- Horizontal wheels are now supported
- MouseState now takes up less memory and has a simpler internal
implementation.
2014-05-04 01:29:55 +02:00
thefiddler 3e33ac9280 [Platform] Refactored INativeWindow backends
All INativeWindow implementations are now derived from
NativeWindowBase. They no longer implement legacy IInputDriver
themselves, but rather rely on LegacyInputDriver provided by
NativeWindowBase for compatibility. They also implement the new Mouse*
events.
2014-05-02 16:52:11 +02:00
thefiddler 674cd54c29 [Mac] Fixed initial window position
Cocoa sets the desktop origin at the bottom-left of the main screen,
with +y going up. OpenTK is setting the origin at the top-left of the
main screen, so we need to invert the y-axis.
2014-05-02 15:13:38 +02:00
thefiddler 3824f55f18 [Mac] Fixed cursor coords when CursorVisible=false 2014-05-02 14:21:32 +02:00
thefiddler 612652910f [Platform] Inherit NativeWindowBase 2014-05-02 14:18:40 +02:00
thefiddler 300203f73b [Mac] Use On* methods from base class 2014-05-02 09:41:27 +02:00
thefiddler f2eca2924f [Mac] Inherit from NativeWindowBase
This reduces code duplication significantly.
2014-05-02 09:37:25 +02:00