Skip to content
Merged
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
16 changes: 16 additions & 0 deletions crates/canvas-napi/src/host/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use napi::bindgen_prelude::ObjectFinalize;
use napi::{Env, Error, Result};
use napi_derive::napi;

mod drawable;

mod imp {
use super::*;

Expand Down Expand Up @@ -54,7 +56,12 @@ mod imp {
(0, 0, -1, -1)
}

fn size_allocate(&self, _: i32, _: i32, _: i32) {
drawable::allocate_children(&self.obj());
}

fn snapshot(&self, snapshot: &gtk::Snapshot) {
drawable::snapshot_children(&self.obj());
let Some(frame) = self.frame.borrow().clone() else {
return;
};
Expand Down Expand Up @@ -835,6 +842,15 @@ impl NSCCanvas {
self.view.as_ptr() as usize as f64
}

/// Whether a hosted child (`content="drawable"`) takes input at (x, y) DIP.
#[napi]
pub fn picks_child(&self, x: f64, y: f64) -> bool {
self
.view
.pick(x, y, gtk::PickFlags::DEFAULT)
.is_some_and(|picked| picked != *self.view.upcast_ref::<gtk::Widget>())
}

#[napi(getter)]
pub fn surface_width(&self) -> u32 {
if !self.offscreen.is_null() {
Expand Down
Loading
Loading