window: add display_exit()
Add a function, that schedules the display_run() event loop to break out. When display_exit() is called, processing continues as usual, until currently waiting events and deferred tasks have been processed, and sent requests are flushed. Then, display_run() will return. This enables toytoolkit apps to handle their exit instead of just being killed or call exit(). Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
@@ -79,6 +79,8 @@ struct display {
|
|||||||
int epoll_fd;
|
int epoll_fd;
|
||||||
struct wl_list deferred_list;
|
struct wl_list deferred_list;
|
||||||
|
|
||||||
|
int running;
|
||||||
|
|
||||||
struct wl_list window_list;
|
struct wl_list window_list;
|
||||||
struct wl_list input_list;
|
struct wl_list input_list;
|
||||||
struct wl_list output_list;
|
struct wl_list output_list;
|
||||||
@@ -2695,11 +2697,15 @@ display_run(struct display *display)
|
|||||||
struct epoll_event ep[16];
|
struct epoll_event ep[16];
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
|
display->running = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
while (display->mask & WL_DISPLAY_WRITABLE)
|
while (display->mask & WL_DISPLAY_WRITABLE)
|
||||||
wl_display_iterate(display->display,
|
wl_display_iterate(display->display,
|
||||||
WL_DISPLAY_WRITABLE);
|
WL_DISPLAY_WRITABLE);
|
||||||
|
|
||||||
|
if (!display->running)
|
||||||
|
break;
|
||||||
|
|
||||||
count = epoll_wait(display->epoll_fd,
|
count = epoll_wait(display->epoll_fd,
|
||||||
ep, ARRAY_LENGTH(ep), -1);
|
ep, ARRAY_LENGTH(ep), -1);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
@@ -2715,3 +2721,9 @@ display_run(struct display *display)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
display_exit(struct display *display)
|
||||||
|
{
|
||||||
|
display->running = 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ display_watch_fd(struct display *display,
|
|||||||
void
|
void
|
||||||
display_run(struct display *d);
|
display_run(struct display *d);
|
||||||
|
|
||||||
|
void
|
||||||
|
display_exit(struct display *d);
|
||||||
|
|
||||||
enum pointer_type {
|
enum pointer_type {
|
||||||
POINTER_BOTTOM_LEFT,
|
POINTER_BOTTOM_LEFT,
|
||||||
POINTER_BOTTOM_RIGHT,
|
POINTER_BOTTOM_RIGHT,
|
||||||
|
|||||||
Reference in New Issue
Block a user