Commit graph

51 commits

Author SHA1 Message Date
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 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 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 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 461fbce45f Cleaned up a number of obsolete warnings 2014-07-21 16:39:58 +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 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 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 4b115c443b [Mac] Add horizontal scrolling 2014-05-04 15:24:02 +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
thefiddler c8c0d32fcc [OpenTK] Rearranged MouseCursor parameters
MouseCursor and WindowIcon now match GL.TexImage2D in the way they
arrange their parameters. The expected values of each parameter are now
documented.
2014-04-30 20:04:31 +02:00
thefiddler e63970e2be [Mac] Fixed cursor byte order 2014-04-30 09:06:18 +02:00
thefiddler 7d8f14baa7 [Mac] Implement NSCursor rectangles 2014-04-30 08:38:19 +02:00
thefiddler ffb7bd8a4c Merge branch 'pr/105' into develop 2014-04-28 16:19:17 +02:00
thefiddler 53d2c8d1e8 [Mac] Cmd-Q should raise Closing events
It should also be cancelable.
2014-04-28 16:19:04 +02:00
thefiddler 48e21328c5 [Mac] Implement INativeWindow.Cursor 2014-04-27 19:45:20 +02:00
thefiddler a61d20d2eb [Mac] Stubbed INativeWindow.Cursor 2014-04-27 10:56:08 +02:00
Olle Håkansson 160e6ecb31 Added Quit menu item + shortcut (Cmd+Q). 2014-04-27 10:52:28 +02:00
Olle Håkansson a24ce9ba11 Fixed creating contexts without native windows.
To create a context for the GTK GLWidget, you need to be able to
specify the exact NSView you want the OpenGL context to apply to. Also,
you don’t want to initialise the NSApplication in this situation, which
the CocoaContext did before (unintentionally).
2014-04-27 09:58:05 +02:00
thefiddler e36a0d0fbc [OpenTK] Rebased on develop 2014-04-25 13:38:53 +02:00
thefiddler 3475582c30 [Mac] Mouse coordinates are reported in pixels 2014-04-24 13:47:30 +02:00
thefiddler 3250cbbc91 [Mac] Use scrollFactor variable 2014-04-24 13:47:30 +02:00
thefiddler a2212f0184 [Mac] Fixed a warning related to volatile UniqueId
Also changed the class name to OpenTK_GameWindow
2014-04-24 13:47:30 +02:00
thefiddler acb7dd27a7 [Mac] Window should be invisible on startup
Also fixes the initial position of the window.
2014-04-24 13:47:30 +02:00
Olle Håkansson 64fb043b77 Licensed files under MIT/X11. 2014-04-24 13:45:06 +02:00
thefiddler b0eedc122d [Mac] Avoid class conflicts for multiple windows
When creating multiple windows, their classes must have different class
names or they will fail to construct.

This commit ensures their names are unique. It also fixes a potential
memory leak in the Icon setter.
2014-04-24 13:45:06 +02:00
Olle Håkansson 2943bdfecb Fixed too high mouse scrolling speed. 2014-04-24 13:45:06 +02:00
Olle Håkansson 4573db2ceb Much improved handling of window/border states. 2014-04-24 13:45:06 +02:00
Olle Håkansson 86a5399534 Register mouse drag as well as move. 2014-04-24 13:45:05 +02:00
Olle Håkansson 46856dc21d Closing should occur in ProcessEvents. 2014-04-24 13:45:05 +02:00
Olle Håkansson ed87814a7f Cleanups. 2014-04-24 13:45:05 +02:00
Olle Håkansson d1fb2597bb Better handling of maximized window.
Used the “zoom” command before, but it has some limitations (e.g. no
event when zoom is done).
2014-04-24 13:45:05 +02:00
Olle Håkansson 50ed0ee9da Bug fixes. 2014-04-24 13:45:05 +02:00
Olle Håkansson 63d0d057c5 Better fullscreen handling. 2014-04-24 13:45:05 +02:00
Olle Håkansson 59d7889ce0 Restored most window functionality. 2014-04-24 13:45:05 +02:00
Olle Håkansson 6c6beae4fc Setup listening for window events. 2014-04-24 13:45:04 +02:00