void taskbar_atevent (s_window_t *window, s_event_t *event) { int pos = 0; tbar_data_t *tbar_data; tbar_progs_t *tbar_progs; s_desktop_client_t *desktopc; if (event->type & EVENT_TYPE_MOUSE_EXIT) { } if (!(event->type & EVENT_TYPE_DESKTOP)) { return; } tbar_data = (tbar_data_t *) window->data; tbar_progs = (tbar_progs_t *) tbar_data->tbar_progs; while (!s_list_eol(tbar_progs->desktop->clients, 0)) { desktopc = (s_desktop_client_t *) s_list_get(tbar_progs->desktop->clients, 0); s_list_remove(tbar_progs->desktop->clients, 0); s_free(desktopc->title); s_free(desktopc); } while (!s_list_eol(event->desktop->clients, pos)) { desktopc = (s_desktop_client_t *) s_list_get(event->desktop->clients, pos); if ((desktopc->id != window->id) && (desktopc->id != window->parent->id)) { s_list_remove(event->desktop->clients, pos); s_list_add(tbar_progs->desktop->clients, desktopc, -1); } else { pos++; } } taskbar_progs_draw(window); }
static void lxynth_shutdown_driver (void) { DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); if (lxynth_root->running) { lxynth_root->running = 0; s_window_quit(lxynth_root->window); s_thread_join(lxynth_root->tid, NULL); kill_timer(lxynth_root->timerid); } while (!s_list_eol(lxynth_root->eventq->list, 0)) { s_event_t *event = s_list_get(lxynth_root->eventq->list, 0); s_list_remove(lxynth_root->eventq->list, 0); s_event_uninit(event); } s_free(lxynth_root->eventq->list); s_thread_mutex_destroy(lxynth_root->eventq->mut); s_free(lxynth_root->eventq); while (!s_list_eol(lxynth_root->gd->list, 0)) { struct graphics_device *gd = s_list_get(lxynth_root->gd->list, 0); lxynth_device_t *wd = (lxynth_device_t *) gd->driver_data; s_list_remove(lxynth_root->gd->list, 0); s_free(wd->title); s_surface_destroy(wd->surface); s_free(wd); s_free(gd); } s_free(lxynth_root->gd->list); s_thread_mutex_destroy(lxynth_root->gd->mut); s_free(lxynth_root->gd); s_free(lxynth_root); }
int s_eventq_wait (s_window_t *window, s_event_t **event) { int ret; s_event_t *e; s_thread_mutex_lock(window->eventq->mut); while (window->eventq->queue->nb_elt <= 0) { if (s_thread_cond_wait(window->eventq->cond, window->eventq->mut)) { debugf(DSYS, "s_thread_cond_wait failed"); return -1; } } e = (s_event_t *) s_list_get(window->eventq->queue, 0); if (e == NULL) { ret = -1; } else { s_list_remove(window->eventq->queue, 0); *event = e; ret = 0; } s_thread_mutex_unlock(window->eventq->mut); return ret; }
void taskbar_atexit (s_window_t *window) { tbar_data_t *tbar_data; tbar_progs_t *tbar_progs; tbar_clock_t *tbar_clock; s_desktop_client_t *desktopc; tbar_data = (tbar_data_t *) window->data; tbar_progs = (tbar_progs_t *) tbar_data->tbar_progs; tbar_clock = (tbar_clock_t *) tbar_data->tbar_clock; s_font_uninit(tbar_clock->font); s_font_uninit(tbar_progs->prog_font); s_image_uninit(tbar_progs->tbar_img); s_image_uninit(tbar_progs->prog_img[0]); s_image_uninit(tbar_progs->prog_img[1]); while (!s_list_eol(tbar_progs->desktop->clients, 0)) { desktopc = (s_desktop_client_t *) s_list_get(tbar_progs->desktop->clients, 0); s_list_remove(tbar_progs->desktop->clients, 0); s_free(desktopc->title); s_free(desktopc); } s_free(tbar_progs->desktop->clients); s_free(tbar_progs->desktop); s_free(tbar_progs); s_free(tbar_data->tbar_clock); taskbar_clean_smenu(tbar_data->tbar_smenu->progs); s_image_uninit(tbar_data->tbar_smenu->img); s_free(tbar_data->tbar_smenu); s_free(tbar_data); }
int w_clistbox_item_del (w_object_t *object, w_clistbox_item_t *item) { int p; w_clistbox_t *lb; w_clistbox_item_t *active; lb = object->data[OBJECT_CLISTBOX]; active = s_list_get(lb->items, lb->active); p = s_list_get_pos(lb->items, item); s_list_remove(lb->items, p); w_clistbox_item_uninit(item); if (lb->active == p) { active = s_list_get(lb->items, p); if (active == NULL) { active = s_list_get(lb->items, p - 1); } else { lb->pactive = -1; } } if (active == NULL) { lb->active = 0; } else { lb->active = s_list_get_pos(lb->items, active); } if (lb->active < 0) { lb->active = 0; } lb->dirty = 1; w_object_draw(object); return 0; }
btdev_struct *btdev_cache_add(BD_ADDR *bda) { btdev_struct *entry, *mount; int i, num = -1; for (i = 0; (entry = s_list_nth_data(devcache.head, i)); i++) { if (bda_equal(bda, &entry->bda)) { s_list_remove(&devcache.head, entry); num = i; break; } } if (!entry) { /* create new */ entry = malloc(sizeof(btdev_struct)); if (!entry) { perror("btdev_cache allocation failed\n"); return NULL; } memset(entry, 0, sizeof(btdev_struct)); entry->bda = *bda; entry->state = DEVSTATE_UNKNOWN; } /* find linking position */ for (i = 0; (mount = s_list_nth_data(devcache.head, i)); i++) { if (mount->state == DEVSTATE_RANGE) continue; if (mount->state == DEVSTATE_GONE || i == num) break; } s_list_insert(&devcache.head, entry, i); return entry; }
int w_frame_set_image (w_object_t *object, unsigned int style, unsigned int rotation, unsigned int nimgs, char **imgs) { int pos; char *file; w_frame_t *frame; w_frame_image_t *fimg; frame = (w_frame_t *) object->data[OBJECT_FRAME]; for (pos = 0; !s_list_eol(frame->images, pos); pos++) { fimg = (w_frame_image_t *) s_list_get(frame->images, pos); if (fimg->style == style) { s_list_remove(frame->images, pos); w_frame_image_uninit(fimg); break; } } for (pos = 0; pos < nimgs; pos++) { if (access(imgs[pos], R_OK)) { return -1; } } w_frame_image_init(&fimg); fimg->style = style; fimg->rotation = rotation; for (pos = 0; pos < nimgs; pos++) { file = imgs[pos]; #if defined(WIDGET_OPTIMIZE_MEMORY) && WIDGET_OPTIMIZE_MEMORY >= 1 #else w_window_image_add(object->window, file); #endif s_list_add(fimg->names, strdup(file), -1); } s_list_add(frame->images, fimg, -1); return 0; }
static void lxynth_timer (void *arg) { int x = 0; int y = 0; int k = 0; int flag = 0; s_event_t *event; s_thread_mutex_lock(lxynth_root->eventq->mut); while (!s_list_eol(lxynth_root->eventq->list, 0)) { event = (s_event_t *) s_list_get(lxynth_root->eventq->list, 0); s_list_remove(lxynth_root->eventq->list, 0); switch (event->type & EVENT_MASK) { case QUIT_EVENT: break; case MOUSE_EVENT: lxynth_event_parse_mouse(event); break; case KEYBD_EVENT: lxynth_event_parse_keybd(event); break; case CONFIG_EVENT: lxynth_event_parse_config(event); break; } s_event_uninit(event); } s_thread_mutex_unlock(lxynth_root->eventq->mut); if (lxynth_root->running) { lxynth_root->timerid = install_timer(20, lxynth_timer, NULL); } }
int s_handler_del (s_window_t *window, s_handler_t *handler) { int ret = 0; s_thread_mutex_lock(window->handlers->mut); ret = s_list_remove(window->handlers->list, s_list_get_pos(window->handlers->list, handler)); s_thread_mutex_unlock(window->handlers->mut); return ret; }
int s_pollfd_del (s_window_t *window, s_pollfd_t *pfd) { int ret; s_thread_mutex_lock(window->pollfds->mut); ret = s_list_remove(window->pollfds->list, s_list_get_pos(window->pollfds->list, pfd)); s_thread_mutex_unlock(window->pollfds->mut); s_window_wakeup(window); return ret; }
int w_frame_image_uninit (w_frame_image_t *fimg) { char *name; s_image_t *img; while (!s_list_eol(fimg->images, 0)) { img = (s_image_t *) s_list_get(fimg->images, 0); s_list_remove(fimg->images, 0); s_image_uninit(img); } s_list_uninit(fimg->images); while (!s_list_eol(fimg->names, 0)) { name = (char *) s_list_get(fimg->names, 0); s_list_remove(fimg->names, 0); s_free(name); } s_list_uninit(fimg->names); s_free(fimg); return 0; }
int s_dir_sort (s_dir_t *dir) { int i; int j; s_dir_t *d; s_dir_t *di; s_dir_t *dj; s_file_t *fi; s_file_t *fj; for (i = 0; i < dir->dirs->nb_elt - 1; i++) { for (j = 0; j < dir->dirs->nb_elt - 1; j++) { di = (s_dir_t *) s_list_get(dir->dirs, j); dj = (s_dir_t *) s_list_get(dir->dirs, j + 1); if (strcmp(dj->path, di->path) < 0) { s_list_remove(dir->dirs, j); s_list_add(dir->dirs, di, j + 1); } } } for (i = 0; i < dir->files->nb_elt - 1; i++) { for (j = 0; j < dir->files->nb_elt - 1; j++) { fi = (s_file_t *) s_list_get(dir->files, j); fj = (s_file_t *) s_list_get(dir->files, j + 1); if (strcmp(fj->path, fi->path) < 0) { s_list_remove(dir->files, j); s_list_add(dir->files, fi, j + 1); } } } i = 0; while (!s_list_eol(dir->dirs, i)) { d = (s_dir_t *) s_list_get(dir->dirs, i); s_dir_sort(d); i++; } return 0; }
int s_config_uninit (s_config_t *cfg) { while (!s_list_eol(cfg->category, 0)) { s_config_cat_t *cat = (s_config_cat_t *) s_list_get(cfg->category, 0); s_list_remove(cfg->category, 0); s_config_category_uninit(cat); } s_list_uninit(cfg->category); s_free(cfg); return 0; }
void w_clistbox_uninit (w_object_t *object) { w_clistbox_t *lb; w_clistbox_item_t *li; w_clistbox_item_image_t *ii; lb = object->data[OBJECT_CLISTBOX]; while (!s_list_eol(lb->items, 0)) { li = (w_clistbox_item_t *) s_list_get(lb->items, 0); s_list_remove(lb->items, 0); w_clistbox_item_uninit(li); } while (!s_list_eol(lb->item_images, 0)) { ii = (w_clistbox_item_image_t *) s_list_get(lb->item_images, 0); s_list_remove(lb->item_images, 0); w_clistbox_item_image_uninit(ii); } s_list_uninit(lb->item_images); s_list_uninit(lb->items); w_frame_uninit(object); s_free(lb); }
int s_config_category_uninit (s_config_cat_t *cat) { while (!s_list_eol(cat->variable, 0)) { s_config_var_t *var = (s_config_var_t *) s_list_get(cat->variable, 0); s_list_remove(cat->variable, 0); s_config_variable_uninit(var); } s_list_uninit(cat->variable); s_free(cat->name); s_free(cat); return 0; }
int s_files_uninit (s_list_t *files) { s_file_t *file; while (!s_list_eol(files, 0)) { file = (s_file_t *) s_list_get(files, 0); s_list_remove(files, 0); s_file_uninit(file); } free(files); return 0; }
int s_dirs_uninit (s_list_t *dirs) { s_dir_t *dir; while (!s_list_eol(dirs, 0)) { dir = (s_dir_t *) s_list_get(dirs, 0); s_list_remove(dirs, 0); s_dir_uninit(dir); } free(dirs); return 0; }
void w_frame_uninit (w_object_t *object) { w_frame_t *frame; w_frame_image_t *fimg; frame = (w_frame_t *) object->data[OBJECT_FRAME]; w_object_uninit(object); while (!s_list_eol(frame->images, 0)) { fimg = s_list_get(frame->images, 0); s_list_remove(frame->images, 0); w_frame_image_uninit(fimg); } s_list_uninit(frame->images); s_free(frame); }
int s_image_layers_uninit (s_image_t *img) { s_image_t *img_; while (!s_list_eol(img->layers, 0)) { img_ = (s_image_t *) s_list_get(img->layers, 0); s_list_remove(img->layers, 0); s_image_layer_uninit(img_); } s_list_uninit(img->layers); img->layers = NULL; return 0; }
void taskbar_clean_smenu (s_list_t *list) { smenu_prog_t *p; while (!s_list_eol(list, 0)) { p = s_list_get(list, 0); s_list_remove(list, 0); s_free(p->name); s_free(p->icon); s_free(p->menu); s_free(p->exec); taskbar_clean_smenu(p->progs); s_free(p); } s_free(list); }
int s_handlers_uninit (s_window_t *window) { s_handler_t *hndl; s_thread_mutex_lock(window->handlers->mut); while (!s_list_eol(window->handlers->list, 0)) { hndl = (s_handler_t *) s_list_get(window->handlers->list, 0); s_list_remove(window->handlers->list, 0); s_handler_uninit(hndl); } s_thread_mutex_unlock(window->handlers->mut); s_thread_mutex_destroy(window->handlers->mut); s_list_uninit(window->handlers->list); s_free(window->handlers); return 0; }
static void lxynth_shutdown_device (struct graphics_device *dev) { int acc = 0; int pos = 0; lxynth_device_t *wd; struct graphics_device *gd; DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); s_thread_mutex_lock(lxynth_root->gd->mut); while (!s_list_eol(lxynth_root->gd->list, pos)) { gd = (struct graphics_device *) s_list_get(lxynth_root->gd->list, pos); if (gd == dev) { s_list_remove(lxynth_root->gd->list, pos); if (lxynth_root->gd->list->nb_elt > 0) { lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, 0); acc = 1; } else { lxynth_root->gd->active = NULL; } break; } pos++; } unregister_bottom_half(lxynth_surface_register_update, dev); wd = (lxynth_device_t *) dev->driver_data; s_free(wd->title); s_surface_destroy(wd->surface); s_free(wd); s_free(dev); s_thread_mutex_unlock(lxynth_root->gd->mut); if (acc && lxynth_root->running) { char *title; struct rect r; r.x1 = 0; r.y1 = 0; r.x2 = lxynth_root->window->surface->buf->w; r.y2 = lxynth_root->window->surface->buf->h; title = strdup(((lxynth_device_t *) lxynth_root->gd->active->driver_data)->title); lxynth_set_title(lxynth_root->gd->active, title); lxynth_root->gd->active->resize_handler(lxynth_root->gd->active); lxynth_root->gd->active->redraw_handler(lxynth_root->gd->active, &r); s_free(title); } }
int w_clistbox_clear (w_object_t *object) { w_clistbox_t *lb; w_clistbox_item_t *li; lb = object->data[OBJECT_CLISTBOX]; while (!s_list_eol(lb->items, 0)) { li = s_list_get(lb->items, 0); s_list_remove(lb->items, 0); w_clistbox_item_uninit(li); } lb->dirty = 1; lb->height = 0; lb->yoffset = 0; lb->active = 0; lb->pactive = -1; w_object_draw(object); return 0; }
int s_eventq_uninit (s_window_t *window) { s_event_t *e; s_thread_mutex_destroy(window->eventq->mut); s_thread_cond_destroy(window->eventq->cond); while (!s_list_eol(window->eventq->queue, 0)) { e = (s_event_t *) s_list_get(window->eventq->queue, 0); s_list_remove(window->eventq->queue, 0); s_event_uninit(e); } s_free(window->eventq->queue); s_free(window->eventq); return 0; }
int s_event_uninit (s_event_t *event) { s_desktop_client_t *desktopc; while (!s_list_eol(event->desktop->clients, 0)) { desktopc = (s_desktop_client_t *) s_list_get(event->desktop->clients, 0); s_list_remove(event->desktop->clients, 0); s_free(desktopc->title); s_free(desktopc); } s_list_uninit(event->desktop->clients); s_free(event->desktop); s_free(event->expose->rect); s_free(event->expose); s_free(event->mouse); s_free(event->keybd); s_free(event); return 0; }
void w_signal_delete (w_object_t *object) { int pos = 0; s_event_t *event; w_signal_t *signal; s_thread_mutex_lock(object->window->window->eventq->mut); while (!s_list_eol(object->window->window->eventq->queue, pos)) { event = (s_event_t *) s_list_get(object->window->window->eventq->queue, pos); signal = (w_signal_t *) event->data; if ((event->type == SIGNAL_EVENT) && ((signal->from == object) || (signal->to == object))) { s_list_remove(object->window->window->eventq->queue, pos); s_free(signal); s_event_uninit(event); } else { pos++; } } s_thread_mutex_unlock(object->window->window->eventq->mut); }
int s_pollfds_uninit (s_window_t *window) { s_pollfd_t *pfd; s_thread_mutex_lock(window->pollfds->mut); while (!s_list_eol(window->pollfds->list, 0)) { pfd = (s_pollfd_t *) s_list_get(window->pollfds->list, 0); s_list_remove(window->pollfds->list, 0); if (pfd->pf_close != NULL) { pfd->pf_close(window, pfd); } s_pollfd_uninit(pfd); } s_thread_mutex_unlock(window->pollfds->mut); s_thread_mutex_destroy(window->pollfds->mut); s_list_uninit(window->pollfds->list); s_free(window->pollfds); return 0; }
int s_eventq_get (s_window_t *window, s_event_t **event) { int ret; s_event_t *e; s_thread_mutex_lock(window->eventq->mut); e = (s_event_t *) s_list_get(window->eventq->queue, 0); if (e == NULL) { ret = 1; } else { s_list_remove(window->eventq->queue, 0); *event = e; ret = 0; } s_thread_mutex_unlock(window->eventq->mut); return ret; }
void code_parse_element (s_xml_node_t *node, s_xml_node_t *style) { int p; s_xml_node_t *tmp; s_xml_node_t *dmp; s_xml_node_t *chl; s_xml_node_attr_t *sid; s_xml_node_attr_t *stype; s_xml_node_attr_t *ntype; if (style == NULL) { return; } for (p = 0; !s_list_eol(node->nodes, p); p++) { tmp = (s_xml_node_t *) s_list_get(node->nodes, p); code_parse_element(tmp, style); } ntype = s_xml_node_get_attr(node, "type"); if (strcmp(node->name, "element") == 0 && ntype && ntype->value != NULL) { for (p = 0; !s_list_eol(style->nodes, p); p++) { tmp = (s_xml_node_t *) s_list_get(style->nodes, p); sid = s_xml_node_get_attr(tmp, "id"); stype = s_xml_node_get_attr(tmp, "type"); if (strcmp(tmp->name, "element") == 0 && sid && strcmp(sid->value, ntype->value) == 0) { s_xml_node_dublicate(tmp, &dmp); s_free(node->name); s_free(ntype->value); node->name = strdup("object"); ntype->value = (stype->value) ? strdup(stype->value) : NULL; while (!s_list_eol(dmp->nodes, 0)) { chl = (s_xml_node_t *) s_list_get(dmp->nodes, dmp->nodes->nb_elt - 1); chl->parent = node; s_list_add(node->nodes, chl, 0); s_list_remove(dmp->nodes, dmp->nodes->nb_elt - 1); } s_xml_node_uninit(dmp); } } } }
static void lxynth_event_parse_keybd (s_event_t *event) { int k = 0; int flag = 0; if (!(event->type & KEYBD_PRESSED)) { return; } switch (event->keybd->keycode) { case S_KEYCODE_RETURN: k = KBD_ENTER; break; case S_KEYCODE_DELETE: k = KBD_BS; break; case S_KEYCODE_TAB: k = KBD_TAB; break; case S_KEYCODE_ESCAPE: k = KBD_ESC; break; case S_KEYCODE_UP: k = KBD_UP; break; case S_KEYCODE_DOWN: k = KBD_DOWN; break; case S_KEYCODE_LEFT: k = KBD_LEFT; break; case S_KEYCODE_RIGHT: k = KBD_RIGHT; break; case S_KEYCODE_INSERT: k = KBD_INS; break; case S_KEYCODE_REMOVE: k = KBD_DEL; break; case S_KEYCODE_HOME: k = KBD_HOME; break; case S_KEYCODE_END: k = KBD_END; break; case S_KEYCODE_PAGEUP: k = KBD_PAGE_UP;break; case S_KEYCODE_PAGEDOWN:k = KBD_PAGE_DOWN;break; case S_KEYCODE_F1: k = KBD_F1; break; case S_KEYCODE_F2: k = KBD_F2; break; case S_KEYCODE_F3: k = KBD_F3; break; case S_KEYCODE_F4: k = KBD_F4; break; case S_KEYCODE_F5: k = KBD_F5; break; case S_KEYCODE_F6: k = KBD_F6; break; case S_KEYCODE_F7: k = KBD_F7; break; case S_KEYCODE_F8: k = KBD_F8; break; case S_KEYCODE_F9: k = KBD_F9; break; case S_KEYCODE_F10: k = KBD_F10; break; case S_KEYCODE_F11: k = KBD_F11; break; case S_KEYCODE_F12: k = KBD_F12; break; default: k = event->keybd->ascii; if (!isprint(k)) { return; } break; } if (event->keybd->flag & (KEYCODE_CTRLF)) { flag |= KBD_CTRL; } if (event->keybd->flag & (KEYCODE_SHIFTF)) { } if (event->keybd->flag & (KEYCODE_ALTF | KEYCODE_ALTGRF)) { flag |= KBD_ALT; } #define KEYBD_HOOK0 \ int acc = 0;\ int pos = 0;\ struct graphics_device *gd;\ s_thread_mutex_lock(lxynth_root->gd->mut);\ while (!s_list_eol(lxynth_root->gd->list, pos)) {\ gd = (struct graphics_device *) s_list_get(lxynth_root->gd->list, pos);\ if (gd == lxynth_root->gd->active) {\ #define KEYBD_HOOK1 \ }\ pos++;\ }\ s_thread_mutex_unlock(lxynth_root->gd->mut);\ if (acc) {\ char *title;\ struct rect r;\ r.x1 = 0;\ r.y1 = 0;\ r.x2 = lxynth_root->window->surface->buf->w;\ r.y2 = lxynth_root->window->surface->buf->h;\ title = strdup(((lxynth_device_t *) lxynth_root->gd->active->driver_data)->title);\ lxynth_set_title(lxynth_root->gd->active, title);\ lxynth_root->gd->active->resize_handler(lxynth_root->gd->active);\ lxynth_root->gd->active->redraw_handler(lxynth_root->gd->active, &r);\ s_free(title);\ } if ((flag == KBD_CTRL) && (event->keybd->ascii == 'w')) { KEYBD_HOOK0; if (lxynth_root->gd->list->nb_elt > 1) { s_list_remove(lxynth_root->gd->list, pos); lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, 0); acc = 1; break; } KEYBD_HOOK1; if (acc) { gd->keyboard_handler(gd, KBD_CLOSE, 0); } } else if ((flag == KBD_CTRL) && (k == KBD_LEFT)) { KEYBD_HOOK0; if (pos >= 1) { lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, pos - 1); acc = 1; break; } KEYBD_HOOK1; } else if ((flag == KBD_CTRL) && (k == KBD_RIGHT)) { KEYBD_HOOK0; if ((pos + 1) < lxynth_root->gd->list->nb_elt) { lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, pos + 1); acc = 1; break; } KEYBD_HOOK1; } else { lxynth_root->gd->active->keyboard_handler(lxynth_root->gd->active, k, flag); } }