summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthanatos <thanatos@noreply.codeberg.org>2024-06-20 18:48:47 -0600
committerLeonardo Hernández Hernández <leohdz172@proton.me>2024-06-20 19:11:53 -0600
commit650a918010ac5769787d461812392cff786e4d3b (patch)
treeb7a77db6d8361b44cc8c9b2aee247d8daf4e4e4c
parent2902df94d6e3da04b7abc92f846b0da7d40ff4ea (diff)
Updated power management handling to address issues raised in the PR
-rw-r--r--Makefile8
-rw-r--r--dwl.c20
2 files changed, 17 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 8375772..fdc581a 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
all: dwl
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
+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
# 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:
$(WAYLAND_SCANNER) server-header \
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:
$(WAYLAND_SCANNER) server-header \
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:
cp config.def.h $@
diff --git a/dwl.c b/dwl.c
index 4867760..2cdc819 100644
--- a/dwl.c
+++ b/dwl.c
@@ -312,7 +312,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 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);
@@ -963,8 +963,6 @@ createmon(struct wl_listener *listener, void *data)
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
- m->asleep = 0;
-
wlr_output_state_set_enabled(&state, 1);
wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state);
@@ -1899,6 +1897,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)
@@ -2018,12 +2020,16 @@ printstatus(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_state state = {0};
+
+ if (!event->output->data)
+ return;
- wlr_output_enable(event->output, event->mode);
- wlr_output_commit(event->output);
+ wlr_output_state_set_enabled(&state, event->mode);
+ wlr_output_commit_state(event->output, &state);
((Monitor *)(event->output->data))->asleep = !event->mode;
}
@@ -2440,7 +2446,7 @@ setup(void)
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);
+ LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmode);
/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */