Commit graph

223 commits

Author SHA1 Message Date
Daniel Collin 1b58e0e7cc Call XInitThreads on X11
This allows using minifb on multiple threads under x11

Closes #309
2023-02-18 13:07:35 +01:00
Daniel Collin b48e531e8d Fix for not being able to use F10 key
Closes #310
2023-02-18 12:56:43 +01:00
Heiko Behrens f92e38a181
fix compilation of minifb's X11 binding for 32-bit (#308) 2023-01-29 09:36:26 +01:00
nils måsén c042d26ffd
fix: set byposition flag when removing menus (#304) 2022-12-27 10:53:41 +01:00
smb123w64gb ad331de5c2
ARM and AARCH64 Windows Support (#300)
* ARM and AARCH64 Windows Support
2022-10-11 19:12:00 +02:00
Andreas Neukoetter 193726cd6d
Fix get_window_position for multiscreen setups on macOS. (#299) 2022-07-26 19:00:56 +02:00
Edgar Onghena 3da7b7b22e
Fix X11 window names not supporting UTF-8 (#295) 2022-05-06 15:16:42 +02:00
Mara Huldra e96380375c
Reduce wayland dependencies (#293)
This change removes dependency on the `xkb` and `xkbcommon-sys` crates
(and this indirectly, `bindgen` and everything below it) by using our
own ffi wrapper, based on sctk's.

A new feature `dlopen`, enabled by default, is added that causes
xkbcommon to be loaded at runtime instead of linked at build-time.
2022-04-19 09:47:39 +02:00
Matt Thompson 7019ba41ea
Use coercion on types failing compilation on 64 bit raspbian bullseye (#292)
Awesome! Thanks

Closes #291
2022-04-16 18:27:35 +02:00
Mara Huldra a4f7958fab
wayland: Fix key character callback (#290)
- Make the character callback use the key converted through the keymap,
  instead of trying to perform a direct conversion.

- Store a persistent keymap_state, instead of creating a new one every
  time. This makes sure that modifiers such as shift/capslock/ctrl are
  taken into account.

Closes #288.
2022-04-16 06:47:25 +02:00
Emilio Moretti f42f516339
Wasm websys wip (#239)
* WIP on wasm support

Fix canvas not showing by actually placing it in the document
Also set the initial title
Use the js! macro to draw pixels
Draw to the canvas using ImageData
It doesn't work because an animation frame needs to be requested somehow

* Complete WASM work into a usable state.

This works on the previous commits and makes it usable.
There is a multi platform example about how to use it here:
https://github.com/dc740/minifb-async-examples

Co-authored-by: Thomas Versteeg <thomasversteeg@gmx.com>
2022-04-02 17:00:48 +02:00
Daniel Collin 80e8d4885a Updated docs for updates 2022-03-27 10:08:10 +02:00
Daniel Collin 48a41a9f6e Updated docs for update calles 2022-03-27 09:55:46 +02:00
Daniel Collin abbe3db980 Use XkbSetDetectableAutoRepeat on x11
Fixes #284
2022-03-26 20:45:00 +01:00
Daniel Collin 9dcbac0285 Rustfmt 2022-03-14 16:05:25 +01:00
Daniel Collin ad9648769d Fixed button hold on window exit
On Windows when moving the cursor out of the window while holding a
mouse button down it would still be set to
true when entering the window
even if the button had been released
outside of the window.

Closes #280
2022-03-14 15:28:55 +01:00
abonnaudet-ledger bedec9b59d
Fix typo in lib.rs (#279) 2022-03-03 11:01:23 +01:00
Greg Depoire--Ferrer 344a1997c7
Memory-map the keymap FD on Wayland to fix EOF error (#278)
wlroots based compositors reuse the same FD for keymap, so after a first
read is done, the file is seeked to the end and the next read fails,
causing the following error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err`
value: Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }'

The Wayland documentation says the FD "can be memory-mapped to provide
a keyboard mapping description" and then "From version 7 onwards, the
fd must be mapped with MAP_PRIVATE by the recipient, as MAP_SHARED may
fail."

Although it is not very clear, it probably means that the FD must be
memory-mapped.
2022-02-18 14:35:00 +01:00
Rémi Lauzier 4962afd3f5
small fixes and update (#277) 2022-02-18 09:32:00 +01:00
Andreas Neukoetter 032d616bbe
Add getter for window position. (#276)
* + Add getter for window position (macos, windows).

+ Add getter STUB for window position (posix x11/wayland).

* Implement getter for window position (posix x11).

* Remove todo from getter for window position and return 0,0 (posix wayland).
2022-02-03 10:01:00 +01:00
Kevin K c25b5d114a
Fix clippy lints under windows (#275) 2022-02-01 22:44:32 +01:00
Kevin K 9a435460b0
Add set_icon() method to set a window icon at runtime (#274)
* Add set_icon() for Windows

* Start x11 icon method

* Add set_icon() for X11

* Add unimplemented message

* Add Icon class for abstraction

* Adjust example in docs

* Remove CStrings from X11 because of heap allocations

* Fix rustfmt

* Revert accidental changes to image.rs

* Fix doc error
2022-01-30 18:29:12 +01:00
Sean Cross 8b9445eea4
key_handler: add a callback for key events (#243)
* key_handler: add a callback for key events

Add a callback for key events. This includes complete events such as
Shift, not just text events.

A default handler is provided for backwards compatibility.

Signed-off-by: Sean Cross <sean@xobs.io>

* fix: EventQueue::dispatch blocks until some events are available (#265)

use non blocking alternative as documented in EventQueue

Co-authored-by: vemoo <berublan@gmail.com>
2022-01-26 08:23:38 +01:00
KaDiWa 8927b29a69
macOS: Fix segmentation fault when resizing window (#269) 2021-12-12 23:06:17 +01:00
vemoo 49aad5c586
Revert bump of xkbcommon-sys (#268)
`xkb` still depends on the previous version
and there are some issues in the new version
https://github.com/meh/rust-xkbcommon-sys/issues/7
2021-12-07 07:24:30 +01:00
vemoo 0f7d175621
address clippy lints (#267) 2021-12-06 16:34:01 +01:00
vemoo a4ba00b209
Bump versions (#266)
* bump wayland deps

* bump xkbcommon-sys

* bump raw-window-handle

* bump png
2021-12-06 14:17:01 +01:00
vemoo e0992261c9
fix: EventQueue::dispatch blocks until some events are available (#265)
use non blocking alternative as documented in EventQueue
2021-12-06 12:11:50 +01:00
Daniel Collin 64f2afde3d Fixed typo 2021-11-28 18:08:38 +01:00
Daniel Collin 883679e96b Fix for stuck scrollwheel on macOS 2021-11-28 18:03:01 +01:00
john01dav 2b2540067c
Support typed keys on x11
* Added not-yet-working draft implementation of proper X11 support for reading correct typed characters

* Made shift work for capital letters with X11, but compose key is still broken

* Compose key and numpad now work correctly in X11

* XIM and XIC are now freed when a window destructor runs

* Ran cargo fmt on x11.rs

* Removed commented-out empty-string

Closes #200
2021-11-15 08:45:44 +01:00
Elijah Hartvigsen deb235507f
Changing return types of get_keys from Option<Vec<Key>> to Vec<Key> (#260)
* KeyHandler: Updated return type to Vec on get_keys

* Window: Updated Window structs get_keys return type across all currently supported OS's

* Updated return type of get_keys of Window, and updated the docs for all related functions

* Docs: Corrected incorrect variable ident in docs post update

* Resolved error resulting from get_keys return type change

* Formatting: Ran cargo fmt

Co-authored-by: Zij-IT <elijah.reed@hartvigsen.xyz>
2021-10-23 11:39:18 +02:00
Thomas L. Martin 67fe3a6f29
Minor update to error.rs (#258)
to fix copy/paste issue
2021-09-13 10:04:28 +02:00
swismer 75a25ce898
Fix size calculation of non-decorated windows (#245) (#246) 2021-04-03 08:08:51 +02:00
Quentin Hibon afa0b2ffe5
Add missing words in description (#242) 2021-03-11 06:56:14 +01:00
Emilio Moretti 241c01219f
Fix wayland missing cursor. (#238)
This fixes the problem with the window automatically closing itself when
the mouse goes over it.
2021-02-21 07:57:29 +01:00
Sean Cross e5b5cc50d5
windows: use c_void from winapi (#235)
The `SelectObject()` call accepts a `HGDIOBJ` which is typecast to a
`std::os::raw::c_void` when building using libstd, and is its own thing
when building with std disabled:

winapi/0.3.9/src/winapi/lib.rs.html:
    #[cfg(feature = "std")]
    pub use std::os::raw::c_void;
    #[cfg(not(feature = "std"))]
    pub enum c_void {}

This patch uses `HGDIOBJ` as the typecast as necessary.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-02-10 09:04:47 +01:00
Daniel Jordan ae5172b8a1
Update xkb_keymap reference (#233)
The xkbcommon_sys crate seems to have been updated today, and now the minifb project won't compile. 

We can fix this by updating XKB_KEYMAP_FORMAT_TEXT_v1 to XKB_KEYMAP_FORMAT_TEXT_V1.
2021-01-09 21:12:23 +01:00
CoffmanLevi b39df21ba8
Made the debug text for Error include any sub-errors (#232) 2020-12-30 08:27:32 +01:00
sinclairzx81 ffa4a55487
Fix: winuser | DestroyWindow (#230)
* winuser | DestroyWindow

* rustfmt pass
2020-12-09 13:18:04 +01:00
Max von Forell c1ff776260
change default pointer visibility to true on wayland (#225) 2020-11-12 11:52:24 +01:00
Santeri Salmijärvi 5e29a18ff4
Windows: Fix mouse positions not honoring MouseMode (#223) 2020-11-05 18:44:41 +01:00
Ondřej Hruška a3852bab8a
Fix Key::RightBracket not working on POSIX (#222)
There was a typo in the mappings, right bracket didn't work.
2020-10-24 06:58:37 +02:00
Rupansh efbe6a1c71
WindowOptions: Support none flag (#219)
* WindowOptions: add none flag

* windows: support none flag

Signed-off-by: rupansh <rupanshsekar@hotmail.com>

* os: implement none flags for other operating systems

redox, posix
not applicable on OSX

* WindowOptions: document none option

Signed-off-by: rupansh-arch <rupanshsekar@hotmail.com>
2020-10-01 13:06:48 +02:00
Daniel Collin ee3b185098 Removed dummy logging 2020-09-22 20:59:07 +02:00
derpeter 65e5be1dcf
change pointer type to plattform specific type as the cast is otherwi… (#212)
* change pointer type to plattform specific type as the cast is otherwise broken on ARM (and maybe other) platform.

* shrink the line changed in previous commit to make linter happy

Co-authored-by: Peter Hasse <peter.hasse@fokus.fraunhofer.de>
2020-09-03 18:16:07 +02:00
phillvancejr 15bce84a4e
Added Topmost (always on top) functionality to Windows (#159)
* Added always on top functionality for Windows

* Added always on top functionality for Windows

* Made topmost method in Window public so that the topmost attribute can be defined either at or after creation time as opposed to just at creation time. This allows the topmost functionality to be toggled during the programs runtime as opposed to only at window creation
2020-08-28 21:14:49 +02:00
Evgeniy Reizner 8efa8064c7
Remove the 'cast' dependency. (#208) 2020-08-23 14:22:49 +02:00
Daniel Collin f99ee45552 Test fix for get_keys_released on Wayland 2020-08-13 20:15:16 +02:00
Nelson Chen 291d8a0441
Support topmost functionality in Windows (#201)
Most of this was taken from #159. This does not include the API addition of adding a topmost call on Window.

That should probably be in another PR. And the doc fixes as well.

Used implementation from https://github.com/emoon/rust_minifb/pull/159#discussion_r401374050

Co-authored-by: phillvancejr <phillipvancejr@gmail.com>
Co-authored-by: Daniel Collin <daniel@collin.com>

Co-authored-by: phillvancejr <phillipvancejr@gmail.com>
Co-authored-by: Daniel Collin <daniel@collin.com>
2020-07-27 09:27:13 +02:00