Commit graph

264 commits

Author SHA1 Message Date
d8daa2a84f core: fix pollfds hup check loop 2023-10-14 11:58:18 +01:00
Ngô Huy
60af24a70d
dbus: Fix issue #114 (#115)
The line #249 calls system bus by default, dbus will deny this request,
then we need to call session bus instead.
2023-10-12 23:17:00 +01:00
vaxerski
ec2e207740 core: fix missing sentinel in execl 2023-10-10 14:47:03 +01:00
vaxerski
667007fa4e core: kill process if threads are in a deadlock 2023-10-10 14:45:54 +01:00
vaxerski
ec31e99056 core: free modifiers if allocated 2023-10-10 01:12:16 +01:00
vaxerski
ff87a16b2b dmabuf: correctly list modifiers
relates to #99 and #106
2023-10-10 01:11:43 +01:00
vaxerski
bf6689a209 core: use abort() instead of exit() in format funcs 2023-10-08 01:57:17 +01:00
vaxerski
f147831c53 core: remove debug terminate
I am a fucking idiot. fixes #107
2023-10-08 01:05:34 +01:00
vaxerski
7df2d3e9e5 screencopy: avoid execution after terminate() 2023-10-05 16:54:28 +01:00
vaxerski
39fd0e46b1 screencopy: avoid defective exit() calls 2023-10-05 16:53:47 +01:00
vaxerski
552e928e7c screencopy: log dma format 2023-10-05 16:53:10 +01:00
vaxerski
158b5892bd internal: gracefully exit on termination after creating the event loop
possibly might help #103
2023-10-05 01:24:55 +01:00
Rudolchr
f9461b0b7d
build: Fix build when using clang (#100)
* Add -Wno-address-of-temporary to allow taking an address of temporary like -fpermissive does for gcc

* Make some implicit casts explicit

* Implement the wl_array_for_each macro inline as clang does not like to handle it's implicit typecast

* Removed unecessary include that was automatically added by the ide

* Replaced reinterpret_cast's with c-style casts
2023-09-26 22:23:02 +01:00
Jan Beich
54b5467ec1
build: Unbreak build on FreeBSD (#98)
* helpers: add missing header after 9dfb9e125b

src/helpers/MiscFunctions.cpp: In function 'void addHyprlandNotification(const std::string&, float, const std::string&, const std::string&)':
src/helpers/MiscFunctions.cpp:24:9: error: 'fork' was not declared in this scope
   24 |     if (fork() == 0)
      |         ^~~~
src/helpers/MiscFunctions.cpp:25:9: error: 'execl' was not declared in this scope
   25 |         execl("/bin/sh", "/bin/sh", "-c", CMD.c_str(), nullptr);
      |         ^~~~~

* build: add missing dependency for libc++ after 2f48e65503

ld.lld: error: undefined symbol: pthread_create
>>> referenced by PortalManager.cpp
>>>               src/xdg-desktop-portal-hyprland.p/core_PortalManager.cpp.o:(CPortalManager::startEventLoop())
>>> referenced by PortalManager.cpp
>>>               src/xdg-desktop-portal-hyprland.p/core_PortalManager.cpp.o:(CPortalManager::startEventLoop())
2023-09-18 20:00:21 +01:00
Commrade Goad
b645ab7cce
screencopy: fix unescaped quotes in titles (#96) 2023-09-16 18:51:54 +01:00
vaxerski
2f48e65503 core: rework event loop for polling and C++-style awaits
Stops the event loop from checking all the time in favor of locks and polling.
2023-09-16 18:22:53 +01:00
vaxerski
8f45a64350 internal: make frame callbacks log a trace 2023-09-13 19:08:00 +01:00
vaxerski
9dfb9e125b internal: add a notification on missing qt-wayland packages
fixes #91
2023-09-11 23:31:33 +01:00
Jan Beich
676571b2c0
build: drop unused dependencies after 022469529c (#84) 2023-09-08 23:38:55 +01:00
Vaxry
022469529c
Woo! Full rewrite, v1.0 release. (#78) 2023-09-06 20:36:48 +02:00
Nicola Guerrera
af539f4e4d
screencast: correct array size (#72) 2023-07-23 15:48:06 +02:00
vaxerski
43300c11a9 toplevelexport: remove _done call from _buffer
requires recent hyprland commit to work
2023-07-20 12:41:50 +02:00
vaxerski
7276435c46 pw: guard output in transform checks 2023-07-20 12:01:23 +02:00
vaxerski
ca077cc05c screencast: restore window share by class 2023-05-25 16:54:02 +02:00
vaxerski
c0e2339555 screencast: send transform to pw 2023-04-25 17:16:24 +01:00
Lucas Alber
f9f08c802e
Fix build after 7d3da7e968 (#54) 2023-04-24 15:04:59 +01:00
Pascal J
7d3da7e968
fix implicit function declaration (#53)
Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
2023-04-23 19:37:42 +01:00
vaxerski
bf035bf3d5 pw: set type for all planes 2023-04-14 17:29:17 +01:00
vaxerski
a7b7880172 screencast: send damage via pw 2023-04-14 17:27:28 +01:00
vaxerski
7fc2e78581 screencast: use spa-pod-dynamic 2023-04-14 17:22:16 +01:00
vaxerski
78dee83d77 screencast: add fallback for linear modifier 2023-04-14 17:14:41 +01:00
vaxerski
2366b4d415 internal: remove metadata cursor mode 2023-04-13 21:14:13 +01:00
Jan Beich
e33206673d
globalshortcuts: fix -Wint-conversion as error with Clang 15 (#42)
src/globalshortcuts/global_shortcuts.c:40:44: error: incompatible pointer to integer conversion initializing 'uint64_t' (aka 'unsigned long') with an expression of type 'void *' [-Wint-conversion]
    SD_BUS_SIGNAL("Activated", "osta{sv}", NULL),
                                           ^~~~
src/globalshortcuts/global_shortcuts.c:41:46: error: incompatible pointer to integer conversion initializing 'uint64_t' (aka 'unsigned long') with an expression of type 'void *' [-Wint-conversion]
    SD_BUS_SIGNAL("Deactivated", "osta{sv}", NULL),
                                             ^~~~
src/globalshortcuts/global_shortcuts.c:42:53: error: incompatible pointer to integer conversion initializing 'uint64_t' (aka 'unsigned long') with an expression of type 'void *' [-Wint-conversion]
    SD_BUS_SIGNAL("ShortcutsChanged", "oa(sa{sv})", NULL),
                                                    ^~~~
/usr/include/sys/_null.h:34:14: note: expanded from macro 'NULL'
 #define NULL    ((void *)0)
                 ^~~~~~~~~~~
/usr/include/basu/sd-bus-vtable.h:113:26: note: expanded from macro 'SD_BUS_SIGNAL'
                .flags = _flags,                                        \
                         ^~~~~~
2023-04-10 12:27:59 +01:00
vaxerski
0527deefe8 internal: bring back metadata cursor support 2023-04-10 12:27:18 +01:00
vaxerski
7ca51f935e screencast: make restore persistent 2023-04-10 00:03:24 +01:00
vaxerski
ab8d54f6f6 feat: add session restore 2023-04-09 23:30:19 +01:00
Vaxry
510257c0e9
[WIP] Global Shortcuts impl (#35)
Implements the `GlobalShortcuts` portal via `hyprland-global-shortcuts-v1`

---------

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2023-04-09 13:47:05 +01:00
vaxerski
803c00db11 screencast: crudely allow metadata and ignore it 2023-04-05 22:23:59 +01:00
vaxerski
74128d2a97 minor fix for region sharing 2023-03-16 15:11:27 +00:00
vaxerski
8707444cf5 fix shell tab behavior in headers 2023-02-03 18:41:28 +00:00
vaxerski
a0fa7909cd nuke toplevel_mgr_bind 2023-02-03 16:50:06 +00:00
vaxerski
f8cdd28cc8 sanitize input to the picker 2023-02-03 12:14:28 +00:00
vaxerski
13db7db849 fix returnlist on no manager 2023-02-01 19:48:49 +00:00
vaxerski
ee73fca9cc Bind toplevel protos once before first screencast
Also style.
2023-02-01 17:49:29 +00:00
vaxerski
101b58d9c5 add missing s 2022-12-13 18:55:32 +00:00
vaxerski
9fb4fae94b bring back qt wayland platform 2022-12-13 00:55:12 +00:00
Vaxry
3c4c9969cc
Toplevel sharing Rev2 impl (#3)
* toplevel sharing rev2

* nix: fix build

* updated protocols

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2022-12-12 14:51:37 +00:00
vaxerski
756789211e export HIS to the picker 2022-12-05 23:20:49 +00:00
vaxerski
2a634b0a60 log more about screencast 2022-12-05 23:11:13 +00:00
vaxerski
4ac6a9af82 export xcursor size to avoid odd-sized cursors 2022-12-05 18:53:51 +00:00
vaxerski
cea7c28bae force wayland platform for qt in invoking picker 2022-12-05 00:37:10 +00:00
vaxerski
bd91bd0d4e pass env to popen cmd picker 2022-12-05 00:13:36 +00:00
vaxerski
8a4e83da96 prevent segfaults on no toplevel proto available 2022-12-04 23:18:10 +00:00
Vaxry
3c850a0336
Window sharing (#2)
* added window sharing support

* nix: add hyprland-protocols and streamline build

Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
2022-12-04 21:12:57 +00:00
Leftas
607ce73671
Change from wlr to hyprland so dbus would recognize different implementation 2022-12-04 19:57:30 +02:00
vaxerski
e2cfaf3eee minor nix fixes 2022-12-03 23:42:56 +00:00
vaxerski
37c76fd7d8 start at pos 7 to avoid a warn 2022-12-03 23:40:08 +00:00
vaxerski
2dc95fe02f Allow region sharing 2022-12-03 22:42:21 +00:00
vaxerski
80775707ea Implement hyprland-share-picker 2022-12-03 21:27:49 +00:00
columbarius
c83b3cc514 screenshot: Announce version property 2022-09-12 23:33:54 +02:00
columbarius
723934d0b0 screencast: check if a valid format was received from wlr_screencopy
When a screencast is started we do a roundtrip on get the offered
formats from wlr_screencopy. This roundtrip can fail [1]. In this case
the formats won't be initialized and we will just error out of the
screencast session.

[1] https://github.com/emersion/xdg-desktop-portal-wlr/issues/214
2022-06-09 11:19:54 +02:00
columbarius
0bbd652c1c screencast: send pesentation timestamp via PipeWire 2022-06-01 21:12:46 +02:00
columbarius
b5491df0c0 screencast: destroy session if output is removed
We teardown all existing screencast_instances using the removed output
by destroying the frame, removing all timers and then marking the
instance as ready for teardown so we can destroy it after the last connected
session is closed.

Any wlr_screencopy_frame_v1 has to be destroyed before the connected
output can be removed. Otherwise wlr_screencopy_frame_v1_destroy
segfaults the whole program. To ensure this we will make all frame
callbacks safe to be triggered for a previous destroyed frame.
2022-05-31 01:23:34 +02:00
columbarius
ab0a07142d screencast: use wl_array for format-modifier-pairs
wl_array is a better fit than wl_list. It's less intensive on memory and
fits nicely with the flow of dmabuf_feedback announcing all format
modifier pairs at once and reseting them on change.
2022-05-31 01:22:48 +02:00
columbarius
2d54aeb36d screencast: fix handler logging for tranche_formats 2022-05-26 09:39:14 +02:00
columbarius
e70a1efa43 screencast: skip duplicated format-modifier pairs 2022-05-26 09:00:40 +02:00
columbarius
2219db7508 screencast: use dmabuf_feedback
The compositor can announce it's default rendering device via
linux_dmabuf_feedback as the main_device [1]. We should use this device
whenever possible. If aquiring this device fails we are adviced to use
force linear layout on buffers allocated with the implicit api.

With linux_dmabuf_v1 the modifier event is deprecated. Instead the
format_table event in combination with the tranches of
linux_dmabuf_feedback_v1 has to be used.

[1] https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/linux-dmabuf/feedback.rst
2022-05-26 09:00:40 +02:00
columbarius
14852efb05 screencast: Remove MESA hack from the old gbm api fallback
Calling gbm_bo_create_with_modifiers2(...) and setting the modifiers
pointer to NULL for the same result as gmb_bo_create(...) is a MESA hack,
which I missed to remove from 84282e9b5f.
2022-05-05 18:13:02 +02:00
columbarius
29f86168b6 screencast: announce supported explicit modifiers
We query the supported modifiers via a wrapper and announce them via
PipeWire.

This wrapper queries the supported formats from wlroots and returns them
as a simple array. The purpose of this wrapper is to ease the use of the
query functions which are kept in the style of the equivalent egl
queries.
2022-04-24 21:46:39 +02:00
columbarius
18efde6dde screencast: add function to query supported modifiers for a format
This function follows the structure of the equivalent function in egl
operating on basis of the announced format modifier pairs by wlroots.
2022-04-24 21:46:39 +02:00
columbarius
2ca2b7b603 screencast: get supported format modifier pairs from wlroots
Registering a zwp_linux_dmabuf_v1_listener gives access to the supported
format modifier pairs of the compositor.

This handler emits events for each format modifier pair. Those are stored
and will later be used to announce capabilities via PipeWire.
2022-04-24 21:46:39 +02:00
columbarius
b9c4472c50 screencast: stop assuming that allocation with implicit modifier works
It has shown that the assumption: "Allocation with implicit modifier will
always be available" doesn't hold true in all cases. Thus if allocation
of any dmabuf fails we mark the session to avoid dmabufs, thus falling
back to shm transport.
2022-04-24 21:46:39 +02:00
columbarius
84282e9b5f screencast: fixate modifier from PipeWire format negotiation result
This implements the modifier fixation procedure. The producer of a
stream has to ensure that it can create a buffer with the negotiated
properties. To do that we will take the result of the intersection of
supported modifiers by PipeWire and select the "best" modifier from that
list.

To do this we do the following allocations and fixate on the
modifier of the created buffer should the allocation suceed.
* Try to allocate a buffer with explicit modifiers using the list
  provided by PipeWire
* Walk the list of modifiers and do single allocations for implicit and
  linear modifiers using the old api.

If none of the allocations above succeed we fall back to shm buffers.
This is implemented in the next commit.

If an allocation was successfull we fixate the modifier with
fixate_format().
This function creates an EnumFormat like build_format, but will only
announce support for a single modifier.
It is used to finish the negotiation process by announcing it together
with EnumFormats of our full supported formats.
2022-04-24 21:46:39 +02:00
columbarius
a70a1195d4 screencast: check if pipewire returns a modifier list
Using SPA_POD_PROP_FLAG_DONT_FIXATE pipewire can return a list of
supported modifiers. In that case are we responsible to select one
modifier and fixate it.
2022-04-24 21:46:39 +02:00
columbarius
77bcd14ad2 screencast: support allocation of buffers with explicit modifiers 2022-04-24 21:46:39 +02:00
columbarius
1a7276068b screencast: support multiplane buffers with xdpw_buffer 2022-04-24 21:46:39 +02:00
columbarius
5799adeb57 screencast: enqueue pipewire when screencopy failed
Keeping a buffer when the copy failed has the risk of having this buffer
removed while we wait for the next buffer_done event. To prevent this we
just enqueue the buffer marking it as corrupt. A new buffer will be
dequeued at the buffer_done event.
2022-04-24 21:46:39 +02:00
columbarius
2f32d17448 screencast: remove swap_buffer function
Dequeuing a new buffer imidiately creates a problem when the buffer is
destroid while renegotiation of a valid modifier because we can end up using
a buffer which was freed while waiting for the buffer_done event. Then
xdpw will segfault when requesting a copy with a nonexisting buffer. To fix
this we can just dequeue a buffer right before we need it. This makes
the fallback via on_process obsolete since we dequeue the buffer at the
lates possible time.
2022-04-24 21:46:39 +02:00
Alias Gram
657b9edad5 chore(logging): change config file error to info 2022-04-18 18:44:47 +02:00
columbarius
6cec421f92 screencast: improve logging for pipewire events
We should log buffer add and remove events in the debug loglevel, since
they signal starts, stops and renegotiations of the buffer transfer.
Additionaly logging the negotiated pwr_format should help classify
issues from the DEBUG loglevel.
2022-04-10 13:38:01 +02:00
columbarius
852e1c95c7 screencast: HACK set an arbitrary chunk size for dmabufs
Clients have wrongly used the chunk size to detect if a buffer was valid
or not. Since dmabufs might not have a well defined buffer size we will
set an arbitrary value until clients are patched.
2022-04-10 13:38:01 +02:00
columbarius
0683f7ca7e screencast: add option to force implicit modifier to be linear
Linear buffer layouts are supported by most gpu vendors and as such
should be compatible in mixed mutli gpu setup where the implicit
modifier of one gpu is not supported by the other.

This option should make xdpw work in these environemnts.

The option is marked as experimental since it might be removed if
explicit modifiers provide a better solution.
2022-04-10 13:38:01 +02:00
columbarius
9085996111 screencast: announce implicit modifier via PipeWire 2022-04-10 13:38:01 +02:00
columbarius
d89631c792 screencast: allocate dmabuf with implicit modifier
This is using the older gbm api without support for explicit modifiers.
This is required to support AMD gpus using the GFX8 or older
architecture and older intel gpus.
2022-04-10 13:38:01 +02:00
columbarius
b2c5a94e8c screencast: add linux_dmabuf to registry 2022-04-10 13:38:01 +02:00
columbarius
9d620273e5 screencast: create gbm device
This is done by using the first device returned by getDRMDevices2
containing a render node (DRM_NODE_RENDER).
2022-04-10 13:38:01 +02:00
columbarius
bae393a684 screencast: support modifiers in build_format
When announcing support for dmabufs via PipeWire this is done by adding
the SPA_FORMAT_VIDEO_modifier property to an EnumFormat. Producers can
choose between two different ways [1]:

* Supporting only implicit modifiers by adding the property as a sigle
  value together with the SPA_POD_PROP_FLAG_MANDATORY flag
* Support for multiple modifiers. This is done by announcing a
  SPA_CHOICE_ENUM array together with the use of the
  SPA_POD_PROP_FLAG_MANDATORY and SPA_POD_PROP_FLAG_DONT_FIXATE flag

[1] https://docs.pipewire.org/page_dma_buf.html
2022-04-10 13:38:01 +02:00
columbarius
6630525b7a screencast: implement wlr_frame_linux_dmabuf 2022-04-10 13:38:01 +02:00
columbarius
12de0cd144 screencast: introduce buffer_type
We want to support WL_SHM and DMABUFS based buffers. The buffer_type
member tracks the type of a xdpw_buffer and screencopy_frame_info of the
screencast_instance will be an array with an element for each buffer type
indexed by the value of the buffer_type enum. Only members of the
xdpw_screencopy_frame_info relevant to the buffer type should be used.
2022-04-10 13:38:01 +02:00
columbarius
88a8a9cb7e screencast: add build_buffer function
This function makes it easier to omit attributes like size or stride for
cases where they won't be well defined like muliplanar dmabufs
2022-04-10 13:38:01 +02:00
columbarius
0835d8287b screencast: introduce build_formats
We build EnumFormats from our supported format multiple times. This
commit just creates a function to do that. This makes it easier to
handle the announcement of multiple buffer types.
2022-04-10 13:38:01 +02:00
columbarius
ba0f40e45c screencast: disable instance sharing
PipeWire currently will not renegotiate the used format of a stream when
a new client connects. This causes clients to get stuck when they are
incompatible with the format negotiated for the existing stream.
This will be problematic when some clients support dmabuf transport
while others won't. Thus we disable it until a solution is found.
2022-04-10 13:38:01 +02:00
columbarius
3a57c24437 screencast: use drm format instead of wl_shm
drm format defined by drm_fourcc.h is the standard to describe the
format of a buffer. This will be used when dealing with dmabufs and to
simplify things we should drm_formats for all internal structs.
2022-04-10 13:38:01 +02:00
columbarius
ce9d77c90c screencast: relax buffer flip
In case a client doesn't return a buffer early enough we can give it a
second chance by triggering on_process before we pass the buffer to
wlroots in the frame_buffer_done event.
2022-04-04 15:37:53 +02:00
columbarius
074e62d0c3 screencast: restructure the screencopy flow
The previous implemented way to use wlr_screencopy events to cicle the
screencast had issues, like halting the stream if it was paused and
resumed before PipeWire triggered a recreation of buffers. This came
from not returning a dequeued buffer. This is now mititgated by
enqueuing the current pw_buffer imidiately on a paused event and trying
to dequeue a buffer just before requesting a screencopy if none is
present.
2022-04-04 15:37:53 +02:00
columbarius
058bd97815 screencast: introduce xdpw_buffer
It showed that handling self contained buffers is much easier then have
the metadata of the buffer seperated from the actual buffer attached to
the screencast instance.

The goal of the following changes is to separate the meta informations
like requested buffer attributes and wlr_screencast data from the actual
buffers.

This enables us to:
* Simplify the flow between the PipeWire loop and the wlroots one
* Track and apply damage to each used buffer (ext_screencopy)
2022-04-04 15:37:53 +02:00
columbarius
e28f5e06e6 screencast: rename screencopy_frame to screencopy_frame_info 2022-04-04 15:37:53 +02:00
columbarius
21d26fe23e session: destroy screencast_instance directly when paused
A PipeWire client might pause the stream which enables us to stop
requesting buffers from the compositor. In this case the the quit bool
won't be enacted on and thus we should destroy it directly from here.
2022-04-04 15:37:53 +02:00
columbarius
10a07f7e90 screencast: don't use the PipeWire event to trigger screencast
Using the on_process event of the PipeWire can create a race condition
when a previous started screencast hasn't finished before the next
event.
2022-04-04 15:37:53 +02:00
columbarius
c34d09877c screencast: fix check on loop_iterate
According to the documentation [1] pw_loop_iterate (a macro for
spa_loop_control_iterate) will return the number of dispatched fd's
and thus we should check only negative return values.

[1] https://docs.pipewire.org/group__spa__loop.html#ga3bae0b32100f5752b3372a505c8e04f6
2022-01-20 16:27:35 +01:00