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

feat(clipboard): fix interaction with freeze and select feature: Issue #109 #110

Merged
Changes from 1 commit
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
15 changes: 12 additions & 3 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,13 @@ impl WayshotConnection {
Ok(frame_copies)
}

fn overlay_frames(&self, frames: &[(FrameCopy, FrameGuard, OutputInfo)]) -> Result<()> {
/// Create a layer shell surface for each output,
/// render the screen captures on them and use the callback to select a region from them
fn overlay_frames_and_select_region(
&self,
frames: &[(FrameCopy, FrameGuard, OutputInfo)],
callback: Box<dyn Fn() -> Result<LogicalRegion, Error>>,
) -> Result<(LogicalRegion)> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) -> Result<(LogicalRegion)> {
) -> Result<LogicalRegion> {

@Shinyzenith it seems like we don't have clippy enabled in GitHub actions?

   Compiling wayshot v1.3.2-dev (/home/andreas/dev/wayshot/wayshot)
warning: unused import: `Region`
  --> libwayshot/src/lib.rs:55:29
   |
55 |     region::{LogicalRegion, Region, Size},
   |                             ^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around type
   --> libwayshot/src/lib.rs:422:17
    |
422 |     ) -> Result<(LogicalRegion)> {
    |                 ^             ^
    |
    = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
    |
422 -     ) -> Result<(LogicalRegion)> {
422 +     ) -> Result<LogicalRegion> {
    |

warning: unused import: `GenericImageView`
 --> libwayshot/src/image_util.rs:1:27
  |
1 | use image::{DynamicImage, GenericImageView};
  |                           ^^^^^^^^^^^^^^^^

warning: unused variable: `logical_height`
  --> libwayshot/src/image_util.rs:15:25
   |
15 |     let (logical_width, logical_height) = match transform {
   |                         ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_logical_height`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `libwayshot` (lib) generated 4 warnings (run `cargo fix --lib -p libwayshot` to apply 3 suggestions)
warning: unused import: `fs::File`
 --> wayshot/src/wayshot.rs:2:5
  |
2 |     fs::File,
  |     ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `wayshot` (bin "wayshot") generated 1 warning (run `cargo fix --bin "wayshot"` to apply 1 suggestion)
    Finished release [optimized] target(s) in 0.92s
     Running `target/release/wayshot --clipboard --slurp ''`
Error: error occurred in freeze callback

Location:
    wayshot/src/wayshot.rs:72:9

Shouldn't impact the PR, but wanted to mention.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will address this.

let mut state = LayerShellState {
configured_outputs: HashSet::new(),
};
Expand Down Expand Up @@ -491,7 +497,10 @@ impl WayshotConnection {
Ok(())
})?;
}
Ok(())
let region = callback()?;
layer_shell.destroy();
event_queue.blocking_dispatch(&mut state)?;
CheerfulPianissimo marked this conversation as resolved.
Show resolved Hide resolved
Ok(region)
}

/// Take a screenshot from the specified region.
Expand Down Expand Up @@ -547,7 +556,7 @@ impl WayshotConnection {
RegionCapturer::Outputs(outputs) => outputs.as_slice().try_into()?,
RegionCapturer::Region(region) => region,
RegionCapturer::Freeze(callback) => {
self.overlay_frames(&frames).and_then(|_| callback())?
self.overlay_frames_and_select_region(&frames, callback)?
}
};

Expand Down
Loading