Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Move error and dpi types into a separate crate + split out x11 symbol loading code + xinerama & multihead support #1298

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@ jobs:
Check_Formatting:
runs-on: ubuntu-latest
steps:

# FIXME
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_interface
path: glutin_interface
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_x11_sym
path: glutin_x11_sym
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/winit_types
path: winit_types
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_sys
path: glutin_sys
ref: master

- uses: actions/checkout@v1
- uses: hecrj/setup-rust-action@v1
with:
Expand Down Expand Up @@ -54,6 +77,29 @@ jobs:

runs-on: ${{ matrix.platform.os }}
steps:

# FIXME
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_interface
path: glutin_interface
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_x11_sym
path: glutin_x11_sym
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/winit_types
path: winit_types
ref: master
- uses: actions/checkout@v1
with:
repository: rust-windowing/glutin_sys
path: glutin_sys
ref: master

- uses: actions/checkout@v1
# Used to cache cargo-web
- name: Cache cargo folder
Expand Down Expand Up @@ -95,12 +141,12 @@ jobs:

- name: Build with serde enabled
shell: bash
run: cargo $WEB build --verbose --target ${{ matrix.platform.target }} --features serde,$FEATURES
run: cargo $WEB build --verbose --target ${{ matrix.platform.target }} --features serde_feature,$FEATURES

- name: Build tests with serde enabled
shell: bash
run: cargo $WEB test --no-run --verbose --target ${{ matrix.platform.target }} --features serde,$FEATURES
run: cargo $WEB test --no-run --verbose --target ${{ matrix.platform.target }} --features serde_feature,$FEATURES
- name: Run tests with serde enabled
shell: bash
if: (!contains(matrix.platform.target, 'ios') && !contains(matrix.platform.target, 'wasm32'))
run: cargo $WEB test --verbose --target ${{ matrix.platform.target }} --features serde,$FEATURES
run: cargo $WEB test --verbose --target ${{ matrix.platform.target }} --features serde_feature,$FEATURES
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

- On Wayland, fix coordinates in touch events when scale factor isn't 1.
- On Wayland, fix color from `close_button_icon_color` not applying.
- **Breaking:** Renamed `serde` feature to `serde_feature`.
- **Breaking:** On X11, the function `xlib_screen_id` was renamed to `xlib_screen`. Also added `x11_screen` to `MonitorHandle`. `MonitorHandle`'s `native_id` now returns an `Option`.
- **Breaking:** The types in `winit::dpi` and `winit::error` have been moved to the new `winit_types` crate.
- **Breaking:** Unified all functions to return the same error type, `winit_types::error::Error`.
- Winit's panic and log messages now begin with "[winit]" as to help distinguish them from glutin's.
- **Breaking:** `Window::set_fullscreen` now returns an `Result<(), Error>` instead of panicking or doing nothing silently.
- On X11, if the RandR extension is not present, winit will no longer panic. Instead it will return the list of X11 screens, augmenting it with information from Xinerama if present.

# 0.21.0 (2020-02-04)

Expand Down
58 changes: 31 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,48 @@ documentation = "https://docs.rs/winit"
categories = ["gui"]

[package.metadata.docs.rs]
features = ["serde"]
features = ["serde_feature"]

[features]
web-sys = ["web_sys", "wasm-bindgen", "instant/wasm-bindgen"]
stdweb = ["std_web", "instant/stdweb"]
serde_feature = ["winit_types/serde_feature", "serde"]

[dependencies]
instant = "0.1"
lazy_static = "1"
libc = "0.2.64"
log = "0.4"
serde = { version = "1", optional = true, features = ["serde_derive"] }
raw-window-handle = "0.3"
bitflags = "1"
instant = "0.1.2"
lazy_static = "1.4.0"
libc = "0.2.66"
log = "0.4.8"
serde = { version = "1.0.104", optional = true, features = ["serde_derive"] }
raw-window-handle = "0.3.3"
winit_types = { version = "0.1.0", path = "../winit_types" }
glutin_interface = { version = "0.1.0", path = "../glutin_interface" }
bitflags = "1.2.1"

[dev-dependencies]
image = "0.21"
simple_logger = "1"
image = "0.22.4"
simple_logger = "1.4.0"

[target.'cfg(target_os = "android")'.dependencies.android_glue]
version = "0.2"
[target.'cfg(target_os = "android")'.dependencies]
android_glue = "0.2.3"

[target.'cfg(target_os = "ios")'.dependencies]
objc = "0.2.3"
objc = "0.2.7"

[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.19.1"
core-foundation = "0.6"
core-graphics = "0.17.3"
cocoa = "0.20.0"
core-foundation = "0.7.0"
core-graphics = "0.19.0"
dispatch = "0.2.0"
objc = "0.2.6"
objc = "0.2.7"

[target.'cfg(target_os = "macos")'.dependencies.core-video-sys]
version = "0.1.3"
default_features = false
features = ["display_link"]

[target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3.6"
version = "0.3.8"
features = [
"combaseapi",
"commctrl",
Expand All @@ -75,14 +78,15 @@ features = [

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies]
wayland-client = { version = "0.23.0", features = [ "dlopen", "egl", "cursor", "eventloop"] }
mio = "0.6"
mio-extras = "2.0"
smithay-client-toolkit = "0.6"
x11-dl = "2.18.3"
percent-encoding = "2.0"
mio = "0.6.21"
mio-extras = "2.0.6"
smithay-client-toolkit = "0.6.4"
glutin_x11_sym = { version = "0.1.0", path = "../glutin_x11_sym" }
percent-encoding = "2.1.0"
x11-dl = "2.18.4"

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "windows"))'.dependencies.parking_lot]
version = "0.10"
[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "windows"))'.dependencies]
parking_lot = "0.10.0"

[target.'cfg(target_arch = "wasm32")'.dependencies.web_sys]
package = "web-sys"
Expand All @@ -109,7 +113,7 @@ features = [
]

[target.'cfg(target_arch = "wasm32")'.dependencies.wasm-bindgen]
version = "0.2.45"
version = "0.2.58"
optional = true

[target.'cfg(target_arch = "wasm32")'.dependencies.std_web]
Expand All @@ -119,4 +123,4 @@ optional = true
features = ["experimental_features_which_may_break_on_minor_version_bumps"]

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
console_log = "0.1"
console_log = "0.1.2"
2 changes: 1 addition & 1 deletion FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ If your PR makes notable changes to Winit's features, please update this section
* Getting the preferred video mode

## Usability
* `serde`: Enables serialization/deserialization of certain types with Serde. (Maintainer: @Osspial)
* `serde_feature`: Enables serialization/deserialization of certain types with Serde. (Maintainer: @Osspial)

## Compatibility Matrix

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Winit is only officially supported on the latest stable version of the Rust comp
### Cargo Features

Winit provides the following features, which can be enabled in your `Cargo.toml` file:
* `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).
* `serde_feature`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).

### Platform-specific usage

Expand Down
2 changes: 1 addition & 1 deletion examples/custom_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ fn main() {

#[cfg(target_arch = "wasm32")]
fn main() {
panic!("This example is not supported on web.");
panic!("[winit] This example is not supported on web.");
}
6 changes: 3 additions & 3 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
let fullscreen = Some(match num {
1 => Fullscreen::Exclusive(prompt_for_video_mode(&prompt_for_monitor(&event_loop))),
2 => Fullscreen::Borderless(prompt_for_monitor(&event_loop)),
_ => panic!("Please enter a valid number"),
_ => panic!("[winit] Please enter a valid number"),
});

let mut is_maximized = false;
Expand Down Expand Up @@ -48,9 +48,9 @@ fn main() {
(VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit,
(VirtualKeyCode::F, ElementState::Pressed) => {
if window.fullscreen().is_some() {
window.set_fullscreen(None);
window.set_fullscreen(None).unwrap();
} else {
window.set_fullscreen(fullscreen.clone());
window.set_fullscreen(fullscreen.clone()).unwrap();
}
}
(VirtualKeyCode::S, ElementState::Pressed) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/min_max_size.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use winit::{
dpi::LogicalSize,
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use winit_types::dpi::LogicalSize;

fn main() {
simple_logger::init().unwrap();
Expand Down
24 changes: 13 additions & 11 deletions examples/multithreaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ fn main() {
use std::{collections::HashMap, sync::mpsc, thread, time::Duration};

use winit::{
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::{CursorIcon, Fullscreen, WindowBuilder},
};
use winit_types::dpi::{PhysicalPosition, PhysicalSize, Position, Size};

const WINDOW_COUNT: usize = 3;
const WINDOW_SIZE: PhysicalSize<u32> = PhysicalSize::new(600, 400);
Expand Down Expand Up @@ -81,15 +81,17 @@ fn main() {
video_modes.iter().nth(video_mode_id).unwrap()
);
}
F => window.set_fullscreen(match (state, modifiers.alt()) {
(true, false) => {
Some(Fullscreen::Borderless(window.current_monitor()))
}
(true, true) => Some(Fullscreen::Exclusive(
video_modes.iter().nth(video_mode_id).unwrap().clone(),
)),
(false, _) => None,
}),
F => window
.set_fullscreen(match (state, modifiers.alt()) {
(true, false) => {
Some(Fullscreen::Borderless(window.current_monitor()))
}
(true, true) => Some(Fullscreen::Exclusive(
video_modes.iter().nth(video_mode_id).unwrap().clone(),
)),
(false, _) => None,
})
.unwrap(),
G => window.set_cursor_grab(state).unwrap(),
H => window.set_cursor_visible(!state),
I => {
Expand Down Expand Up @@ -181,5 +183,5 @@ fn main() {

#[cfg(target_arch = "wasm32")]
fn main() {
panic!("Example not supported on Wasm");
panic!("[winit] Example not supported on Wasm");
}
2 changes: 1 addition & 1 deletion examples/resizable.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use winit::{
dpi::LogicalSize,
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use winit_types::dpi::LogicalSize;

fn main() {
simple_logger::init().unwrap();
Expand Down
3 changes: 2 additions & 1 deletion examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use winit::{
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
use winit_types::dpi::LogicalSize;

fn main() {
simple_logger::init().unwrap();
let event_loop = EventLoop::new();

let window = WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.with_inner_size(LogicalSize::new(128.0, 128.0))
.build(&event_loop)
.unwrap();

Expand Down
12 changes: 8 additions & 4 deletions examples/window_debug.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This example is used by developers to test various window functions.

use winit::{
dpi::{LogicalSize, PhysicalSize},
event::{DeviceEvent, ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::{Fullscreen, WindowBuilder},
};
use winit_types::dpi::{LogicalSize, PhysicalSize};

fn main() {
simple_logger::init().unwrap();
Expand Down Expand Up @@ -75,17 +75,21 @@ fn main() {
.video_modes()
.max_by(|a, b| area(a.size()).cmp(&area(b.size())))
{
window.set_fullscreen(Some(Fullscreen::Exclusive(mode)));
window
.set_fullscreen(Some(Fullscreen::Exclusive(mode)))
.unwrap();
} else {
eprintln!("no video modes available");
}
}
VirtualKeyCode::F => {
if window.fullscreen().is_some() {
window.set_fullscreen(None);
window.set_fullscreen(None).unwrap();
} else {
let monitor = window.current_monitor();
window.set_fullscreen(Some(Fullscreen::Borderless(monitor)));
window
.set_fullscreen(Some(Fullscreen::Borderless(monitor)))
.unwrap();
}
}
VirtualKeyCode::M => {
Expand Down
2 changes: 1 addition & 1 deletion examples/window_icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn load_icon(path: &Path) -> Icon {
let (width, height) = image.dimensions();
let mut rgba = Vec::with_capacity((width * height) as usize * 4);
for (_, _, pixel) in image.pixels() {
rgba.extend_from_slice(&pixel.to_rgba().data);
rgba.extend_from_slice(&pixel.to_rgba().0);
}
(rgba, width, height)
};
Expand Down
Loading