diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-05-13 09:04:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 09:04:15 -0400 |
commit | 537096807efebad8dab2b5573187dbf0d2337810 (patch) | |
tree | 8654459a95395a38a1ddf692c07a6422f97106ee /example/main.c | |
parent | c436e76240ab190a07afcd961ca2dd279af72968 (diff) | |
parent | 599d1bcbdc8e0e9fb2d743d70dbf8b6fa9f3bea2 (diff) |
Merge pull request #3 from ascent12/master
DPMS support
Diffstat (limited to 'example/main.c')
-rw-r--r-- | example/main.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/example/main.c b/example/main.c index 2c168d98..ed9eac0b 100644 --- a/example/main.c +++ b/example/main.c @@ -81,6 +81,18 @@ int timer_done(void *data) { return 1; } +int dpms_on(void *data) { + struct wlr_backend *backend = data; + wlr_drm_backend_dpms(backend, false); + return 1; +} + +int dpms_off(void *data) { + struct wlr_backend *backend = data; + wlr_drm_backend_dpms(backend, true); + return 1; +} + int main() { if (getenv("DISPLAY")) { fprintf(stderr, "Detected that X is running. Run this in its own virtual terminal.\n"); @@ -120,8 +132,14 @@ int main() { bool done = false; struct wl_event_source *timer = wl_event_loop_add_timer(event_loop, timer_done, &done); - - wl_event_source_timer_update(timer, 5000); + struct wl_event_source *timer_dpms_on = wl_event_loop_add_timer(event_loop, + dpms_on, wlr); + struct wl_event_source *timer_dpms_off = wl_event_loop_add_timer(event_loop, + dpms_off, wlr); + + wl_event_source_timer_update(timer, 20000); + wl_event_source_timer_update(timer_dpms_on, 5000); + wl_event_source_timer_update(timer_dpms_off, 10000); while (!done) { wl_event_loop_dispatch(event_loop, 0); |