1
0
Fork 0
Commit graph

275 commits

Author SHA1 Message Date
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
George Atkinson a8010016fb
Bump dependencies (#100) 2022-02-06 17:58:11 -06: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
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
william light 6172090be3
Merge pull request #102 from DGriffin91/master
add scrollwheel support for windows
2021-10-10 02:11:07 +02:00
DGriffin91 6bfcfbb74d add scrollwheel support for windows 2021-10-09 16:52:56 -07:00
william light e7a6c661ef
Merge pull request #97 from BillyDM/master
send initial window resized event in x11
2021-07-16 12:36:40 +02:00
william light de8316c5fc
Merge pull request #98 from greatest-ape/better-ci
Build examples too in CI
2021-07-16 12:36:03 +02:00
Joakim Frostegård 5eb17ed0fd Build examples too in CI 2021-07-16 01:10:29 +02: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
william light 68a5c4a19f
Merge pull request #92 from greatest-ape/derives
Derive Clone, Copy, PartialEq for EventStatus and WindowScalePolicy
2021-02-10 17:48:07 +01: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
william light 663f9d5d4c
Merge pull request #88 from glowcoil/on_frame_window
add window argument to WindowHandler::on_frame()
2021-01-27 16:56:03 +01: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
Micah Johnston b76d416d7a update readme feature table 2020-12-19 17:48:14 -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
william light db1725a33b
Merge pull request #67 from greatest-ape/macos-flags-changed
macOS: handle changed flags
2020-12-05 02:01:23 +01: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
william light a13b3af3d1
Merge pull request #66 from greatest-ape/macos-dpi
macOS: always use scale=1.0 with WindowScalePolicy::SystemScaleFactor
2020-12-04 23:43:52 +01:00
Joakim Frostegård edbc26aa4a macOS: always use scale=1.0 with WindowScalePolicy::SystemScaleFactor 2020-12-04 23:38:17 +01:00
william light 67cdd7bdfc
Merge pull request #65 from BillyDM/master
implement try_send_message for Linux
2020-12-04 22:41:57 +01:00
Billy Messenger f696c7d14d implement try_send_message for Linux 2020-12-04 15:29:55 -06:00