Applied the power management patch

This commit is contained in:
Micah Gorrell 2023-05-12 16:15:02 -06:00
parent 2eca253c15
commit 7f19498c4d
4 changed files with 408 additions and 1 deletions

19
dwl.c
View file

@ -30,8 +30,10 @@
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output.h>
#include <wlr/interfaces/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_presentation_time.h>
#include <wlr/types/wlr_primary_selection.h>
@ -301,6 +303,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 quitsignal(int signo);
static void rendermon(struct wl_listener *listener, void *data);
@ -380,6 +383,9 @@ static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static struct wlr_output_power_manager_v1 *power_mgr;
static struct wl_listener power_mgr_set_mode = {.notify = powermgrsetmodenotify};
static struct wlr_seat *seat;
static struct wl_list keyboards;
static unsigned int cursor_mode;
@ -2093,6 +2099,16 @@ printstatus(void)
fflush(stdout);
}
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);
if (event->mode)
wlr_output_damage_whole(event->output);
wlr_output_commit(event->output);
}
void
quit(const Arg *arg)
{
@ -2436,6 +2452,9 @@ setup(void)
activation = wlr_xdg_activation_v1_create(dpy);
wl_signal_add(&activation->events.request_activate, &request_activate);
power_mgr = wlr_output_power_manager_v1_create(dpy);
wl_signal_add(&power_mgr->events.set_mode, &power_mgr_set_mode);
/* 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();