1
0
Fork 0
Commit graph

320 commits

Author SHA1 Message Date
Jussi Viiri eb3a02115a Change how DragTarget functions parse coordinates
Instead of working around the winapi bug by manually parsing the pointer we're (incorrectly) given, use the correct function signature and transmute the function pointer
2023-06-10 22:21:37 +03:00
Jussi Viiri 2019efde65 Use Rc instead of Arc for DropTarget 2023-06-10 22:01:23 +03:00
Jussi Viiri 4f0a71736c Remove unnecessary transmute 2023-06-10 21:58:31 +03:00
Jussi Viiri e47f25facd DropTargetVtbl instance is const now 2023-06-10 21:52:44 +03:00
Jussi Viiri 92d7560f4b Document EventStatus::AcceptDrop 2023-06-05 22:24:29 +03:00
Jussi Viiri ab673fe534 Comment cleanup 2023-06-05 22:20:07 +03:00
Jussi Viiri fe03957514 Add keyboard modifiers to drag events
Remove fields from DragLeft
2023-06-05 21:00:19 +03:00
Jussi Viiri e9a1460a5b Use Point for drag coordinates like other mouse events 2023-06-05 20:53:25 +03:00
Jussi Viiri 1a8484bc55 Add coordinates to drag events 2023-06-05 20:48:06 +03:00
Jussi Viiri 1c50c326cb Add drop data to all drag events
Add DragData::None instead of using Option<DragData>
2023-06-05 20:25:27 +03:00
Jussi Viiri b5f3939930 Parse drop data
Only handling files for now
2023-06-04 23:43:10 +03:00
Jussi Viiri ef64cae538 Delete some unused lines committed by accident 2023-06-04 21:40:45 +03:00
Jussi Viiri f5840bc65b Refactor away duplicated code 2023-06-04 21:39:59 +03:00
Jussi Viiri d8ffd4abc6 Drop effect is now set based on EventStatus 2023-06-03 22:50:39 +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
Taylor Holliday dbda356826 Use &str instead of String. 2023-02-22 10:14:54 -08:00
Taylor Holliday 2b70a08e14 Add stubs for copy_to_clipboard. 2023-02-21 17:09:17 -08:00
Taylor Holliday 775d15df38 Simplify and use copy_to_clipboard. 2023-02-21 15:45:11 -08:00
Taylor Holliday 0675273801 Formatting 2023-02-21 15:26:22 -08:00
Taylor Holliday ffdc278e97 Add copy_to_clipboard. 2023-02-21 15:22:52 -08:00
Robbert van der Helm 425ee7ac35 Add missing AdjustWindowRectEx() for resize 2023-01-02 00:09:25 +01:00
Robbert van der Helm be5238ec46 Replace Rcs by reference to entire WindowState
This removes the need to pass through individual Rcs at the cost of
adding more lifetime parameters to the internals of the shared `Window`
struct and requiring an `Option` for the handler.
2023-01-01 23:41:41 +01:00
Robbert van der Helm c10ca6b40f Clean up the Windows WindowState
This would leak before this change.
2023-01-01 23:05:34 +01:00
Robbert van der Helm 8e3e078220 Fix Clippy lints in macOS backend 2023-01-01 22:38:57 +01:00
Robbert van der Helm 39e97ab2be Fix Clippy lints in Windows backend 2023-01-01 22:38:49 +01:00
Robbert van der Helm 96c0401865 Replace AtomicBool with Cell<bool>
https://github.com/RustAudio/baseview/pull/136#discussion_r1059198419
2023-01-01 22:35:23 +01:00
Robbert van der Helm 512c3f2393 Set macOS window size using setContentSize
I somehow completely missed this the first five times I looked through
the docs.
2022-12-16 23:20:56 +01:00
Robbert van der Helm d7a8c52d23 Round size before resizing on macOS
Otherwise the top row of pixels may contain flickering artifacts.
2022-12-02 20:17:11 +01:00
Robbert van der Helm bc2b2bd458 Factor in decorations when resizing macOS window
Apparently macOS doesn't do this for you. If you don't do this then
parts of the bottom and right of the window will be cut off.
2022-12-02 20:17:11 +01:00
Robbert van der Helm c7b61fa39b Also resize the OpenGL view on macOS
This fixes resizing with OpenGL applications.
2022-12-02 20:17:11 +01:00
Robbert van der Helm e0c79c58fb Implement window resizing for macOS
Now this works on all baseview platforms.
2022-12-02 20:17:11 +01:00
Robbert van der Helm 80fb0a00b8 Only send resize event on macOS on actual change
To follow the same behavior as on Linux and Windows.
2022-12-02 20:17:11 +01:00
Robbert van der Helm 537c303ee5 Only send resize event on Windows on actual change
To be in line with the Linux implementation.
2022-12-02 20:17:11 +01:00
Robbert van der Helm 5a1bb0f4d8 Ensure WindowEvent::Resized fires for Linux resize 2022-12-02 20:17:11 +01:00
Robbert van der Helm 80b30ce617 Implement window resizing for Windows 2022-12-02 20:17:11 +01:00
Robbert van der Helm b8a5867436 Replace uses of Arc with Rc in Windows impl
Everything is single threaded so there's no need to use Arcs.
2022-11-30 20:03:12 +01:00
Robbert van der Helm c5867b6af6 Use interior mutability for Windows WindowState
This is a prerequisite for being able to handle reentrant messages.
2022-11-30 20:03:12 +01:00
Robbert van der Helm 3dfff613b9 Use physical sizes in X11 window resize
And update the window info for any future events.
2022-11-30 20:03:12 +01:00
Robbert van der Helm d61f21666c Add window resizing for X11 2022-11-30 20:03:12 +01:00
Robbert van der Helm f2ca0ffa6d Support horizontal scrolling on Windows 2022-11-22 15:42:10 +01:00
Robbert van der Helm 9798d3ca86 Support horizontal scrolling on X11
This was previously bound to the mouse forwards/back
buttons (canonically mouse 4 and 5).
2022-11-22 15:39:49 +01:00
Robbert van der Helm 025f34b80f Map mouse forward and back correctly on X11
Buttons 6 and 7 are for horizontal scrolling, just like buttons 4 and 5
are for vertical scrolling. I couldn't find a list of button numbers in
the X11 protocol specs, but this is what the buttons are bound to on my
Logitech G502 and
http://xahlee.info/linux/linux_x11_mouse_button_number.html also
confirms this.
2022-11-22 15:32:43 +01:00
Robbert van der Helm 13cc12d4e7 Ensure a consistent frame pacing in X11 windows
The next frame's time stamp needs to be computed based on the last
frame's, not based on the current time, unless the last frame took too
long to process.
2022-11-18 15:24:33 +01:00
William Light 1780c89baf macos/view: fix compilation 2022-11-13 02:22:53 +01:00
william light eeded04b3e
Merge pull request #110 from ingo-dsp/macos-scrollwheel
macOS: scroll event handling
2022-11-13 02:14:16 +01:00
Ingo Budde 3dd255f238 Merge branch 'master' into macos-scrollwheel 2022-07-24 00:25:46 +02:00
Robbert van der Helm 5b57af2463 Add the active modifiers to the mouse event
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.
2022-03-11 22:28:42 +01:00
Robbert van der Helm e46001a448 Remove unused mouse click event
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.
2022-03-11 22:28:42 +01:00
Robbert van der Helm 85b6437de8 Swap out X11 error handling mutex for a RefCell 2022-03-07 18:53:07 +01:00
Robbert van der Helm 0aae938af0 Remove unnecessary unsafe blocks 2022-03-07 18:41:29 +01:00
Robbert van der Helm ef86e56ac7 Keep the first X11 error 2022-03-07 18:17:50 +01:00
Robbert van der Helm aa1ad823ce Use a thread local variable for the X11 error
So in the situation that multiple X11 clients are handling errors from
different threads they don't see and interfere with each other's errors.

As mentioned in
https://github.com/glowcoil/raw-gl-context/pull/15#pullrequestreview-891405163.
2022-03-07 18:13:47 +01:00
Robbert van der Helm ba442a4382 Fix overlapping cell borrows in Windows impl
b4a3d2bb04 missed some immutable borrows,
but these borrows need to be local anyways because of the way the
closing is implemented.
2022-02-10 03:14:01 +01:00
Robbert van der Helm 43860aba84 Fix a whackton of warnings and clippy lints
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.
2022-02-07 23:10:53 +01:00
Robbert van der Helm d83517565b Implement the OpenGL context on macOS 2022-02-07 22:43:38 +01:00
Robbert van der Helm fe107ab378 Implement the OpenGL context on Windows 2022-02-07 22:36:37 +01:00
Robbert van der Helm 2f7f177be8 Move RawWindowHandleWrapper to a shared module
We're going to need this for the other platforms as well.
2022-02-07 21:51:54 +01:00
Robbert van der Helm 3551d5e253 Implement OpenGL contexts for X11
This should in theory work! When requesting an OpenGL context, the
window visual is determined based on the matched framebuffer config.
2022-02-07 20:23:13 +01:00
Robbert van der Helm b4a3d2bb04 Add stubs for creating OpenGL contexts
There are now three todo!()s when compiling with the OpenGL flag that
need to be filled in, with the only nontrivial one being the X11
version.
2022-02-07 19:00:48 +01:00
Robbert van der Helm 80802dfbe9 Make opengl context creation private for now 2022-02-07 18:05:32 +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 45e29b4891 Add the entire tree from raw-gl-handle
Including @prokopyl's PR that adds more X11 error handling:
https://github.com/glowcoil/raw-gl-context/pull/15

Commit: prokopyl@raw-gl-context@98cd3cf1104ee254a67e3fed30e4e6b2ae2b6821 (with `cargo fmt`)
Branch base: RustAudio/baseview@b68a05b4dc
2022-02-07 17:21:27 +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
Robbert van der Helm 625fde7957 Create X11 windows with a depth of 32-bits
This should fix the inability to create OpenGL contexts with alpha
channels in raw-gl-context, but it seems like that still needs a bit
more work.
2022-02-07 13:20:46 +01:00
Adrien Prokopowicz 89c051cccc
Add error checking on X11 window creation, and fix parented X11 window creation (#113) 2022-02-06 17:55:12 -06:00
Ingo Budde 912628030e Add scrollwheel support for macos 2022-01-17 20:23:36 +01:00
Joakim Frostegård 004065e9a4
macOS: clear ivar earlier to prevent double free in release (#108) 2021-12-07 18:39:54 -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
Pedro Tacla Yamada 2a894c6bc9
Run cargo fmt on source files (#106)
* Run cargo fmt on source files

* Update with rustfmt.toml

* Change rustfmt configuration and run it again
2021-11-10 00:57:54 -06:00
glowcoil 9fbfe18f9a
NSView lifetime fixes (#104)
* 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.
2021-11-07 16:57:12 -06:00
DGriffin91 6bfcfbb74d add scrollwheel support for windows 2021-10-09 16:52:56 -07:00
Billy Messenger ae2f28c5fd add window resizing and dpi scaling support in Windows 2021-07-14 19:32:28 -05:00
Billy Messenger f7873f1854 typo 2021-07-14 11:45:06 -05:00
Billy Messenger d316c6ae54 send initial window resized event in x11 2021-07-14 11:44:00 -05:00
anunge d399c12755
using viewDidChangeBackingProperties callback to detect scale factor … (#95)
* using viewDidChangeBackingProperties callback to detect scale factor changes and propagate via WindowEvent::Resized

* null check on ns_window

* changed match with if
2021-03-29 13:39:53 -05:00
Weird Constructor 50c41755fd
Fix: Check for remaining events in the internal X11/xcb buffers (#86)
* Fix: Check for remaining events in the internal X11/xcb buffers before going to sleep.

* Also need to set the queue owner to xcb as wrl suggested.
2021-03-04 11:00:42 -06:00
Joakim Frostegård 5ad2d2bfb2 Derive Clone, Copy, PartialEq for EventStatus and WindowScalePolicy 2021-02-10 17:01:49 +01:00
Joakim Frostegård 72b6a4a2d1
Support passing back some events to the platform (#90)
* 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
2021-02-09 14:47:31 -06:00
micah ef27adeda1 add window argument to WindowHandler::on_frame() 2021-01-27 02:13:08 -05:00
micah 36e4474c8a separate Window::open() into three functions (parented, as_if_parented, and blocking) 2021-01-01 22:52:59 -06:00
micah 86bf222601 PhantomData<*mut ()> in Window to ensure it is !Send 2021-01-01 22:52:59 -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 868bd0583c cleanup on window destroyed (free WindowHandler, unregister wndclass) 2020-12-23 16:26:17 -06:00
Micah Johnston d138cfaccf treat WM_MOUSEMOVE coordinates as i16 to handle negative coordinates properly 2020-12-20 15:36:03 -06:00
George Atkinson cc6ead3669 Fixed a bug causing 'already borrowed' error
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.
2020-12-20 15:26:41 -06:00
George Atkinson 9fdb75155d
Added mouse capture/release to windows backend (#81)
* 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
2020-12-19 17:41:40 -06:00
Micah Johnston c64b2257f5 use W variants of winapi functions 2020-12-19 15:33:29 -06:00
micah 043fe41d05 don't call on_frame on expose events in x11 backend 2020-12-19 15:43:53 -05:00
Micah Johnston e02854452e remove WindowHandle 2020-12-12 17:15:09 -06:00
Micah Johnston 0633874266 pass WindowHandler as trait object in x11 backend 2020-12-12 17:12:24 -06:00
Micah Johnston e9507f8d86 store WindowHandler as trait object in cocoa backend 2020-12-12 17:12:24 -06:00
Micah Johnston 4e70af1162 store WindowHandler as trait object to reduce generics in winapi backend 2020-12-12 17:12:24 -06:00
Micah Johnston 8402310c88 remove Message api 2020-12-12 17:06:50 -06:00
Micah Johnston cd0d5215d0 remove unused code from windows backend 2020-12-12 17:06:50 -06:00
Micah Johnston 7ff31ea6f7 ensure title lives long enough to pass it to CreateWindowEx; also validate it as a CString 2020-12-08 23:16:34 -06:00
Micah Johnston 30c34db12e set default arrow cursor on window class rather than null 2020-12-07 01:16:08 -06:00
Micah Johnston 2faea075b1 call on_frame on WM_TIMER events 2020-12-07 01:03:55 -06:00
Micah Johnston 365cc8c018 allow DefWindowProc to be called in the case of WM_PAINT 2020-12-07 01:03:55 -06:00
Micah Johnston ab0cb10a22 call DefWindowProc in the case of WM_SYSKEYDOWN. makes alt-f4 work.
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.
2020-12-07 01:03:41 -06:00
micah 08e56bd5ae remove unnecessary dependencies (log, libc) 2020-12-05 18:01:33 -06:00