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

Bug: clipboard option freezes everything when used with slurp #109

Open
Gigas002 opened this issue Mar 27, 2024 · 14 comments · Fixed by #110
Open

Bug: clipboard option freezes everything when used with slurp #109

Gigas002 opened this issue Mar 27, 2024 · 14 comments · Fixed by #110

Comments

@Gigas002
Copy link
Contributor

Built from freeze-feat-andreas branch. Just running wayshot --clipboard works fine, but when trying to run wayshot --clipboard -s "slurp" compositor freezes, until wayshot is killed from tty

@Shinyzenith
Copy link
Member

I think I misunderstood your issue. Apologies.

@Shinyzenith
Copy link
Member

CC: @CheerfulPianissimo

@CheerfulPianissimo
Copy link
Contributor

CheerfulPianissimo commented Mar 28, 2024

Can reproduce. Sway does not actually freeze but you have to full-screen apps before you can interact with them. Likely a bad interaction between freeze-feat's use of callbacks+layer-shell and wl-clipboard-rs's thread use or our own daemonization functionality. Will look into it.

@CheerfulPianissimo
Copy link
Contributor

CheerfulPianissimo commented Mar 28, 2024

My preliminary theory is that freeze-feat destroys the overlay shell surface as a side effect of the program terminating rather than removing it manually on completion of selection, so when wayshot persists instead of terminating immediately to keep the image on the clipboard, the layer shell does too. Could this be plausible @AndreasBackx ?

@CheerfulPianissimo
Copy link
Contributor

yeah that seems to have been it. Have a patch solving this.

@AndreasBackx
Copy link
Member

@CheerfulPianissimo your assertion seems very likely. It made me look into why we're doing it this way in the first place and I looked into the unsafe code for the clipboard stuff.

@Shinyzenith, I don't fully understand why we need to fork here. Could you explain why we cnanot piggyback on the wl-clipboard implementation? It it because you did not want this to block and it's blocking for a long time?

Also, from my understanding of daemonisation (I'm using it quite extensively at work as a "hack" to make sure terminals exit quickly and can do some work afterwards), this is not daemonisation. We are forking, but we are not "daemonising" the process. That requires a second fork and a setsid call. Unless the Rust stuff does it differently somewhat, the current behaviour simply has 2 processes but should not exit earlier than without this forking code. Though please correct me if I'm wrong.

@CheerfulPianissimo
Copy link
Contributor

The rationale for doing the fork is explained here: #89 (comment)

It it because you did not want this to block and it's blocking for a long time?

Yes, it blocks till the user copies something else to the clipboard. We could just block stdout and not exit till this happens but that would be surprising behavior imo and would not be in line with the other clipboard tools in the ecosystem like wl-copy.

Unless the Rust stuff does it differently somewhat, the current behaviour simply has 2 processes but should not exit earlier than without this forking code.

Presently wayshot forks and exits while the forked child process sets wl-clipboard's foreground option to true and calls copy. Only one process remains as the parent process' clipboard_daemonize returns Ok and immediately reaches the end of the main function.

My goal here was to basically disconnect wayshot from the terminal it's running in along with the stdout/stdin/stderr. I searched around a bit and this seemed to be the idiomatic unix way to do this. Do you have any suggestions to improve this @AndreasBackx ?

Shinyzenith pushed a commit that referenced this issue Apr 6, 2024
…#109 (#110)

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

* feat(clipboard): handle callback fails
@Gigas002
Copy link
Contributor Author

Checked out running after merging #110, have this error after slurp is done with selecting:

Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12
Error: dispatch error: Backend error: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12

Caused by:
   0: Backend error: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12
   1: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12

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

@CheerfulPianissimo
Copy link
Contributor

Can reproduce this but not consistently (about 1 in 6 times?). Happens without the --clipboard flag too. Does this reproduce consistently for you @Gigas002 ? What command are you using?

@CheerfulPianissimo
Copy link
Contributor

Some logs:

Logs

 WAYLAND_DEBUG=1 cargo run -- -s ""
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/wayshot -s ''`
[4252678.226][rs] -> [email protected]_registry(wl_registry@2)
[4252678.291][rs] -> [email protected](wl_callback@3)
[4252678.473][rs] <- [email protected], (1, Some("wl_shm"), 1)
[4252678.568][rs] <- [email protected], (2, Some("wl_drm"), 2)
[4252678.634][rs] <- [email protected], (3, Some("zwp_linux_dmabuf_v1"), 4)
[4252678.726][rs] <- [email protected], (4, Some("wl_compositor"), 6)
[4252678.802][rs] <- [email protected], (5, Some("wl_subcompositor"), 1)
[4252678.889][rs] <- [email protected], (6, Some("wl_data_device_manager"), 3)
[4252678.990][rs] <- [email protected], (7, Some("zwlr_gamma_control_manager_v1"), 1)
[4252679.102][rs] <- [email protected], (8, Some("zxdg_output_manager_v1"), 3)
[4252679.204][rs] <- [email protected], (9, Some("ext_idle_notifier_v1"), 1)
[4252679.287][rs] <- [email protected], (10, Some("zwp_idle_inhibit_manager_v1"), 1)
[4252679.441][rs] <- [email protected], (11, Some("zwlr_layer_shell_v1"), 4)
[4252679.585][rs] <- [email protected], (12, Some("xdg_wm_base"), 2)
[4252679.671][rs] <- [email protected], (13, Some("zwp_tablet_manager_v2"), 1)
[4252679.773][rs] <- [email protected], (14, Some("org_kde_kwin_server_decoration_manager"), 1)
[4252679.896][rs] <- [email protected], (15, Some("zxdg_decoration_manager_v1"), 1)
[4252679.970][rs] <- [email protected], (16, Some("zwp_relative_pointer_manager_v1"), 1)
[4252680.095][rs] <- [email protected], (17, Some("zwp_pointer_constraints_v1"), 1)
[4252680.211][rs] <- [email protected], (18, Some("wp_presentation"), 1)
[4252680.302][rs] <- [email protected], (19, Some("zwlr_output_manager_v1"), 4)
[4252680.433][rs] <- [email protected], (20, Some("zwlr_output_power_manager_v1"), 1)
[4252680.555][rs] <- [email protected], (21, Some("zwp_input_method_manager_v2"), 1)
[4252680.663][rs] <- [email protected], (22, Some("zwp_text_input_manager_v3"), 1)
[4252680.778][rs] <- [email protected], (23, Some("zwlr_foreign_toplevel_manager_v1"), 3)
[4252680.916][rs] <- [email protected], (24, Some("ext_session_lock_manager_v1"), 1)
[4252681.063][rs] <- [email protected], (25, Some("wp_drm_lease_device_v1"), 1)
[4252681.168][rs] <- [email protected], (26, Some("zwlr_export_dmabuf_manager_v1"), 1)
[4252681.277][rs] <- [email protected], (27, Some("zwlr_screencopy_manager_v1"), 3)
[4252681.479][rs] <- [email protected], (28, Some("zwlr_data_control_manager_v1"), 2)
[4252681.600][rs] <- [email protected], (29, Some("wp_security_context_manager_v1"), 1)
[4252681.712][rs] <- [email protected], (30, Some("wp_viewporter"), 1)
[4252681.794][rs] <- [email protected], (31, Some("wp_single_pixel_buffer_manager_v1"), 1)
[4252681.919][rs] <- [email protected], (32, Some("wp_content_type_manager_v1"), 1)
[4252682.031][rs] <- [email protected], (33, Some("wp_fractional_scale_manager_v1"), 1)
[4252682.150][rs] <- [email protected], (34, Some("zxdg_exporter_v1"), 1)
[4252682.248][rs] <- [email protected], (35, Some("zxdg_importer_v1"), 1)
[4252682.334][rs] <- [email protected], (36, Some("zxdg_exporter_v2"), 1)
[4252682.437][rs] <- [email protected], (37, Some("zxdg_importer_v2"), 1)
[4252682.518][rs] <- [email protected], (38, Some("xdg_activation_v1"), 1)
[4252682.608][rs] <- [email protected], (39, Some("wp_cursor_shape_manager_v1"), 1)
[4252682.724][rs] <- [email protected], (40, Some("zwp_virtual_keyboard_manager_v1"), 1)
[4252682.883][rs] <- [email protected], (41, Some("zwlr_virtual_pointer_manager_v1"), 2)
[4252683.024][rs] <- [email protected], (42, Some("zwlr_input_inhibit_manager_v1"), 1)
[4252683.161][rs] <- [email protected], (43, Some("zwp_keyboard_shortcuts_inhibit_manager_v1"), 1)
[4252683.316][rs] <- [email protected], (44, Some("zwp_pointer_gestures_v1"), 3)
[4252683.422][rs] <- [email protected], (45, Some("wl_seat"), 8)
[4252683.481][rs] <- [email protected], (47, Some("zwp_primary_selection_device_manager_v1"), 1)
[4252683.595][rs] <- [email protected], (48, Some("wl_output"), 4)
[4252683.656][rs] <- [email protected], (212556)
[4252683.689][rs] <- [email protected]_id, (3)
[4252683.810][rs] -> [email protected](8, Some("zxdg_output_manager_v1"), 3, zxdg_output_manager_v1@3)
[4252683.990][rs] -> [email protected]_registry(wl_registry@4)
[4252684.045][rs] -> [email protected](wl_callback@5)
[4252684.324][rs] <- [email protected], (1, Some("wl_shm"), 1)
[4252684.444][rs] <- [email protected], (2, Some("wl_drm"), 2)
[4252684.509][rs] <- [email protected], (3, Some("zwp_linux_dmabuf_v1"), 4)
[4252684.584][rs] <- [email protected], (4, Some("wl_compositor"), 6)
[4252684.650][rs] <- [email protected], (5, Some("wl_subcompositor"), 1)
[4252684.731][rs] <- [email protected], (6, Some("wl_data_device_manager"), 3)
[4252684.814][rs] <- [email protected], (7, Some("zwlr_gamma_control_manager_v1"), 1)
[4252684.918][rs] <- [email protected], (8, Some("zxdg_output_manager_v1"), 3)
[4252685.006][rs] <- [email protected], (9, Some("ext_idle_notifier_v1"), 1)
[4252685.091][rs] <- [email protected], (10, Some("zwp_idle_inhibit_manager_v1"), 1)
[4252685.183][rs] <- [email protected], (11, Some("zwlr_layer_shell_v1"), 4)
[4252685.263][rs] <- [email protected], (12, Some("xdg_wm_base"), 2)
[4252685.324][rs] <- [email protected], (13, Some("zwp_tablet_manager_v2"), 1)
[4252685.433][rs] <- [email protected], (14, Some("org_kde_kwin_server_decoration_manager"), 1)
[4252685.578][rs] <- [email protected], (15, Some("zxdg_decoration_manager_v1"), 1)
[4252685.706][rs] <- [email protected], (16, Some("zwp_relative_pointer_manager_v1"), 1)
[4252685.841][rs] <- [email protected], (17, Some("zwp_pointer_constraints_v1"), 1)
[4252685.974][rs] <- [email protected], (18, Some("wp_presentation"), 1)
[4252686.065][rs] <- [email protected], (19, Some("zwlr_output_manager_v1"), 4)
[4252686.176][rs] <- [email protected], (20, Some("zwlr_output_power_manager_v1"), 1)
[4252686.305][rs] <- [email protected], (21, Some("zwp_input_method_manager_v2"), 1)
[4252686.440][rs] <- [email protected], (22, Some("zwp_text_input_manager_v3"), 1)
[4252686.551][rs] <- [email protected], (23, Some("zwlr_foreign_toplevel_manager_v1"), 3)
[4252686.650][rs] <- [email protected], (24, Some("ext_session_lock_manager_v1"), 1)
[4252686.743][rs] <- [email protected], (25, Some("wp_drm_lease_device_v1"), 1)
[4252686.839][rs] <- [email protected], (26, Some("zwlr_export_dmabuf_manager_v1"), 1)
[4252686.935][rs] <- [email protected], (27, Some("zwlr_screencopy_manager_v1"), 3)
[4252687.039][rs] <- [email protected], (28, Some("zwlr_data_control_manager_v1"), 2)
[4252687.140][rs] <- [email protected], (29, Some("wp_security_context_manager_v1"), 1)
[4252687.240][rs] <- [email protected], (30, Some("wp_viewporter"), 1)
[4252687.311][rs] <- [email protected], (31, Some("wp_single_pixel_buffer_manager_v1"), 1)
[4252687.432][rs] <- [email protected], (32, Some("wp_content_type_manager_v1"), 1)
[4252687.526][rs] <- [email protected], (33, Some("wp_fractional_scale_manager_v1"), 1)
[4252687.635][rs] <- [email protected], (34, Some("zxdg_exporter_v1"), 1)
[4252687.708][rs] <- [email protected], (35, Some("zxdg_importer_v1"), 1)
[4252687.783][rs] <- [email protected], (36, Some("zxdg_exporter_v2"), 1)
[4252687.857][rs] <- [email protected], (37, Some("zxdg_importer_v2"), 1)
[4252687.928][rs] <- [email protected], (38, Some("xdg_activation_v1"), 1)
[4252688.008][rs] <- [email protected], (39, Some("wp_cursor_shape_manager_v1"), 1)
[4252688.109][rs] <- [email protected], (40, Some("zwp_virtual_keyboard_manager_v1"), 1)
[4252688.212][rs] <- [email protected], (41, Some("zwlr_virtual_pointer_manager_v1"), 2)
[4252688.319][rs] <- [email protected], (42, Some("zwlr_input_inhibit_manager_v1"), 1)
[4252688.450][rs] <- [email protected], (43, Some("zwp_keyboard_shortcuts_inhibit_manager_v1"), 1)
[4252688.563][rs] <- [email protected], (44, Some("zwp_pointer_gestures_v1"), 3)
[4252688.643][rs] <- [email protected], (45, Some("wl_seat"), 8)
[4252688.716][rs] <- [email protected], (47, Some("zwp_primary_selection_device_manager_v1"), 1)
[4252688.859][rs] <- [email protected], (48, Some("wl_output"), 4)
[4252688.933][rs] <- [email protected], (212556)
[4252688.964][rs] <- [email protected]_id, (5)
[4252689.096][rs] -> [email protected](48, Some("wl_output"), 4, wl_output@5)
[4252689.210][rs] -> [email protected]_xdg_output(zxdg_output_v1@6, wl_output@5)
[4252689.261][rs] -> [email protected](wl_callback@7)
[4252689.549][rs] <- [email protected], (0, 0, 340, 190, 0, Some("AU Optronics"), Some("0x499F"), 0)
[4252689.708][rs] <- [email protected], (1, 1920, 1080, 60056)
[4252689.753][rs] <- [email protected], (1)
[4252689.785][rs] <- [email protected], (Some("eDP-1"))
[4252689.838][rs] <- [email protected], (Some("AU Optronics 0x499F (eDP-1)"))
[4252689.933][rs] <- [email protected], ()
[4252689.963][rs] <- [email protected], (Some("eDP-1"))
[4252690.021][rs] <- [email protected], (Some("AU Optronics 0x499F (eDP-1)"))
[4252690.118][rs] <- [email protected]_position, (0, 0)
[4252690.165][rs] <- [email protected]_size, (1920, 1080)
[4252690.201][rs] <- [email protected], ()
[4252690.233][rs] <- [email protected], (212556)
[4252690.269][rs] <- [email protected]_id, (7)
[4252690.459][rs] -> [email protected]()
[4252691.346][rs] -> [email protected](27, Some("zwlr_screencopy_manager_v1"), 3, zwlr_screencopy_manager_v1@7)
[4252691.612][rs] -> [email protected]_output(zwlr_screencopy_frame_v1@8, 0, wl_output@5)
[4252691.871][rs] <- [email protected]_id, (6)
[4252691.912][rs] <- [email protected], (875709016, 1920, 1080, 7680)
[4252692.001][rs] <- [email protected]_dmabuf, (875713112, 1920, 1080)
[4252692.052][rs] <- [email protected]_done, ()
[4252692.169][rs] -> [email protected](1, Some("wl_shm"), 1, wl_shm@6)
[4252692.274][rs] -> [email protected]_pool(wl_shm_pool@9, 4, 8294400)
[4252692.344][rs] -> [email protected]_buffer(wl_buffer@10, 0, 1920, 1080, 7680, 875709016)
[4252692.455][rs] -> [email protected](wl_buffer@10)
[4252692.657][rs] <- [email protected], (0)
[4252692.706][rs] <- [email protected], (1)
[4252692.741][rs] <- [email protected], (875709016)
[4252692.775][rs] <- [email protected], (875708993)
[4252692.812][rs] <- [email protected], (875710274)
[4252692.849][rs] <- [email protected], (842094674)
[4252692.887][rs] <- [email protected], (842088786)
[4252692.924][rs] <- [email protected], (892426322)
[4252692.962][rs] <- [email protected], (892420434)
[4252693.009][rs] <- [email protected], (909199186)
[4252693.050][rs] <- [email protected], (808665688)
[4252693.091][rs] <- [email protected], (808665665)
[4252693.130][rs] <- [email protected], (1211384408)
[4252693.165][rs] <- [email protected], (1211384385)
[4252693.211][rs] <- [email protected], (942948952)
[4252693.246][rs] <- [email protected], (942948929)
[4252717.769][rs] <- [email protected], (0)
[4252717.832][rs] <- [email protected], (0, 113940, 722237399)
[4252717.870][rs] <- [email protected], ()
[4252718.382][rs] -> [email protected](4, Some("wl_compositor"), 3, wl_compositor@11)
[4252718.649][rs] -> [email protected](11, Some("zwlr_layer_shell_v1"), 1, zwlr_layer_shell_v1@12)
[4252718.767][rs] -> [email protected]_surface(wl_surface@13)
[4252718.853][rs] -> [email protected]_layer_surface(zwlr_layer_surface_v1@14, wl_surface@13, wl_output@5, 2, Some("wayshot"))
[4252718.972][rs] -> [email protected]_exclusive_zone(-1)
[4252719.011][rs] -> [email protected]_anchor(5)
[4252719.051][rs] -> [email protected]_size(1920, 1080)
[4252719.096][rs] -> [email protected]()
[4252719.432][rs] <- [email protected], (wl_output@5)
[4252719.516][rs] <- [email protected], (212558, 1920, 1080)
[4252719.594][rs] <- [email protected], (212561, 1920, 1080)
[4252719.717][rs] -> [email protected]_configure(212558)
[4252719.777][rs] -> [email protected]_configure(212561)
[4252719.833][rs] -> [email protected]_buffer_transform(0)
[4252719.887][rs] -> [email protected](wl_buffer@10, 0, 0)
[4252719.954][rs] -> [email protected]()
[4252727.892][rs] <- [email protected], (212565, 1920, 1080)
[4252728.031][rs] <- [email protected], ()
[4252728.222][rs] -> [email protected]_configure(212565)
[4253394.079][rs] -> [email protected]()
[4253394.235][rs] <- [email protected], (212569, 1920, 1080)
[4253394.294][rs] <- [email protected], (212573, 1920, 1080)
[4253394.339][rs] <- [email protected], (212578, 1920, 1080)
[4253394.427][rs] <- [email protected], (212589, 1920, 1080)
[4253394.524][rs] <- [email protected], (1, 1, Some("invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12"))
Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12
[4253394.766][rs] -> [email protected]()
[4253394.807][rs] -> [email protected]()
Error: dispatch error: Backend error: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12

Caused by:
   0: Backend error: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12
   1: Protocol error 1 on object wl_display@1: invalid method 1 (since 1 < 3), object zwlr_layer_shell_v1@12

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

Could be a case of use after destroy? [email protected]() is called but the error is that method 1(get_layer_surface?) is getting called on zwlr_layer_shell_v1@12 after the fact.

@Gigas002
Copy link
Contributor Author

Does this reproduce consistently for you @Gigas002 ? What command are you using?

Yeah, happens every time for me. Running wayshot --clipboard -s "d"

@CheerfulPianissimo
Copy link
Contributor

Which compositor are you using @Gigas002 ?

@Gigas002
Copy link
Contributor Author

I'm using hyprland

@CheerfulPianissimo
Copy link
Contributor

CheerfulPianissimo commented Apr 12, 2024

I'm using sway. Alright, I have a patch that solves this. The existing code destroys the layer_shell object instead of the layer_surface objects, destroying only layer_surface objects seems to solve the issue but destroying both in that order doesn't. It isn't clear to me why this is the case but I'll create a PR for you to test.

Shinyzenith added a commit that referenced this issue Feb 12, 2025
* Refactor: introduce FrameGuard, ScreenCapturer, and Logical/EmbeddedRegion

* Add freeze functionality

* Move to clap_derive so CLI arguments are typed



* Renames `clap.rs` to `cli.rs` because otherwise there's confusion between the `clap` crate and local module.
* `Cli` struct added that almost identically represents the current state of the CLI with no logical changes.

---

## `--help` Comparison

Before: https://gist.github.com/AndreasBackx/5945b366e989159f4669e7ba30c13239

After:  https://gist.github.com/AndreasBackx/8929c8bde080eac0cafd33128210b0cc

Diff (ignoring whitespace changes due to table alignment):
```diff
1c1
< Screenshot tool for compositors implementing zwlr_screencopy_v1.
---
> Screenshot tool for wlroots based compositors implementing the zwlr_screencopy_v1 protocol.
9d8
<   -c, --cursor                      Enable cursor in screenshots
10a10
>   -c, --cursor                      Enable cursor in screenshots
12c12
<   -l, --listoutputs                 List all valid outputs
---
>   -l, --list-outputs                List all valid outputs
14c14
<       --chooseoutput                Present a fuzzy selector for outputs
---
>       --choose-output               Present a fuzzy selector for outputs
16a17
>
```

You can see that the only changes are:
- About is longer, this is now using the value from Cargo.toml instead of a duplicate text that was shorter.
- Some have a dash where the English words would have a space, e.g: "list-outputs" instead of "listoutputs". I've also made the old still work via an alias: https://gist.github.com/AndreasBackx/6025e91844e3d766d4264a01ae4d1a71

This seems like a tiny improvement? I plan to make further changes later, but I want to keep PRs separate.

* Improve CLI design


This "improves" (and that is subjective) the design of the CLI. I am aiming to get some feedback on what people think of the new design:

```
Screenshot tool for wlroots based compositors implementing the zwlr_screencopy_v1 protocol.

Usage: wayshot [OPTIONS] [OUTPUT]

Arguments:
  [OUTPUT]
          Where to save the screenshot, "-" for stdout. Defaults to "$UNIX_TIMESTAMP-wayshot.$EXTENSION"

Options:
      --log-level <LOG_LEVEL>
          Log level to be used for printing to stderr

          [default: info]
          [possible values: trace, debug, info, warn, error]

  -s, --slurp <SLURP_ARGS>
          Arguments to call slurp with for selecting a region

  -c, --cursor
          Enable cursor in screenshots

      --encoding <FILE_EXTENSION>
          Set image encoder, if output file contains an extension, that will be used instead

          [default: png]
          [aliases: extension, format, output-format]

          Possible values:
          - jpg: JPG/JPEG encoder
          - png: PNG encoder
          - ppm: PPM encoder
          - qoi: Qut encoder

  -l, --list-outputs
          List all valid outputs

  -o, --output <OUTPUT>
          Choose a particular output/display to screenshot

      --choose-output
          Present a fuzzy selector for output/display selection

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version
```

The main changes are:
1. `--debug` is now `--log-level` because this makes it easy to select more specifically what log level to use. I considered using `-v`, `-vv`... to increase verbosity but the `clap-verbosity-crate` uses `log` and not `tracing`. We could use it somewhat, but we'd pull in `log` (which seems fine) and we'd need to map from `log`'s Level to `tracing`'s Level enums (they use inverse ordering).
2.  `--stdout` and `--file` has been made an optional positional argument. This because it's what other CLIs often do and I wasn't sure what to call the option otherwise because `--output` and `-O`/`-o` is often what others use but we use it here to refer to displays/monitors/Wayland outputs. This avoids that confusion hopefully and I've also clarified this in the documentation.
    * Additionally if a path is given, its extension will always be used. So you cannot save `jpg` to `foo.png`. Perhaps this behaviour can be changed, though I don't see a reason to support this weird edge case? When is someone saving `png` to `jpg`?
3. `--extension` is `--encoding` with aliases like `extension`.

Again, let me know what you think.

* Remove explicit panics and exits

Let's bubble up errors instead of panicking and also not use `exit(...)` because it does not call destructors which might give issues.

* Make region, sizing, and positioning data structs reusable

We use different structs/fields to store the same three types of data everywhere:
- Position (x,y)
- Size (width,height)
- Region(position, size)

This makes it so they all reuse the same information.

* First version of scaling fix. (#85)

* chore: remove useless roundtrip (#105)

* feat(clipboard): implement clipboard integration (#91)

* feat(clipboard): implement clipboard integration

Add the --clipboard flag and implement functionality to make image available on the clipboard using wl-clipboard-rs.

* style(format): apply code formatting to cli.rs

* feat(clipboard): implement fork wait for clipboard

Add functionality offering image on clipboard persistently in the background

* feat(clipboard): inform user about wayshot persisting in background with --clipboard

* feat(clipboard): use tracing::warn instead of print if fork fails

* feat(clipboard): Switch from the fork crate to the nix crate for daemonization

* style(format): code formatting to wayshot.rs

* style(typo): corrected a typo in the comments

* docs(ManPage): Fix capitalization issue

Signed-off-by: Shinyzenith <[email protected]>

* docs: Document clipboard interaction

Signed-off-by: Shinyzenith <[email protected]>

* chore: Update Cargo.lock

Signed-off-by: Shinyzenith <[email protected]>

* feat: added time_stamp flag (#93)

* feat: added time_stamp flag

* Syntax Refactor and filename format fixed

* file name format fixes

* wayshot-{timestamp}.{extension} as default filename

* chore: Update Cargo.lock

Signed-off-by: Shinyzenith <[email protected]>

---------

Signed-off-by: Shinyzenith <[email protected]>
Authored-by: rachancheet <[email protected]>
Co-authored-by: Shinyzenith <[email protected]>

* chore: Update Cargo.lock

Signed-off-by: Shinyzenith <[email protected]>

* feat: Add support for webp (#98)


Signed-off-by: Shinyzenith <[email protected]>

---------

Signed-off-by: Shinyzenith <[email protected]>
Co-authored-by: Shinyzenith <[email protected]>

* refactor(libwayshot): Reduce allocations (#99)

* refactor: remove unnecessary to_string()

* refactor: fix clippy warnings

* refactor: remove 1 level of indirection via &Vec<T> -> &[T]

Typically `&Vec<T>` isn't something you want when you need a read-only view
over a Vec, because it adds another level of indirection: Vec already stores
a pointer to heap-allocated buffer internally.

Using slices `&[T]` removes such unnecessary level of indirection and
is considered a cleaner design. It is cache friendlier and can be better
optimized by the compiler (not that it should matter in this case).

* feat: account for directories in file path (#96)

Signed-off-by: Shinyzenith <[email protected]>

---------

Signed-off-by: Shinyzenith <[email protected]>
Authored-by: rachancheet <[email protected]>
Co-authored-by: Shinyzenith <[email protected]>

* fix: Clipboard flag ignored if path is qualified to file (#108)

* feat(clipboard): fix issue #106 clipboard flag ignored if path is qualified to file

* feat(clipboard): clarify flag description of --clipboard

* feat(clipboard): enable multiline comment description for --clipboard feature flag

Signed-off-by: Shinyzenith <[email protected]>

* feat(clipboard): reduce buffer allocations for encoding image

* feat(clipboard): improve code quality

* feat(clipboard): code style change: perform match inside function call

---------

Signed-off-by: Shinyzenith <[email protected]>
Co-authored-by: Shinyzenith <[email protected]>

* chore: make clippy happy (#111)

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

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

* feat(clipboard): handle callback fails

* Destroy layer shell surfaces

* [fix] unmap layer shell surfaces before destroying them

* Implement missing conversion from string to webp enum (#121)

* Replace nix with rustix (#120)

* Update documentation with changes in freeze-feat (#116)

* [docs] update manpage (1) with changes in freeze-feat

* [fix] make arguments to slurp optional

* [docs] update manpage(7) with cli changes

* [docs] update README with new cli

* Add screencopy dmabuf backend (#122)

* [feat] rough MVP for screencpy+dmabuf

* [feat] refactor MVP into libwayshot - create new constructor

* [refactor] first draft of dmabuf API

* [refactor]
- Add error handling
- Add example/demo for wayshot dmabuf API

* [feat] import wayland-egl-ctx for use as MVP for dmabuf import functionality

* [fix] correct modifier_lo parameter in waymirror-egl MVP

* [feat] get waymirror-egl dmabuf MVP demo working

* [feat] refactored dmabuf->eglImage API into libwayshot

* [feat] - Implemented clean dropping of EGLImage
-  Improved API docs for dmabuf functions

* [fix]  libwayshot build error fixed

* [fix] remove hardcoded GPU path from libwayshot constructor

* [fix]] remove reduntant dmabuf_to_texture call from waymirror-egl

* [docs] document WayshotConnection dmabuf constructor

* [feat] Added helper/wrapper function to convert screencapture EGLImages into GL textures

* [fix] improved logging in dmabuf API code

* [doc] update waymirror-egl Readme

* [fix] change logging level in waymirror-egl to Debug

* [fix] remove unnecessary .gitignore in waymirror-egl

* [ci/cd] attempting to fix the build

* [ci\cd] add libegl system deps to fix github CI

* [fix] remove unused egl_image struct field in Waymirror demo

* fix: I find out a smart way to fix scale problem (#128)

* fix: I find out a smart way to fix scale problem

* Update libwayshot/src/lib.rs

Co-authored-by: Aakash Sen Sharma <[email protected]>

---------

Co-authored-by: Aakash Sen Sharma <[email protected]>

* Fix for 'cargo test' (#114)

* fixes for 'cargo test' & bump flake.lock due to outdated cargo

* commit to pass `cargo fmt -- --check` test

* add `cargo test` to Makefile

---------

Co-authored-by: id3v1669 <[email protected]>

---------

Signed-off-by: Shinyzenith <[email protected]>
Co-authored-by: Access <[email protected]>
Co-authored-by: Andreas Backx <[email protected]>
Co-authored-by: Andreas Backx <[email protected]>
Co-authored-by: Shivang K Raghuvanshi <[email protected]>
Co-authored-by: Sooraj S <[email protected]>
Co-authored-by: rachancheet <[email protected]>
Co-authored-by: Gigas002 <[email protected]>
Co-authored-by: Sergey A <[email protected]>
Co-authored-by: id3v1669 <[email protected]>
Co-authored-by: id3v1669 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants