This would solve the most important use case for #116. Only the Linux
version has been tested, but the Windows should work perfectly fine, and
I don't know anything about macOS programming but that version also
compiles so it should be fine.
Since this isn't emitted anywhere, this can only lead to confusion for
library consumers. They'd need to implement their own click detection
with the button up and button down events.
The things remaining are all of the cursor things in the X11
implementation (there's _a lot_ of it, so there's probably a reason why
it's all still there but unused), and the super unsound immutable
reference to mutable reference cast in the macOS implementation that
Clippy automatically errors out on.
The main change is that all of these types are simplified, there are
more different OS-specific window handle types, and they are no longer
gated behind the respective targets which makes the library a bit easier
to use for applications.
* add ability to close window from user code, add HostWindowHandle
* fix manual close method for Mac, rename HostWindowHandle to ChildWindowHandle
* fix rustfmt.toml and run cargo format
* fix merge conflict mistake
* fix more merge conflict mistakes
* implement requested changes (with a non-broken commit this time)
* implement requested changes
* slight reordering of impls
* drain autorelease pools in Window::open_* methods
* fixes to NSView lifetime logic:
- in open_parented and open_blocking, release NSView after adding
it as a subview of the parent
- in open_blocking, don't call autorelease on NSWindow. previously
it was a no-op, but now that we are actually draining our
autorelease pools, it ends up prematurely releasing the window.
* fixes to NSView cleanup logic:
- Move retainCount check to before calling [super release].
If [super release] happens first, then in the final call to
release, [super release] deallocates the object and the call to
retainCount results in a segfault.
- Move objc_disposeClassPair to dealloc. Previously we were
calling it when retainCount == 1, but that's exactly when
dealloc is called, so this is cleaner. Also, we need to call
objc_disposeClassPair after [super dealloc].
NOTE: The circular-reference-breaking logic in release is
definitely broken. It's easy to thwart it by e.g. creating a
wgpu surface at some point after build() or dropping one at some
point before drop(). Need to come up with a better solution.
* using viewDidChangeBackingProperties callback to detect scale factor changes and propagate via WindowEvent::Resized
* null check on ns_window
* changed match with if
* Add mutable event status argument to WindowHandler::on_event
* macOS: simplify method declaration for simple mouse event handlers
* macOS: add macro for adding simple keyboard class methods
* macOS: reorder code in mouse_moved
* Take EventStatus as return value in WindowHandler::on_event
* Add doc comments for EventStatus
* Improve EventStatus documentation
* x11: ignore return value of on_event for now
* EventStatus: improve docs
* Improve EventsStatus docs
* Improve EventStatus docs further
* macOS: ignore EventStatus::Ignored for mouse events
* macOS: minor formatting improvement
* improve EventStatus docs again
* macOS: fix property_no fn
* Use CFRunLoopTimer instead if NSTimer
This means the timer doesn't keep a reference to the view,
which should make it easer to check retain_count in release.
* macOS: take pointer instead of Arc in WindowState::setup_timer
* Save retain count increase from build fn, use in release fn
* macOS: in window setup, run build fn before doing parenting
* macOS: clean up parenting
* macOS: wrap WindowState in Box instead of Arc to improve clarity
* macOS: use better names for ivar consts, move them to view.rs
* Remove no longer used crate static_assertions
* macOS: in view release fn, delete class when retain_count == 1
* macOS: set window state ivar to null after dropping
* macOS: store retain count after build in WindowState
* macOS: rename BASEVIEW_WINDOW_STATE_IVAR to BASEVIEW_STATE_IVAR
Fixed a bug where an 'already borrowed' arror would occur when pressing keyboard keys in quick succession. Moving the borrow and borrow_mut of the window state inside the button down/up event seems to fix this.
* Added mouse capture/release to windows backend
* Mouse capture now automatic only
Removed manual ability to trigger mouse capture and release.
* Added refcount for mouse button event
Added refcount to prevent the mouse capture from releasing before all mouse buttons have been released.
* Removed unnecessary function from window
if we call DefWindowProc for non-system events, pressing alt or f10 puts
focus on the (nonexistent) dropdown menu until the next click or
keystroke, so we only call it in the case of WM_SYSKEYDOWN.
* macOS: add basic event handling
* macos: don't store subview pointer in WindowHandle
* macOS: mention inspiration from antonok's vst_window crate, clean up
* Add Anton Lazarev and myself to author list
* macOS: fix event handling issues
- Rename EventDelegate to WindowState
- Make Window.ns_window optional, only set it if parentless
- Put our own NSView subclass in Window.ns_view
- Don't create useless "intermediate" NSView in parentless mode
* macOS: use Arc::from_raw in WindowHandler dealloc fn
* macOS: move subview code own file, handle more mouse events
* macOS: add (non-tested) support for AsIfParented window
* macOS: rename subview module to view
* macOS: rename "mouse_click_extern_fn!" to "mouse_button_extern_fn!"
This avoids confusion with the click event
* macOS: make WindowState Arc wrapping code clearer
* macOS: handle basic key press and release events
* macOS: accept mouseMoved events, don't trigger them on clicks
* macOS: fix cursor movement location conversion
* macOS: add WindowState.trigger_event fn, make fields private
* macOS: in view, set preservesContentInLiveResize to NO
* macOS: add NSTrackingArea, cursor enter/exit events, better window init
* macOS: remove unused WindowState.size field
* macOS: acceptFirstMouse = YES in view
* macOS: rename macro mouse_button_extern_fn to mouse_simple_extern_fn
* macOS: remove key event handling, it will be implemented differently
* macOS: trigger CursorMoved on right and middle mouse drag
* macOS: run NSEvent.setMouseCoalescingEnabled(NO)
* macOS: clean up
* macOS: non-parented mode: don't "activate ignoring other apps"
This is rarely necessary according to
https://developer.apple.com/documentation/appkit/nsapplication/1428468-activate
and I don't see any reason why we would need to do it.
* macOS: call NSApp() before doing more work in non-parented mode
* macOS: don't attempt to declare NSView subclass multiple times
* macOS: add random suffix to name of NSView subclass to prevent issues
* macOS: send tracking area options as a usize (objc UInt)
* macOS: use UUID for class name suffix
* macOS: fix view_will_move_to_window super call
* macOS: drop WindowState when our NSView is released
* macOS: in Window::open, autorelease an NSString that was allocated
* macOS: delete our view class when the view is released
* Upgrade cocoa dependency to version 0.24.0
* macOS: reorder some code in view.rs
* macOS: mark WindowState::from_field as unsafe, update doc comment
* macOS: in HasRawWindowHandle impl, use unwrap_or for ns_window