mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-20 00:33:17 +00:00
Use HWND instead of HWND__
This commit is contained in:
parent
25b583ddbb
commit
a5f0d26535
2 changed files with 9 additions and 10 deletions
|
|
@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use urlencoding::decode;
|
use urlencoding::decode;
|
||||||
use webview2::Controller;
|
use webview2::Controller;
|
||||||
use winapi::shared::windef::HWND__;
|
use winapi::shared::windef::HWND;
|
||||||
use winapi::um::winuser::*;
|
use winapi::um::winuser::*;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -28,7 +28,7 @@ pub struct WebView {
|
||||||
impl WebView {
|
impl WebView {
|
||||||
fn resize_to_window_bounds_and_show(
|
fn resize_to_window_bounds_and_show(
|
||||||
controller: Option<&Controller>,
|
controller: Option<&Controller>,
|
||||||
hwnd: Option<*mut HWND__>,
|
hwnd: Option<HWND>,
|
||||||
) {
|
) {
|
||||||
if let (Some(controller), Some(hwnd)) = (controller, hwnd) {
|
if let (Some(controller), Some(hwnd)) = (controller, hwnd) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
@ -56,14 +56,13 @@ impl PartialUi for WebView {
|
||||||
|
|
||||||
let parent = parent.expect("No parent window").into();
|
let parent = parent.expect("No parent window").into();
|
||||||
|
|
||||||
let hwnd = parent.hwnd().expect("Cannot obtain window handle") as i64;
|
let hwnd = parent.hwnd().expect("Cannot obtain window handle");
|
||||||
nwg::Notice::builder()
|
nwg::Notice::builder()
|
||||||
.parent(parent)
|
.parent(parent)
|
||||||
.build(&mut data.notice)
|
.build(&mut data.notice)
|
||||||
.ok();
|
.ok();
|
||||||
let controller_clone = data.controller.clone();
|
let controller_clone = data.controller.clone();
|
||||||
let endpoint = data.endpoint.clone();
|
let endpoint = data.endpoint.clone();
|
||||||
let hwnd = hwnd as *mut HWND__;
|
|
||||||
let result = webview2::EnvironmentBuilder::new()
|
let result = webview2::EnvironmentBuilder::new()
|
||||||
.with_additional_browser_arguments("--disable-gpu --autoplay-policy=no-user-gesture-required")
|
.with_additional_browser_arguments("--disable-gpu --autoplay-policy=no-user-gesture-required")
|
||||||
.build(move |env| {
|
.build(move |env| {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{cmp, mem};
|
use std::{cmp, mem};
|
||||||
use winapi::shared::windef::HWND__;
|
use winapi::shared::windef::HWND;
|
||||||
use winapi::um::winuser::{
|
use winapi::um::winuser::{
|
||||||
GetForegroundWindow, GetSystemMetrics, GetWindowLongA, GetWindowRect, IsIconic, IsZoomed,
|
GetForegroundWindow, GetSystemMetrics, GetWindowLongA, GetWindowRect, IsIconic, IsZoomed,
|
||||||
SetWindowLongA, SetWindowPos, GWL_EXSTYLE, GWL_STYLE, HWND_NOTOPMOST, HWND_TOPMOST,
|
SetWindowLongA, SetWindowPos, GWL_EXSTYLE, GWL_STYLE, HWND_NOTOPMOST, HWND_TOPMOST,
|
||||||
|
|
@ -27,7 +27,7 @@ pub struct WindowStyle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowStyle {
|
impl WindowStyle {
|
||||||
pub fn get_window_state(self, hwnd: *mut HWND__) -> u32 {
|
pub fn get_window_state(self, hwnd: HWND) -> u32 {
|
||||||
let mut state: WindowState = WindowState::empty();
|
let mut state: WindowState = WindowState::empty();
|
||||||
if 0 != unsafe { IsIconic(hwnd) } {
|
if 0 != unsafe { IsIconic(hwnd) } {
|
||||||
state |= WindowState::MINIMIZED;
|
state |= WindowState::MINIMIZED;
|
||||||
|
|
@ -43,7 +43,7 @@ impl WindowStyle {
|
||||||
}
|
}
|
||||||
state.bits() as u32
|
state.bits() as u32
|
||||||
}
|
}
|
||||||
pub fn show_window_at(&self, hwnd: *mut HWND__, pos: *mut HWND__) {
|
pub fn show_window_at(&self, hwnd: HWND, pos: HWND) {
|
||||||
unsafe {
|
unsafe {
|
||||||
SetWindowPos(
|
SetWindowPos(
|
||||||
hwnd,
|
hwnd,
|
||||||
|
|
@ -56,7 +56,7 @@ impl WindowStyle {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn center_window(&mut self, hwnd: *mut HWND__, min_width: i32, min_height: i32) {
|
pub fn center_window(&mut self, hwnd: HWND, min_width: i32, min_height: i32) {
|
||||||
let monitor_w = unsafe { GetSystemMetrics(SM_CXSCREEN) };
|
let monitor_w = unsafe { GetSystemMetrics(SM_CXSCREEN) };
|
||||||
let monitor_h = unsafe { GetSystemMetrics(SM_CYSCREEN) };
|
let monitor_h = unsafe { GetSystemMetrics(SM_CYSCREEN) };
|
||||||
let small_side = cmp::min(monitor_w, monitor_h) * 70 / 100;
|
let small_side = cmp::min(monitor_w, monitor_h) * 70 / 100;
|
||||||
|
|
@ -67,7 +67,7 @@ impl WindowStyle {
|
||||||
self.pos = ((monitor_w - self.size.0) / 2, (monitor_h - self.size.1) / 2);
|
self.pos = ((monitor_w - self.size.0) / 2, (monitor_h - self.size.1) / 2);
|
||||||
self.show_window_at(hwnd, HWND_NOTOPMOST);
|
self.show_window_at(hwnd, HWND_NOTOPMOST);
|
||||||
}
|
}
|
||||||
pub fn toggle_full_screen(&mut self, hwnd: *mut HWND__) {
|
pub fn toggle_full_screen(&mut self, hwnd: HWND) {
|
||||||
if self.full_screen {
|
if self.full_screen {
|
||||||
let topmost = if self.ex_style as u32 & WS_EX_TOPMOST == WS_EX_TOPMOST {
|
let topmost = if self.ex_style as u32 & WS_EX_TOPMOST == WS_EX_TOPMOST {
|
||||||
HWND_TOPMOST
|
HWND_TOPMOST
|
||||||
|
|
@ -115,7 +115,7 @@ impl WindowStyle {
|
||||||
self.full_screen = true;
|
self.full_screen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn toggle_topmost(&mut self, hwnd: *mut HWND__) {
|
pub fn toggle_topmost(&mut self, hwnd: HWND) {
|
||||||
let topmost = if unsafe { GetWindowLongA(hwnd, GWL_EXSTYLE) } as u32 & WS_EX_TOPMOST
|
let topmost = if unsafe { GetWindowLongA(hwnd, GWL_EXSTYLE) } as u32 & WS_EX_TOPMOST
|
||||||
== WS_EX_TOPMOST
|
== WS_EX_TOPMOST
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue