mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-10 13:29:44 -05:00
Generalize DPMS, remove DRM refs from example
This commit is contained in:
parent
03c9b46034
commit
fee409bd0a
10 changed files with 65 additions and 50 deletions
|
|
@ -101,11 +101,3 @@ error_backend:
|
|||
free(backend);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wlr_drm_backend_dpms(struct wlr_backend *backend, bool screen_on) {
|
||||
struct wlr_backend_state *state = backend->state;
|
||||
for (size_t i = 0; i < state->outputs->length; ++i) {
|
||||
struct wlr_output_state *output = state->outputs->items[i];
|
||||
wlr_drm_output_dpms(state->fd, output, screen_on);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,6 +236,28 @@ error:
|
|||
return false;
|
||||
}
|
||||
|
||||
static void wlr_drm_output_enable(struct wlr_output_state *output, bool enable) {
|
||||
struct wlr_backend_state *state =
|
||||
wl_container_of(output->renderer, state, renderer);
|
||||
if (output->state != DRM_OUTPUT_CONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms,
|
||||
DRM_MODE_DPMS_ON);
|
||||
|
||||
// Start rendering loop again by drawing a black frame
|
||||
wlr_drm_output_begin(output);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
wlr_drm_output_end(output);
|
||||
} else {
|
||||
drmModeConnectorSetProperty(state->fd, output->connector, output->props.dpms,
|
||||
DRM_MODE_DPMS_STANDBY);
|
||||
}
|
||||
}
|
||||
|
||||
static void wlr_drm_output_destroy(struct wlr_output_state *output) {
|
||||
wlr_drm_output_cleanup(output, true);
|
||||
wlr_drm_renderer_free(output->renderer);
|
||||
|
|
@ -244,6 +266,7 @@ static void wlr_drm_output_destroy(struct wlr_output_state *output) {
|
|||
|
||||
static struct wlr_output_impl output_impl = {
|
||||
.set_mode = wlr_drm_output_set_mode,
|
||||
.enable = wlr_drm_output_enable,
|
||||
.destroy = wlr_drm_output_destroy,
|
||||
};
|
||||
|
||||
|
|
@ -454,23 +477,3 @@ void wlr_drm_output_cleanup(struct wlr_output_state *output, bool restore) {
|
|||
}
|
||||
// TODO: free wlr_output
|
||||
}
|
||||
|
||||
void wlr_drm_output_dpms(int fd, struct wlr_output_state *output, bool screen_on) {
|
||||
if (output->state != DRM_OUTPUT_CONNECTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (screen_on) {
|
||||
drmModeConnectorSetProperty(fd, output->connector, output->props.dpms,
|
||||
DRM_MODE_DPMS_ON);
|
||||
|
||||
// Start rendering loop again by drawing a black frame
|
||||
wlr_drm_output_begin(output);
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
wlr_drm_output_end(output);
|
||||
} else {
|
||||
drmModeConnectorSetProperty(fd, output->connector, output->props.dpms,
|
||||
DRM_MODE_DPMS_STANDBY);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue