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
Joakim Frostegård
19b6a2f701
macOS: handle changed flags
...
This enables catching pressed modifier keys with no other
keys pressed
2020-12-05 01:48:26 +01:00
Joakim Frostegård
edbc26aa4a
macOS: always use scale=1.0 with WindowScalePolicy::SystemScaleFactor
2020-12-04 23:38:17 +01:00
Billy Messenger
f696c7d14d
implement try_send_message for Linux
2020-12-04 15:29:55 -06:00
Joakim Frostegård
1aebdfb331
Move MESSAGE_QUEUE_LEN const from macOS module to crate root
2020-12-04 21:46:55 +01:00
Joakim Frostegård
dd1955285e
macOS: clean up
2020-12-04 20:03:55 +01:00
Joakim Frostegård
2273a2c07c
macOS: add and use MESSAGE_QUEUE_LEN constant
2020-12-04 20:03:55 +01:00
Joakim Frostegård
35a03aff17
Split off AppRunner from WindowHandle on Windows and Linux
2020-12-04 20:03:55 +01:00
Joakim Frostegård
c1d04b978e
Clean up
2020-12-04 20:03:55 +01:00
Joakim Frostegård
60244c3888
Add comment to WindowState static assertions code
2020-12-04 20:03:55 +01: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
99fdbff4e2
macOS: remove runtime timer, use frame timer instead
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
b79a7fbcf5
Add Send constraint to WindowHandler::Message
2020-12-04 20:03:55 +01:00
Joakim Frostegård
35a9841b29
Add WindowHandle::try_send_message, implement it on macOS
2020-12-04 20:03:55 +01:00
glowcoil
6f81e28d90
Merge pull request #63 from glowcoil/remove-x11-prints
...
remove print on unhandled event (produces too much spam)
2020-12-03 23:08:06 -06:00
Micah Johnston
0cbcf989df
remove print on unhandled event (produces too much spam)
2020-12-03 23:05:51 -06:00
Micah Johnston
3f34a70fa8
windows mouse events
2020-11-30 10:10:40 -06:00
glowcoil
3db2bdee17
Merge pull request #57 from greatest-ape/windows-keyboard
...
Add windows keyboard event support with druid code
2020-11-28 18:23:02 -06:00
Joakim Frostegård
dd87afefd9
api unification: impl HasRawWindowHandle on wrapper Window
2020-11-27 00:34:09 +01:00
Joakim Frostegård
1ddd6fa47e
api unification: return shared WindowHandle in platform code
2020-11-24 20:41:55 +01:00
Joakim Frostegård
a8c7c707d2
unify platforms: simplify imports
2020-11-23 22:26:27 +01:00
Joakim Frostegård
6450bff368
api unification: add Linux support
2020-11-23 22:24:25 +01:00
Joakim Frostegård
185bd62447
api unification: make cross-platform Window hold a reference
2020-11-23 22:09:33 +01:00
Joakim Frostegård
f9226c366e
platform api unification: support Windows
2020-11-23 20:26:17 +01:00
Joakim Frostegård
4ba64d8f86
Add cross-platform Window wrapper, currently only macOS support
2020-11-23 20:05:36 +01:00
Joakim Frostegård
ff09c3a256
macOS: add timer triggering WindowHandler::on_frame ( #58 )
...
* macOS: add simple NSTimer that triggers WindowHandler::on_frame
* macOS: invalidate frame timer when releasing view
* macOS: clean up
2020-11-23 14:38:32 +01:00
Joakim Frostegård
bdd0f8f562
Add windows keyboard event support with code from druid
2020-11-23 08:43:09 +01:00
Joakim Frostegård
0a6a0bdffd
Use keyboard_types::KeyboardEvent directly instead of wrapping it
2020-11-14 17:46:12 +01:00
Joakim Frostegård
546b0d6eae
Use keyboard-types types directly instead of druid wrappers
2020-11-14 17:46:12 +01:00
Joakim Frostegård
86b2aff624
Attempt to fix linux build
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
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
Billy Messenger
7904ed77e1
reword comment
2020-10-20 19:18:42 -05:00
Billy Messenger
b2146908cc
add comments to size
2020-10-20 19:17:20 -05:00
Billy Messenger
2096c37495
rename UseScaleFactor to ScaleFactor
2020-10-20 19:11:47 -05:00
Billy Messenger
42e8ea6bef
fix mac build
2020-10-20 19:05:49 -05:00
Billy Messenger
579dfee1eb
clean up dpi features
2020-10-20 19:02:45 -05:00
Billy Messenger
b0196b8c5f
attempt to fix mac build
2020-10-20 17:09:59 -05:00
Billy Messenger
84cac3e7ba
attempt to fix mac build
2020-10-20 17:07:37 -05:00
Billy Messenger
2ee975231b
fix Windows build
2020-10-20 17:04:37 -05:00
Billy Messenger
3fe752ca80
remove min/max resize policy
2020-10-20 16:06:40 -05:00
Billy Messenger
61ef63409b
Merge branch 'master' of https://github.com/RustAudio/baseview into master
2020-10-20 15:56:54 -05:00
Billy Messenger
ad12985d08
put WindowHandle back into platform-specific code
2020-10-20 15:52:09 -05:00
William Light
cf96f3cc85
win/mac: closure for building WindowHandler
2020-10-20 21:33:57 +02:00
William Light
43cdc39335
x11: closure for building WindowHandler
2020-10-20 21:33:52 +02:00
Billy Messenger
a91a5a1126
update x11 code
2020-10-17 17:36:28 -05:00
Billy Messenger
688d45c720
refactor to use conversion between Point and Size to PhyPoint and PhySize
2020-10-17 17:27:06 -05:00
Billy Messenger
6bae3e7507
Fix window_state pointer
2020-10-17 16:47:36 -05:00
Billy Messenger
5866bf372e
fix window_info_from_scale
2020-10-17 15:42:16 -05:00
Billy Messenger
3fca9d3c78
remove #[repr(C)] as it did not work
2020-10-17 15:23:24 -05:00
Billy Messenger
11ee384908
fix windows build
2020-10-17 15:19:06 -05:00
Billy Messenger
dc5d3b9622
Add Point and Size structs
2020-10-17 14:01:03 -05:00
Billy Messenger
1b9fbf9bb8
refactor and modify events
2020-10-17 13:35:39 -05:00
Billy Messenger
a4c226277c
change size hints to physical size
2020-10-15 16:38:09 -05:00
Billy Messenger
aee594d23c
add window resize hints
2020-10-15 16:31:38 -05:00
Billy Messenger
0758e4834b
fix spacing in use statement
2020-10-15 13:28:21 -05:00
Billy Messenger
61de5e37f7
rename width, height to logical_width, logical_height
2020-10-15 13:26:21 -05:00
Billy Messenger
ed1db27f52
revert WindowEvent traits
2020-10-15 13:24:08 -05:00
Billy Messenger
2bf229575f
add UI scaling support
2020-10-15 13:17:03 -05:00
William Light
d5c3ba0bb0
x11/window: take render time into account when computing next frame time
2020-09-15 22:36:42 +02:00
William Light
c26507c322
x11: fix potential missed resize events
2020-09-14 06:21:25 +02:00
William Light
a59ccae56f
x11: suppress non-resize configure notify events
2020-09-14 03:30:30 +02:00
William Light
23a43c4cdd
x11: refactor cursor logic
2020-09-14 02:47:58 +02:00
Billy Messenger
d156d42e69
refactor x11 cursor changing code into x11/cursor.rs
2020-09-13 19:01:18 -05:00
Billy Messenger
53debfc706
remove unused Mutex import
2020-09-13 18:39:13 -05:00
Billy Messenger
d84a1fde44
Add set_mouse_cursor method to X11 Window
2020-09-13 18:23:51 -05:00
Billy Messenger
c24d12c453
Merge branch 'master' of https://github.com/RustAudio/baseview into master
2020-09-13 09:19:11 -05:00
Billy Messenger
adc8fe0974
Add mouse cursor to Window
2020-09-13 09:19:05 -05:00
William Light
9cad2d1b5a
x11: coalesce CONFIGURE_NOTIFY events
2020-09-12 19:31:13 +02:00
William Light
ac0e1215f7
fix syntax error
2020-09-12 19:16:45 +02:00
William Light
29461b14e4
replace *mut c_void with RawWindowHandle in Parent::WithParent
2020-09-12 19:06:21 +02:00
William Light
47b122c86e
remove duplicate imports
2020-09-11 22:36:33 +02:00
William Light
bb18518cf6
fix some rustfmt annoyances
2020-09-11 22:29:29 +02:00
Billy Messenger
3e4c1edfc7
Add method to window so user can get window info
2020-09-11 14:52:32 -05:00
Billy Messenger
9bf1fa08bb
cargo fmt
2020-09-11 12:42:14 -05:00
Billy Messenger
0ddc2c5f3f
Merge branch 'master' of https://github.com/RustAudio/baseview into master
2020-09-11 12:41:53 -05:00
Billy Messenger
cc2ae0ef39
rebase, cargo fmt
2020-09-11 12:38:06 -05:00
William Light
76e5851b62
x11: don't return from Window::open() until the window is actually open
2020-09-11 19:37:46 +02:00
Billy Messenger
08564cc317
Merge branch 'master' of https://github.com/RustAudio/baseview into master
2020-09-11 12:35:51 -05:00
Billy Messenger
7bdff33847
Detect window resize in x11
2020-09-11 12:32:55 -05:00
William Light
4d9c6c3131
remove FileDropEvent
...
we have no implementations for it, so it's just dead code for now.
2020-09-11 19:10:49 +02:00
William Light
409b03cfdb
macOS: fix build
2020-09-11 18:53:33 +02:00
William Light
bc79e42314
macOS: WindowHandle.app_run_blocking()
2020-09-11 18:53:33 +02:00
William Light
888e3bdf0c
windows: nitpicky code aesthetics
2020-09-11 18:53:33 +02:00
William Light
17a7477400
windows: WindowHandle.app_run_blocking()
2020-09-11 18:53:33 +02:00
William Light
196883b390
x11: WindowHandle.app_run_blocking()
2020-09-11 18:53:33 +02:00
William Light
5207d961d9
x11: run window in a separate thread
...
there's a thread.join() to mimic the previous semantics (which are the
same as on the other platforms).
2020-09-11 18:53:33 +02:00
Billy Messenger
e67887d92f
Remove Interval event
2020-09-11 11:49:56 -05:00
Billy Messenger
52580cc2a9
rebase
2020-09-11 11:43:46 -05:00
Billy Messenger
ddbc95a2ed
Merge branch 'master' of https://github.com/RustAudio/baseview into master
2020-09-11 11:39:20 -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
Billy Messenger
9efade9a18
Fix Windows build
2020-09-11 10:44:05 -05:00
Billy Messenger
83f2ffd27a
Rename scale_factor to scale
2020-09-11 10:23:19 -05:00
Billy Messenger
b8bc006fc1
Add and refactor events
2020-09-11 10:21:05 -05:00
William Light
072918cb3f
rename WindowHandler.draw() to WindowHandler.on_frame()
...
also remove the `Window` ref argument because `on_frame()` shouldn't be
doing any window system ops (this is my opinion and i am happy to
backpedal if it turns out to be wrong).
2020-09-11 16:54:13 +02:00
William Light
b650bf772f
x11: frame/draw callbacks
...
currently fixed at 15ms (just above 60fps), but easily configurable and
something we can query the display server for in the future.
2020-09-11 16:32:21 +02:00
William Light
dcb99e5c43
x11: switch from wait_for_event() to directly using poll()
2020-09-11 16:13:32 +02:00
William Light
c76f089c96
x11/window: nitpicky code aesthetics
2020-09-11 15:50:10 +02:00
William Light
b5dfbd946e
x11: pass XCB conn error back through XcbConnection::new()
2020-09-11 15:47:00 +02:00
William Light
da2c12dd25
x11: move scaling determination funcs into xcb_connection.rs
2020-09-11 15:44:01 +02:00
William Light
54f8bc7345
x11: split event loop and XCB event handling into separate fns
2020-09-11 15:40:19 +02:00
Micah Johnston
5ecce5d28d
Window::open() returns WindowHandle struct
2020-09-08 18:45:29 -05:00
Micah Johnston
601a5d62a4
remove mspc channel (to be replaced by baseview-specific WindowHandle
2020-09-08 18:45:29 -05:00
Micah Johnston
c51aea5c12
rename AppWindow -> WindowHandler
2020-09-08 18:45:29 -05:00
micah
057324e688
adapt x11 backend to new api
2020-09-07 21:33:03 -04:00
Micah Johnston
bb6a5eeeac
adapt macos backend to new api
2020-09-07 21:33:03 -04:00
Micah Johnston
e78598954f
adapt windows backend to new api
2020-09-07 21:33:03 -04:00
Micah Johnston
58ed00eb11
api change: AppWindow methods receive an &mut Window, which implements HasRawWindowHandle
2020-09-07 21:33:03 -04:00
Micah Johnston
08c9aec50c
switch from Arc<Mutex<>> to Rc<RefCell<>> since the wndproc is only called on one thread
2020-09-07 02:16:45 -05:00
Micah Johnston
aafd54b76c
get Window as pointer instead of using Arc::from_raw()
2020-09-07 02:12:06 -05:00
Micah Johnston
89bd912a73
call DispatchMessage in event loop and combine handle_message with wnd_proc
2020-09-07 01:17:14 -05:00
Micah Johnston
4464e6ec1f
get macos building
2020-09-06 11:18:46 -05:00
Micah Johnston
0da82a4bdd
pass Arc<Window> by reference instead of cloning
2020-09-05 21:37:35 -05:00
Micah Johnston
10d3870644
clean up some warnings and cargo fmt
2020-09-05 21:19:37 -05:00
Micah Johnston
9d39ba9117
don't need to reset userdata, just leak the Arc with into_raw so it stays alive
2020-09-05 21:15:17 -05:00
Micah Johnston
6e7038d26e
remove gl context creation code from windows
2020-09-05 21:15:15 -05:00
Micah Johnston
6a7bea1fa4
get windows building again
2020-09-05 20:12:05 -05:00
Billy Messenger
147037e639
Change unwrap() to unwrap_or(1.0)
2020-09-05 17:33:41 -05:00
Billy Messenger
08390d6004
Change AppWindow::create_context() to AppWindow::build()
2020-09-05 17:29:36 -05:00
Billy Messenger
93dfe909a8
fix minor nitpicks
2020-09-05 17:08:20 -05:00
Billy Messenger
dcfc988047
Change raw_handle to use an Xlib handle instead of an Xcb handle
2020-09-05 16:29:47 -05:00
Billy Messenger
c7d9d7d107
Add small wrapper for RawWindowHandle
2020-09-05 15:22:23 -05:00
Billy Messenger
f3ba681877
Replace dpi with scale
2020-09-05 14:55:45 -05:00
Billy Messenger
15b0c2e857
Replace RenderExpose event with draw method
2020-09-05 14:41:26 -05:00
Billy Messenger
6cf5966afa
Rename Application tratit to AppWindow
2020-09-05 11:19:09 -05:00