Updated power management handling to address issues raised in the PR

This commit is contained in:
thanatos 2024-06-20 18:48:47 -06:00 committed by Leonardo Hernández Hernández
parent 2902df94d6
commit 650a918010
No known key found for this signature in database
GPG Key ID: E538897EE11B9624
2 changed files with 17 additions and 11 deletions

View File

@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
all: dwl all: dwl
dwl: dwl.o util.o dwl: dwl.o util.o
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -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 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 wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
util.o: util.c util.h util.o: util.c util.h
# wayland-scanner is a tool which generates C headers and rigging for Wayland # wayland-scanner is a tool which generates C headers and rigging for Wayland
@ -34,12 +34,12 @@ pointer-constraints-unstable-v1-protocol.h:
wlr-layer-shell-unstable-v1-protocol.h: wlr-layer-shell-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \ $(WAYLAND_SCANNER) server-header \
protocols/wlr-layer-shell-unstable-v1.xml $@ protocols/wlr-layer-shell-unstable-v1.xml $@
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
wlr-output-power-management-unstable-v1-protocol.h: wlr-output-power-management-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \ $(WAYLAND_SCANNER) server-header \
protocols/wlr-output-power-management-unstable-v1.xml $@ protocols/wlr-output-power-management-unstable-v1.xml $@
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
config.h: config.h:
cp config.def.h $@ cp config.def.h $@

20
dwl.c
View File

@ -312,7 +312,7 @@ static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface, static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time); double sx, double sy, uint32_t time);
static void printstatus(void); static void printstatus(void);
static void powermgrsetmodenotify(struct wl_listener *listener, void *data); static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data); static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data); static void requestdecorationmode(struct wl_listener *listener, void *data);
@ -963,8 +963,6 @@ createmon(struct wl_listener *listener, void *data)
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon); LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate); LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
m->asleep = 0;
wlr_output_state_set_enabled(&state, 1); wlr_output_state_set_enabled(&state, 1);
wlr_output_commit_state(wlr_output, &state); wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state); wlr_output_state_finish(&state);
@ -1899,6 +1897,10 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
Monitor *m = wlr_output->data; Monitor *m = wlr_output->data;
struct wlr_output_state state; 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_init(&state);
wlr_output_state_set_enabled(&state, config_head->state.enabled); wlr_output_state_set_enabled(&state, config_head->state.enabled);
if (!config_head->state.enabled) if (!config_head->state.enabled)
@ -2018,12 +2020,16 @@ printstatus(void)
} }
void void
powermgrsetmodenotify(struct wl_listener *listener, void *data) powermgrsetmode(struct wl_listener *listener, void *data)
{ {
struct wlr_output_power_v1_set_mode_event *event = data; struct wlr_output_power_v1_set_mode_event *event = data;
struct wlr_output_state state = {0};
wlr_output_enable(event->output, event->mode); if (!event->output->data)
wlr_output_commit(event->output); return;
wlr_output_state_set_enabled(&state, event->mode);
wlr_output_commit_state(event->output, &state);
((Monitor *)(event->output->data))->asleep = !event->mode; ((Monitor *)(event->output->data))->asleep = !event->mode;
} }
@ -2440,7 +2446,7 @@ setup(void)
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma); LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
power_mgr = wlr_output_power_manager_v1_create(dpy); power_mgr = wlr_output_power_manager_v1_create(dpy);
LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmodenotify); LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmode);
/* Creates an output layout, which a wlroots utility for working with an /* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */ * arrangement of screens in a physical layout. */