add support to protocol: output-power-manager + output-manager

This commit is contained in:
DanyLE
2025-07-09 20:32:33 +02:00
parent 194b7894cd
commit 9cc2408dc8
6 changed files with 779 additions and 99 deletions

34
diyac.c
View File

@ -8,7 +8,6 @@
#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>
@ -75,7 +74,7 @@ int main(int argc, char *argv[])
switch (c)
{
case 'v':
if(log_level < WLR_DEBUG)
if (log_level < WLR_DEBUG)
{
log_level++;
}
@ -95,7 +94,7 @@ int main(int argc, char *argv[])
}
if (optind < argc)
{
if(optind != argc - 1)
if (optind != argc - 1)
{
help();
return 1;
@ -167,15 +166,6 @@ int main(int argc, char *argv[])
*/
wlr_primary_selection_v1_device_manager_create(server.wl_display);
/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
server.output_layout = wlr_output_layout_create(server.wl_display);
/* Configure a listener to be notified when new outputs are available on the
* backend. */
wl_list_init(&server.outputs);
server.new_output.notify = diyac_server_new_output;
wl_signal_add(&server.backend->events.new_output, &server.new_output);
/* Create a scene graph. This is a wlroots abstraction that handles all
* rendering and damage tracking. All the compositor author needs to do
@ -184,22 +174,22 @@ int main(int argc, char *argv[])
* necessary.
*/
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);
diyac_output_init(&server);
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);
wlr_fractional_scale_manager_v1_create(server.wl_display, 1);
diya_init_idle_manager(server.wl_display);
/* 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
* https://drewdevault.com/2018/07/29/Wayland-shells.html.
*/
wl_list_init(&server.views);
/**
* TODO: free these tree when finish
*/
* TODO: free these tree when finish
*/
server.view_tree = wlr_scene_tree_create(&server.scene->tree);
server.xdg_popup_tree = wlr_scene_tree_create(&server.scene->tree);
@ -263,7 +253,7 @@ int main(int argc, char *argv[])
wlr_log(WLR_INFO, "Running Wayland compositor on WAYLAND_DISPLAY=%s",
socket);
server.proc_mon = NULL;
if( startup_cmd && exit_with_session)
if (startup_cmd && exit_with_session)
{
if (server.session_pid == -1)
{
@ -283,13 +273,17 @@ int main(int argc, char *argv[])
/* Once wl_display_run returns, we destroy all clients then shut down the
* server. */
if(server.proc_mon)
if (server.proc_mon)
{
wl_event_source_remove(server.proc_mon);
}
wl_list_remove(&server.new_xdg_toplevel.link);
wl_list_remove(&server.new_layer_surface.link);
wl_list_remove(&server.new_output.link);
wl_list_remove(&server.output_power_manager_set_mode.link);
wl_list_remove(&server.output_manager_apply.link);
wl_list_remove(&server.output_manager_test.link);
wl_list_remove(&server.output_layout_change.link);
wl_display_destroy_clients(server.wl_display);
// wlr_scene_node_destroy(&server.scene->tree.node);
wlr_xcursor_manager_destroy(server.seat.cursor_mgr);
@ -301,5 +295,5 @@ int main(int argc, char *argv[])
/**
* @brief TODO
* reload configuration (keymap, etc.) when sighub is received
*
*
*/