aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/backend.c49
-rw-r--r--backend/drm/backend.c11
-rw-r--r--backend/drm/drm.c84
-rw-r--r--backend/drm/util.c19
-rw-r--r--backend/headless/output.c4
-rw-r--r--backend/multi/backend.c36
-rw-r--r--backend/session/logind.c127
-rw-r--r--backend/wayland/output.c26
-rw-r--r--backend/x11/output.c7
9 files changed, 316 insertions, 47 deletions
diff --git a/backend/backend.c b/backend/backend.c
index 78b90007..4b186767 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -15,6 +15,7 @@
#include <wlr/backend/wayland.h>
#include <wlr/config.h>
#include <wlr/util/log.h>
+#include "backend/multi.h"
/* WLR_HAS_X11_BACKEND needs to be after wlr/config.h */
#ifdef WLR_HAS_X11_BACKEND
@@ -56,6 +57,20 @@ struct wlr_renderer *wlr_backend_get_renderer(struct wlr_backend *backend) {
return NULL;
}
+struct wlr_session *wlr_backend_get_session(struct wlr_backend *backend) {
+ if (backend->impl->get_session) {
+ return backend->impl->get_session(backend);
+ }
+ return NULL;
+}
+
+clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
+ if (backend->impl->get_presentation_clock) {
+ return backend->impl->get_presentation_clock(backend);
+ }
+ return CLOCK_MONOTONIC;
+}
+
static size_t parse_outputs_env(const char *name) {
const char *outputs_str = getenv(name);
if (outputs_str == NULL) {
@@ -158,10 +173,12 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
return attempt_headless_backend(display, create_renderer_func);
} else if (strcmp(name, "drm") == 0 || strcmp(name, "libinput") == 0) {
// DRM and libinput need a session
- *session = wlr_session_create(display);
if (!*session) {
- wlr_log(WLR_ERROR, "failed to start a session");
- return NULL;
+ *session = wlr_session_create(display);
+ if (!*session) {
+ wlr_log(WLR_ERROR, "failed to start a session");
+ return NULL;
+ }
}
if (strcmp(name, "libinput") == 0) {
@@ -178,13 +195,12 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
wlr_renderer_create_func_t create_renderer_func) {
struct wlr_backend *backend = wlr_multi_backend_create(display);
+ struct wlr_multi_backend *multi = (struct wlr_multi_backend *)backend;
if (!backend) {
wlr_log(WLR_ERROR, "could not allocate multibackend");
return NULL;
}
- struct wlr_session *session = NULL;
-
char *names = getenv("WLR_BACKENDS");
if (names) {
names = strdup(names);
@@ -197,12 +213,12 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
char *saveptr;
char *name = strtok_r(names, ",", &saveptr);
while (name != NULL) {
- struct wlr_backend *subbackend =
- attempt_backend_by_name(display, backend, &session, name, create_renderer_func);
+ struct wlr_backend *subbackend = attempt_backend_by_name(display,
+ backend, &multi->session, name, create_renderer_func);
if (subbackend == NULL) {
wlr_log(WLR_ERROR, "failed to start backend '%s'", name);
wlr_backend_destroy(backend);
- wlr_session_destroy(session);
+ wlr_session_destroy(multi->session);
free(names);
return NULL;
}
@@ -210,7 +226,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
if (!wlr_multi_backend_add(backend, subbackend)) {
wlr_log(WLR_ERROR, "failed to add backend '%s'", name);
wlr_backend_destroy(backend);
- wlr_session_destroy(session);
+ wlr_session_destroy(multi->session);
free(names);
return NULL;
}
@@ -245,29 +261,30 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
#endif
// Attempt DRM+libinput
- session = wlr_session_create(display);
- if (!session) {
+ multi->session = wlr_session_create(display);
+ if (!multi->session) {
wlr_log(WLR_ERROR, "Failed to start a DRM session");
wlr_backend_destroy(backend);
return NULL;
}
- struct wlr_backend *libinput = wlr_libinput_backend_create(display, session);
+ struct wlr_backend *libinput = wlr_libinput_backend_create(display,
+ multi->session);
if (!libinput) {
wlr_log(WLR_ERROR, "Failed to start libinput backend");
wlr_backend_destroy(backend);
- wlr_session_destroy(session);
+ wlr_session_destroy(multi->session);
return NULL;
}
wlr_multi_backend_add(backend, libinput);
- struct wlr_backend *primary_drm =
- attempt_drm_backend(display, backend, session, create_renderer_func);
+ struct wlr_backend *primary_drm = attempt_drm_backend(display, backend,
+ multi->session, create_renderer_func);
if (!primary_drm) {
wlr_log(WLR_ERROR, "Failed to open any DRM device");
wlr_backend_destroy(libinput);
wlr_backend_destroy(backend);
- wlr_session_destroy(session);
+ wlr_session_destroy(multi->session);
return NULL;
}
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 76918e7d..a9082077 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -65,10 +65,16 @@ static struct wlr_renderer *backend_get_renderer(
}
}
+static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
+ struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
+ return drm->clock;
+}
+
static struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_renderer = backend_get_renderer,
+ .get_presentation_clock = backend_get_presentation_clock,
};
bool wlr_backend_is_drm(struct wlr_backend *b) {
@@ -203,8 +209,3 @@ error_fd:
free(drm);
return NULL;
}
-
-struct wlr_session *wlr_drm_backend_get_session(struct wlr_backend *backend) {
- struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
- return drm->session;
-}
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 784a0233..00525762 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -1,3 +1,4 @@
+#define _POSIX_C_SOURCE 199309L
#include <assert.h>
#include <drm_mode.h>
#include <EGL/egl.h>
@@ -27,8 +28,8 @@
#include "util/signal.h"
bool check_drm_features(struct wlr_drm_backend *drm) {
+ uint64_t cap;
if (drm->parent) {
- uint64_t cap;
if (drmGetCap(drm->fd, DRM_CAP_PRIME, &cap) ||
!(cap & DRM_PRIME_CAP_IMPORT)) {
wlr_log(WLR_ERROR,
@@ -51,16 +52,21 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
const char *no_atomic = getenv("WLR_DRM_NO_ATOMIC");
if (no_atomic && strcmp(no_atomic, "1") == 0) {
- wlr_log(WLR_DEBUG, "WLR_DRM_NO_ATOMIC set, forcing legacy DRM interface");
+ wlr_log(WLR_DEBUG,
+ "WLR_DRM_NO_ATOMIC set, forcing legacy DRM interface");
drm->iface = &legacy_iface;
} else if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
- wlr_log(WLR_DEBUG, "Atomic modesetting unsupported, using legacy DRM interface");
+ wlr_log(WLR_DEBUG,
+ "Atomic modesetting unsupported, using legacy DRM interface");
drm->iface = &legacy_iface;
} else {
wlr_log(WLR_DEBUG, "Using atomic DRM interface");
drm->iface = &atomic_iface;
}
+ int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap);
+ drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME;
+
return true;
}
@@ -150,6 +156,11 @@ bool init_drm_resources(struct wlr_drm_backend *drm) {
wlr_log(WLR_INFO, "Found %d DRM CRTCs", res->count_crtcs);
drm->num_crtcs = res->count_crtcs;
+ if (drm->num_crtcs == 0) {
+ drmModeFreeResources(res);
+ return true;
+ }
+
drm->crtcs = calloc(drm->num_crtcs, sizeof(drm->crtcs[0]));
if (!drm->crtcs) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
@@ -427,9 +438,9 @@ static void realloc_planes(struct wlr_drm_backend *drm, const uint32_t *crtc_in,
continue;
}
- uint32_t possible[drm->num_type_planes[type]];
- uint32_t crtc[drm->num_crtcs];
- uint32_t crtc_res[drm->num_crtcs];
+ uint32_t possible[drm->num_type_planes[type] + 1];
+ uint32_t crtc[drm->num_crtcs + 1];
+ uint32_t crtc_res[drm->num_crtcs + 1];
for (size_t i = 0; i < drm->num_type_planes[type]; ++i) {
possible[i] = drm->type_planes[type][i].possible_crtcs;
@@ -724,6 +735,43 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
return ok;
}
+static void drm_connector_schedule_frame(struct wlr_output *output) {
+ struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
+ struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
+ if (!drm->session->active) {
+ return;
+ }
+
+ // We need to figure out where we are in the vblank cycle
+ // TODO: try using drmWaitVBlank and fallback to pageflipping
+
+ struct wlr_drm_crtc *crtc = conn->crtc;
+ if (!crtc) {
+ return;
+ }
+ struct wlr_drm_plane *plane = crtc->primary;
+ struct gbm_bo *bo = plane->surf.back;
+ if (!bo) {
+ // We haven't swapped buffers yet -- can't do a pageflip
+ wlr_output_send_frame(output);
+ return;
+ }
+ uint32_t fb_id = get_fb_for_bo(bo);
+
+ if (conn->pageflip_pending) {
+ wlr_log(WLR_ERROR, "Skipping pageflip on output '%s'",
+ conn->output.name);
+ return;
+ }
+
+ if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) {
+ return;
+ }
+
+ conn->pageflip_pending = true;
+ wlr_output_update_enabled(output, true);
+}
+
static void drm_connector_destroy(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
drm_connector_cleanup(conn);
@@ -745,6 +793,7 @@ static const struct wlr_output_impl output_impl = {
.set_gamma = set_drm_connector_gamma,
.get_gamma_size = drm_connector_get_gamma_size,
.export_dmabuf = drm_connector_export_dmabuf,
+ .schedule_frame = drm_connector_schedule_frame,
};
bool wlr_output_is_drm(struct wlr_output *output) {
@@ -1134,7 +1183,7 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
}
}
- bool changed_outputs[wl_list_length(&drm->outputs)];
+ bool changed_outputs[wl_list_length(&drm->outputs) + 1];
memset(changed_outputs, false, sizeof(changed_outputs));
for (size_t i = 0; i < new_outputs_len; ++i) {
struct wlr_drm_connector *conn = new_outputs[i];
@@ -1166,9 +1215,13 @@ void scan_drm_connectors(struct wlr_drm_backend *drm) {
attempt_enable_needs_modeset(drm);
}
+static int mhz_to_nsec(int mhz) {
+ return 1000000000000LL / mhz;
+}
+
static void page_flip_handler(int fd, unsigned seq,
- unsigned tv_sec, unsigned tv_usec, void *user) {
- struct wlr_drm_connector *conn = user;
+ unsigned tv_sec, unsigned tv_usec, void *data) {
+ struct wlr_drm_connector *conn = data;
struct wlr_drm_backend *drm =
get_drm_backend_from_backend(conn->output.backend);
@@ -1188,6 +1241,19 @@ static void page_flip_handler(int fd, unsigned seq,
post_drm_surface(&conn->crtc->primary->mgpu_surf);
}
+ struct timespec present_time = {
+ .tv_sec = tv_sec,
+ .tv_nsec = tv_usec * 1000,
+ };
+ struct wlr_output_event_present present_event = {
+ .when = &present_time,
+ .seq = seq,
+ .refresh = mhz_to_nsec(conn->output.refresh),
+ .flags = WLR_OUTPUT_PRESENT_VSYNC | WLR_OUTPUT_PRESENT_HW_CLOCK |
+ WLR_OUTPUT_PRESENT_HW_COMPLETION,
+ };
+ wlr_output_send_present(&conn->output, &present_event);
+
if (drm->session->active) {
wlr_output_send_frame(&conn->output);
}
diff --git a/backend/drm/util.c b/backend/drm/util.c
index f9637c33..6b2c0981 100644
--- a/backend/drm/util.c
+++ b/backend/drm/util.c
@@ -32,21 +32,30 @@ static const char *get_manufacturer(uint16_t id) {
case ID('A', 'A', 'A'): return "Avolites Ltd";
case ID('A', 'C', 'I'): return "Ancor Communications Inc";
case ID('A', 'C', 'R'): return "Acer Technologies";
+ case ID('A', 'D', 'A'): return "Addi-Data GmbH";
case ID('A', 'P', 'P'): return "Apple Computer Inc";
+ case ID('A', 'S', 'K'): return "Ask A/S";
+ case ID('A', 'V', 'T'): return "Avtek (Electronics) Pty Ltd";
case ID('B', 'N', 'O'): return "Bang & Olufsen";
case ID('C', 'M', 'N'): return "Chimei Innolux Corporation";
case ID('C', 'M', 'O'): return "Chi Mei Optoelectronics corp.";
case ID('C', 'R', 'O'): return "Extraordinary Technologies PTY Limited";
case ID('D', 'E', 'L'): return "Dell Inc.";
+ case ID('D', 'G', 'C'): return "Data General Corporation";
case ID('D', 'O', 'N'): return "DENON, Ltd.";
case ID('E', 'N', 'C'): return "Eizo Nanao Corporation";
case ID('E', 'P', 'H'): return "Epiphan Systems Inc.";
+ case ID('E', 'X', 'P'): return "Data Export Corporation";
+ case ID('F', 'N', 'I'): return "Funai Electric Co., Ltd.";
case ID('F', 'U', 'S'): return "Fujitsu Siemens Computers GmbH";
case ID('G', 'S', 'M'): return "Goldstar Company Ltd";
case ID('H', 'I', 'Q'): return "Kaohsiung Opto Electronics Americas, Inc.";
case ID('H', 'S', 'D'): return "HannStar Display Corp";
+ case ID('H', 'T', 'C'): return "Hitachi Ltd";
case ID('H', 'W', 'P'): return "Hewlett Packard";
case ID('I', 'N', 'T'): return "Interphase Corporation";
+ case ID('I', 'N', 'X'): return "Communications Supply Corporation (A division of WESCO)";
+ case ID('I', 'T', 'E'): return "Integrated Tech Express Inc";
case ID('I', 'V', 'M'): return "Iiyama North America";
case ID('L', 'E', 'N'): return "Lenovo Group Limited";
case ID('M', 'A', 'X'): return "Rogen Tech Distribution Inc";
@@ -55,6 +64,7 @@ static const char *get_manufacturer(uint16_t id) {
case ID('M', 'T', 'C'): return "Mars-Tech Corporation";
case ID('M', 'T', 'X'): return "Matrox";
case ID('N', 'E', 'C'): return "NEC Corporation";
+ case ID('N', 'E', 'X'): return "Nexgen Mediatech Inc.";
case ID('O', 'N', 'K'): return "ONKYO Corporation";
case ID('O', 'R', 'N'): return "ORION ELECTRIC CO., LTD.";
case ID('O', 'T', 'M'): return "Optoma Corporation";
@@ -63,15 +73,24 @@ static const char *get_manufacturer(uint16_t id) {
case ID('P', 'I', 'O'): return "Pioneer Electronic Corporation";
case ID('P', 'N', 'R'): return "Planar Systems, Inc.";
case ID('Q', 'D', 'S'): return "Quanta Display Inc.";
+ case ID('R', 'A', 'T'): return "Rent-A-Tech";
+ case ID('R', 'E', 'N'): return "Renesas Technology Corp.";
case ID('S', 'A', 'M'): return "Samsung Electric Company";
+ case ID('S', 'A', 'N'): return "Sanyo Electric Co., Ltd.";
case ID('S', 'E', 'C'): return "Seiko Epson Corporation";
case ID('S', 'H', 'P'): return "Sharp Corporation";
case ID('S', 'I', 'I'): return "Silicon Image, Inc.";
case ID('S', 'N', 'Y'): return "Sony";
+ case ID('S', 'T', 'D'): return "STD Computer Inc";
+ case ID('S', 'V', 'S'): return "SVSI";
+ case ID('S', 'Y', 'N'): return "Synaptics Inc";
+ case ID('T', 'C', 'L'): return "Technical Concepts Ltd";
case ID('T', 'O', 'P'): return "Orion Communications Co., Ltd.";
case ID('T', 'S', 'B'): return "Toshiba America Info Systems Inc";
case ID('T', 'S', 'T'): return "Transtream Inc";
case ID('U', 'N', 'K'): return "Unknown";
+ case ID('V', 'E', 'S'): return "Vestel Elektronik Sanayi ve Ticaret A. S.";
+ case ID('V', 'I', 'T'): return "Visitech AS";
case ID('V', 'I', 'Z'): return "VIZIO, Inc";
case ID('V', 'S', 'C'): return "ViewSonic Corporation";
case ID('Y', 'M', 'H'): return "Yamaha Corporation";
diff --git a/backend/headless/output.c b/backend/headless/output.c
index 143900d4..3cb35dce 100644
--- a/backend/headless/output.c
+++ b/backend/headless/output.c
@@ -67,7 +67,9 @@ static bool output_make_current(struct wlr_output *wlr_output, int *buffer_age)
static bool output_swap_buffers(struct wlr_output *wlr_output,
pixman_region32_t *damage) {
- return true; // No-op
+ // Nothing needs to be done for pbuffers
+ wlr_output_send_present(wlr_output, NULL);
+ return true;
}
static void output_destroy(struct wlr_output *wlr_output) {
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index 3707fe34..cefaa361 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -1,7 +1,8 @@
+#define _POSIX_C_SOURCE 199309L
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <wlr/backend/drm.h>
+#include <time.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/session.h>
#include <wlr/util/log.h>
@@ -72,10 +73,32 @@ static struct wlr_renderer *multi_backend_get_renderer(
return NULL;
}
+static struct wlr_session *multi_backend_get_session(
+ struct wlr_backend *_backend) {
+ struct wlr_multi_backend *backend = multi_backend_from_backend(_backend);
+ return backend->session;
+}
+
+static clockid_t multi_backend_get_presentation_clock(
+ struct wlr_backend *backend) {
+ struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
+
+ struct subbackend_state *sub;
+ wl_list_for_each(sub, &multi->backends, link) {
+ if (sub->backend->impl->get_presentation_clock) {
+ return wlr_backend_get_presentation_clock(sub->backend);
+ }
+ }
+
+ return CLOCK_MONOTONIC;
+}
+
struct wlr_backend_impl backend_impl = {
.start = multi_backend_start,
.destroy = multi_backend_destroy,
.get_renderer = multi_backend_get_renderer,
+ .get_session = multi_backend_get_session,
+ .get_presentation_clock = multi_backend_get_presentation_clock,
};
static void handle_display_destroy(struct wl_listener *listener, void *data) {
@@ -191,17 +214,6 @@ void wlr_multi_backend_remove(struct wlr_backend *_multi,
}
}
-struct wlr_session *wlr_multi_get_session(struct wlr_backend *_backend) {
- struct wlr_multi_backend *backend = multi_backend_from_backend(_backend);
- struct subbackend_state *sub;
- wl_list_for_each(sub, &backend->backends, link) {
- if (wlr_backend_is_drm(sub->backend)) {
- return wlr_drm_backend_get_session(sub->backend);
- }
- }
- return NULL;
-}
-
bool wlr_multi_is_empty(struct wlr_backend *_backend) {
assert(wlr_backend_is_multi(_backend));
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend;
diff --git a/backend/session/logind.c b/backend/session/logind.c
index 39143a2f..b44112e6 100644
--- a/backend/session/logind.c
+++ b/backend/session/logind.c
@@ -35,6 +35,11 @@ struct logind_session {
char *id;
char *path;
+
+ // specifies whether a drm device was taken
+ // if so, the session will be (de)activated with the drm fd,
+ // otherwise with the dbus PropertiesChanged on "active" signal
+ bool has_drm;
};
static struct logind_session *logind_session_from_session(
@@ -57,6 +62,10 @@ static int logind_take_device(struct wlr_session *base, const char *path) {
return -1;
}
+ if (major(st.st_rdev) == DRM_MAJOR) {
+ session->has_drm = true;
+ }
+
ret = sd_bus_call_method(session->bus, "org.freedesktop.login1",
session->path, "org.freedesktop.login1.Session", "TakeDevice",
&error, &msg, "uu", major(st.st_rdev), minor(st.st_rdev));
@@ -262,6 +271,7 @@ static int pause_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_e
}
if (major == DRM_MAJOR) {
+ assert(session->has_drm);
session->base.active = false;
wlr_signal_emit_safe(&session->base.session_signal, session);
}
@@ -307,6 +317,115 @@ error:
return 0;
}
+static int properties_changed(sd_bus_message *msg, void *userdata,
+ sd_bus_error *ret_error) {
+ struct logind_session *session = userdata;
+ int ret = 0;
+
+ // if we have a drm fd we don't depend on this
+ if (session->has_drm) {
+ return 0;
+ }
+
+ // PropertiesChanged arg 1: interface
+ const char *interface;
+ ret = sd_bus_message_read_basic(msg, 's', &interface); // skip path
+ if (ret < 0) {
+ goto error;
+ }
+
+ if (strcmp(interface, "org.freedesktop.login1.Session") != 0) {
+ // not interesting for us; ignore
+ wlr_log(WLR_DEBUG, "ignoring PropertiesChanged from %s", interface);
+ return 0;
+ }
+
+ // PropertiesChanged arg 2: changed properties with values
+ ret = sd_bus_message_enter_container(msg, 'a', "{sv}");
+ if (ret < 0) {
+ goto error;
+ }
+
+ const char *s;
+ while ((ret = sd_bus_message_enter_container(msg, 'e', "sv")) > 0) {
+ ret = sd_bus_message_read_basic(msg, 's', &s);
+ if (ret < 0) {
+ goto error;
+ }
+
+ if (strcmp(s, "Active") == 0) {
+ int ret;
+ ret = sd_bus_message_enter_container(msg, 'v', "b");
+ if (ret < 0) {
+ goto error;
+ }
+
+ bool active;
+ ret = sd_bus_message_read_basic(msg, 'b', &active);
+ if (ret < 0) {
+ goto error;
+ }
+
+ if (session->base.active != active) {
+ session->base.active = active;
+ wlr_signal_emit_safe(&session->base.session_signal, session);
+ }
+ return 0;
+ } else {
+ sd_bus_message_skip(msg, "{sv}");
+ }
+
+ ret = sd_bus_message_exit_container(msg);
+ if (ret < 0) {
+ goto error;
+ }
+ }
+
+ if (ret < 0) {
+ goto error;
+ }
+
+ ret = sd_bus_message_exit_container(msg);
+ if (ret < 0) {
+ goto error;
+ }
+
+ // PropertiesChanged arg 3: changed properties without values
+ sd_bus_message_enter_container(msg, 'a', "s");
+ while ((ret = sd_bus_message_read_basic(msg, 's', &s)) > 0) {
+ if (strcmp(s, "Active") == 0) {
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ bool active;
+ ret = sd_bus_get_property_trivial(session->bus,
+ "org.freedesktop.login1", session->path,
+ "org.freedesktop.login1.Session", "Active", &error,
+ 'b', &active);
+ if (ret < 0) {
+ wlr_log(WLR_ERROR, "Failed to get 'Active' property: '%s' (%s)",
+ error.message, strerror(ret));
+ return 0;
+ }
+
+ if (session->base.active != active) {
+ session->base.active = active;
+ wlr_signal_emit_safe(&session->base.session_signal, session);
+ }
+ return 0;
+ }
+ }
+
+ if (ret < 0) {
+ goto error;
+ }
+
+ return 0;
+
+error:
+ wlr_log(WLR_ERROR, "Failed to parse D-Bus PropertiesChanged %s",
+ strerror(-ret));
+ return 0;
+}
+
static bool add_signal_matches(struct logind_session *session) {
int ret;
@@ -338,6 +457,14 @@ static bool add_signal_matches(struct logind_session *session) {
return false;
}
+ ret = sd_bus_match_signal(session->bus, NULL, "org.freedesktop.login1",
+ session->path, "org.freedesktop.DBus.Properties", "PropertiesChanged",
+ properties_changed, session);
+ if (ret < 0) {
+ wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret));
+ return false;
+ }
+
return true;
}
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 4eb99a3b..bc4067ab 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -66,8 +66,14 @@ static bool output_swap_buffers(struct wlr_output *wlr_output,
output->frame_callback = wl_surface_frame(output->surface);
wl_callback_add_listener(output->frame_callback, &frame_listener, output);
- return wlr_egl_swap_buffers(&output->backend->egl, output->egl_surface,
- damage);
+ if (!wlr_egl_swap_buffers(&output->backend->egl,
+ output->egl_surface, damage)) {
+ return false;
+ }
+
+ // TODO: if available, use the presentation-time protocol
+ wlr_output_send_present(wlr_output, NULL);
+ return true;
}
static void output_transform(struct wlr_output *wlr_output,
@@ -186,11 +192,24 @@ void update_wl_output_cursor(struct wlr_wl_output *output) {
}
}
-bool output_move_cursor(struct wlr_output *_output, int x, int y) {
+static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
// TODO: only return true if x == current x and y == current y
return true;
}
+static void output_schedule_frame(struct wlr_output *wlr_output) {
+ struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
+
+ if (output->frame_callback != NULL) {
+ wlr_log(WLR_ERROR, "Skipping frame scheduling");
+ return;
+ }
+
+ output->frame_callback = wl_surface_frame(output->surface);
+ wl_callback_add_listener(output->frame_callback, &frame_listener, output);
+ wl_surface_commit(output->surface);
+}
+
static const struct wlr_output_impl output_impl = {
.set_custom_mode = output_set_custom_mode,
.transform = output_transform,
@@ -199,6 +218,7 @@ static const struct wlr_output_impl output_impl = {
.swap_buffers = output_swap_buffers,
.set_cursor = output_set_cursor,
.move_cursor = output_move_cursor,
+ .schedule_frame = output_schedule_frame,
};
bool wlr_output_is_wl(struct wlr_output *wlr_output) {
diff --git a/backend/x11/output.c b/backend/x11/output.c
index e0210b1a..1ac12a8d 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -102,7 +102,12 @@ static bool output_swap_buffers(struct wlr_output *wlr_output,
struct wlr_x11_output *output = (struct wlr_x11_output *)wlr_output;
struct wlr_x11_backend *x11 = output->x11;
- return wlr_egl_swap_buffers(&x11->egl, output->surf, damage);
+ if (!wlr_egl_swap_buffers(&x11->egl, output->surf, damage)) {
+ return false;
+ }
+
+ wlr_output_send_present(wlr_output, NULL);
+ return true;
}
static const struct wlr_output_impl output_impl = {