[PATCH weston] compositor: don't let weston terminate with dpms set to off if possible
Philipp Brüschweiler
blei42 at gmail.com
Sat Mar 30 09:10:19 PDT 2013
This will not catch the cases where weston crashes, but it's at least
better than the current state.
---
src/compositor.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index a3d1ede..7a656e7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3236,10 +3236,15 @@ weston_version(int *major, int *minor, int *micro)
static int on_term_signal(int signal_number, void *data)
{
- struct wl_display *display = data;
+ struct weston_compositor *ec = data;
weston_log("caught signal %d\n", signal_number);
- wl_display_terminate(display);
+
+ /* Turn DPMS back on, so we're not left with a black screen */
+ if (ec->state == WESTON_COMPOSITOR_SLEEPING)
+ weston_compositor_dpms(ec, WESTON_DPMS_ON);
+
+ wl_display_terminate(ec->wl_display);
return 1;
}
@@ -3577,15 +3582,9 @@ int main(int argc, char *argv[])
display = wl_display_create();
loop = wl_display_get_event_loop(display);
- signals[0] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
- display);
- signals[1] = wl_event_loop_add_signal(loop, SIGINT, on_term_signal,
- display);
- signals[2] = wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal,
- display);
wl_list_init(&child_process_list);
- signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
+ signals[0] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
NULL);
if (!backend) {
@@ -3610,6 +3609,13 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ signals[1] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
+ ec);
+ signals[2] = wl_event_loop_add_signal(loop, SIGINT, on_term_signal,
+ ec);
+ signals[3] = wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal,
+ ec);
+
catch_signals();
segv_compositor = ec;
@@ -3642,6 +3648,10 @@ int main(int argc, char *argv[])
wl_display_run(display);
out:
+ /* Turn DPMS back on, so we're not left with a black screen */
+ if (ec->state == WESTON_COMPOSITOR_SLEEPING)
+ weston_compositor_dpms(ec, WESTON_DPMS_ON);
+
/* prevent further rendering while shutting down */
ec->state = WESTON_COMPOSITOR_OFFSCREEN;
--
1.8.2
More information about the wayland-devel
mailing list