mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-02-04 10:13:11 +00:00
protocols: init protocols dir & add wlr-output-power-management-v1 protocol
This commit is contained in:
parent
17f0bd9db4
commit
7ff25209c4
16
protocols/wlr-output-power-management/README.md
Normal file
16
protocols/wlr-output-power-management/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
### Description
|
||||||
|
|
||||||
|
Implements the [wlr-output-power-management](https://wayland.app/protocols/wlr-output-power-management-unstable-v1) protocol, allowing clients to control power management modes of outputs that are currently part of the compositor space (i.e. allowing clients to power down outputs when the system is idle)
|
||||||
|
|
||||||
|
### Download
|
||||||
|
|
||||||
|
- [git branch](/jackinfurs/dwl/src/branch/main)
|
||||||
|
- [main](/jackinfurs/dwl-patches/raw/branch/main/protocols/wlr-output-power-management/wlr-output-power-management-v1.patch)
|
||||||
|
|
||||||
|
### Authors
|
||||||
|
|
||||||
|
- [Leonardo Hernández Hernández](https://codeberg.org/sevz)
|
||||||
|
- [thanatos](https://codeberg.org/thanatos)
|
||||||
|
- [Emil Miler](https://codeberg.org/realcharmer)
|
||||||
|
- [Dima Krasner](https://codeberg.org/dimkr)
|
||||||
|
|
||||||
@ -0,0 +1,252 @@
|
|||||||
|
From 99bfbb079135709726def083397f9378f2829efa Mon Sep 17 00:00:00 2001
|
||||||
|
From: jackinfurs <jackdunne626@gmail.com>
|
||||||
|
Date: Tue, 23 Dec 2025 19:34:40 +0000
|
||||||
|
Subject: [PATCH] protocol: wlr-output-power-management
|
||||||
|
|
||||||
|
---
|
||||||
|
Makefile | 2 +-
|
||||||
|
dwl.c | 30 ++++
|
||||||
|
...lr-output-power-management-unstable-v1.xml | 128 ++++++++++++++++++
|
||||||
|
3 files changed, 159 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 protocols/wlr-output-power-management-unstable-v1.xml
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index f1ade34..578194f 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -21,7 +21,7 @@ dwl: dwl.o util.o
|
||||||
|
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||||
|
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
|
||||||
|
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
|
||||||
|
- xdg-shell-protocol.h
|
||||||
|
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||||
|
util.o: util.c util.h
|
||||||
|
|
||||||
|
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index 506a514..12f441e 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -37,6 +37,7 @@
|
||||||
|
#include <wlr/types/wlr_output.h>
|
||||||
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
|
#include <wlr/types/wlr_output_management_v1.h>
|
||||||
|
+#include <wlr/types/wlr_output_power_management_v1.h>
|
||||||
|
#include <wlr/types/wlr_pointer.h>
|
||||||
|
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
||||||
|
#include <wlr/types/wlr_presentation_time.h>
|
||||||
|
@@ -310,6 +311,7 @@ static void outputmgrtest(struct wl_listener *listener, void *data);
|
||||||
|
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||||
|
double sx, double sy, uint32_t time);
|
||||||
|
static void printstatus(void);
|
||||||
|
+static void powermgrsetmode(struct wl_listener *listener, void *data);
|
||||||
|
static void quit(const Arg *arg);
|
||||||
|
static void rendermon(struct wl_listener *listener, void *data);
|
||||||
|
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
||||||
|
@@ -379,6 +381,7 @@ static struct wlr_output_manager_v1 *output_mgr;
|
||||||
|
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||||
|
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
||||||
|
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
|
||||||
|
+static struct wlr_output_power_manager_v1 *power_mgr;
|
||||||
|
|
||||||
|
static struct wlr_pointer_constraints_v1 *pointer_constraints;
|
||||||
|
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
|
||||||
|
@@ -423,6 +426,7 @@ static struct wl_listener new_xdg_decoration = {.notify = createdecoration};
|
||||||
|
static struct wl_listener new_layer_surface = {.notify = createlayersurface};
|
||||||
|
static struct wl_listener output_mgr_apply = {.notify = outputmgrapply};
|
||||||
|
static struct wl_listener output_mgr_test = {.notify = outputmgrtest};
|
||||||
|
+static struct wl_listener output_power_mgr_set_mode = {.notify = powermgrsetmode};
|
||||||
|
static struct wl_listener request_activate = {.notify = urgent};
|
||||||
|
static struct wl_listener request_cursor = {.notify = setcursor};
|
||||||
|
static struct wl_listener request_set_psel = {.notify = setpsel};
|
||||||
|
@@ -769,6 +773,7 @@ cleanuplisteners(void)
|
||||||
|
wl_list_remove(&new_layer_surface.link);
|
||||||
|
wl_list_remove(&output_mgr_apply.link);
|
||||||
|
wl_list_remove(&output_mgr_test.link);
|
||||||
|
+ wl_list_remove(&output_power_mgr_set_mode.link);
|
||||||
|
wl_list_remove(&request_activate.link);
|
||||||
|
wl_list_remove(&request_cursor.link);
|
||||||
|
wl_list_remove(&request_set_psel.link);
|
||||||
|
@@ -1998,6 +2003,10 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
||||||
|
Monitor *m = wlr_output->data;
|
||||||
|
struct wlr_output_state state;
|
||||||
|
|
||||||
|
+ /* Ensure displays previously disabled by wlr-output-power-management-v1
|
||||||
|
+ * are properly handled*/
|
||||||
|
+ m->asleep = 0;
|
||||||
|
+
|
||||||
|
wlr_output_state_init(&state);
|
||||||
|
wlr_output_state_set_enabled(&state, config_head->state.enabled);
|
||||||
|
if (!config_head->state.enabled)
|
||||||
|
@@ -2113,6 +2122,24 @@ printstatus(void)
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+powermgrsetmode(struct wl_listener *listener, void *data)
|
||||||
|
+{
|
||||||
|
+ struct wlr_output_power_v1_set_mode_event *event = data;
|
||||||
|
+ struct wlr_output_state state = {0};
|
||||||
|
+ Monitor *m = event->output->data;
|
||||||
|
+
|
||||||
|
+ if (!m)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the ouput */
|
||||||
|
+ wlr_output_state_set_enabled(&state, event->mode);
|
||||||
|
+ wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
+
|
||||||
|
+ m->asleep = !event->mode;
|
||||||
|
+ updatemons(NULL, NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
quit(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -2503,6 +2530,9 @@ setup(void)
|
||||||
|
|
||||||
|
wlr_scene_set_gamma_control_manager_v1(scene, wlr_gamma_control_manager_v1_create(dpy));
|
||||||
|
|
||||||
|
+ power_mgr = wlr_output_power_manager_v1_create(dpy);
|
||||||
|
+ wl_signal_add(&power_mgr->events.set_mode, &output_power_mgr_set_mode);
|
||||||
|
+
|
||||||
|
/* Creates an output layout, which is a wlroots utility for working with an
|
||||||
|
* arrangement of screens in a physical layout. */
|
||||||
|
output_layout = wlr_output_layout_create(dpy);
|
||||||
|
diff --git a/protocols/wlr-output-power-management-unstable-v1.xml b/protocols/wlr-output-power-management-unstable-v1.xml
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..a977839
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/protocols/wlr-output-power-management-unstable-v1.xml
|
||||||
|
@@ -0,0 +1,128 @@
|
||||||
|
+<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
+<protocol name="wlr_output_power_management_unstable_v1">
|
||||||
|
+ <copyright>
|
||||||
|
+ Copyright © 2019 Purism SPC
|
||||||
|
+
|
||||||
|
+ Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
+ copy of this software and associated documentation files (the "Software"),
|
||||||
|
+ to deal in the Software without restriction, including without limitation
|
||||||
|
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
+ and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
+ Software is furnished to do so, subject to the following conditions:
|
||||||
|
+
|
||||||
|
+ The above copyright notice and this permission notice (including the next
|
||||||
|
+ paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
+ Software.
|
||||||
|
+
|
||||||
|
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
+ DEALINGS IN THE SOFTWARE.
|
||||||
|
+ </copyright>
|
||||||
|
+
|
||||||
|
+ <description summary="Control power management modes of outputs">
|
||||||
|
+ This protocol allows clients to control power management modes
|
||||||
|
+ of outputs that are currently part of the compositor space. The
|
||||||
|
+ intent is to allow special clients like desktop shells to power
|
||||||
|
+ down outputs when the system is idle.
|
||||||
|
+
|
||||||
|
+ To modify outputs not currently part of the compositor space see
|
||||||
|
+ wlr-output-management.
|
||||||
|
+
|
||||||
|
+ Warning! The protocol described in this file is experimental and
|
||||||
|
+ backward incompatible changes may be made. Backward compatible changes
|
||||||
|
+ may be added together with the corresponding interface version bump.
|
||||||
|
+ Backward incompatible changes are done by bumping the version number in
|
||||||
|
+ the protocol and interface names and resetting the interface version.
|
||||||
|
+ Once the protocol is to be declared stable, the 'z' prefix and the
|
||||||
|
+ version number in the protocol and interface names are removed and the
|
||||||
|
+ interface version number is reset.
|
||||||
|
+ </description>
|
||||||
|
+
|
||||||
|
+ <interface name="zwlr_output_power_manager_v1" version="1">
|
||||||
|
+ <description summary="manager to create per-output power management">
|
||||||
|
+ This interface is a manager that allows creating per-output power
|
||||||
|
+ management mode controls.
|
||||||
|
+ </description>
|
||||||
|
+
|
||||||
|
+ <request name="get_output_power">
|
||||||
|
+ <description summary="get a power management for an output">
|
||||||
|
+ Create a output power management mode control that can be used to
|
||||||
|
+ adjust the power management mode for a given output.
|
||||||
|
+ </description>
|
||||||
|
+ <arg name="id" type="new_id" interface="zwlr_output_power_v1"/>
|
||||||
|
+ <arg name="output" type="object" interface="wl_output"/>
|
||||||
|
+ </request>
|
||||||
|
+
|
||||||
|
+ <request name="destroy" type="destructor">
|
||||||
|
+ <description summary="destroy the manager">
|
||||||
|
+ All objects created by the manager will still remain valid, until their
|
||||||
|
+ appropriate destroy request has been called.
|
||||||
|
+ </description>
|
||||||
|
+ </request>
|
||||||
|
+ </interface>
|
||||||
|
+
|
||||||
|
+ <interface name="zwlr_output_power_v1" version="1">
|
||||||
|
+ <description summary="adjust power management mode for an output">
|
||||||
|
+ This object offers requests to set the power management mode of
|
||||||
|
+ an output.
|
||||||
|
+ </description>
|
||||||
|
+
|
||||||
|
+ <enum name="mode">
|
||||||
|
+ <entry name="off" value="0"
|
||||||
|
+ summary="Output is turned off."/>
|
||||||
|
+ <entry name="on" value="1"
|
||||||
|
+ summary="Output is turned on, no power saving"/>
|
||||||
|
+ </enum>
|
||||||
|
+
|
||||||
|
+ <enum name="error">
|
||||||
|
+ <entry name="invalid_mode" value="1" summary="inexistent power save mode"/>
|
||||||
|
+ </enum>
|
||||||
|
+
|
||||||
|
+ <request name="set_mode">
|
||||||
|
+ <description summary="Set an outputs power save mode">
|
||||||
|
+ Set an output's power save mode to the given mode. The mode change
|
||||||
|
+ is effective immediately. If the output does not support the given
|
||||||
|
+ mode a failed event is sent.
|
||||||
|
+ </description>
|
||||||
|
+ <arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/>
|
||||||
|
+ </request>
|
||||||
|
+
|
||||||
|
+ <event name="mode">
|
||||||
|
+ <description summary="Report a power management mode change">
|
||||||
|
+ Report the power management mode change of an output.
|
||||||
|
+
|
||||||
|
+ The mode event is sent after an output changed its power
|
||||||
|
+ management mode. The reason can be a client using set_mode or the
|
||||||
|
+ compositor deciding to change an output's mode.
|
||||||
|
+ This event is also sent immediately when the object is created
|
||||||
|
+ so the client is informed about the current power management mode.
|
||||||
|
+ </description>
|
||||||
|
+ <arg name="mode" type="uint" enum="mode"
|
||||||
|
+ summary="the output's new power management mode"/>
|
||||||
|
+ </event>
|
||||||
|
+
|
||||||
|
+ <event name="failed">
|
||||||
|
+ <description summary="object no longer valid">
|
||||||
|
+ This event indicates that the output power management mode control
|
||||||
|
+ is no longer valid. This can happen for a number of reasons,
|
||||||
|
+ including:
|
||||||
|
+ - The output doesn't support power management
|
||||||
|
+ - Another client already has exclusive power management mode control
|
||||||
|
+ for this output
|
||||||
|
+ - The output disappeared
|
||||||
|
+
|
||||||
|
+ Upon receiving this event, the client should destroy this object.
|
||||||
|
+ </description>
|
||||||
|
+ </event>
|
||||||
|
+
|
||||||
|
+ <request name="destroy" type="destructor">
|
||||||
|
+ <description summary="destroy this power management">
|
||||||
|
+ Destroys the output power management mode control object.
|
||||||
|
+ </description>
|
||||||
|
+ </request>
|
||||||
|
+ </interface>
|
||||||
|
+</protocol>
|
||||||
|
--
|
||||||
|
2.51.2
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user