Skip to content

Commit

Permalink
fix: 修复Linux下窗口位置偏移的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Mar 13, 2023
1 parent d4c43ae commit eee4494
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src-tauri/src/shortcut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,13 @@ fn get_mouse_location() -> Result<(i32, i32), String> {
// 获取桌面窗口的句柄
let hwnd = GetDesktopWindow();
if GetWindowRect(hwnd, &mut rect).as_bool() {
println!("{:?}", point);
println!("{:?}", rect);

if point.x + 400 > rect.right {
x = rect.right - 400;
}
if point.y + 500 > rect.bottom {
y = rect.bottom - 500;
}
}
println!("{}{}", x, y);
return Ok((x, y));
} else {
return Err("error".to_string());
Expand Down Expand Up @@ -157,7 +153,13 @@ fn translate() {
}
#[cfg(target_os = "linux")]
{
let window = builder.transparent(true).build().unwrap();
let window = builder
.transparent(true)
// x11根据inner_size这个初始值来判断窗口是否超出屏幕
// 不设置的话会有一个默认尺寸,导致窗口出现位置不对
.inner_size(400.0, 500.0)
.build()
.unwrap();
window.set_size(PhysicalSize::new(400, 500)).unwrap();
window
.set_min_size(Some(PhysicalSize::new(400, 400)))
Expand Down

0 comments on commit eee4494

Please sign in to comment.