Files
nix-config/patches/dwl/refresh_rate.patch

32 lines
1.2 KiB
Diff

--- dwl-bak/dwl.c 2026-04-09 15:53:00.841862418 +0200
+++ dwl/dwl.c 2026-04-09 16:02:39.604999328 +0200
@@ -1045,6 +1045,7 @@
size_t i;
struct wlr_output_state state;
Monitor *m;
+ struct wlr_output_mode *mode = NULL;
if (!wlr_output_init_render(wlr_output, alloc, drw))
return;
@@ -1077,7 +1078,19 @@
* monitor supports only a specific set of modes. We just pick the
* monitor's preferred mode; a more sophisticated compositor would let
* the user configure it. */
- wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output));
+ if (refresh_rate || s_width || s_height) {
+ wl_list_for_each(mode, &wlr_output->modes, link) {
+ if ((refresh_rate == 0 || mode->refresh == refresh_rate) && (s_width == 0 || mode->width == s_width) && (s_height == 0 || mode->height == s_height)) {
+ break;
+ }
+ }
+ }
+ if (mode == NULL) {
+ printf("Was not able find output mode with (width, height, refresh rate): (%d, %d, %d)\n", s_width, s_height, refresh_rate);
+ mode = wlr_output_preferred_mode(wlr_output);
+ }
+
+ wlr_output_state_set_mode(&state, mode);
/* Set up event listeners */
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);