add support for the following protocols:

- wlr_xdg_output_v1
 - wlr_screencopy_v1
 - wlr_export_dmabuf_v1
 - wlr_data_control_v1
 - wlr_single_pixel_buffer_v1

minor feature: add option -v to increase the log level
This commit is contained in:
DanyLE
2025-07-05 19:07:57 +02:00
parent 6be0e9b5c4
commit 13543e1382

26
diyac.c
View File

@ -8,6 +8,11 @@
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <wlr/types/wlr_xdg_output_v1.h>
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include "output.h"
#include "xdg.h"
#include "cursor.h"
@ -54,15 +59,20 @@ static int session_monitor(void *data)
int main(int argc, char *argv[])
{
wlr_log_init(WLR_INFO, NULL);
char *startup_cmd = NULL;
int exit_with_session = 0;
int log_level = WLR_ERROR;
int c;
while ((c = getopt(argc, argv, "xh")) != -1)
while ((c = getopt(argc, argv, "xvh")) != -1)
{
switch (c)
{
case 'v':
if(log_level < WLR_DEBUG)
{
log_level++;
}
break;
case 'x':
exit_with_session = 1;
break;
@ -86,6 +96,7 @@ int main(int argc, char *argv[])
// the last argument is the startup command
startup_cmd = argv[optind];
}
wlr_log_init(log_level, NULL);
struct diyac_server server = {0};
/* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, manging Wayland globals, and so on. */
@ -167,6 +178,11 @@ int main(int argc, char *argv[])
*/
server.scene = wlr_scene_create();
server.scene_layout = wlr_scene_attach_output_layout(server.scene, server.output_layout);
wlr_xdg_output_manager_v1_create(server.wl_display,server.output_layout);
wlr_export_dmabuf_manager_v1_create(server.wl_display);
wlr_data_control_manager_v1_create(server.wl_display);
wlr_screencopy_manager_v1_create(server.wl_display);
wlr_single_pixel_buffer_manager_v1_create(server.wl_display);
wlr_fractional_scale_manager_v1_create(server.wl_display,1);
/* Set up xdg-shell version 6 The xdg-shell is a Wayland protocol which is
* used for application windows. For more detail on shells, refer to
@ -263,7 +279,9 @@ int main(int argc, char *argv[])
{
wl_event_source_remove(server.proc_mon);
}
// TODO remove all event listeners
wl_list_remove(&server.new_xdg_toplevel.link);
wl_list_remove(&server.new_layer_surface.link);
wl_list_remove(&server.new_output.link);
wl_display_destroy_clients(server.wl_display);
// wlr_scene_node_destroy(&server.scene->tree.node);
wlr_xcursor_manager_destroy(server.seat.cursor_mgr);