winit-sonoma-fix/src/platform/unix.rs

546 lines
16 KiB
Rust
Raw Normal View History

Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
#![cfg(any(
target_os = "linux",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
))]
use std::os::raw;
#[cfg(feature = "x11")]
use std::{ptr, sync::Arc};
2018-06-15 09:42:18 +10:00
use crate::{
event_loop::{EventLoop, EventLoopWindowTarget},
monitor::MonitorHandle,
window::{Window, WindowBuilder},
};
#[cfg(feature = "x11")]
use crate::dpi::Size;
#[cfg(feature = "x11")]
use crate::platform_impl::x11::{ffi::XVisualInfo, XConnection};
use crate::platform_impl::{
EventLoop as LinuxEventLoop, EventLoopWindowTarget as LinuxEventLoopWindowTarget,
Window as LinuxWindow,
2018-06-15 09:42:18 +10:00
};
// TODO: stupid hack so that glutin can do its work
#[doc(hidden)]
#[cfg(feature = "x11")]
pub use crate::platform_impl::x11;
#[cfg(feature = "x11")]
pub use crate::platform_impl::{x11::util::WindowType as XWindowType, XNotSupported};
2017-03-15 20:11:43 +11:00
/// Additional methods on `EventLoopWindowTarget` that are specific to Unix.
pub trait EventLoopWindowTargetExtUnix {
/// True if the `EventLoopWindowTarget` uses Wayland.
#[cfg(feature = "wayland")]
fn is_wayland(&self) -> bool;
/// True if the `EventLoopWindowTarget` uses X11.
#[cfg(feature = "x11")]
fn is_x11(&self) -> bool;
#[doc(hidden)]
#[cfg(feature = "x11")]
fn xlib_xconnection(&self) -> Option<Arc<XConnection>>;
/// Returns a pointer to the `wl_display` object of wayland that is used by this
/// `EventLoopWindowTarget`.
///
Squashed commit of the following: (#853) commit fa95f204d3c10ceca70e794870657a0f33349761 Author: Hal Gentz <zegentzy@protonmail.com> Date: Sun Apr 28 00:14:01 2019 -0600 xrender Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit b62cee51c7b22f6f150bfe04f9b28f024e641323 Merge: 3f021ea7 a6551f46 Author: Hal Gentz <zegentzy@protonmail.com> Date: Thu Apr 25 18:13:43 2019 -0600 Merge branch 'macos-gentz' of github.com:ZeGentzy/winit into macos-gentz commit 3f021ea7f7ac6bc2a697a5b6e4e6424e838a2139 Author: Hal Gentz <zegentzy@protonmail.com> Date: Thu Apr 25 18:04:02 2019 -0600 Get rid of warnings. Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit a6551f4607ea0bc26df8716dee8115371ef367db Author: Hal Gentz <zegentzy@protonmail.com> Date: Thu Apr 25 07:40:56 2019 -0600 Fix example Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit cbfda6c57e9740b49d2b496bda43197f611cb48c Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:47:46 2019 -0600 Fixes Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 86bc86f3d3add4a6125aa9b2eca79061c0dfcd91 Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:39:19 2019 -0600 Backport https://github.com/rust-windowing/winit/commit/9a23ec3c373d096e5e9dd0cc0a23f7baf0b64135#diff-1d95fe39cdbaa708c975380a16c314cb Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 742a688efe2f0eeacc2ffbf49b1157c4aaffccbd Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:09:14 2019 -0600 Backports https://github.com/rust-windowing/winit/commit/45a428141329377a1669698e4ca6561834c0dbcc#diff-1d95fe39cdbaa708c975380a16c314cb Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 6c81f2a517d4e2d5ba2ff3eddca030bce972cb2a Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:05:57 2019 -0600 Francesca's macos changes Also backports https://github.com/rust-windowing/winit/commit/bfbcab3a010667e74fa3cc07ac85bd4c85491e65#diff-1d95fe39cdbaa708c975380a16c314cb commit 7c2e1300c26a0634ad505ce72b90eb6dc2fdcac7 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Apr 24 20:58:26 2019 -0600 Squashed commit of the following: commit 5f4aa9f01a719eef98c6d894801c20ee8f96d30f Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 17:14:14 2018 -0500 Protect against reentrancy (messily) commit b75073a5b2a8d65ab8806a00ffee390752255c8c Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 15:15:27 2018 -0500 Send resize events immediately commit 8e9fc01bd6b404f59488b130413f48e4e5f89b0d Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 16:07:43 2018 -0500 Don't use struct for window delegate commit c6853b0c4a8fe357f463604bb879dc1be424860e Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 21:17:48 2018 -0500 Split up util commit 262c46b148413130fa239099f1151c1f1bd5c13c Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 20:55:00 2018 -0500 Use dispatch crate commit 63152c2f475794d1a36a5b3687c777664d7d5613 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 20:29:13 2018 -0500 RedrawRequested commit 27e475c7c78b059fd9b5e8350cd26756eecdfc94 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 19:24:44 2018 -0500 User events commit 157418d7dedace9c571e977d98ea92464c3188b2 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 18 22:38:05 2018 -0500 Moved out cursor loading commit b4925641c973979a38743202b4269efe09ac43b4 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 18 21:32:12 2018 -0500 Fixed a bunch of threading issues commit 4aef63dfb78dfaf38c83cb0e88d4ea9d8d0578a6 Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 17 13:54:59 2018 -0500 Wait works commit 72ed426c695df5dc410902263bd74188059b8ddd Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 20:49:10 2018 -0500 Fixed drag and dropg commit 658209f4a20acd536218f41a01fb8cbbebc705e0 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 20:42:42 2018 -0500 Made mutexes finer for less deadlock risk commit 8e6b9866084690da900c4d058e412cab8ebb30c4 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 16:45:06 2018 -0500 Dump (encapsulate) everything into AppState commit d2dc83df15939d89301e2cff0ffa2d98c48b406f Author: Francesca Plebani <franplebani@gmail.com> Date: Thu Dec 13 17:36:47 2018 -0500 All window events work! commit 7c7fcc98872b3c35bd7767b5c6235a74bc105e06 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 12 17:11:09 2018 -0500 Very rough usage of CFRunLoop commit 3c7a52ff4df683b5b7e1751e4051ec445a818774 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 11 15:45:23 2018 -0500 Fixed deadlocks commit b74c7fe1bcd173e9b0c0e004956c257e805bc2a2 Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 10 18:59:46 2018 -0500 Fix keyDown deadlock commit 3798f9c1a4bef2a3d1552f846b26efc31b1bbb6c Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 10 18:44:40 2018 -0500 It builds! commit 8c8620214357714c5cd0b3beefda6704512e3f64 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 7 21:09:55 2018 -0500 Horribly broken so far commit 8269ed2a9270e5ec5b14f80fd21d1e0e6f51be29 Author: Osspial <osspial@gmail.com> Date: Mon Nov 19 23:51:20 2018 -0500 Fix crash with runner refcell not getting dropped commit 54ce6a21a0722e408ae49c74f5008005fc1e4cbf Author: Osspial <osspial@gmail.com> Date: Sun Nov 18 19:12:45 2018 -0500 Fix buffered events not getting dispatched commit 2c18b804df66f49f93cfe722a679d6c5e01d8cb1 Author: Osspial <osspial@gmail.com> Date: Sun Nov 18 18:51:24 2018 -0500 Fix thread executor not executing closure when called from non-loop thread commit 5a3a5e2293cec3e566c4aac344ae7eaa343608b5 Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 22:43:59 2018 -0500 Fix some deadlocks that could occur when changing window state commit 2a3cefd8c5df1c06127b05651cbdf5e3d9e3a6d3 Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 16:45:17 2018 -0500 Document and implement Debug for EventLoopWindowTarget commit fa46825a289ca0587dc97f9c00dea5516fb4925a Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 16:40:48 2018 -0500 Replace &EventLoop in callback with &EventLoopWindowTarget commit 9f36a7a68e1dc379cf9091213dae2c3586d3e473 Author: Osspial <osspial@gmail.com> Date: Wed Nov 14 21:28:38 2018 -0500 Fix freeze when setting decorations commit d9c3daca9b459e02ef614568fe803a723965fe8d Author: Osspial <osspial@gmail.com> Date: Fri Nov 9 20:41:15 2018 -0500 Fix 1.24.1 build commit 5289d22372046bac403a279c3641737c0cfc46d2 Author: Osspial <osspial@gmail.com> Date: Fri Nov 9 00:00:27 2018 -0500 Remove serde implementations from ControlFlow commit 92ac3d6ac7915923c22c380cc3a74c5f3830708e Author: Osspial <osspial@gmail.com> Date: Thu Nov 8 23:46:41 2018 -0500 Remove crossbeam dependency and make drop events work again commit 8299eb2f03773a34079c61fc8adb51405aafc467 Author: Osspial <osspial@gmail.com> Date: Thu Sep 13 22:39:40 2018 -0400 Fix crash when running in release mode commit bb6ab1bb6e9595e90f1915fdde7e23904f2ba594 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 14:28:16 2018 -0400 Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. commit 5068ff4ee152bfe93c9190235f02d001202feb88 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 14:14:28 2018 -0400 Improve clarity/fix typos in docs commit 8ed575ff4a4f0961bb2e784bda1ae109c6bd37b7 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 00:19:53 2018 -0400 Update send test and errors that broke some examples/APIs commit bf7bfa82ebb5d6ae110ce0492c124ef462945f85 Author: Osspial <osspial@gmail.com> Date: Wed Sep 5 22:36:05 2018 -0400 Fix resize lag when waiting in some situations commit 70722cc4c322e3e599b3a03bce5058a5d433970b Author: Osspial <osspial@gmail.com> Date: Wed Sep 5 19:58:52 2018 -1100 When SendEvent is called during event closure, buffer events commit 53370924b25da15ddd172173150b228065324864 Author: Osspial <osspial@gmail.com> Date: Sun Aug 26 21:55:51 2018 -0400 Improve WaitUntil timer precision commit a654400e730400c2e3584be2f47153043b5b7efe Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 21:06:19 2018 -0400 Add CHANGELOG entry commit deb7d379b7c04e61d6d50ff655eccac0ad692e44 Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:19:56 2018 -0400 Rename MonitorId to MonitorHandle commit 8d8d9b7cd1386c99c40023d86e17d10c3fd6652f Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:16:52 2018 -0400 Change instances of "events_loop" to "event_loop" commit 0f344087630ae252c9c8f453864e684a1a5405b1 Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:13:53 2018 -0400 Improve docs for run and run_return commit fba41f7a7ed8585cbb658b6d0b2f34f75482cb3d Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 19:09:53 2018 -0400 Small changes to examples commit 42e8a0d2cf77af79da082fff7cd29cc8f52d99df Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 19:09:19 2018 -0400 Improve documentation commit 4377680a44ea86dad52954f90bc7d8ad7ed0b4bf Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 23:01:36 2018 -0400 Re-organize into module structure commit f20fac99f6ac57c51603a92d792fd4f665feb7f6 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 22:07:39 2018 -0400 Add platform::desktop module with EventLoopExt::run_return commit dad24d086aaaff60e557efc4f41d1ae7e3c71738 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 18:03:41 2018 -0400 Rename os to platform, add Ext trait postfixes commit 7df59c60a06008226f6455619e7242ed0156ed8d Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 17:59:36 2018 -0400 Rename platform to platform_impl commit 99c0f84a9fc771c9c96099232de3716ddf27ca80 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 17:55:27 2018 -0400 Add request_redraw commit a0fef1a5fad9b5d5da59fff191c7d9c398ea9e01 Author: Osspial <osspial@gmail.com> Date: Mon Aug 20 01:47:11 2018 -0400 Fully invert windows control flow so win32 calls into winit's callback commit 2c607ff87f8fbcad8aa9dc3783b3298c014dd177 Author: Osspial <osspial@gmail.com> Date: Sun Aug 19 13:44:22 2018 -0400 Add ability to send custom user events commit a0b2bb36953f018ff782cef8fc86c6db9343095d Author: Osspial <osspial@gmail.com> Date: Fri Aug 17 17:49:46 2018 -0400 Add StartCause::Init support, timer example commit 02f922f003f56215b92b8feeb9148ad2dd181fc2 Author: Osspial <osspial@gmail.com> Date: Fri Aug 17 17:31:04 2018 -0400 Implement new ControlFlow and associated events commit 8b8a7675ec67e15a0f8f69db0bdeb79bee0ac20d Author: Osspial <osspial@gmail.com> Date: Fri Jul 13 01:48:26 2018 -0400 Replace windows Mutex with parking_lot Mutex commit 9feada206f6b9fb1e9da118be6b77dfc217ace8d Author: Osspial <osspial@gmail.com> Date: Fri Jul 13 01:39:53 2018 -0400 Update run_forever to hijack thread commit 2e83bac99cc264cd2723cb182feea84a0a15e08d Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 23:43:58 2018 -0400 Remove second thread from win32 backend commit 64b8a9c6a50362d10c074077a1e37b057f3e3c81 Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 22:13:07 2018 -0400 Rename WindowEvent::Refresh to WindowEvent::Redraw commit 529c08555fd0b709a23d486211d28fbd0980fc94 Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 22:04:38 2018 -0400 Rename EventsLoop and associated types to EventLoop Signed-off-by: Hal Gentz <zegentzy@protonmail.com> Co-authored-by: Hal Gentz <zegentzy@protonmail.com> commit cfb929ba0a9e787f8bb1a6dae4e05e4c7776bc97 Author: Hal Gentz <zegentzy@protonmail.com> Date: Thu Apr 25 07:40:56 2019 -0600 Fix example Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 68d3317ff58381d55f5f9bd3db0860d66544fe12 Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:47:46 2019 -0600 Fixes Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 02d1aae4db27df054b703aa935ca118f31e17123 Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:39:19 2019 -0600 Backport https://github.com/rust-windowing/winit/commit/9a23ec3c373d096e5e9dd0cc0a23f7baf0b64135#diff-1d95fe39cdbaa708c975380a16c314cb Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit dd9de5a6d444a9ab17afe470f4cf2a57e3ed76ae Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:09:14 2019 -0600 Backports https://github.com/rust-windowing/winit/commit/45a428141329377a1669698e4ca6561834c0dbcc#diff-1d95fe39cdbaa708c975380a16c314cb Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 533e2adc1d1e417742475786635848b1620e476c Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 23:05:57 2019 -0600 Francesca's macos changes Also backports https://github.com/rust-windowing/winit/commit/bfbcab3a010667e74fa3cc07ac85bd4c85491e65#diff-1d95fe39cdbaa708c975380a16c314cb commit 73b52221080bd3a881ae3a58c2dbb19bc8d954c6 Author: Hal Gentz <zegentzy@protonmail.com> Date: Wed Apr 24 20:58:26 2019 -0600 Squashed commit of the following: commit 5f4aa9f01a719eef98c6d894801c20ee8f96d30f Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 17:14:14 2018 -0500 Protect against reentrancy (messily) commit b75073a5b2a8d65ab8806a00ffee390752255c8c Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 15:15:27 2018 -0500 Send resize events immediately commit 8e9fc01bd6b404f59488b130413f48e4e5f89b0d Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 21 16:07:43 2018 -0500 Don't use struct for window delegate commit c6853b0c4a8fe357f463604bb879dc1be424860e Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 21:17:48 2018 -0500 Split up util commit 262c46b148413130fa239099f1151c1f1bd5c13c Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 20:55:00 2018 -0500 Use dispatch crate commit 63152c2f475794d1a36a5b3687c777664d7d5613 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 20:29:13 2018 -0500 RedrawRequested commit 27e475c7c78b059fd9b5e8350cd26756eecdfc94 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 19 19:24:44 2018 -0500 User events commit 157418d7dedace9c571e977d98ea92464c3188b2 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 18 22:38:05 2018 -0500 Moved out cursor loading commit b4925641c973979a38743202b4269efe09ac43b4 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 18 21:32:12 2018 -0500 Fixed a bunch of threading issues commit 4aef63dfb78dfaf38c83cb0e88d4ea9d8d0578a6 Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 17 13:54:59 2018 -0500 Wait works commit 72ed426c695df5dc410902263bd74188059b8ddd Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 20:49:10 2018 -0500 Fixed drag and dropg commit 658209f4a20acd536218f41a01fb8cbbebc705e0 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 20:42:42 2018 -0500 Made mutexes finer for less deadlock risk commit 8e6b9866084690da900c4d058e412cab8ebb30c4 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 14 16:45:06 2018 -0500 Dump (encapsulate) everything into AppState commit d2dc83df15939d89301e2cff0ffa2d98c48b406f Author: Francesca Plebani <franplebani@gmail.com> Date: Thu Dec 13 17:36:47 2018 -0500 All window events work! commit 7c7fcc98872b3c35bd7767b5c6235a74bc105e06 Author: Francesca Plebani <franplebani@gmail.com> Date: Wed Dec 12 17:11:09 2018 -0500 Very rough usage of CFRunLoop commit 3c7a52ff4df683b5b7e1751e4051ec445a818774 Author: Francesca Plebani <franplebani@gmail.com> Date: Tue Dec 11 15:45:23 2018 -0500 Fixed deadlocks commit b74c7fe1bcd173e9b0c0e004956c257e805bc2a2 Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 10 18:59:46 2018 -0500 Fix keyDown deadlock commit 3798f9c1a4bef2a3d1552f846b26efc31b1bbb6c Author: Francesca Plebani <franplebani@gmail.com> Date: Mon Dec 10 18:44:40 2018 -0500 It builds! commit 8c8620214357714c5cd0b3beefda6704512e3f64 Author: Francesca Plebani <franplebani@gmail.com> Date: Fri Dec 7 21:09:55 2018 -0500 Horribly broken so far commit 8269ed2a9270e5ec5b14f80fd21d1e0e6f51be29 Author: Osspial <osspial@gmail.com> Date: Mon Nov 19 23:51:20 2018 -0500 Fix crash with runner refcell not getting dropped commit 54ce6a21a0722e408ae49c74f5008005fc1e4cbf Author: Osspial <osspial@gmail.com> Date: Sun Nov 18 19:12:45 2018 -0500 Fix buffered events not getting dispatched commit 2c18b804df66f49f93cfe722a679d6c5e01d8cb1 Author: Osspial <osspial@gmail.com> Date: Sun Nov 18 18:51:24 2018 -0500 Fix thread executor not executing closure when called from non-loop thread commit 5a3a5e2293cec3e566c4aac344ae7eaa343608b5 Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 22:43:59 2018 -0500 Fix some deadlocks that could occur when changing window state commit 2a3cefd8c5df1c06127b05651cbdf5e3d9e3a6d3 Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 16:45:17 2018 -0500 Document and implement Debug for EventLoopWindowTarget commit fa46825a289ca0587dc97f9c00dea5516fb4925a Author: Osspial <osspial@gmail.com> Date: Thu Nov 15 16:40:48 2018 -0500 Replace &EventLoop in callback with &EventLoopWindowTarget commit 9f36a7a68e1dc379cf9091213dae2c3586d3e473 Author: Osspial <osspial@gmail.com> Date: Wed Nov 14 21:28:38 2018 -0500 Fix freeze when setting decorations commit d9c3daca9b459e02ef614568fe803a723965fe8d Author: Osspial <osspial@gmail.com> Date: Fri Nov 9 20:41:15 2018 -0500 Fix 1.24.1 build commit 5289d22372046bac403a279c3641737c0cfc46d2 Author: Osspial <osspial@gmail.com> Date: Fri Nov 9 00:00:27 2018 -0500 Remove serde implementations from ControlFlow commit 92ac3d6ac7915923c22c380cc3a74c5f3830708e Author: Osspial <osspial@gmail.com> Date: Thu Nov 8 23:46:41 2018 -0500 Remove crossbeam dependency and make drop events work again commit 8299eb2f03773a34079c61fc8adb51405aafc467 Author: Osspial <osspial@gmail.com> Date: Thu Sep 13 22:39:40 2018 -0400 Fix crash when running in release mode commit bb6ab1bb6e9595e90f1915fdde7e23904f2ba594 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 14:28:16 2018 -0400 Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. commit 5068ff4ee152bfe93c9190235f02d001202feb88 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 14:14:28 2018 -0400 Improve clarity/fix typos in docs commit 8ed575ff4a4f0961bb2e784bda1ae109c6bd37b7 Author: Osspial <osspial@gmail.com> Date: Sun Sep 9 00:19:53 2018 -0400 Update send test and errors that broke some examples/APIs commit bf7bfa82ebb5d6ae110ce0492c124ef462945f85 Author: Osspial <osspial@gmail.com> Date: Wed Sep 5 22:36:05 2018 -0400 Fix resize lag when waiting in some situations commit 70722cc4c322e3e599b3a03bce5058a5d433970b Author: Osspial <osspial@gmail.com> Date: Wed Sep 5 19:58:52 2018 -1100 When SendEvent is called during event closure, buffer events commit 53370924b25da15ddd172173150b228065324864 Author: Osspial <osspial@gmail.com> Date: Sun Aug 26 21:55:51 2018 -0400 Improve WaitUntil timer precision commit a654400e730400c2e3584be2f47153043b5b7efe Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 21:06:19 2018 -0400 Add CHANGELOG entry commit deb7d379b7c04e61d6d50ff655eccac0ad692e44 Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:19:56 2018 -0400 Rename MonitorId to MonitorHandle commit 8d8d9b7cd1386c99c40023d86e17d10c3fd6652f Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:16:52 2018 -0400 Change instances of "events_loop" to "event_loop" commit 0f344087630ae252c9c8f453864e684a1a5405b1 Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 20:13:53 2018 -0400 Improve docs for run and run_return commit fba41f7a7ed8585cbb658b6d0b2f34f75482cb3d Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 19:09:53 2018 -0400 Small changes to examples commit 42e8a0d2cf77af79da082fff7cd29cc8f52d99df Author: Osspial <osspial@gmail.com> Date: Thu Aug 23 19:09:19 2018 -0400 Improve documentation commit 4377680a44ea86dad52954f90bc7d8ad7ed0b4bf Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 23:01:36 2018 -0400 Re-organize into module structure commit f20fac99f6ac57c51603a92d792fd4f665feb7f6 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 22:07:39 2018 -0400 Add platform::desktop module with EventLoopExt::run_return commit dad24d086aaaff60e557efc4f41d1ae7e3c71738 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 18:03:41 2018 -0400 Rename os to platform, add Ext trait postfixes commit 7df59c60a06008226f6455619e7242ed0156ed8d Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 17:59:36 2018 -0400 Rename platform to platform_impl commit 99c0f84a9fc771c9c96099232de3716ddf27ca80 Author: Osspial <osspial@gmail.com> Date: Wed Aug 22 17:55:27 2018 -0400 Add request_redraw commit a0fef1a5fad9b5d5da59fff191c7d9c398ea9e01 Author: Osspial <osspial@gmail.com> Date: Mon Aug 20 01:47:11 2018 -0400 Fully invert windows control flow so win32 calls into winit's callback commit 2c607ff87f8fbcad8aa9dc3783b3298c014dd177 Author: Osspial <osspial@gmail.com> Date: Sun Aug 19 13:44:22 2018 -0400 Add ability to send custom user events commit a0b2bb36953f018ff782cef8fc86c6db9343095d Author: Osspial <osspial@gmail.com> Date: Fri Aug 17 17:49:46 2018 -0400 Add StartCause::Init support, timer example commit 02f922f003f56215b92b8feeb9148ad2dd181fc2 Author: Osspial <osspial@gmail.com> Date: Fri Aug 17 17:31:04 2018 -0400 Implement new ControlFlow and associated events commit 8b8a7675ec67e15a0f8f69db0bdeb79bee0ac20d Author: Osspial <osspial@gmail.com> Date: Fri Jul 13 01:48:26 2018 -0400 Replace windows Mutex with parking_lot Mutex commit 9feada206f6b9fb1e9da118be6b77dfc217ace8d Author: Osspial <osspial@gmail.com> Date: Fri Jul 13 01:39:53 2018 -0400 Update run_forever to hijack thread commit 2e83bac99cc264cd2723cb182feea84a0a15e08d Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 23:43:58 2018 -0400 Remove second thread from win32 backend commit 64b8a9c6a50362d10c074077a1e37b057f3e3c81 Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 22:13:07 2018 -0400 Rename WindowEvent::Refresh to WindowEvent::Redraw commit 529c08555fd0b709a23d486211d28fbd0980fc94 Author: Osspial <osspial@gmail.com> Date: Thu Jul 12 22:04:38 2018 -0400 Rename EventsLoop and associated types to EventLoop Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit ab1dfaaaa53a3acd206bf494ac90e3fe130dc609 Author: Hal Gentz <zegentzy@protonmail.com> Date: Tue Apr 23 21:52:17 2019 -0600 Minor Signed-off-by: Hal Gentz <zegentzy@protonmail.com> commit 7933209d603e0794adb806d9cf53507f1c2f1d3c Author: Victor Berger <victor.berger@m4x.org> Date: Thu Apr 18 09:10:41 2019 +0200 wayland/x11: Make ControlFlow::Exit sticky commit 8355a7513e299ffba21062c8518bcf4bdb735ba9 Author: Victor Berger <victor.berger@m4x.org> Date: Tue Apr 16 12:21:33 2019 +0200 x11: Implement run_return using calloop commit f64edb60cc85fcd98a1cec955ba9980f617fdd73 Author: Victor Berger <victor.berger@m4x.org> Date: Tue Apr 16 10:42:04 2019 +0200 x11: port to evl2 with stubs commit be372898ddc60e47887c9a152c10ff498445f8cf Author: Victor Berger <victor.berger@m4x.org> Date: Mon Apr 15 17:35:59 2019 +0200 Fix compilation on Linux. Signed-off-by: Hal Gentz <zegentzy@protonmail.com> Co-authored-by: Francesca Plebani <franplebani@gmail.com>
2019-05-02 09:03:30 +10:00
/// Returns `None` if the `EventLoop` doesn't use wayland (if it uses xlib for example).
///
/// The pointer will become invalid when the winit `EventLoop` is destroyed.
#[cfg(feature = "wayland")]
fn wayland_display(&self) -> Option<*mut raw::c_void>;
}
impl<T> EventLoopWindowTargetExtUnix for EventLoopWindowTarget<T> {
#[inline]
#[cfg(feature = "wayland")]
fn is_wayland(&self) -> bool {
self.p.is_wayland()
}
#[inline]
#[cfg(feature = "x11")]
fn is_x11(&self) -> bool {
!self.p.is_wayland()
}
#[inline]
#[doc(hidden)]
#[cfg(feature = "x11")]
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
match self.p {
LinuxEventLoopWindowTarget::X(ref e) => Some(e.x_connection().clone()),
#[cfg(feature = "wayland")]
_ => None,
}
}
#[inline]
#[cfg(feature = "wayland")]
fn wayland_display(&self) -> Option<*mut raw::c_void> {
match self.p {
LinuxEventLoopWindowTarget::Wayland(ref p) => {
Some(p.display().get_display_ptr() as *mut _)
}
#[cfg(feature = "x11")]
_ => None,
}
}
2017-01-08 00:34:38 +11:00
}
/// Additional methods on `EventLoop` that are specific to Unix.
pub trait EventLoopExtUnix {
/// Builds a new `EventLoop` that is forced to use X11.
///
/// # Panics
///
/// If called outside the main thread. To initialize an X11 event loop outside
/// the main thread, use [`new_x11_any_thread`](#tymethod.new_x11_any_thread).
#[cfg(feature = "x11")]
fn new_x11() -> Result<Self, XNotSupported>
where
Self: Sized;
/// Builds a new `EventLoop` that is forced to use Wayland.
///
/// # Panics
///
/// If called outside the main thread. To initialize a Wayland event loop outside
/// the main thread, use [`new_wayland_any_thread`](#tymethod.new_wayland_any_thread).
#[cfg(feature = "wayland")]
fn new_wayland() -> Self
where
Self: Sized;
/// Builds a new `EventLoop` on any thread.
///
/// This method bypasses the cross-platform compatibility requirement
/// that `EventLoop` be created on the main thread.
fn new_any_thread() -> Self
where
Self: Sized;
/// Builds a new X11 `EventLoop` on any thread.
///
/// This method bypasses the cross-platform compatibility requirement
/// that `EventLoop` be created on the main thread.
#[cfg(feature = "x11")]
fn new_x11_any_thread() -> Result<Self, XNotSupported>
where
Self: Sized;
/// Builds a new Wayland `EventLoop` on any thread.
///
/// This method bypasses the cross-platform compatibility requirement
/// that `EventLoop` be created on the main thread.
#[cfg(feature = "wayland")]
fn new_wayland_any_thread() -> Self
where
Self: Sized;
}
fn wrap_ev<T>(event_loop: LinuxEventLoop<T>) -> EventLoop<T> {
EventLoop {
event_loop,
_marker: std::marker::PhantomData,
}
}
impl<T> EventLoopExtUnix for EventLoop<T> {
#[inline]
fn new_any_thread() -> Self {
wrap_ev(LinuxEventLoop::new_any_thread())
}
#[inline]
#[cfg(feature = "x11")]
fn new_x11_any_thread() -> Result<Self, XNotSupported> {
LinuxEventLoop::new_x11_any_thread().map(wrap_ev)
}
#[inline]
#[cfg(feature = "wayland")]
fn new_wayland_any_thread() -> Self {
wrap_ev(
LinuxEventLoop::new_wayland_any_thread()
// TODO: propagate
.expect("failed to open Wayland connection"),
)
}
#[inline]
#[cfg(feature = "x11")]
fn new_x11() -> Result<Self, XNotSupported> {
LinuxEventLoop::new_x11().map(wrap_ev)
}
#[inline]
#[cfg(feature = "wayland")]
fn new_wayland() -> Self {
wrap_ev(
LinuxEventLoop::new_wayland()
// TODO: propagate
.expect("failed to open Wayland connection"),
)
}
}
2016-01-08 02:01:18 +11:00
/// Additional methods on `Window` that are specific to Unix.
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
pub trait WindowExtUnix {
/// Returns the ID of the `Window` xlib object that is used by this window.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
#[cfg(feature = "x11")]
fn xlib_window(&self) -> Option<raw::c_ulong>;
/// Returns a pointer to the `Display` object of xlib that is used by this window.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
///
/// The pointer will become invalid when the glutin `Window` is destroyed.
#[cfg(feature = "x11")]
fn xlib_display(&self) -> Option<*mut raw::c_void>;
2016-10-20 03:11:02 +11:00
#[cfg(feature = "x11")]
fn xlib_screen_id(&self) -> Option<raw::c_int>;
2016-10-20 03:11:02 +11:00
#[doc(hidden)]
#[cfg(feature = "x11")]
fn xlib_xconnection(&self) -> Option<Arc<XConnection>>;
/// Set window urgency hint (`XUrgencyHint`). Only relevant on X.
#[cfg(feature = "x11")]
fn set_urgent(&self, is_urgent: bool);
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
///
/// Returns `None` if the window doesn't use xlib (if it uses wayland for example).
///
/// The pointer will become invalid when the glutin `Window` is destroyed.
#[cfg(feature = "x11")]
fn xcb_connection(&self) -> Option<*mut raw::c_void>;
2016-05-08 17:28:54 +10:00
/// Returns a pointer to the `wl_surface` object of wayland that is used by this window.
///
/// Returns `None` if the window doesn't use wayland (if it uses xlib for example).
///
/// The pointer will become invalid when the glutin `Window` is destroyed.
#[cfg(feature = "wayland")]
fn wayland_surface(&self) -> Option<*mut raw::c_void>;
/// Returns a pointer to the `wl_display` object of wayland that is used by this window.
///
/// Returns `None` if the window doesn't use wayland (if it uses xlib for example).
///
/// The pointer will become invalid when the glutin `Window` is destroyed.
#[cfg(feature = "wayland")]
fn wayland_display(&self) -> Option<*mut raw::c_void>;
/// Sets the color theme of the client side window decorations on wayland
#[cfg(feature = "wayland")]
fn set_wayland_theme<T: Theme>(&self, theme: T);
/// Check if the window is ready for drawing
///
/// It is a remnant of a previous implementation detail for the
/// wayland backend, and is no longer relevant.
///
/// Always return true.
#[deprecated]
fn is_ready(&self) -> bool;
}
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
impl WindowExtUnix for Window {
#[inline]
#[cfg(feature = "x11")]
fn xlib_window(&self) -> Option<raw::c_ulong> {
match self.window {
LinuxWindow::X(ref w) => Some(w.xlib_window()),
#[cfg(feature = "wayland")]
_ => None,
}
}
#[inline]
#[cfg(feature = "x11")]
fn xlib_display(&self) -> Option<*mut raw::c_void> {
match self.window {
LinuxWindow::X(ref w) => Some(w.xlib_display()),
#[cfg(feature = "wayland")]
_ => None,
}
}
2016-05-08 17:28:54 +10:00
#[inline]
#[cfg(feature = "x11")]
fn xlib_screen_id(&self) -> Option<raw::c_int> {
match self.window {
LinuxWindow::X(ref w) => Some(w.xlib_screen_id()),
#[cfg(feature = "wayland")]
_ => None,
2016-10-20 03:11:02 +11:00
}
}
#[inline]
#[doc(hidden)]
#[cfg(feature = "x11")]
fn xlib_xconnection(&self) -> Option<Arc<XConnection>> {
match self.window {
LinuxWindow::X(ref w) => Some(w.xlib_xconnection()),
#[cfg(feature = "wayland")]
_ => None,
}
}
2016-10-20 03:11:02 +11:00
#[inline]
#[cfg(feature = "x11")]
fn set_urgent(&self, is_urgent: bool) {
match self.window {
LinuxWindow::X(ref w) => w.set_urgent(is_urgent),
#[cfg(feature = "wayland")]
_ => (),
}
}
#[inline]
#[cfg(feature = "x11")]
fn xcb_connection(&self) -> Option<*mut raw::c_void> {
match self.window {
LinuxWindow::X(ref w) => Some(w.xcb_connection()),
#[cfg(feature = "wayland")]
_ => None,
}
}
2016-05-08 17:28:54 +10:00
#[inline]
#[cfg(feature = "wayland")]
fn wayland_surface(&self) -> Option<*mut raw::c_void> {
match self.window {
LinuxWindow::Wayland(ref w) => Some(w.surface().as_ref().c_ptr() as *mut _),
#[cfg(feature = "x11")]
_ => None,
2016-05-08 17:28:54 +10:00
}
}
#[inline]
#[cfg(feature = "wayland")]
fn wayland_display(&self) -> Option<*mut raw::c_void> {
match self.window {
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
LinuxWindow::Wayland(ref w) => Some(w.display().get_display_ptr() as *mut _),
#[cfg(feature = "x11")]
_ => None,
2016-05-08 17:28:54 +10:00
}
}
#[inline]
#[cfg(feature = "wayland")]
fn set_wayland_theme<T: Theme>(&self, theme: T) {
match self.window {
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
LinuxWindow::Wayland(ref w) => w.set_theme(theme),
#[cfg(feature = "x11")]
2019-06-25 02:14:55 +10:00
_ => {}
}
}
#[inline]
fn is_ready(&self) -> bool {
true
}
}
2016-01-08 02:01:18 +11:00
/// Additional methods on `WindowBuilder` that are specific to Unix.
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
pub trait WindowBuilderExtUnix {
#[cfg(feature = "x11")]
fn with_x11_visual<T>(self, visual_infos: *const T) -> Self;
#[cfg(feature = "x11")]
fn with_x11_screen(self, screen_id: i32) -> Self;
/// Build window with `WM_CLASS` hint; defaults to the name of the binary. Only relevant on X11.
#[cfg(feature = "x11")]
fn with_class(self, class: String, instance: String) -> Self;
/// Build window with override-redirect flag; defaults to false. Only relevant on X11.
#[cfg(feature = "x11")]
fn with_override_redirect(self, override_redirect: bool) -> Self;
/// Build window with `_NET_WM_WINDOW_TYPE` hints; defaults to `Normal`. Only relevant on X11.
#[cfg(feature = "x11")]
fn with_x11_window_type(self, x11_window_type: Vec<XWindowType>) -> Self;
/// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11.
#[cfg(feature = "x11")]
fn with_gtk_theme_variant(self, variant: String) -> Self;
/// Build window with resize increment hint. Only implemented on X11.
#[cfg(feature = "x11")]
fn with_resize_increments<S: Into<Size>>(self, increments: S) -> Self;
/// Build window with base size hint. Only implemented on X11.
#[cfg(feature = "x11")]
fn with_base_size<S: Into<Size>>(self, base_size: S) -> Self;
/// Build window with a given application ID. It should match the `.desktop` file distributed with
/// your program. Only relevant on Wayland.
///
/// For details about application ID conventions, see the
/// [Desktop Entry Spec](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id)
#[cfg(feature = "wayland")]
fn with_app_id(self, app_id: String) -> Self;
2016-01-08 02:01:18 +11:00
}
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
impl WindowBuilderExtUnix for WindowBuilder {
#[inline]
#[cfg(feature = "x11")]
fn with_x11_visual<T>(mut self, visual_infos: *const T) -> Self {
{
self.platform_specific.visual_infos =
Some(unsafe { ptr::read(visual_infos as *const XVisualInfo) });
}
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_x11_screen(mut self, screen_id: i32) -> Self {
self.platform_specific.screen_id = Some(screen_id);
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_class(mut self, instance: String, class: String) -> Self {
self.platform_specific.class = Some((instance, class));
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_override_redirect(mut self, override_redirect: bool) -> Self {
self.platform_specific.override_redirect = override_redirect;
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_x11_window_type(mut self, x11_window_types: Vec<XWindowType>) -> Self {
self.platform_specific.x11_window_types = x11_window_types;
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_gtk_theme_variant(mut self, variant: String) -> Self {
self.platform_specific.gtk_theme_variant = Some(variant);
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_resize_increments<S: Into<Size>>(mut self, increments: S) -> Self {
self.platform_specific.resize_increments = Some(increments.into());
self
}
#[inline]
#[cfg(feature = "x11")]
fn with_base_size<S: Into<Size>>(mut self, base_size: S) -> Self {
self.platform_specific.base_size = Some(base_size.into());
self
}
#[inline]
#[cfg(feature = "wayland")]
fn with_app_id(mut self, app_id: String) -> Self {
self.platform_specific.app_id = Some(app_id);
self
}
2016-01-08 02:01:18 +11:00
}
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
/// Additional methods on `MonitorHandle` that are specific to Linux.
pub trait MonitorHandleExtUnix {
/// Returns the inner identifier of the monitor.
fn native_id(&self) -> u32;
}
Event Loop 2.0 API and Windows implementation (#638) * Rename EventsLoop and associated types to EventLoop * Rename WindowEvent::Refresh to WindowEvent::Redraw * Remove second thread from win32 backend * Update run_forever to hijack thread * Replace windows Mutex with parking_lot Mutex * Implement new ControlFlow and associated events * Add StartCause::Init support, timer example * Add ability to send custom user events * Fully invert windows control flow so win32 calls into winit's callback * Add request_redraw * Rename platform to platform_impl * Rename os to platform, add Ext trait postfixes * Add platform::desktop module with EventLoopExt::run_return * Re-organize into module structure * Improve documentation * Small changes to examples * Improve docs for run and run_return * Change instances of "events_loop" to "event_loop" * Rename MonitorId to MonitorHandle * Add CHANGELOG entry * Improve WaitUntil timer precision * When SendEvent is called during event closure, buffer events * Fix resize lag when waiting in some situations * Update send test and errors that broke some examples/APIs * Improve clarity/fix typos in docs * Fix unreachable panic after setting ControlFlow to Poll during some RedrawRequested events. * Fix crash when running in release mode * Remove crossbeam dependency and make drop events work again * Remove serde implementations from ControlFlow * Fix 1.24.1 build * Fix freeze when setting decorations * Replace &EventLoop in callback with &EventLoopWindowTarget * Document and implement Debug for EventLoopWindowTarget * Fix some deadlocks that could occur when changing window state * Fix thread executor not executing closure when called from non-loop thread * Fix buffered events not getting dispatched * Fix crash with runner refcell not getting dropped * Address review feedback * Fix CHANGELOG typo * Catch panics in user callback
2019-02-06 02:30:33 +11:00
impl MonitorHandleExtUnix for MonitorHandle {
#[inline]
fn native_id(&self) -> u32 {
self.inner.native_identifier()
}
}
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// A theme for a Wayland's client side decorations.
#[cfg(feature = "wayland")]
pub trait Theme: Send + 'static {
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// Title bar color.
fn element_color(&self, element: Element, window_active: bool) -> ARGBColor;
/// Color for a given button part.
fn button_color(
&self,
button: Button,
state: ButtonState,
foreground: bool,
window_active: bool,
) -> ARGBColor;
/// Font name and the size for the title bar.
///
/// By default the font is `sans-serif` at the size of 11.
///
/// Returning `None` means that title won't be drawn.
fn font(&self) -> Option<(String, f32)> {
// Not having any title isn't something desirable for the users, so setting it to
// something generic.
Some((String::from("sans-serif"), 11.))
}
}
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// A button on Wayland's client side decorations.
#[cfg(feature = "wayland")]
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Button {
/// Button that maximizes the window.
Maximize,
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// Button that minimizes the window.
Minimize,
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// Button that closes the window.
Close,
}
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
/// A button state of the button on Wayland's client side decorations.
#[cfg(feature = "wayland")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ButtonState {
/// Button is being hovered over by pointer.
Hovered,
/// Button is not being hovered over by pointer.
Idle,
/// Button is disabled.
Disabled,
}
#[cfg(feature = "wayland")]
Update SCTK to 0.11.0 * Update SCTK to 0.11.0 Updates smithay-client-toolkit to 0.11.0. The major highlight of that updated, is update of wayland-rs to 0.27.0. Switching to wayland-cursor, instead of using libwayland-cursor. It also fixes the following bugs: - Disabled repeat rate not being handled. - Decoration buttons not working after tty switch. - Scaling not being applied on output reenable. - Crash when `XCURSOR_SIZE` is `0`. - Pointer getting created in some cases without pointer capability. - On kwin, fix space between window and decorations on startup. - Incorrect size event when entering fullscreen when using client side decorations. - Client side decorations not being hided properly in fullscreen. - Size tracking between fullscreen/tiled state changes. - Repeat rate triggering multiple times from slow callback handler. - Resizable attribute not being applied properly on startup. - Not working IME Besides those fixes it also adds a bunch of missing virtual key codes, implements proper cursor grabbing, adds right click on decorations to open application menu, disabled maximize button for non-resizeable window, and fall back for cursor icon to similar ones, if the requested is missing. It also adds new methods to a `Theme` trait, such as: - `title_font(&self) -> Option<(String, f32)>` - The font for a title. - `title_color(&self, window_active: bool) -> [u8; 4]` - The color of the text in the title. Fixes #1680. Fixes #1678. Fixes #1676. Fixes #1646. Fixes #1614. Fixes #1601. Fixes #1533. Fixes #1509. Fixes #952. Fixes #947.
2020-09-29 07:11:43 +10:00
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Element {
/// Bar itself.
Bar,
/// Separator between window and title bar.
Separator,
/// Title bar text.
Text,
}
#[cfg(feature = "wayland")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ARGBColor {
pub a: u8,
pub r: u8,
pub g: u8,
pub b: u8,
}