aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/headless/output.c6
-rw-r--r--backend/x11/output.c20
-rw-r--r--include/backend/headless.h2
-rw-r--r--include/backend/x11.h2
4 files changed, 24 insertions, 6 deletions
diff --git a/backend/headless/output.c b/backend/headless/output.c
index a13ed22c..583e521e 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -25,6 +25,10 @@ static bool output_set_custom_mode(struct wlr_output *wlr_output, int32_t width,
(struct wlr_headless_output *)wlr_output;
struct wlr_headless_backend *backend = output->backend;
+ if (refresh == 0) {
+ refresh = HEADLESS_DEFAULT_REFRESH;
+ }
+
if (output->egl_surface) {
eglDestroySurface(backend->egl.display, output->egl_surface);
}
@@ -114,7 +118,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
goto error;
}
- output_set_custom_mode(wlr_output, width, height, 60*1000);
+ output_set_custom_mode(wlr_output, width, height, 0);
strncpy(wlr_output->make, "headless", sizeof(wlr_output->make));
strncpy(wlr_output->model, "headless", sizeof(wlr_output->model));
snprintf(wlr_output->name, sizeof(wlr_output->name), "HEADLESS-%d",
diff --git a/backend/x11/output.c b/backend/x11/output.c
index 07dbe868..a2d8ba2d 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -23,14 +23,25 @@ static void parse_xcb_setup(struct wlr_output *output, xcb_connection_t *xcb_con
xcb_setup->protocol_minor_version);
}
-static bool output_set_custom_mode(struct wlr_output *wlr_output, int32_t width,
- int32_t height, int32_t refresh) {
+static void output_set_refresh(struct wlr_output *wlr_output, int32_t refresh) {
struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
- struct wlr_x11_backend *x11 = output->x11;
+
+ if (refresh == 0) {
+ refresh = X11_DEFAULT_REFRESH;
+ }
wlr_output_update_custom_mode(&output->wlr_output, wlr_output->width,
wlr_output->height, refresh);
+
output->frame_delay = 1000000 / refresh;
+}
+
+static bool output_set_custom_mode(struct wlr_output *wlr_output,
+ int32_t width, int32_t height, int32_t refresh) {
+ struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
+ struct wlr_x11_backend *x11 = output->x11;
+
+ output_set_refresh(&output->wlr_output, refresh);
const uint32_t values[] = { width, height };
xcb_configure_window(x11->xcb_conn, output->win,
@@ -97,8 +108,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) {
struct wlr_output *wlr_output = &output->wlr_output;
wlr_output_init(wlr_output, &x11->backend, &output_impl, x11->wl_display);
- wlr_output->refresh = 60 * 1000000;
- output->frame_delay = 16; // 60 Hz
+ output_set_refresh(&output->wlr_output, 0);
snprintf(wlr_output->name, sizeof(wlr_output->name), "X11-%d",
wl_list_length(&x11->outputs) + 1);
diff --git a/include/backend/headless.h b/include/backend/headless.h
index e130bae1..add4c4e8 100644
--- a/include/backend/headless.h
+++ b/include/backend/headless.h
@@ -4,6 +4,8 @@
#include <wlr/backend/headless.h>
#include <wlr/backend/interface.h>
+#define HEADLESS_DEFAULT_REFRESH (60 * 1000) // 60 Hz
+
struct wlr_headless_backend {
struct wlr_backend backend;
struct wlr_egl egl;
diff --git a/include/backend/x11.h b/include/backend/x11.h
index 2fce409e..1c88cefc 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -12,6 +12,8 @@
#define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f
+#define X11_DEFAULT_REFRESH (60 * 1000) // 60 Hz
+
struct wlr_x11_backend;
struct wlr_x11_output {