1
0
Fork 0
Commit graph

46 commits

Author SHA1 Message Date
Alex Janka 0d20459065 update deps 2024-08-19 15:28:17 +10:00
Alex Janka e51b4dd832 raw-window-handle 0.6.0 (windows only!!!!) 2024-05-26 10:45:32 +10:00
Micah Johnston 905854d026
Remove unnecessary dependences from CI pipeline (#185) 2024-03-30 06:29:18 +01:00
Adrien Prokopowicz 119fc25cd6
Add additional CI checks (#182) 2024-03-30 00:55:44 +01:00
Adrien Prokopowicz 70e7af6c61
Add a new example for OpenGL setup using femtovg (#176) 2024-03-27 06:39:21 +01:00
Micah Johnston fdc5d282fc
Switch from xcb crate to x11rb (#173)
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.
2024-03-25 11:20:28 -05:00
Adrien Prokopowicz 998ced845c
Added functional open_parented example (#172)
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.
2024-03-24 17:16:16 -05:00
Robbert van der Helm 54af726498
Merge pull request #134 from greatest-ape/raw-window-handle-0.5
Upgrade to raw-window-handle version 0.5
2023-10-07 15:12:01 +02:00
Joakim Frostegård 1c0490f9ec Upgrade to raw-window-handle 0.5, impl HasRawDisplayHandle for macOS 2023-09-30 17:00:08 +02:00
Jussi Viiri b5f3939930 Parse drop data
Only handling files for now
2023-06-04 23:43:10 +03:00
Jussi Viiri 0eff674319 Janky first version of drag and drop
Just recognized as a drop target
2023-05-31 22:43:30 +03:00
Robbert van der Helm 690a94f9f1 Enable the glx feature for the x11 crate 2022-02-07 21:41:45 +01:00
Robbert van der Helm d2e3d5d1ac Don't enable the OpenGL feature by default 2022-02-07 17:58:45 +01:00
Robbert van der Helm 0f1b8353d0 Patch up the raw-gl-context modules for a feature
This only needed a couple changes for the raw-window-handle migration,
and for the different module paths.
2022-02-07 17:31:19 +01:00
Robbert van der Helm d76b02df44 Upgrade to raw-window-handle 0.4.x
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.
2022-02-07 17:13:51 +01:00
George Atkinson a8010016fb
Bump dependencies (#100) 2022-02-06 17:58:11 -06:00
Billy Messenger f6e99e9aa6
add ability to close window from user code, add HostWindowHandle (#103)
* 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
2021-11-16 00:00:22 -06:00
Joakim Frostegård 72302e9dd0
macOS: use CFRunLoopTimer, improve view release logic (#84)
* 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
2020-12-27 20:44:23 -06:00
Micah Johnston 8402310c88 remove Message api 2020-12-12 17:06:50 -06:00
micah 08e56bd5ae remove unnecessary dependencies (log, libc) 2020-12-05 18:01:33 -06:00
Joakim Frostegård 1c81921688 Use wait-free spsc message chan; split off AppRunner from WindowHandle 2020-12-04 20:03:55 +01:00
Joakim Frostegård 1ea32123ed Assert at compile-time that WindowHandle is Sync 2020-12-04 20:03:55 +01:00
Joakim Frostegård dd3f85b347 Cargo.toml: set default-features = false for keyboard-types 2020-11-14 17:46:12 +01:00
Joakim Frostegård 9748e16ebe Add support for macOS and X11 key events with code from druid 2020-11-14 17:46:12 +01:00
Joakim Frostegård e569015c31 Add license statement and files (dual MIT or Apache 2.0) 2020-11-12 21:52:49 +01:00
Joakim Frostegård 2167a091fa
macOS: basic event handling (#52)
* 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
2020-11-11 16:04:40 -06:00
William Light 647925ceeb Cargo.toml: remove maybe-uninit 2020-09-14 03:12:59 +02:00
Billy Messenger d84a1fde44 Add set_mouse_cursor method to X11 Window 2020-09-13 18:23:51 -05:00
William Light b64183fb19 x11: Event::WillClose support
this is a nightmare of ICCCM protocols but hey it's done now.
2020-09-11 18:03:04 +02:00
William Light dcb99e5c43 x11: switch from wait_for_event() to directly using poll() 2020-09-11 16:13:32 +02:00
Billy Messenger 2934a4c1fb Remove context creation code. Add mpsc Message channel. 2020-09-03 10:17:54 -05:00
Billy Messenger 9234f050c0 Add compiler arguments for choosing between OpenGL or wgpu. Add Receiver and Message types. 2020-09-02 16:22:49 -05:00
Mirko Covizzi fd7f4c1032 Merge remote-tracking branch 'upstream/master' into experiments 2020-07-08 23:04:39 +02:00
Mirko Covizzi df72b11c74 Successful execution and rendering on Windows host 2020-07-08 23:03:03 +02:00
Mirko Covizzi 96380305d4 Merge branch 'events' 2020-06-15 23:03:16 +02:00
Mirko Covizzi c499697a9a Windows: add basic event handling 2020-06-15 23:02:39 +02:00
Charles Saracco c42b218bb1 Better DPI scale factor strategy for X11 2020-06-14 00:25:37 -04:00
Charles Saracco cc6d17169e OpenGL surface for X11/XCB 2020-05-31 14:39:14 -04:00
Mirko Covizzi e2c4c53f32 Add OpenGL context on Windows 2020-05-29 21:03:22 +02:00
Micah Johnston 951ba2a595 initial macos code 2020-05-25 16:17:59 -05:00
Mirko Covizzi 23a63d15a5 Merge 2020-05-25 22:24:16 +02:00
Mirko Covizzi f75177e9b6 Setup unique class naming for windows on Windows 2020-05-25 22:15:58 +02:00
Mirko Covizzi 5d429fd5ae Fix format and setup platform specific dependencies 2020-05-25 21:55:49 +02:00
Charles Saracco 741318b7f6 barebones x11 window 2020-05-25 15:49:29 -04:00
Mirko Covizzi e7c8a9780d Add Windows initial code 2020-05-25 21:35:03 +02:00
William Light 7f299cf69b add WindowOpenOptions 2020-05-25 20:04:48 +02:00