Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix scale_factor #685

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src-tauri/src/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ pub fn screenshot(x: i32, y: i32) {
let screens = Screen::all().unwrap();
for screen in screens {
let info = screen.display_info;
let scale_factor = info.scale_factor as i32;
info!("Screen: {:?}", info);
if info.x == x && info.y == y {
if info.x * scale_factor == x && info.y * scale_factor == y {
let handle = APP.get().unwrap();
let mut app_cache_dir_path = cache_dir().expect("Get Cache Dir Failed");
app_cache_dir_path.push(&handle.config().tauri.bundle.identifier);
Expand Down
11 changes: 7 additions & 4 deletions src-tauri/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ fn get_current_monitor(x: i32, y: i32) -> Monitor {
for m in monitors {
let size = m.size();
let position = m.position();
let scale_factor = m.scale_factor() as i32;
let scaled_x = x * scale_factor;
let scaled_y = y * scale_factor;

if x >= position.x
&& x <= (position.x + size.width as i32)
&& y >= position.y
&& y <= (position.y + size.height as i32)
if scaled_x >= position.x/scale_factor
&& scaled_x <= (position.x + size.width as i32)
&& scaled_y >= position.y/scale_factor
&& scaled_y <= (position.y + size.height as i32)
{
info!("Current Monitor: {:?}", m);
return m;
Expand Down