void s_window_uninit (s_window_t *window) { if (window == NULL) { return; } window->event->type = EVENT_TYPE_QUIT; s_event_changed(window); s_thread_join(window->eventq->tid, NULL); s_childs_uninit(window); if (window->type & (WINDOW_TYPE_TEMP | WINDOW_TYPE_CHILD)) { if (s_child_del(window->parent, window) == 0) { s_thread_detach(window->tid); } } else if (window->type & WINDOW_TYPE_POPUP) { s_thread_detach(window->tid); } debugf(DCLI, "[%d] Exiting (%s%s)", window->id, (window->type & WINDOW_TYPE_MAIN) ? "WINDOW_TYPE_MAIN" : ((window->type & WINDOW_TYPE_CHILD) ? "WINDOW_TYPE_CHILD" : ((window->type & WINDOW_TYPE_TEMP) ? "WINDOW_TYPE_TEMP" : ((window->type & WINDOW_TYPE_POPUP) ? "WINDOW_TYPE_POPUP" : ((window->type & WINDOW_TYPE_DESKTOP) ? "WINDOW_TYPE_DESKTOP" : "WINDOW_UNKNOWN")))), (window->type & WINDOW_TYPE_NOFORM) ? " | WINDOW_TYPE_NOFORM" : ""); /* andrei * call atexit only after we have released all children * the idea is to let the children access their parent's data attribute */ if (window->atexit != NULL) { window->atexit(window); } s_timers_uninit(window); s_pollfds_uninit(window); s_handlers_uninit(window); s_eventq_uninit(window); s_surface_uninit(window); s_event_uninit(window->event); s_free(window->title); s_free(window); window = NULL; }
void s_window_uninit (s_window_t *window) { if (window == NULL) { return; } window->event->type = QUIT_EVENT; s_event_changed(window); s_thread_join(window->eventq->tid, NULL); s_timers_uninit(window); s_pollfds_uninit(window); s_handlers_uninit(window); if (window->atexit != NULL) { window->atexit(window); } s_childs_uninit(window); if (window->type & (WINDOW_TEMP | WINDOW_CHILD)) { if (s_child_del(window->parent, window) == 0) { s_free(window->tid); } } debugf(DCLI, "[%d] Exiting (%s%s)", window->id, (window->type & WINDOW_MAIN) ? "WINDOW_MAIN" : ((window->type & WINDOW_CHILD) ? "WINDOW_CHILD" : ((window->type & WINDOW_TEMP) ? "WINDOW_TEMP" : ((window->type & WINDOW_DESKTOP) ? "WINDOW_DESKTOP" : "WINDOW_UNKNOWN"))), (window->type & WINDOW_NOFORM) ? " | WINDOW_NOFORM" : ""); s_eventq_uninit(window); s_surface_uninit(window); s_event_uninit(window->event); s_gettext_uninit(window); s_free(window->title); s_free(window); window = NULL; }
int s_window_init (s_window_t **window) { s_window_t *w; w = (s_window_t *) s_calloc(1, sizeof(s_window_t)); if (s_pollfds_init(w)) { goto err1; } if (s_timers_init(w)) { goto err2; } if (s_socket_init(w)) { goto err3; } if (s_handlers_init(w)) { goto err4; } if (s_childs_init(w)) { goto err5; } if (s_eventq_init(w)) { goto err6; } if (s_event_init(&w->event)) { goto err7; } w->running = 1; w->id = -1; w->pri = -1; w->mapped = -1; w->viewable = -1; w->resizeable = 1; w->alwaysontop = 0; w->cursor = CURSOR_TYPE_ARROW; w->mouse_entered = 0; *window = w; if (s_surface_init(w)) { goto err8; } if (s_socket_request(w, SOC_DATA_DISPLAY)) { goto err9; } if (s_surface_attach(w)) { goto err10; } return 0; err10: err9: s_surface_uninit(w); err8: s_event_uninit(w->event); err7: s_eventq_uninit(w); err6: s_childs_uninit(w); err5: s_handlers_uninit(w); err4: err3: s_timers_uninit(w); err2: s_pollfds_uninit(w); err1: s_free(w); debugf(DCLI | DFAT, "Cannot connect to server"); return -1; }
int s_window_init (s_window_t **window) { s_window_t *w; w = (s_window_t *) s_calloc(1, sizeof(s_window_t)); if (s_surface_init(w)) { goto err1; } if (s_pollfds_init(w)) { goto err2; } if (s_timers_init(w)) { goto err3; } if (s_socket_init(w)) { goto err4; } if (s_handlers_init(w)) { goto err4; } if (s_childs_init(w)) { goto err5; } if (s_eventq_init(w)) { goto err6; } if (s_event_init(&w->event)) { goto err7; } if (s_gettext_init(w)) { goto err8; } w->running = 1; w->id = -1; w->pri = -1; w->resizeable = 1; /* -1 means no limits on width or height. */ w->min_w = w->min_h = w->max_w = w->max_h = -1; w->alwaysontop = 0; w->cursor = MOUSE_CURSOR_ARROW; w->mouse_entered = 0; *window = w; if (s_socket_request(w, SOC_DATA_DISPLAY)) { goto err9; } return 0; err9: s_gettext_uninit(w); err8: s_event_uninit(w->event); err7: s_eventq_uninit(w); err6: s_childs_uninit(w); err5: s_handlers_uninit(w); err4: s_timers_uninit(w); err3: s_pollfds_uninit(w); err2: s_free(w->surface); err1: s_free(w); debugf(DCLI | DFAT, "Cannot connect to server"); return -1; }