summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorEmil Miler <em@0x45.cz>2024-01-17 09:45:03 +0100
committerLeonardo Hernández Hernández <leohdz172@proton.me>2024-06-20 19:11:52 -0600
commit9b1f35e42bf435b212dfcdcc510439ef8b4f2e31 (patch)
treeacdfca5e544552e08890a227a2a48660c7b94f99 /dwl.c
parent92d1c286b8041bcdf5c335a63f5c060460e2a0e0 (diff)
Implement support for output power management
This patch is based on the original stale patch by Guido Cella @guidocella. It has been modified to apply cleanly to the latest v5.0 tag. Since the SLOC limit is now lifted, this core feature should be merged into dwl upstream. Thanks to Dima Krasner @dimkr for the cherry-pick. Closes: #559, #525
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 3dba2bf..7a2920e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -34,6 +34,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 powermgrsetmodenotify(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);
@@ -381,6 +383,7 @@ static struct wlr_gamma_control_manager_v1 *gamma_control_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;
@@ -2012,6 +2015,14 @@ printstatus(void)
}
void
+powermgrsetmodenotify(struct wl_listener *listener, void *data)
+{
+ struct wlr_output_power_v1_set_mode_event *event = data;
+ wlr_output_enable(event->output, event->mode);
+ wlr_output_commit(event->output);
+}
+
+void
quit(const Arg *arg)
{
wl_display_terminate(dpy);
@@ -2422,6 +2433,9 @@ setup(void)
gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
+ power_mgr = wlr_output_power_manager_v1_create(dpy);
+ LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmodenotify);
+
/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
output_layout = wlr_output_layout_create();