Replace the `xcb` and `xcb-util` crates with `x11rb`. We were using an old version of the `xcb` crate which had some soundness issue. `x11rb` doesn't have these issues and generally provides a safer and nicer to use API.
It's possible to use `x11rb` without linking to xcb at all, using the `RustConnection` API, but unfortunately we have to use the `XCBConnection` API (which uses xcb under the hood) due to our use of the xlib GLX API for creating OpenGL contexts. In the future, it might be possible to avoid linking to xlib and xcb by replacing GLX with EGL.
Getting the xlib-xcb integration to work also necessitated upgrading the version of the `x11` crate, since the version we were using was missing some necessary functionality that was previously being provided by the `xcb` crate.
This PR adds a simple example that allows to test and showcase the `Window::open_parented` method.
That example first creates a parent window using `Window::open_blocking`, and then creates a smaller child window using `Window::open_parented`.
Both window's handlers log all of their events to the console, in a similar fashion to the `open_window` example.
Both windows actually do rendering (unlike the `open_window` example for now): the parent fills its window with a grey backround, and the child fills its window with a red background.
This example also uses the `softbuffer` crate to perform the rendering, which allows testing it in a more portable manner and in the simplest use case possible, without having to involve OpenGL or any 3D rendering pipeline at all.
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
* 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
* 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