Skip to content

Commit ceface7

Browse files
committed
Update for 0.22 glutin API changes
1 parent 132bed2 commit ceface7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ fn main2() {
229229
let (res, mut resui) = resources::Manager::new();
230230
let resource_manager = Arc::new(RwLock::new(res));
231231

232-
let mut events_loop = glutin::EventsLoop::new();
233-
let window_builder = glutin::WindowBuilder::new()
232+
let mut events_loop = glutin::event_loop::EventLoop::new();
233+
let window_builder = glutin::window::WindowBuilder::new()
234234
.with_title("Stevenarella")
235235
.with_dimensions(glutin::dpi::LogicalSize::new(854.0, 480.0));
236236
let window = glutin::ContextBuilder::new()
@@ -268,7 +268,7 @@ fn main2() {
268268
}
269269

270270
let textures = renderer.get_textures();
271-
let dpi_factor = window.window().get_current_monitor().get_hidpi_factor();
271+
let dpi_factor = window.window().current_monitor().get_hidpi_factor();
272272
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
273273
opt.default_protocol_version.unwrap_or("".to_string()));
274274
let mut game = Game {
@@ -307,8 +307,8 @@ fn main2() {
307307
let diff = now.duration_since(last_frame);
308308
last_frame = now;
309309
let delta = (diff.subsec_nanos() as f64) / frame_time;
310-
let (width, height) = window.window().get_inner_size().unwrap().into();
311-
let (physical_width, physical_height) = window.window().get_inner_size().unwrap().to_physical(game.dpi_factor).into();
310+
let (width, height) = window.window().inner_size().unwrap().into();
311+
let (physical_width, physical_height) = window.window().inner_size().unwrap().to_physical(game.dpi_factor).into();
312312

313313
let version = {
314314
let try_res = game.resource_manager.try_write();
@@ -367,8 +367,8 @@ fn main2() {
367367
fn handle_window_event(window: &mut glutin::WindowedContext<glutin::PossiblyCurrent>,
368368
game: &mut Game,
369369
ui_container: &mut ui::Container,
370-
event: glutin::Event) {
371-
use glutin::*;
370+
event: glutin::event::Event) {
371+
use glutin::event::*;
372372
match event {
373373
Event::DeviceEvent{event, ..} => match event {
374374
DeviceEvent::MouseMotion{delta:(xrel, yrel)} => {
@@ -429,7 +429,7 @@ fn handle_window_event(window: &mut glutin::WindowedContext<glutin::PossiblyCurr
429429
WindowEvent::MouseInput{device_id: _, state, button, modifiers: _} => {
430430
match (state, button) {
431431
(ElementState::Released, MouseButton::Left) => {
432-
let (width, height) = window.window().get_inner_size().unwrap().into();
432+
let (width, height) = window.window().inner_size().unwrap().into();
433433

434434
if game.server.is_connected() && !game.focused && !game.screen_sys.is_current_closable() {
435435
game.focused = true;
@@ -457,7 +457,7 @@ fn handle_window_event(window: &mut glutin::WindowedContext<glutin::PossiblyCurr
457457
game.last_mouse_y = y;
458458

459459
if !game.focused {
460-
let (width, height) = window.window().get_inner_size().unwrap().into();
460+
let (width, height) = window.window().inner_size().unwrap().into();
461461
ui_container.hover_at(game, x, y, width, height);
462462
}
463463
},
@@ -493,7 +493,7 @@ fn handle_window_event(window: &mut glutin::WindowedContext<glutin::PossiblyCurr
493493
},
494494
(ElementState::Pressed, Some(VirtualKeyCode::F11)) => {
495495
if !game.is_fullscreen {
496-
window.window().set_fullscreen(Some(window.window().get_current_monitor()));
496+
window.window().set_fullscreen(Some(window.window().current_monitor()));
497497
} else {
498498
window.window().set_fullscreen(None);
499499
}

src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::console;
22
use std::marker::PhantomData;
3-
use glutin::VirtualKeyCode;
3+
use glutin::event::VirtualKeyCode;
44
// Might just rename this to settings.rs
55

66
pub const R_MAX_FPS: console::CVar<i64> = console::CVar {

src/ui/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::rc::{Rc, Weak};
1818
use std::cell::{RefCell, RefMut};
1919
use crate::render;
2020
use crate::format;
21-
use glutin::VirtualKeyCode;
21+
use glutin::event::VirtualKeyCode;
2222
#[cfg(not(target_arch = "wasm32"))]
2323
use clipboard::{ClipboardProvider, ClipboardContext};
2424

0 commit comments

Comments
 (0)