Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
core graphics initialization problem fix and readme.md updates
Browse files Browse the repository at this point in the history
  • Loading branch information
liam committed Apr 19, 2024
1 parent c5cee27 commit 8ca2324
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# CrabGrab
🦀 🖥️ 🦀
# CrabGrab 🦀 🖥️ 🦀

## A cross-platform screen-capturing crate for rust
A cross-platform screen-capturing crate for rust

Features:
---------
- Screen and window capture supported
- Compatible with multiple GPU APIs:
- Wgpu
- DirectX 11
- DXGI
- Metal
- IOSurface
- Easy frame bitmap generation
- Sound capture (wip)
- Platform specific extension features
- Screenshot facility

Examples
--------

Examples can be found at [crabgrab/examples](examples). You can run the examples from a copy of the repository:

`cargo run --example <example_name>`

Note that feature examples will require that feature:

`cargo run --example <example name> --feature <feature name>`
4 changes: 3 additions & 1 deletion src/platform/macos/capturable_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use libc::getpid;

use crate::{capturable_content::{CapturableContentFilter, CapturableContentError}, util::{Rect, Point, Size}};

use super::objc_wrap::{SCDisplay, SCRunningApplication, SCShareableContent, SCWindow};
use super::objc_wrap::{CGMainDisplayID, SCDisplay, SCRunningApplication, SCShareableContent, SCWindow};

pub struct MacosCapturableContent {
pub windows: Vec<SCWindow>,
Expand All @@ -14,6 +14,8 @@ pub struct MacosCapturableContent {

impl MacosCapturableContent {
pub async fn new(filter: CapturableContentFilter) -> Result<Self, CapturableContentError> {
// Force core graphics initialization
unsafe { CGMainDisplayID() };
let (exclude_desktop, onscreen_only) = filter.windows.map_or((false, true), |filter| (!filter.desktop_windows, filter.onscreen_only));
let (tx, rx) = oneshot::channel();
let tx = Cell::new(Some(tx));
Expand Down

0 comments on commit 8ca2324

Please sign in to comment.