aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-07 19:25:38 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2023-02-07 13:35:56 -0500
commitb4ce0a30c1d8d7f2af82f4da5858c1379f8399a1 (patch)
tree89ccc0947511e12379ca550c532279ec97d0a3b4 /sway
parent7d0351b41195671263a92997caab620c763d9d65 (diff)
Use wlr_linux_dmabuf_feedback_v1_init_with_options()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3933 Closes: https://github.com/swaywm/sway/issues/7436 Closes: https://github.com/swaywm/sway/pull/7437
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/container.c70
1 files changed, 7 insertions, 63 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index dbe88028..fa76dd6a 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -3,14 +3,10 @@
#include <drm_fourcc.h>
#include <stdint.h>
#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/stat.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_subcompositor.h>
-#include <wlr/render/drm_format_set.h>
#include "linux-dmabuf-unstable-v1-protocol.h"
#include "cairo_util.h"
#include "pango.h"
@@ -1060,16 +1056,6 @@ void container_end_mouse_operation(struct sway_container *container) {
}
}
-static bool devid_from_fd(int fd, dev_t *devid) {
- struct stat stat;
- if (fstat(fd, &stat) != 0) {
- sway_log_errno(SWAY_ERROR, "fstat failed");
- return false;
- }
- *devid = stat.st_rdev;
- return true;
-}
-
static void set_fullscreen(struct sway_container *con, bool enable) {
if (!con->view) {
return;
@@ -1096,60 +1082,18 @@ static void set_fullscreen(struct sway_container *con, bool enable) {
}
struct sway_output *output = con->pending.workspace->output;
- struct wlr_output *wlr_output = output->wlr_output;
-
- // TODO: add wlroots helpers for all of this stuff
-
- const struct wlr_drm_format_set *renderer_formats =
- wlr_renderer_get_dmabuf_texture_formats(server.renderer);
- assert(renderer_formats);
- int renderer_drm_fd = wlr_renderer_get_drm_fd(server.renderer);
- int backend_drm_fd = wlr_backend_get_drm_fd(wlr_output->backend);
- if (renderer_drm_fd < 0 || backend_drm_fd < 0) {
- return;
- }
-
- dev_t render_dev, scanout_dev;
- if (!devid_from_fd(renderer_drm_fd, &render_dev) ||
- !devid_from_fd(backend_drm_fd, &scanout_dev)) {
- return;
- }
-
- const struct wlr_drm_format_set *output_formats =
- wlr_output_get_primary_formats(output->wlr_output,
- WLR_BUFFER_CAP_DMABUF);
- if (!output_formats) {
- return;
- }
-
- struct wlr_drm_format_set scanout_formats = {0};
- if (!wlr_drm_format_set_intersect(&scanout_formats,
- output_formats, renderer_formats)) {
+ const struct wlr_linux_dmabuf_feedback_v1_init_options options = {
+ .main_renderer = server.renderer,
+ .scanout_primary_output = output->wlr_output,
+ };
+ struct wlr_linux_dmabuf_feedback_v1 feedback = {0};
+ if (!wlr_linux_dmabuf_feedback_v1_init_with_options(&feedback, &options)) {
return;
}
-
- struct wlr_linux_dmabuf_feedback_v1_tranche tranches[] = {
- {
- .target_device = scanout_dev,
- .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
- .formats = &scanout_formats,
- },
- {
- .target_device = render_dev,
- .formats = renderer_formats,
- },
- };
-
- const struct wlr_linux_dmabuf_feedback_v1 feedback = {
- .main_device = render_dev,
- .tranches = tranches,
- .tranches_len = sizeof(tranches) / sizeof(tranches[0]),
- };
wlr_linux_dmabuf_v1_set_surface_feedback(server.linux_dmabuf_v1,
con->view->surface, &feedback);
-
- wlr_drm_format_set_finish(&scanout_formats);
+ wlr_linux_dmabuf_feedback_v1_finish(&feedback);
}
static void container_fullscreen_workspace(struct sway_container *con) {