Skip to content

Commit

Permalink
feat: 修改 macos 窗口 z 值 (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: nashaofu <[email protected]>
  • Loading branch information
nashaofu and nashaofu authored Dec 21, 2024
1 parent 0b2a322 commit 0243fdf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/macos/impl_window.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::ffi::c_void;

use core_foundation::{
array::{CFArrayGetCount, CFArrayGetValueAtIndex},
base::{FromVoid, TCFType},
Expand All @@ -14,7 +16,6 @@ use core_graphics::{
window::{kCGNullWindowID, kCGWindowSharingNone},
};
use image::RgbaImage;
use std::ffi::c_void;

use crate::{error::XCapResult, XCapError};

Expand Down Expand Up @@ -127,14 +128,13 @@ impl ImplWindow {
impl_monitors: &[ImplMonitor],
window_name: String,
window_owner_name: String,
z: i32,
) -> XCapResult<ImplWindow> {
let id = get_cf_number_i32_value(window_cf_dictionary_ref, "kCGWindowNumber")? as u32;
let pid = get_cf_number_i32_value(window_cf_dictionary_ref, "kCGWindowOwnerPID")? as u32;

let cg_rect = get_window_cg_rect(window_cf_dictionary_ref)?;

let window_layer = get_cf_number_i32_value(window_cf_dictionary_ref, "kCGWindowLayer")?;

let primary_monitor = ImplMonitor::new(CGDisplay::main().id)?;

let (is_maximized, current_monitor) = {
Expand Down Expand Up @@ -172,7 +172,7 @@ impl ImplWindow {
current_monitor: current_monitor.clone(),
x: cg_rect.origin.x as i32,
y: cg_rect.origin.y as i32,
z: window_layer,
z,
width: cg_rect.size.width as u32,
height: cg_rect.size.height as u32,
is_minimized,
Expand Down Expand Up @@ -239,6 +239,7 @@ impl ImplWindow {
&impl_monitors,
window_name.clone(),
window_owner_name.clone(),
num_windows as i32 - i as i32 - 1,
) {
impl_windows.push(impl_window);
} else {
Expand Down

0 comments on commit 0243fdf

Please sign in to comment.