Commit Graph

230 Commits

Author SHA1 Message Date
Simon Ser e23e109e41 Handle POLLHUP
This makes xdpw exit when either the D-Bus daemon, the Wayland
compositor or Pipewire is shut down. This avoids having dangling
non-functional xdpw instances, e.g. when restarting the compositor.

To test, start Sway nested in Sway, run xdpw with
WAYLAND_DISPLAY=wayland-2, and exit the nested Sway.
2021-07-01 11:58:26 +02:00
columbarius 96d2789d8f screencast: don't rely on the structure of xdpw_screencast_instance to convert formats 2021-06-29 15:08:02 +02:00
columbarius bb24b226e4 screencast: respect the maximal framerate negotiated by pipewire 2021-06-23 09:32:08 +02:00
columbarius 976fa8374d screencast: limit screencast framerate by output framerate 2021-06-23 09:32:08 +02:00
columbarius 6438edb7b9 config: handle missing HOME env variable gracefully
Fixes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/149
2021-06-17 09:37:16 +02:00
Tobias Jakobi 0d23a5ea15 screencast: move xdpw_pwr_stream_destroy() up
- keep the order of functions in-sync with the header
2021-05-24 10:03:40 +02:00
Tobias Jakobi f60bdcef71 screencast: improve cleanup on error in xdpw_screencast_init()
- currently the cleanup can segfault due to uninitialized
  list objects
- introduce xdpw_pwr_context_destroy() and fixup goto logic
2021-05-24 10:03:40 +02:00
Tobias Jakobi d2fa4aa5e7 screencast: protect against NULL stream in xdpw_pwr_stream_destroy()
- this allows repeated calls of xdpw_pwr_stream_destroy() on a
  single screencast instance
2021-05-24 10:03:40 +02:00
Tobias Jakobi dbe71a66c7 screencast: bring function names in line with the wlroots guidelines
- no functional changes
2021-05-24 10:03:40 +02:00
columbarius b20b9d76d7 config: fix format specifier for max_fps 2021-05-22 12:26:50 +02:00
columbarius bbd4f9d2b1 doc: add note about the list character of env XDG_CURRENT_DESKTOP 2021-05-21 19:35:58 +02:00
columbarius feede20314 config: parse XDG_CURRENT_DESKTOP as a list 2021-05-20 22:45:10 +02:00
columbarius c60b2b6ca8 config: fix memory leak config_home_fallback 2021-05-06 11:52:16 +02:00
Tobias Langendorf 5d4dd833a4 screenshot: implement PickColor method
closes #129
2021-05-03 23:56:06 +02:00
columbarius 47635b94eb screencast: add prompt to dmenu style default choosers 2021-05-03 15:58:40 +02:00
Tobias Langendorf 83086e9af8 screenshot: implement `interactive` option 2021-05-03 15:51:05 +02:00
columbarius 620946b320 config: add missing keys to print_config 2021-05-03 15:19:20 +02:00
columbarius 22af25749e config: use inih instead if iniparser 2021-05-03 15:19:20 +02:00
Simon Ser 7f6b4090e0 Add -r flag to slurp
This prevents the user from selecting a custom region, and forces
them to select a full output.
2021-05-03 11:57:11 +02:00
Simon Ser 5d3cf9a8fa Remove -o and -f options
These can be specified in the configuration file now.
2021-04-21 12:12:40 -04:00
columbarius f978a6eb77 Revert "screencast: workaround corrupted output_list"
This reverts commit 94f1f5d0a8.
2021-04-19 15:42:50 +02:00
columbarius e89c58c731 wlr_screencopy: make sure xdg_output_manager is supported 2021-04-19 15:42:50 +02:00
Stefano Ragni ebb50839a5 wlr_screencast: fix return value on cmd failure 2021-04-18 19:56:54 +02:00
columbarius 5e4edae701 wlr_screencast: remove wl_display_dispatch
wl_display_dispatch is unnecessary and can cause hangs, if no new requests are queued
2021-04-17 16:25:54 +02:00
columbarius ca46a98b86 wlr_screencast: add xdg_output_listener after output registration if possible 2021-04-17 11:33:48 +02:00
columbarius 3ca286b0b4 wlr_screencast: call wlr_remove_output only if global is an output 2021-04-17 11:33:48 +02:00
columbarius d83431335d wlr_screencast: create clean xdpw_wlr_output and free on remove 2021-04-17 11:33:48 +02:00
Aleksei Bavshin 9ba958c7d2 Fix gcc warnings on invalid `free` call
```
../src/core/config.c: In function ‘finish_config’:
../src/core/config.c:26:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 16 [-Werror=free-nonheap-object]
   26 |         free(&config->screencast_conf.exec_before);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/core/config.c:27:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 24 [-Werror=free-nonheap-object]
   27 |         free(&config->screencast_conf.exec_after);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/core/config.c:28:9: error: ‘free’ called on pointer ‘config_7(D)’ with nonzero offset 32 [-Werror=free-nonheap-object]
   28 |         free(&config->screencast_conf.chooser_cmd);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```
2021-04-10 10:50:24 +02:00
columbarius 94f1f5d0a8 screencast: workaround corrupted output_list 2021-04-02 15:07:38 +02:00
columbarius 9d78b21695 screencast: add outputchooser with config option
Supports "dmenu" chooser type, which is called with a dmenu type list
piped to stdin, "simple" type, which recieves nothing on stdin and
default, which tries the hardcoded choosers.
Choosers are required to return the name of the choosen output as given
by the xdg-output protocol.

Thanks to piater for closing overlooked pipes.
Thanks to ericonr for suggestions regarding fork and pipes.
2021-04-02 15:07:38 +02:00
David96 4c2d8fc808 Add exec_before and exec_after
Adds an option to execute some program before and after screencast (e.g.
for disabling notifications during a cast)
2021-03-16 23:44:08 +01:00
Stefano Ragni 6c8f6ca78e pipewire: Fix building EnumFormat spa object
Make sure that in SPA_POD_CHOICE_ENUM_Id(n_vals, ...) we always pass
exactly n_vals arguments. For this we build the object with separate
spa_pod_builder_add calls, since n_vals is known at runtime.
Fix #102
2021-03-16 15:43:47 -04:00
Simon Ser a18c298ad4 Don't use ~/.config when XDG_CONFIG_HOME is set
According to the spec, ~/.config is a fallback used when
XDG_CONFIG_HOME is unset. When the user has explicitly set
XDG_CONFIG_HOME, we shouldn't try to use the fallback.
2021-03-15 18:08:57 +01:00
Simon Ser 491cbb1cc6 Constify config_path arguments
These are not modified.
2021-03-15 18:08:57 +01:00
Simon Ser b92ad3eb6b Drop /etc/xdg-desktop-portal-wlr/ from config file dirs
We were checking both /etc/xdg-desktop-portal-wlr/ and
/etc/xdg/xdg-desktop-portal-wlr/. These two directories serve the same
purpose, let's just settle on a single one.
2021-03-15 18:08:57 +01:00
Zsolt Donca ab8ff54f4c Control how many frames are captured per second
The goal is to control the rate of capture while in screencast, as it
can represent a performance issue and can cause input lag and the
feeling of having a laggy mouse.

This commit addresses the issue reported in #66.

The code measures the time elapsed to make a single screen capture, and
calculates how much to wait for the next capture to achieve the targeted
frame rate. To delay the capturing of the next frame, the code
introduces timers into the event loop based on the event loop in
https://github.com/emersion/mako

Added a command-line argument and an entry in the config file as well
for the max FPS. The default value is 0, meaning no rate control.

Added code to measure the average FPS every 5 seconds and print it with
DEBUG level.
2021-03-08 16:59:17 +01:00
Simon Ser d3ac33a0aa Fix segfault in config_parse_file
configfile is a `char *`. %s needs a `char *`, so we shouldn't
dereference the pointer here.

Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/91
2021-03-04 14:16:30 -05:00
columbarius 07154bb1e3
Add support for config file
Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/60
2021-03-03 10:29:56 +01:00
Simon Ser 5401e7f9f2 Add --replace flag
This allows replacing a running xdpw instance. xdg-desktop-portal
itself has this feature.

This is useful when developing, to stop the currently running
system instance.
2021-02-11 13:24:53 -05:00
Simon Ser c6d52b4412 Remove extraneous whitespace 2021-02-11 18:55:48 +01:00
Simon Ser 9f72a6d874 Fix freeze on skipped frame
When a frame is skipped, we weren't destroying the wlr frame. Since
this function kicks off the next frame capture, the stream was getting
stuck.

Closes: https://github.com/emersion/xdg-desktop-portal-wlr/issues/81
2021-02-11 18:55:48 +01:00
Jan Beich a3e203584a screencast: prefix macros to avoid conflict with system definitions
In file included from ../src/screencast/wlr_screencast.c:18:
../include/pipewire_screencast.h:7:9: error: 'ALIGN' macro redefined [-Werror,-Wmacro-redefined]
 #define ALIGN 16
         ^
/usr/include/machine/param.h:79:9: note: previous definition is here
 #define ALIGN(p)                _ALIGN(p)
         ^
2021-01-09 12:21:13 +01:00
columbarius f0e1de02f4 Fix cursor_mode checks in screencast.c 2020-11-06 13:44:58 +01:00
columbarius 24bc68f0f2 Remove SPA_PARAM_BUFFERS_dataType
Don't announce a SPA_PARAM_BUFFERS_dataType. This is reserved for consumer
2020-11-04 11:09:09 -05:00
columbarius dafb25fdb1
Update to wlr-screencopy-unstable-v1 version 3 2020-10-19 23:40:30 +02:00
columbarius c2883a4e43 Add pipewire buffers_dataType parameter in pipwire_screencast.c 2020-09-19 10:22:44 +02:00
Manuel Romei 25e7719d18
Revert "Remove unnecessary check from wlr_screencast.c" (#54)
* Revert "Remove unnecessary check from wlr_screencast.c"

This reverts commit cc59abb124.
Fixes emersion/xdg-desktop-portal-wlr#50

* Clarify why the check in wlr_screencast is needed
2020-09-11 10:38:04 -04:00
columbarius 61db8968f9 Fix linewidth in wlr_screencast.c 2020-08-23 20:06:47 +02:00
columbarius cc59abb124 Remove unnecessary check from wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 5ea10ef253 Remove TODO from wlr_sreencast.c 2020-08-18 15:47:44 +02:00
columbarius a8d12c6163 Rename wlr_frame_buffer_clear to wlr_frame_buffer_destroy in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 24a793135c Add comments to wlr_frame_buffer_clear in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 06aa0a0bda Change loglevel for existing buffer in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 15e30ed35d Remove unecessary checks in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius c6253415c0 Add functions to clean simple_buffer.{data,buffer} in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius f23e9e4921 Change refresh logic and add tests in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 9d4193e5b2 Refresh buffer on change in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 9c353d6cfb Fix log messages in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 1245e9c353 munmap simple_frame.data only if needed in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius 4c20660f74 Only recreate simple_frame on change in wlr_screencast.c 2020-08-18 15:47:44 +02:00
columbarius e57beee43d Destroy wlr_buffer only on quit or error in wlr_screencast.c 2020-08-18 15:47:44 +02:00
Marian Buschsieweke 1e92d603a8 core/main: Clean up option handling
- Add a missing space in the usage string
- Drop short option "p", which is unused
2020-05-26 17:02:56 +02:00
Marian Buschsieweke 4cd31295cf core/main: Use EXIT_FAILURE / EXIT_SUCCESS 2020-05-26 12:58:13 +02:00
Marian Buschsieweke 05f44e7a7d core/main: Add static qualifier to internal func 2020-05-26 12:58:13 +02:00
Marian Buschsieweke a105e0e363
core: fix error handling in main
The error handling at the `error:` label tears down the whole state. Thus, the
state needs to be fully initialized in order for the tear down to succeed.
Currently, if e.g. `sd_bus_open_user()` fails, a `segfault` is triggered by
the tear down. This commit adds individual tear down code that only touches
stuff that until that point was successfully initialized.
2020-05-21 16:44:47 +02:00
Simon Ser f5bfe9fe12 Replace void * with correct type in start_screencast 2020-05-05 10:00:10 -04:00
Simon Ser a7ea407e2f Remove --pixelformat flag
This hack is not needed anymore.
2020-05-05 10:00:10 -04:00
Simon Ser 26b6bf69aa Advertise format with alpha channel stripped 2020-05-05 10:00:10 -04:00
Dan Shick 229a34a9fe Globally define _POSIX_C_SOURCE in meson.build
Fix musl issue with time.h
2020-04-23 09:53:34 +02:00
Dan Shick f6d14d9206 Check cast instance refcount before attaching 2020-04-21 14:45:55 +02:00
danshick 55f873dac4
Screencast session support (#22)
* Initial session support WIP
Remove libdrm dependency

Remove display from context, add dbus properties

Use random names for shm and pw_stream, init the stream only for new cast instances

Separate cast initialized flag from refcount, cleanup names and comments

* Refactor and stability improvements

Properly report xdp screencast implementation version
2020-04-16 10:21:55 +02:00
Dan Shick ccc8a31568 Remove pipewire workarounds after upstream fix 2020-04-01 13:38:38 -04:00
Dan Shick bba347be4c Add pipewire 0.3 support. Workaround pipewire bugs. 2020-03-16 22:43:45 +01:00
Dan Shick 45699637d1 Fix CI with libpipewire02, libdrm. Remove png.h unused import. Cleanup style. 2020-03-13 21:01:32 +01:00
Dan Shick c0da39f022 Add proper event loop. Remove last threads. Update CI with pipewire. 2020-03-13 21:01:32 +01:00
Dan Shick eb229b708e Remove thread for pipewire and all locking. Add support for elogind in meson. 2020-03-13 21:01:32 +01:00
Dan Shick b0c50ff911 Add proper logging 2020-03-13 21:01:32 +01:00
Dan Shick 080d519a0d Add xdg_output protocol for output selection 2020-03-13 21:01:32 +01:00
Dan Shick 7b699f3344 Use variable framerate, add CLI option to override pixelformat metadata 2020-03-13 21:01:32 +01:00
Dan Shick 2a31d2d922 Add thread for wlr screensharing 2020-03-13 21:01:32 +01:00