Skip to content

Commit 9a1756d

Browse files
chrisduerrgoddessfreya
authored andcommitted
Fix build failure (rust-windowing#1164)
* Fix build failure This updates glutin to the latest winit commit to resolve all build failures which occured because of name changes. It also locks winit to a fixed revision, so things can be updated in a more controlled manner. * Fix desktop build failure * Fix macos build
1 parent af95c25 commit 9a1756d

File tree

14 files changed

+43
-41
lines changed

14 files changed

+43
-41
lines changed

glutin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ serde = ["winit/serde"]
1919
[dependencies]
2020
lazy_static = "1.3"
2121
#winit = "^0.19.1"
22-
winit = { git = "https://github.com/rust-windowing/winit.git", branch = "eventloop-2.0"}
22+
winit = { git = "https://github.com/rust-windowing/winit.git", rev = "0eefa3b" }
2323

2424
[target.'cfg(target_os = "android")'.dependencies]
2525
android_glue = "0.2"

glutin/src/api/ios/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl Context {
205205
let win = builder.build(el)?;
206206
let context = unsafe {
207207
let eagl_context = Context::create_context(version)?;
208-
let view = win.get_uiview() as ffi::id;
208+
let view = win.uiview() as ffi::id;
209209
let mut context = Context { eagl_context, view };
210210
context.init_context(&win);
211211
context
@@ -222,7 +222,7 @@ impl Context {
222222
) -> Result<Self, CreationError> {
223223
let wb = winit::window::WindowBuilder::new()
224224
.with_visibility(false)
225-
.with_dimensions(size.to_logical(1.));
225+
.with_inner_size(size.to_logical(1.));
226226
Self::new_windowed(wb, el, pf_reqs, gl_attr)
227227
.map(|(_window, context)| context)
228228
}
@@ -270,7 +270,7 @@ impl Context {
270270
self.make_current().unwrap();
271271

272272
let view = self.view;
273-
let scale_factor = win.get_hidpi_factor() as ffi::CGFloat;
273+
let scale_factor = win.hidpi_factor() as ffi::CGFloat;
274274
let _: () = msg_send![view, setContentScaleFactor: scale_factor];
275275
let layer: ffi::id = msg_send![view, layer];
276276
let _: () = msg_send![layer, setContentsScale: scale_factor];

glutin/src/lib.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! let el = glutin::event_loop::EventLoop::new();
1616
//! let wb = glutin::window::WindowBuilder::new()
1717
//! .with_title("Hello world!")
18-
//! .with_dimensions(glutin::dpi::LogicalSize::new(1024.0, 768.0));
18+
//! .with_inner_size(glutin::dpi::LogicalSize::new(1024.0, 768.0));
1919
//! let windowed_context = glutin::ContextBuilder::new()
2020
//! .build_windowed(wb, &el)
2121
//! .unwrap();
@@ -129,6 +129,8 @@ pub use crate::context::*;
129129
pub use crate::windowed::*;
130130
pub use winit::*;
131131

132+
use winit::error::OsError;
133+
132134
use std::io;
133135

134136
/// An object that allows you to build [`Context`]s, [`RawContext<T>`]s and
@@ -322,12 +324,12 @@ impl<'a, T: ContextCurrentState> ContextBuilder<'a, T> {
322324
pub enum CreationError {
323325
OsError(String),
324326
NotSupported(String),
325-
NoBackendAvailable(Box<std::error::Error + Send + Sync>),
327+
NoBackendAvailable(Box<dyn std::error::Error + Send + Sync>),
326328
RobustnessNotSupported,
327329
OpenGlVersionNotSupported,
328330
NoAvailablePixelFormat,
329331
PlatformSpecific(String),
330-
Window(window::CreationError),
332+
Window(OsError),
331333
/// We received multiple errors, instead of one.
332334
CreationErrors(Vec<Box<CreationError>>),
333335
}
@@ -402,7 +404,7 @@ impl std::error::Error for CreationError {
402404
self.to_string()
403405
}
404406

405-
fn cause(&self) -> Option<&std::error::Error> {
407+
fn cause(&self) -> Option<&dyn std::error::Error> {
406408
match *self {
407409
CreationError::NoBackendAvailable(ref err) => Some(&**err),
408410
CreationError::Window(ref err) => Some(err),
@@ -411,8 +413,8 @@ impl std::error::Error for CreationError {
411413
}
412414
}
413415

414-
impl From<window::CreationError> for CreationError {
415-
fn from(err: window::CreationError) -> Self {
416+
impl From<OsError> for CreationError {
417+
fn from(err: OsError) -> Self {
416418
CreationError::Window(err)
417419
}
418420
}

glutin/src/platform_impl/emscripten/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Context {
7979
) -> Result<Self, CreationError> {
8080
let wb = winit::window::WindowBuilder::new()
8181
.with_visibility(false)
82-
.with_dimensions(size.to_logical(1.));
82+
.with_inner_size(size.to_logical(1.));
8383

8484
Self::new_windowed(wb, el, pf_reqs, gl_attr).map(|(w, c)| match c {
8585
Context::Window(c) => Context::WindowedContext(w, c),

glutin/src/platform_impl/macos/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Context {
6969
_ => (),
7070
}
7171

72-
let view = win.get_nsview() as id;
72+
let view = win.nsview() as id;
7373

7474
let gl_profile = helpers::get_gl_profile(gl_attr, pf_reqs)?;
7575
let attributes = helpers::build_nsattributes(pf_reqs, gl_profile)?;

glutin/src/platform_impl/unix/wayland.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Context {
5252
size: Option<dpi::PhysicalSize>,
5353
) -> Result<Self, CreationError> {
5454
let gl_attr = gl_attr.clone().map_sharing(|c| &**c);
55-
let display_ptr = el.get_wayland_display().unwrap() as *const _;
55+
let display_ptr = el.wayland_display().unwrap() as *const _;
5656
let native_display =
5757
NativeDisplay::Wayland(Some(display_ptr as *const _));
5858
if let Some(size) = size {
@@ -90,12 +90,12 @@ impl Context {
9090
) -> Result<(Window, Self), CreationError> {
9191
let win = wb.build(el)?;
9292

93-
let dpi_factor = win.get_hidpi_factor();
94-
let size = win.get_inner_size().unwrap().to_physical(dpi_factor);
93+
let dpi_factor = win.hidpi_factor();
94+
let size = win.inner_size().to_physical(dpi_factor);
9595
let (width, height): (u32, u32) = size.into();
9696

97-
let display_ptr = win.get_wayland_display().unwrap() as *const _;
98-
let surface = win.get_wayland_surface();
97+
let display_ptr = win.wayland_display().unwrap() as *const _;
98+
let surface = win.wayland_surface();
9999
let surface = match surface {
100100
Some(s) => s,
101101
None => {

glutin/src/platform_impl/unix/x11.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl Context {
209209
size: Option<dpi::PhysicalSize>,
210210
fallback: bool,
211211
) -> Result<Self, CreationError> {
212-
let xconn = match el.get_xlib_xconnection() {
212+
let xconn = match el.xlib_xconnection() {
213213
Some(xconn) => xconn,
214214
None => {
215215
return Err(CreationError::NoBackendAvailable(Box::new(
@@ -466,7 +466,7 @@ impl Context {
466466
gl_attr: &GlAttributes<&Context>,
467467
fallback: bool,
468468
) -> Result<(Window, Self), CreationError> {
469-
let xconn = match el.get_xlib_xconnection() {
469+
let xconn = match el.xlib_xconnection() {
470470
Some(xconn) => xconn,
471471
None => {
472472
return Err(CreationError::NoBackendAvailable(Box::new(
@@ -510,7 +510,7 @@ impl Context {
510510
.with_x11_screen(screen_id)
511511
.build(el)?;
512512

513-
let xwin = win.get_xlib_window().unwrap();
513+
let xwin = win.xlib_window().unwrap();
514514
// finish creating the OpenGL context
515515
let context = match context {
516516
Prototype::Glx(ctx) => X11Context::Glx(ctx.finish(xwin)?),

glutin/src/platform_impl/windows/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Context {
5353
gl_attr: &GlAttributes<&Self>,
5454
) -> Result<(Window, Self), CreationError> {
5555
let win = wb.build(el)?;
56-
let hwnd = win.get_hwnd() as HWND;
56+
let hwnd = win.hwnd() as HWND;
5757
let ctx = Self::new_raw_context(hwnd, pf_reqs, gl_attr)?;
5858

5959
Ok((win, ctx))
@@ -187,7 +187,7 @@ impl Context {
187187

188188
let wb = WindowBuilder::new()
189189
.with_visibility(false)
190-
.with_dimensions(size.to_logical(1.));
190+
.with_inner_size(size.to_logical(1.));
191191
Self::new_windowed(wb, &el, pf_reqs, gl_attr).map(|(win, context)| {
192192
match context {
193193
Context::Egl(context) => Context::HiddenWindowEgl(win, context),

glutin_examples/examples/fullscreen.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn main() {
6767
Event::WindowEvent { event, .. } => match event {
6868
WindowEvent::Resized(logical_size) => {
6969
let dpi_factor =
70-
windowed_context.window().get_hidpi_factor();
70+
windowed_context.window().hidpi_factor();
7171
windowed_context
7272
.resize(logical_size.to_physical(dpi_factor));
7373
}
@@ -110,7 +110,7 @@ fn main() {
110110
windowed_context.window().set_fullscreen(None);
111111
} else {
112112
windowed_context.window().set_fullscreen(Some(
113-
windowed_context.window().get_current_monitor(),
113+
windowed_context.window().current_monitor(),
114114
));
115115
}
116116
}
@@ -133,8 +133,8 @@ fn main() {
133133

134134
// Enumerate monitors and prompt user to choose one
135135
fn prompt_for_monitor(el: &EventLoop<()>) -> MonitorHandle {
136-
for (num, monitor) in el.get_available_monitors().enumerate() {
137-
println!("Monitor #{}: {:?}", num, monitor.get_name());
136+
for (num, monitor) in el.available_monitors().enumerate() {
137+
println!("Monitor #{}: {:?}", num, monitor.name());
138138
}
139139

140140
print!("Please write the number of the monitor to use: ");
@@ -144,11 +144,11 @@ fn prompt_for_monitor(el: &EventLoop<()>) -> MonitorHandle {
144144
std::io::stdin().read_line(&mut num).unwrap();
145145
let num = num.trim().parse().ok().expect("Please enter a number");
146146
let monitor = el
147-
.get_available_monitors()
147+
.available_monitors()
148148
.nth(num)
149149
.expect("Please enter a valid ID");
150150

151-
println!("Using {:?}", monitor.get_name());
151+
println!("Using {:?}", monitor.name());
152152

153153
monitor
154154
}

glutin_examples/examples/multiwindow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
ct.get_current(windows[&window_id].0).unwrap();
3737
let windowed_context = windowed_context.windowed();
3838
let dpi_factor =
39-
windowed_context.window().get_hidpi_factor();
39+
windowed_context.window().hidpi_factor();
4040
windowed_context
4141
.resize(logical_size.to_physical(dpi_factor));
4242
}

glutin_examples/examples/raw_context.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ mod this_example {
4545

4646
if el.is_wayland() {
4747
let win = wb.build(&el).unwrap();
48-
let dpi_factor = win.get_hidpi_factor();
48+
let dpi_factor = win.hidpi_factor();
4949
let size =
50-
win.get_inner_size().unwrap().to_physical(dpi_factor);
50+
win.inner_size().to_physical(dpi_factor);
5151
let (width, height): (u32, u32) = size.into();
5252

5353
let display_ptr =
54-
win.get_wayland_display().unwrap() as *const _;
55-
let surface = win.get_wayland_surface().unwrap();
54+
win.wayland_display().unwrap() as *const _;
55+
let surface = win.wayland_surface().unwrap();
5656

5757
let raw_context = ContextBuilder::new()
5858
.build_raw_wayland_context(
@@ -85,8 +85,8 @@ File a PR if you are interested in implementing the latter.
8585
}
8686

8787
let win = wb.build(&el).unwrap();
88-
let xconn = el.get_xlib_xconnection().unwrap();
89-
let xwindow = win.get_xlib_window().unwrap();
88+
let xconn = el.xlib_xconnection().unwrap();
89+
let xwindow = win.xlib_window().unwrap();
9090
let raw_context = ContextBuilder::new()
9191
.build_raw_x11_context(xconn, xwindow)
9292
.unwrap();
@@ -102,7 +102,7 @@ File a PR if you are interested in implementing the latter.
102102
RawContextExt, WindowExtWindows,
103103
};
104104

105-
let hwnd = win.get_hwnd();
105+
let hwnd = win.hwnd();
106106
let raw_context =
107107
ContextBuilder::new().build_raw_context(hwnd).unwrap();
108108

@@ -131,7 +131,7 @@ File a PR if you are interested in implementing the latter.
131131
}
132132
Event::WindowEvent { ref event, .. } => match event {
133133
WindowEvent::Resized(logical_size) => {
134-
let dpi_factor = win.get_hidpi_factor();
134+
let dpi_factor = win.hidpi_factor();
135135
raw_context
136136
.resize(logical_size.to_physical(dpi_factor));
137137
}

glutin_examples/examples/sharing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535

3636
let wb = WindowBuilder::new()
3737
.with_title("A fantastic window!")
38-
.with_dimensions(LogicalSize::from_physical(size, 1.0));
38+
.with_inner_size(LogicalSize::from_physical(size, 1.0));
3939
let windowed_context = ContextBuilder::new()
4040
.with_shared_lists(&headless_context)
4141
.build_windowed(wb, &el)
@@ -115,7 +115,7 @@ fn main() {
115115
WindowEvent::Resized(logical_size) => {
116116
let windowed_context = ct.get_current(windowed_id).unwrap();
117117
let dpi_factor =
118-
windowed_context.windowed().window().get_hidpi_factor();
118+
windowed_context.windowed().window().hidpi_factor();
119119
size = logical_size.to_physical(dpi_factor);
120120
windowed_context.windowed().resize(size);
121121

glutin_examples/examples/transparent.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn main() {
3333
Event::WindowEvent { ref event, .. } => match event {
3434
WindowEvent::Resized(logical_size) => {
3535
let dpi_factor =
36-
windowed_context.window().get_hidpi_factor();
36+
windowed_context.window().hidpi_factor();
3737
windowed_context
3838
.resize(logical_size.to_physical(dpi_factor));
3939
}

glutin_examples/examples/window.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn main() {
3030
Event::WindowEvent { ref event, .. } => match event {
3131
WindowEvent::Resized(logical_size) => {
3232
let dpi_factor =
33-
windowed_context.window().get_hidpi_factor();
33+
windowed_context.window().hidpi_factor();
3434
windowed_context
3535
.resize(logical_size.to_physical(dpi_factor));
3636
}

0 commit comments

Comments
 (0)