From e579a030350e842ace801776f0e1c71542d8fb57 Mon Sep 17 00:00:00 2001 From: Osspial Date: Sat, 13 Apr 2019 18:57:08 -0400 Subject: [PATCH 1/7] Winit Features and Scope (#695) * Add initial draft of SCOPE document * Rephrase/rename feature tiers * Rename to FEATURES and add a few annotations * Fix API Reworks table * Add more annotations * Some phrasing * Split compat matrix into seperate section, to be moved into wiki * Mention compatibility in CONTRIBUTING * Remove some discuss annotations * Apply review changes and rename child windows feature to popup windows * Update based on discussion * Add issue for Android HiDPI * Update FEATURES.md * Update FEATURES.md * Update PULL_REQUEST_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md * Reformat FEATURES.MD * Remove comments * Improve formatting and add guide for extending #Features --- .github/PULL_REQUEST_TEMPLATE.md | 1 + CONTRIBUTING.md | 27 +--- FEATURES.md | 209 +++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 FEATURES.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 08cd768b..b6c3ba05 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,3 +2,4 @@ - [ ] Added an entry to `CHANGELOG.md` if knowledge of this change could be valuable to users - [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior - [ ] Created an example program if it would help users understand this functionality +- [ ] Updated [feature matrix](TODO: LINK), if new features were added or implemented diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d32ec8a4..e122f7d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,28 +1,10 @@ # Winit Contributing Guidelines ## Scope +[See `FEATURES.md`](./FEATURES.md). When requesting or implementing a new Winit feature, you should +consider whether or not it's directly related to window creation or input handling. If it isn't, it +may be worth creating a separate crate that extends Winit's API to add that functionality. -Winit aims to provide a generic platform abstracting the main graphic platforms (Windows, macOS, X11, -Wayland, Android, iOS and the web platform via Emscripten). - -Most platforms expose capabilities that cannot be meaningfully transposed to the others. Winit does not -aim to support every single functionality of every platform, but rather to abstract the set of -capabilities that is common to all platforms. In this context, APIs exposed in winit can be split into -different "support levels": - -- Tier 1: features which are in the main scope of winit. They are part of the common API of winit, and - are taken care of by the maintainers. Any part of these features that is not working correctly is - considered a bug in winit. -- Tier 2: some platform-specific features can be sufficiently fundamental to the platform that winit can - integrate support for them in the platform-specific part of the API. These features are not considered - directly handled by the maintainers of winit. If you have a strong incentive to have such a feature - integrated in winit, consider implementing it and proposing yourself to maintain it in the future. -- Tier 3: these features are not directly exposed by winit, but rather can be implemented using the - raw handles to the underlying platform that winit exposes. If your feature of interest is rather - niche, this is probably where it belongs. - -The exact list of supported Tier 1 features is tracked in this issue: -[#252](https://github.com/tomaka/winit/issues/252). ## Reporting an issue @@ -44,6 +26,9 @@ When making a code contribution to winit, before opening your pull request, plea - you left comments in your code explaining any part that is not straightforward, so that the maintainers and future contributors don't have to try to guess what your code is supposed to do - your PR adds an entry to the changelog file if the introduced change is relevant to winit users +- if your PR affects the platform compatibility of one or more features or adds another feature, the + relevant table in the wiki should be updated + ***//TODO: LINKY*** Once your PR is open, you can ask for review by a maintainer of your platform. Winit's merging policy is that a PR must be approved by at least two maintainers of winit before being merged, including diff --git a/FEATURES.md b/FEATURES.md new file mode 100644 index 00000000..84344e1d --- /dev/null +++ b/FEATURES.md @@ -0,0 +1,209 @@ +# Winit Scope + +Winit aims to expose an interface that abstracts over window creation and input handling, and can +be used to create both games and applications. It supports the main graphical platforms: +- Desktop + - Windows + - macOS + - Unix + - via X11 + - via Wayland +- Mobile + - iOS + - Android +- Web + - via Emscripten + - via WASM + +Most platforms expose capabilities that cannot be meaningfully transposed onto others. Winit does not +aim to support every single feature of every platform, but rather to abstract over the common features +available everywhere. In this context, APIs exposed in winit can be split into different "support tiers": + +- **Core:** Features that are essential to providing a well-formed abstraction over each platform's + windowing and input APIs. +- **Platform:** Platform-specific features that can't be meaningfully exposed through a common API and + cannot be implemented outside of Winit without exposing a significant amount of Winit's internals + or interfering with Winit's abstractions. +- **Usability:** Features that are not strictly essential to Winit's functionality, but provide meaningful + usability improvements and cannot be reasonably implemented in an external crate. These are + generally optional and exposed through Cargo features. + +Core features are taken care of by the core Winit maintainers. Platform features are not. +When a platform feature is submitted, the submitter is considered the expert in the +feature and may be asked to support the feature should it break in the future. + +Winit ***does not*** directly expose functionality for drawing inside windows or creating native +menus, but ***does*** commit to providing APIs that higher-level crates can use to implement that +functionality. + +## `1.0` and stability + +When all core features are implemented to the satisfaction of the Winit maintainers, Winit 1.0 will +be released and the library will enter maintenance mode. For the most part, new core features will not +be added past this point. New platform features may be accepted and exposed through point releases. + +### Tier upgrades +Some platform features could in theory be exposed across multiple platforms, but have not gone +through the implementation work necessary to function on all platforms. When one of these features +gets implemented across all platforms, a PR can be opened to upgrade the feature to a core feature. +If that gets accepted, the platform-specific functions gets deprecated and become permanently +exposed through the core, cross-platform API. + +# Features + +## Extending this section + +If your PR makes notable changes to Winit's features, please update this section as follows: + +- If your PR adds a new feature, add a brief description to the relevant section. If the feature is a core + feature, add a row to the feature matrix and describe what platforms the feature has been implemented on. + +- If your PR begins a new API rework, add a row to the `Pending API Reworks` table. If the PR implements the + API rework on all relevant platforms, please move it to the `Completed API Reworks` table. + +- If your PR implements an already-existing feature on a new platform, either mark the feature as *completed*, + or mark it as *mostly completed* and link to an issue describing the problems with the implementation. + +## Core + +### Windowing +- **Window initialization**: Winit allows the creation of a window +- **Providing pointer to init OpenGL**: Winit provides the necessary pointers to initialize a working opengl context +- **Providing pointer to init Vulkan**: Same as OpenGL but for Vulkan +- **Window decorations**: The windows created by winit are properly decorated, and the decorations can + be deactivated +- **Window decorations toggle**: Decorations can be turned on or off after window creation +- **Window resizing**: The windows created by winit can be resized and generate the appropriate events + when they are. The application can precisely control its window size if desired. +- **Window resize increments**: When the window gets resized, the application can choose to snap the window's + size to specific values. +- **Window transparency**: Winit allows the creation of windows with a transparent background. +- **Window maximization**: The windows created by winit can be maximized upon creation. +- **Window maximization toggle**: The windows created by winit can be maximized and unmaximized after + creation. +- **Fullscreen**: The windows created by winit can be put into fullscreen mode. +- **Fullscreen toggle**: The windows created by winit can be switched to and from fullscreen after + creation. +- **HiDPI support**: Winit assists developers in appropriately scaling HiDPI content. +- **Popup windows**: Windows can be created relative to the client area of other windows, and parent + windows can be disabled in favor of popup windows. This feature also guarantees that popup windows + get drawn above their owner. + + +### System Information +- **Monitor list**: Retrieve the list of monitors and their metadata, including which one is primary. + +### Input Handling +- **Mouse events**: Generating mouse events associated with pointer motion, click, and scrolling events. +- **Mouse set location**: Forcibly changing the location of the pointer. +- **Cursor grab**: Locking the cursor so it cannot exit the client area of a window. +- **Cursor icon**: Changing the cursor icon, or hiding the cursor. +- **Touch events**: Single-touch events. +- **Multitouch**: Multi-touch events, including cancellation of a gesture. +- **Keyboard events**: Properly processing keyboard events using the user-specified keymap and + translating keypresses into UTF-8 characters, handling dead keys and IMEs. +- **Drag & Drop**: Dragging content into winit, detecting when content enters, drops, or if the drop is cancelled. +- **Raw Device Events**: Capturing input from input devices without any OS filtering. +- **Gamepad/Joystick events**: Capturing input from gampads and joysticks. +- **Device movement events:**: Capturing input from the device gyroscope and accelerometer. + +## Platform +### Windows +* Setting the taskbar icon +* Setting the parent window +* `WS_EX_NOREDIRECTIONBITMAP` support + +### macOS +* Window activation policy +* Window movable by background +* Transparent titlebar +* Hidden titlebar +* Hidden titlebar buttons +* Full-size content view + +### Unix +* Window urgency +* X11 Window Class +* X11 Override Redirect Flag +* GTK Theme Variant +* Base window size + +## Usability +* `serde`: Enables serialization/deserialization of certain types with Serde. (Maintainer: @Osspial) + +## Compatibility Matrix + +Legend: + +- ✔️: Works as intended +- ▢: Mostly works but some bugs are known +- ❌: Missing feature or large bugs making it unusable +- **N/A**: Not applicable for this platform +- ❓: Unknown status + +### Windowing +|Feature |Windows|MacOS |Linux x11 |Linux Wayland |Android|iOS |Emscripten| +|-------------------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|Window initialization |✔️ |✔️ |▢[#5] |✔️ |▢[#33]|▢[#33] |❓ | +|Providing pointer to init OpenGL |✔️ |✔️ |✔️ |✔️ |✔️ |✔️ |❓ | +|Providing pointer to init Vulkan |✔️ |✔️ |✔️ |✔️ |✔️ |❓ |**N/A** | +|Window decorations |✔️ |✔️ |✔️ |▢[#306] |**N/A**|**N/A**|**N/A** | +|Window decorations toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** | +|Window resizing |✔️ |▢[#219]|✔️ |▢[#306] |**N/A**|**N/A**|❓ | +|Window resize increments |❌ |❌ |❌ |❌ |❌ |❌ |❌ | +|Window transparency |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** | +|Window maximization |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** | +|Window maximization toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** | +|Fullscreen |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|❌ | +|Fullscreen toggle |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|❌ | +|HiDPI support |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |✔️ | +|Popup windows |❌ |❌ |❌ |❌ |❌ |❌ |❌ | + +### System information +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |Emscripten| +|------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|Monitor list |✔️ |✔️ |✔️ |✔️ |**N/A**|**N/A**|**N/A** | + +### Input handling +|Feature |Windows |MacOS |Linux x11|Linux Wayland|Android|iOS |Emscripten| +|----------------------- | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|Mouse events |✔️ |▢[#63] |✔️ |✔️ |**N/A**|**N/A**|✔️ | +|Mouse set location |✔️ |✔️ |✔️ |❓ |**N/A**|**N/A**|**N/A** | +|Cursor grab |✔️ |▢[#165] |▢[#242] |❌[#306] |**N/A**|**N/A**|✔️ | +|Cursor icon |✔️ |✔️ |✔️ |❌[#306] |**N/A**|**N/A**|❌ | +|Touch events |✔️ |❌ |✔️ |✔️ |✔️ |✔️ |✔️ | +|Multitouch |❓ |❌ |✔️ |✔️ |❓ |❌ |❌ | +|Keyboard events |✔️ |✔️ |✔️ |✔️ |❓ |❌ |✔️ | +|Drag & Drop |▢[#720] |▢[#720] |▢[#720] |❌[#306] |**N/A**|**N/A**|❓ | +|Raw Device Events |▢[#750] |▢[#750] |▢[#750] |❌ |❌ |❌ |❌ | +|Gamepad/Joystick events |❌[#804] |❌ |❌ |❌ |❌ |❌ |❌ | +|Device movement events |❓ |❓ |❓ |❓ |❌ |❌ |❌ | + +### Pending API Reworks +Changes in the API that have been agreed upon but aren't implemented across all platforms. + +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |Emscripten| +|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | +|New API for HiDPI ([#315] [#319]) |✔️ |✔️ |✔️ |✔️ |▢[#721]|✔️ |✔️ | +|Event Loop 2.0 ([#459]) |✔️ |❌ |❌ |✔️ |❌ |❌ |❌ | +|Keyboard Input ([#812]) |❌ |❌ |❌ |❌ |❌ |❌ |❌ | + +### Completed API Reworks +|Feature |Windows|MacOS |Linux x11|Linux Wayland|Android|iOS |Emscripten| +|------------------------------ | ----- | ---- | ------- | ----------- | ----- | ----- | -------- | + +[#165]: https://github.com/tomaka/winit/issues/165 +[#219]: https://github.com/tomaka/winit/issues/219 +[#242]: https://github.com/tomaka/winit/issues/242 +[#306]: https://github.com/tomaka/winit/issues/306 +[#315]: https://github.com/tomaka/winit/issues/315 +[#319]: https://github.com/tomaka/winit/issues/319 +[#33]: https://github.com/tomaka/winit/issues/33 +[#459]: https://github.com/tomaka/winit/issues/459 +[#5]: https://github.com/tomaka/winit/issues/5 +[#63]: https://github.com/tomaka/winit/issues/63 +[#720]: https://github.com/tomaka/winit/issues/720 +[#721]: https://github.com/tomaka/winit/issues/721 +[#750]: https://github.com/tomaka/winit/issues/750 +[#804]: https://github.com/tomaka/winit/issues/804 +[#812]: https://github.com/tomaka/winit/issues/812 From 873f7bcec7bb288cb6747077c50ab43b160d8162 Mon Sep 17 00:00:00 2001 From: Osspial Date: Sat, 13 Apr 2019 20:42:22 -0400 Subject: [PATCH 2/7] Fix link in PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b6c3ba05..e1b4afe8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,4 +2,4 @@ - [ ] Added an entry to `CHANGELOG.md` if knowledge of this change could be valuable to users - [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior - [ ] Created an example program if it would help users understand this functionality -- [ ] Updated [feature matrix](TODO: LINK), if new features were added or implemented +- [ ] Updated [feature matrix](https://github.com/tomaka/winit/blob/master/FEATURES.md), if new features were added or implemented From 0d3e75d6b0f84837828379004934b178b12b139e Mon Sep 17 00:00:00 2001 From: Osspial Date: Sun, 14 Apr 2019 12:05:37 -0400 Subject: [PATCH 3/7] Fix TODO in CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e122f7d9..db0986a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,8 +27,8 @@ When making a code contribution to winit, before opening your pull request, plea maintainers and future contributors don't have to try to guess what your code is supposed to do - your PR adds an entry to the changelog file if the introduced change is relevant to winit users - if your PR affects the platform compatibility of one or more features or adds another feature, the - relevant table in the wiki should be updated - ***//TODO: LINKY*** + relevant sections in [`FEATURES.md`](https://github.com/rust-windowing/winit/blob/master/FEATURES.md#features) + should be updated. Once your PR is open, you can ask for review by a maintainer of your platform. Winit's merging policy is that a PR must be approved by at least two maintainers of winit before being merged, including From e087ebd1c79015ab8ea280c75ddbdfd8f0c57a63 Mon Sep 17 00:00:00 2001 From: Osspial Date: Wed, 24 Apr 2019 06:44:21 -0400 Subject: [PATCH 4/7] Makes changes to CONTRIBUTING.md's table as discussed in #830 (#841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This includes de-listing @francesca64 from the table, as I suggested. I realize that this is a controversial decision, and it's not a decision I make lightly, but I believe I have justification for doing so: I contacted @francesca64 last month asking her about her inactivity as a maintainer on this project. She replied on March 26th as follows. For the sake of her privacy, I've removed removed certain sections of her response, as it contains some personal details that I'm not comfortable sharing with the world at large without her explicit permission. > Hello! Thanks for reaching out!❤ > In short, I've moved on. ...in November, I was hired by a > company that recently started using Rust. I'm very happily building > infrastructure there! > I'm simply not interested in spending more than 8 hours a day > programming. You couldn't even pay me to do it! My time is best spent > going on adventures with my beloved. > I'll still be active in the Rust ecosystem, but only insofar as the > company I work for is. We use winit on iOS, Android, and (to a limited > extent) macOS, so I'll work on those backends as needed. > Thank you for taking care of winit. I hope you're taking care of > yourself too; . I don't begrudge her for her decision, and others shouldn't either - I firmly believe that, as this is unpaid, volunteer work, everybody should have the right to move on when they decide they no longer have the time or will to contribute. The exact impliciation of this in regards to her status as maintainer is open to interpretation. I would argue that this means, should she in her work stumble upon an issue in any of her listed backends, she would be willing to submit PRs addressing those issues. However, it also means that she is not able to put in the time to be active as a maintainer on those platforms, or review PRs and issues for those platforms. On March 28th I responded to her email as follows: > Hey, thanks for responding. > > In the meanwhile, there are still a few loose ends from your time as > maintainer that I'd like to get cleaned up. It's okay if you aren't > going to be spending much time on Winit, but there's still a broad > assumption that you're able to review PRs for them and that doesn't seem > to be the case. Would you be able to do a couple things to ease the > transition to whoever next takes over the macOS, X11, and Android > backends? > 1) Submit a PR downgrading yourself from maintainer for macOS, X11, and > Android, so somebody else can more actively take them over. > 2) Post your WIP macOS backend for EL2.0 as well as the issues it > currently has, so whoever next maintains macOS can finish it. > Going forward, I'd like to reach out to the broader Rust community and > find more active maintainers so Winit can get to 1.0 and I can mostly > move on from it. I recieved no response to that email. On April 4th, I followed up on that email: > If you aren't able to act as a maintainer for Winit, and aren't able to > submit a PR updating your official status as maintainer to reflect > reality, would you mind if I submitted a PR removing you as maintainer? > That's not something I want to do since it's a bad image for me, a bad > image for Winit, and sets an extremely uncomfortable precedent, but I'd > like to start more aggressive outreach to ensure each backend is less > dependent on one specific person and I don't want to see new > contributors pinging you for help when you're unable to provide it. > If you don't reply by the 11th that's the path I'm going to take, but I > consider it the nuclear option and I want to avoid invoking it if at all > possible. Up to this date (April 13th), I have recieved no response. Given the amount of time I've given her to respond, as well as her lack of response, I believe we have the justification to remove her from the table. Should she show back up again, any clarifications on her status would be welcome, and she is welcome to submit a PR re-listing herself on the table with a more accurate description of her current contributor status. However, once we begin the contributor marketing push discussed in #830, I don't want new contributors to attempt to ask her questions on the macOS, X11, or Android backends when she isn't able to give a response. ----------------------------------------------------------------------- This PR also introduces HALL_OF_CHAMPIONS.md, which commends the efforts of former maintainers that have contributed greatly to the Winit project. This wasn't discussed previously, but I think it's important to recognize the people that brought us to where we are today. It currently lists @tomaka and @francesca64, as they are the two individuals I'm aware of that both deserve such recognition and no longer actively contribute to Winit, but if there's anybody I missed feel free to suggest them and a blurb describing their work. --- CONTRIBUTING.md | 19 +++++++++---------- HALL_OF_CHAMPIONS.md | 11 +++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 HALL_OF_CHAMPIONS.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db0986a0..a8a0c783 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,15 +41,14 @@ backends of winit. As such, depending on your platform of interest, your contact This table summarizes who can be contacted in which case, with the following legend: -- `M`: is a main maintainer for this platform -- `R`: can review code for this platform -- `T`: has the ability of testing the platform +- `M` - Maintainer: is a main maintainer for this platform +- `C` - Collaborator: can review code and address issues on this platform +- `T` - Tester: has the ability of testing the platform - ` `: knows nothing of this platform -| Platform | Windows | macOS | X11 | Wayland | Android | iOS | Emscripten | -| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | -| @francesca64 | R | M | M | | M | R | | -| @mitchmindtree | T | | T | T | | | | -| @Osspial | M | | T | T | T | | T | -| @vberger | | | T | M | | | | -| @mtak- | | T | | | T | M | | +| Platform | Windows | macOS | X11 | Wayland | Android | iOS | Emscripten | +| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| @mitchmindtree | T | | T | T | | | | +| @Osspial | M | | T | T | T | | T | +| @vberger | | | T | M | | | | +| @mtak- | | T | | | T | M | | diff --git a/HALL_OF_CHAMPIONS.md b/HALL_OF_CHAMPIONS.md new file mode 100644 index 00000000..c3427514 --- /dev/null +++ b/HALL_OF_CHAMPIONS.md @@ -0,0 +1,11 @@ +# Hall of Champions + +The Winit maintainers would like to recognize the following former Winit +contributors, without whom Winit would not exist in its current form. We thank +them deeply for their time and efforts, and wish them best of luck in their +future endeavors: + +* @tomaka: For creating the Winit project and guiding it through its early + years of existence. +* @francesca64: For taking over the responsibility of maintaining almost every + Winit backend, and standardizing HiDPI support across all of them From 8f6e80917f22b9b4fbd5899825a620567f58e567 Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Thu, 25 Apr 2019 04:56:40 +0200 Subject: [PATCH 5/7] Popup windows are also known as modal windows (#848) --- FEATURES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FEATURES.md b/FEATURES.md index 84344e1d..515ff597 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -85,7 +85,7 @@ If your PR makes notable changes to Winit's features, please update this section - **Fullscreen toggle**: The windows created by winit can be switched to and from fullscreen after creation. - **HiDPI support**: Winit assists developers in appropriately scaling HiDPI content. -- **Popup windows**: Windows can be created relative to the client area of other windows, and parent +- **Popup / modal windows**: Windows can be created relative to the client area of other windows, and parent windows can be disabled in favor of popup windows. This feature also guarantees that popup windows get drawn above their owner. From fa99b9ff5aaab70ffaf5b64d43db9ca0e8eb5632 Mon Sep 17 00:00:00 2001 From: Osspial Date: Thu, 25 Apr 2019 01:20:54 -0400 Subject: [PATCH 6/7] Fix CI links in README.md (#852) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 717d7dac..bc4b6971 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![](http://meritbadge.herokuapp.com/winit)](https://crates.io/crates/winit) [![Docs.rs](https://docs.rs/winit/badge.svg)](https://docs.rs/winit) -[![Build Status](https://travis-ci.org/tomaka/winit.svg?branch=master)](https://travis-ci.org/tomaka/winit) -[![Build status](https://ci.appveyor.com/api/projects/status/5h87hj0g4q2xe3j9/branch/master?svg=true)](https://ci.appveyor.com/project/tomaka/winit/branch/master) +[![Build Status](https://travis-ci.org/rust-windowing/winit.svg?branch=master)](https://travis-ci.org/rust-windowing/winit) +[![Build status](https://ci.appveyor.com/api/projects/status/hr89but4x1n3dphq/branch/master?svg=true)](https://ci.appveyor.com/project/Osspial/winit/branch/master) ```toml [dependencies] From 062e0e52ee3fc34549729870973aecd702e05b7e Mon Sep 17 00:00:00 2001 From: acheronfail Date: Fri, 26 Apr 2019 03:09:32 +1000 Subject: [PATCH 7/7] Feat/fullscreen getters (#838) * feat: [macos] add get_fullscreen and get_simple_fullscreen * feat: [windows] add get_fullscreen * feat: [ios] add get_fullscreen * feat: [android] add get_fullscreen * feat: [emscripten] add get_fullscreen * feat: [linux] add get_fullscreen * feedback: `get_fullscreen() -> bool` -> `get_fullscreen() -> Option` --- examples/fullscreen.rs | 9 +++++++++ src/platform/macos.rs | 8 ++++++++ src/platform_impl/android/mod.rs | 7 +++++++ src/platform_impl/emscripten/mod.rs | 5 +++++ src/platform_impl/ios/mod.rs | 7 +++++++ src/platform_impl/linux/mod.rs | 9 +++++++++ src/platform_impl/linux/wayland/window.rs | 22 +++++++++++++++++++--- src/platform_impl/linux/x11/window.rs | 7 +++++++ src/platform_impl/macos/window.rs | 13 +++++++++++++ src/platform_impl/windows/window.rs | 6 ++++++ src/window.rs | 6 ++++++ 11 files changed, 96 insertions(+), 3 deletions(-) diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index 788a608c..3fd96033 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -86,6 +86,15 @@ fn main() { window.set_fullscreen(Some(window.get_current_monitor())); } } + (VirtualKeyCode::S, ElementState::Pressed) => { + println!("window.get_fullscreen {:?}", window.get_fullscreen()); + + #[cfg(target_os = "macos")] + { + use winit::os::macos::WindowExt; + println!("window.get_simple_fullscreen {:?}", WindowExt::get_simple_fullscreen(&window)); + } + } (VirtualKeyCode::M, ElementState::Pressed) => { is_maximized = !is_maximized; window.set_maximized(is_maximized); diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 8997e3b2..bb312b23 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -23,6 +23,9 @@ pub trait WindowExtMacOS { /// - `true`: the dock icon will bounce until the application is focused. fn request_user_attention(&self, is_critical: bool); + /// Returns whether or not the window is in simple fullscreen mode. + fn get_simple_fullscreen(&self) -> bool; + /// Toggles a fullscreen mode that doesn't require a new macOS space. /// Returns a boolean indicating whether the transition was successful (this /// won't work if the window was already in the native fullscreen). @@ -49,6 +52,11 @@ impl WindowExtMacOS for Window { self.window.request_user_attention(is_critical) } + #[inline] + fn get_simple_fullscreen(&self) -> bool { + self.window.get_simple_fullscreen() + } + #[inline] fn set_simple_fullscreen(&self, fullscreen: bool) -> bool { self.window.set_simple_fullscreen(fullscreen) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index a6c69250..8cad3426 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -368,6 +368,13 @@ impl Window { // Android has single screen maximized apps so nothing to do } + #[inline] + pub fn get_fullscreen(&self) -> Option { + // N/A + // Android has single screen maximized apps so nothing to do + None + } + #[inline] pub fn set_fullscreen(&self, _monitor: Option) { // N/A diff --git a/src/platform_impl/emscripten/mod.rs b/src/platform_impl/emscripten/mod.rs index 571d6b45..95baa7f8 100644 --- a/src/platform_impl/emscripten/mod.rs +++ b/src/platform_impl/emscripten/mod.rs @@ -580,6 +580,11 @@ impl Window { // iOS has single screen maximized apps so nothing to do } + #[inline] + pub fn get_fullscreen(&self) -> Option<::MonitorHandle> { + None + } + #[inline] pub fn set_fullscreen(&self, _monitor: Option<::MonitorHandle>) { // iOS has single screen maximized apps so nothing to do diff --git a/src/platform_impl/ios/mod.rs b/src/platform_impl/ios/mod.rs index da41d15d..ed8d74ba 100644 --- a/src/platform_impl/ios/mod.rs +++ b/src/platform_impl/ios/mod.rs @@ -473,6 +473,13 @@ impl Window { // iOS has single screen maximized apps so nothing to do } + #[inline] + pub fn get_fullscreen(&self) -> Option { + // N/A + // iOS has single screen maximized apps so nothing to do + None + } + #[inline] pub fn set_fullscreen(&self, _monitor: Option) { // N/A diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs index ef79e662..b609a4bc 100644 --- a/src/platform_impl/linux/mod.rs +++ b/src/platform_impl/linux/mod.rs @@ -297,6 +297,15 @@ impl Window { } } + #[inline] + pub fn get_fullscreen(&self) -> Option { + match self { + &Window::X(ref w) => w.get_fullscreen(), + &Window::Wayland(ref w) => w.get_fullscreen() + .map(|monitor_id| RootMonitorHandle { inner: MonitorHandle::Wayland(monitor_id) }) + } + } + #[inline] pub fn set_fullscreen(&self, monitor: Option) { match self { diff --git a/src/platform_impl/linux/wayland/window.rs b/src/platform_impl/linux/wayland/window.rs index 622b3f8d..15f0341c 100644 --- a/src/platform_impl/linux/wayland/window.rs +++ b/src/platform_impl/linux/wayland/window.rs @@ -7,7 +7,7 @@ use monitor::MonitorHandle as RootMonitorHandle; use window::{CreationError, WindowAttributes, MouseCursor}; use sctk::surface::{get_dpi_factor, get_outputs}; -use sctk::window::{ConceptFrame, Event as WEvent, Window as SWindow, Theme}; +use sctk::window::{ConceptFrame, Event as WEvent, State as WState, Window as SWindow, Theme}; use sctk::reexports::client::Display; use sctk::reexports::client::protocol::{wl_seat, wl_surface}; use sctk::output::OutputMgr; @@ -23,7 +23,8 @@ pub struct Window { kill_switch: (Arc>, Arc>), display: Arc, need_frame_refresh: Arc>, - need_refresh: Arc> + need_refresh: Arc>, + fullscreen: Arc>, } impl Window { @@ -31,6 +32,7 @@ impl Window { let (width, height) = attributes.dimensions.map(Into::into).unwrap_or((800, 600)); // Create the window let size = Arc::new(Mutex::new((width, height))); + let fullscreen = Arc::new(Mutex::new(false)); let window_store = evlp.store.clone(); let surface = evlp.env.create_surface(move |dpi, surface| { @@ -45,12 +47,15 @@ impl Window { surface.clone(), (width, height), move |event| match event { - WEvent::Configure { new_size, .. } => { + WEvent::Configure { new_size, states } => { let mut store = window_store.lock().unwrap(); + let is_fullscreen = states.contains(&WState::Fullscreen); + for window in &mut store.windows { if window.surface.as_ref().equals(&my_surface.as_ref()) { window.newsize = new_size; *(window.need_refresh.lock().unwrap()) = true; + *(window.fullscreen.lock().unwrap()) = is_fullscreen; *(window.need_frame_refresh.lock().unwrap()) = true; return; } @@ -117,6 +122,7 @@ impl Window { newsize: None, size: size.clone(), need_refresh: need_refresh.clone(), + fullscreen: fullscreen.clone(), need_frame_refresh: need_frame_refresh.clone(), surface: surface.clone(), kill_switch: kill_switch.clone(), @@ -135,6 +141,7 @@ impl Window { kill_switch: (kill_switch, evlp.cleanup_needed.clone()), need_frame_refresh, need_refresh, + fullscreen, }) } @@ -230,6 +237,14 @@ impl Window { } } + pub fn get_fullscreen(&self) -> Option { + if *(self.fullscreen.lock().unwrap()) { + Some(self.get_current_monitor()) + } else { + None + } + } + pub fn set_fullscreen(&self, monitor: Option) { if let Some(RootMonitorHandle { inner: PlatformMonitorHandle::Wayland(ref monitor_id), @@ -310,6 +325,7 @@ struct InternalWindow { newsize: Option<(u32, u32)>, size: Arc>, need_refresh: Arc>, + fullscreen: Arc>, need_frame_refresh: Arc>, closed: bool, kill_switch: Arc>, diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index 146fe8ff..c205018a 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -38,6 +38,7 @@ pub struct SharedState { pub guessed_dpi: Option, pub last_monitor: Option, pub dpi_adjusted: Option<(f64, f64)>, + pub fullscreen: Option, // Used to restore position after exiting fullscreen. pub restore_position: Option<(i32, i32)>, pub frame_extents: Option, @@ -536,8 +537,14 @@ impl UnownedWindow { } } + #[inline] + pub fn get_fullscreen(&self) -> Option { + self.shared_state.lock().fullscreen.clone() + } + #[inline] pub fn set_fullscreen(&self, monitor: Option) { + self.shared_state.lock().fullscreen = monitor.clone(); self.set_fullscreen_inner(monitor) .flush() .expect("Failed to change window fullscreen state"); diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 34edc551..00c7ab69 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -618,6 +618,11 @@ impl WindowExt for Window2 { } } + #[inline] + fn get_simple_fullscreen(&self) -> bool { + self.delegate.state.is_simple_fullscreen.get() + } + #[inline] fn set_simple_fullscreen(&self, fullscreen: bool) -> bool { let state = &self.delegate.state; @@ -1137,6 +1142,14 @@ impl Window2 { self.delegate.state.perform_maximized(maximized) } + #[inline] + pub fn get_fullscreen(&self) -> Option { + let state = &self.delegate.state; + let win_attribs = state.win_attribs.borrow(); + + win_attribs.fullscreen.clone() + } + #[inline] /// TODO: Right now set_fullscreen do not work on switching monitors /// in fullscreen mode diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 7fe74c32..555955bb 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -399,6 +399,12 @@ impl Window { }); } + #[inline] + pub fn get_fullscreen(&self) -> Option { + let window_state = self.window_state.lock(); + window_state.fullscreen.clone() + } + #[inline] pub fn set_fullscreen(&self, monitor: Option) { unsafe { diff --git a/src/window.rs b/src/window.rs index d837f3cb..0bc9c08b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -536,6 +536,12 @@ impl Window { self.window.set_fullscreen(monitor) } + /// Gets the window's current fullscreen state. + #[inline] + pub fn get_fullscreen(&self) -> Option { + self.window.get_fullscreen() + } + /// Turn window decorations on or off. #[inline] pub fn set_decorations(&self, decorations: bool) {