mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Make Servo components use winapi 0.3
This commit is contained in:
parent
bd0b191d84
commit
600ce022dd
5 changed files with 8 additions and 34 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -1241,15 +1241,6 @@ dependencies = [
|
||||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gdi32-sys"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -3469,7 +3460,6 @@ dependencies = [
|
||||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam-channel 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-channel 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.19.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"keyboard-types 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3480,8 +3470,7 @@ dependencies = [
|
||||||
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winit 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winit 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3604,7 +3593,7 @@ name = "servo_allocator"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jemalloc-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4395,15 +4384,6 @@ dependencies = [
|
||||||
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "user32-sys"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utf-8"
|
name = "utf-8"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
@ -4951,7 +4931,6 @@ dependencies = [
|
||||||
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
|
||||||
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||||
"checksum gaol 0.2.0 (git+https://github.com/servo/gaol)" = "<none>"
|
"checksum gaol 0.2.0 (git+https://github.com/servo/gaol)" = "<none>"
|
||||||
"checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518"
|
|
||||||
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
|
"checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d"
|
||||||
"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05"
|
"checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05"
|
||||||
"checksum gif 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3414b424657317e708489d2857d9575f4403698428b040b609b9d1c1a84a2c"
|
"checksum gif 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3414b424657317e708489d2857d9575f4403698428b040b609b9d1c1a84a2c"
|
||||||
|
@ -5192,7 +5171,6 @@ dependencies = [
|
||||||
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||||
"checksum url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a321979c09843d272956e73700d12c4e7d3d92b2ee112b31548aef0d4efc5a6"
|
"checksum url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a321979c09843d272956e73700d12c4e7d3d92b2ee112b31548aef0d4efc5a6"
|
||||||
"checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea"
|
"checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea"
|
||||||
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
|
|
||||||
"checksum utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f923c601c7ac48ef1d66f7d5b5b2d9a7ba9c51333ab75a3ddf8d0309185a56"
|
"checksum utf-8 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f923c601c7ac48ef1d66f7d5b5b2d9a7ba9c51333ab75a3ddf8d0309185a56"
|
||||||
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
|
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
|
||||||
"checksum uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dab5c5526c5caa3d106653401a267fed923e7046f35895ffcb5ca42db64942e6"
|
"checksum uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dab5c5526c5caa3d106653401a267fed923e7046f35895ffcb5ca42db64942e6"
|
||||||
|
|
|
@ -13,4 +13,4 @@ path = "lib.rs"
|
||||||
jemalloc-sys = { version = "0.1.4" }
|
jemalloc-sys = { version = "0.1.4" }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
kernel32-sys = { version = "0.2.1" }
|
winapi = { version = "0.3", features = ["heapapi"] }
|
||||||
|
|
|
@ -98,9 +98,9 @@ mod platform {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod platform {
|
mod platform {
|
||||||
use kernel32::{GetProcessHeap, HeapSize, HeapValidate};
|
|
||||||
pub use std::alloc::System as Allocator;
|
pub use std::alloc::System as Allocator;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
use winapi::um::heapapi::{GetProcessHeap, HeapSize, HeapValidate};
|
||||||
|
|
||||||
/// Get the size of a heap block.
|
/// Get the size of a heap block.
|
||||||
pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize {
|
pub unsafe extern "C" fn usable_size(mut ptr: *const c_void) -> usize {
|
||||||
|
|
|
@ -60,9 +60,7 @@ osmesa-sys = "0.1.2"
|
||||||
x11 = "2.0.0"
|
x11 = "2.0.0"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = "0.2"
|
winapi = { version = "0.3", features = ["wingdi", "winuser"] }
|
||||||
user32-sys = "0.2"
|
|
||||||
gdi32-sys = "0.2"
|
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "macos", all(target_arch = "x86_64", target_os = "linux")))'.dependencies]
|
[target.'cfg(any(target_os = "macos", all(target_arch = "x86_64", target_os = "linux")))'.dependencies]
|
||||||
osmesa-src = {git = "https://github.com/servo/osmesa-src"}
|
osmesa-src = {git = "https://github.com/servo/osmesa-src"}
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
//! A windowing implementation using winit.
|
//! A windowing implementation using winit.
|
||||||
|
|
||||||
use euclid::{TypedPoint2D, TypedVector2D, TypedScale, TypedSize2D};
|
use euclid::{TypedPoint2D, TypedVector2D, TypedScale, TypedSize2D};
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use gdi32;
|
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
use glutin::{Api, ContextBuilder, GlContext, GlRequest, GlWindow};
|
use glutin::{Api, ContextBuilder, GlContext, GlRequest, GlWindow};
|
||||||
use keyboard_types::{Key, KeyboardEvent, KeyState};
|
use keyboard_types::{Key, KeyboardEvent, KeyState};
|
||||||
|
@ -31,7 +29,7 @@ use std::thread;
|
||||||
use std::time;
|
use std::time;
|
||||||
use super::keyutils::keyboard_event_from_winit;
|
use super::keyutils::keyboard_event_from_winit;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use user32;
|
use winapi;
|
||||||
use winit::{ElementState, Event, MouseButton, MouseScrollDelta, TouchPhase, KeyboardInput};
|
use winit::{ElementState, Event, MouseButton, MouseScrollDelta, TouchPhase, KeyboardInput};
|
||||||
use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -159,8 +157,8 @@ fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, Dev
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||||
let hdc = unsafe { user32::GetDC(::std::ptr::null_mut()) };
|
let hdc = unsafe { winapi::um::winuser::GetDC(::std::ptr::null_mut()) };
|
||||||
let ppi = unsafe { gdi32::GetDeviceCaps(hdc, winapi::wingdi::LOGPIXELSY) };
|
let ppi = unsafe { winapi::um::wingdi::GetDeviceCaps(hdc, winapi::um::wingdi::LOGPIXELSY) };
|
||||||
TypedScale::new(ppi as f32 / 96.0)
|
TypedScale::new(ppi as f32 / 96.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue