void s_server_window_title (int id, char *title) { int i; int v; int h; int yo; s_font_t *font; s_surface_t *srf; if ((id < 0) || (title == NULL) || (server->client[id].type & WINDOW_NOFORM)) { return; } for (v = 0; v < 2; v++) { font = server->theme.font[v]; s_font_set_str(font, title); s_font_get_glyph(font); s_image_get_mat(font->glyph.img); s_image_get_handler(font->glyph.img); font->glyph.img->buf = (char *) s_calloc(1, font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel); if (s_surface_create_from_data(&srf, font->glyph.img->w, font->glyph.img->h, server->window->surface->bitsperpixel, font->glyph.img->buf)) { goto out; } if ((i = font->glyph.img->w / server->theme.form[v][TOP_3].w) > 0) { while (i--) { yo = server->theme.text_v_off[v] - font->glyph.img->handler->y + (server->theme.form[v][TOP_3].handler->h - font->glyph.img->handler->h) / 2; if ((font->glyph.img->h + yo) > server->theme.form[v][TOP_3].h) { h = server->theme.form[v][TOP_3].h - yo; } else { h = font->glyph.img->h; } s_putboxpart(srf, i * server->theme.form[v][TOP_3].w, 0, server->theme.form[v][TOP_3].w, h, server->theme.form[v][TOP_3].w, server->theme.form[v][TOP_3].h, server->theme.form[v][TOP_3].buf, 0, yo); } } if ((i = font->glyph.img->w % server->theme.form[v][TOP_3].w) > 0) { s_putboxpart(srf, font->glyph.img->w - server->theme.form[v][TOP_3].w, 0, server->theme.form[v][TOP_3].w, font->glyph.img->h, server->theme.form[v][TOP_3].w, server->theme.form[v][TOP_3].h, server->theme.form[v][TOP_3].buf, 0, server->theme.text_v_off[v] - font->glyph.img->handler->y + (server->theme.form[v][TOP_3].handler->h - font->glyph.img->handler->h) / 2); } s_putboxrgba(srf, 0, 0, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba); s_free(server->client[id].title.img[v].mat); s_free(server->client[id].title.img[v].buf); server->client[id].title.img[v].mat = (unsigned char *) s_malloc(font->glyph.img->w * font->glyph.img->h); server->client[id].title.img[v].buf = (char *) s_malloc(font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel); server->client[id].title.img[v].w = font->glyph.img->w; server->client[id].title.img[v].h = font->glyph.img->h; server->client[id].title.hy[v] = font->glyph.img->handler->y; server->client[id].title.hh[v] = font->glyph.img->handler->h; memcpy(server->client[id].title.img[v].mat, font->glyph.img->mat, font->glyph.img->w * font->glyph.img->h); memcpy(server->client[id].title.img[v].buf, font->glyph.img->buf, font->glyph.img->w * font->glyph.img->h * server->window->surface->bytesperpixel); s_surface_destroy(srf); out: s_image_uninit(font->glyph.img); s_image_init(&(font->glyph.img)); } }
void taskbar_progs_draw (s_window_t *window) { int x; int pos; int w = 0; s_surface_t *srf; tbar_data_t *tbar_data; tbar_progs_t *tbar_progs; s_desktop_client_t *desktopc; pos = 0; tbar_data = (tbar_data_t *) window->data; tbar_progs = (tbar_progs_t *) tbar_data->tbar_progs; if (tbar_progs->desktop->clients->nb_elt > 0) { w = ((tbar_progs->rect.w / tbar_progs->desktop->clients->nb_elt) > 125) ? 125 : (tbar_progs->rect.w / tbar_progs->desktop->clients->nb_elt); } if (s_surface_create(&srf, tbar_progs->rect.w, tbar_progs->rect.h, window->surface->bitsperpixel)) { return; } for (x = 0; x <= tbar_progs->rect.w; x++) { s_putboxpart(srf, x, 0, 1, tbar_progs->rect.h, 1, 30, tbar_progs->tbar_img->buf, 0, tbar_progs->rect.y); } while (!s_list_eol(tbar_progs->desktop->clients, pos)) { desktopc = (s_desktop_client_t *) s_list_get(tbar_progs->desktop->clients, pos); taskbar_progs_draw_client(tbar_progs, srf, desktopc, w * pos, 0, w, tbar_progs->rect.h); pos++; } s_putbox(window->surface, tbar_progs->rect.x, tbar_progs->rect.y, tbar_progs->rect.w, tbar_progs->rect.h, srf->vbuf); s_surface_destroy(srf); }
static void lxynth_surface_register_update (void *dev) { lxynth_device_t *wd; if (lxynth_root->running == 0) return; s_thread_mutex_lock(lxynth_root->gd->mut); if (lxynth_root->gd->active != dev) { s_thread_mutex_unlock(lxynth_root->gd->mut); return; } wd = (lxynth_device_t *) ((struct graphics_device *) dev)->driver_data; s_putboxpart(lxynth_root->window->surface, wd->update.x, wd->update.y, wd->update.w, wd->update.h, wd->surface->width, wd->surface->height, wd->surface->vbuf, wd->update.x, wd->update.y); wd->update = (s_rect_t) {-1, -1, -1, -1}; s_thread_mutex_unlock(lxynth_root->gd->mut); }
void taskbar_start_menu_handler_rh (s_window_t *window, s_event_t *event, s_handler_t *handler) { int x; s_surface_t *srf; tbar_data_t *tbar_data; tbar_progs_t *tbar_progs; tbar_smenu_t *tbar_smenu; tbar_data = (tbar_data_t *) window->data; tbar_smenu = (tbar_smenu_t *) tbar_data->tbar_smenu; tbar_progs = (tbar_progs_t *) tbar_data->tbar_progs; if (s_surface_create(&srf, (tbar_smenu->rect.w + tbar_progs->tbar_img->w + 2), (tbar_smenu->rect.h + 2), window->surface->bitsperpixel)) { return; } for (x = 0; x <= tbar_smenu->rect.w + 2; x++) { s_putboxpart(srf, x, 0, tbar_progs->tbar_img->w, tbar_smenu->rect.h + 2, tbar_progs->tbar_img->w, tbar_progs->tbar_img->h, tbar_progs->tbar_img->buf, 0, tbar_smenu->rect.y); } s_putboxrgba(srf, 0, 0, tbar_smenu->img->w, tbar_smenu->img->h, tbar_smenu->img->rgba); s_putbox(window->surface, tbar_smenu->rect.x, tbar_smenu->rect.y, srf->width, srf->height, srf->vbuf); s_surface_destroy(srf); }
static void lxynth_draw_bitmap (struct graphics_device *dev, struct bitmap *hndl, int x, int y) { lxynth_device_t *wd; int xs = hndl->x; int ys = hndl->y; char *data = hndl->data; DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); CLIP_PREFACE; if (lxynth_root->running == 0) return; s_thread_mutex_lock(lxynth_root->gd->mut); if (lxynth_root->gd->active != dev) { s_thread_mutex_unlock(lxynth_root->gd->mut); return; } wd = (lxynth_device_t *) dev->driver_data; s_putboxpart(wd->surface, x, y, xs, ys, hndl->x, hndl->y, data, 0, 0); lxynth_surface_update(dev, x, y, xs, ys); s_thread_mutex_unlock(lxynth_root->gd->mut); }
void taskbar_start (s_window_t *window, s_config_t *cfg) { int x; s_timer_t *timer; s_handler_t *hndl; tbar_data_t *tbar_data; s_window_set_coor(window, WINDOW_TYPE_NOFORM, 0, window->surface->height - 30, window->surface->width, 30); s_window_set_alwaysontop(window, 1); s_window_set_resizeable(window, 0); s_window_atevent(window, taskbar_atevent); s_window_atexit(window, taskbar_atexit); s_free(window->surface->vbuf); window->surface->width = window->surface->buf->w; window->surface->height = window->surface->buf->h; window->surface->vbuf = (unsigned char *) s_malloc(window->surface->width * window->surface->height * window->surface->bytesperpixel); tbar_data = (tbar_data_t *) s_malloc(sizeof(tbar_data_t)); tbar_data->tbar_clock = (tbar_clock_t *) s_malloc(sizeof(tbar_clock_t)); tbar_data->tbar_smenu = (tbar_smenu_t *) s_malloc(sizeof(tbar_smenu_t)); s_list_init(&(tbar_data->tbar_smenu->progs)); s_image_init(&(tbar_data->tbar_smenu->img)); s_image_img(DESKTOPDIR "/img/icons/xynth.png", tbar_data->tbar_smenu->img); s_image_get_handler(tbar_data->tbar_smenu->img); tbar_data->tbar_smenu->running = 0; tbar_data->tbar_progs = (tbar_progs_t *) s_malloc(sizeof(tbar_progs_t)); tbar_data->tbar_progs->desktop = (s_desktop_t *) s_malloc(sizeof(s_desktop_t)); s_list_init(&(tbar_data->tbar_progs->desktop->clients)); s_font_init(&(tbar_data->tbar_progs->prog_font), "arial.ttf"); s_image_init(&(tbar_data->tbar_progs->tbar_img)); s_image_img(DESKTOPDIR "/img/widget/taskbar.png", tbar_data->tbar_progs->tbar_img); s_image_get_buf(window->surface, tbar_data->tbar_progs->tbar_img); s_image_init(&(tbar_data->tbar_progs->prog_img[0])); s_image_img(DESKTOPDIR "/img/widget/button4.png", tbar_data->tbar_progs->prog_img[0]); s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[0]); s_image_init(&(tbar_data->tbar_progs->prog_img[1])); s_image_img(DESKTOPDIR "/img/widget/button3.png", tbar_data->tbar_progs->prog_img[1]); s_image_get_buf(window->surface, tbar_data->tbar_progs->prog_img[1]); window->data = (void *) tbar_data; s_fillbox(window->surface, 0, 0, window->surface->buf->w, window->surface->buf->h, s_rgbcolor(window->surface, 255, 255, 255)); s_fillbox(window->surface, 1, 1, window->surface->buf->w - 1, window->surface->buf->h - 1, s_rgbcolor(window->surface, 115, 117, 115)); for (x = 1; x <= window->surface->buf->w; x++) { s_putboxpart(window->surface, x, 1, 1, window->surface->buf->h - 2, 1, 30, tbar_data->tbar_progs->tbar_img->buf, 0, 1); } tbar_data->tbar_clock->clock = NULL; tbar_data->tbar_clock->rect.x = window->surface->width - 3 - 75; tbar_data->tbar_clock->rect.y = 3; tbar_data->tbar_clock->rect.w = 75; tbar_data->tbar_clock->rect.h = window->surface->height - 6; s_font_init(&(tbar_data->tbar_clock->font), "veramono.ttf"); s_font_set_size(tbar_data->tbar_clock->font, tbar_data->tbar_clock->rect.h); tbar_data->tbar_smenu->rect.x = 3; tbar_data->tbar_smenu->rect.y = 3; tbar_data->tbar_smenu->rect.w = window->surface->height - 6; tbar_data->tbar_smenu->rect.h = window->surface->height - 6; tbar_data->tbar_progs->rect.x = 3 + tbar_data->tbar_smenu->rect.w + 3; tbar_data->tbar_progs->rect.y = 3; tbar_data->tbar_progs->rect.w = window->surface->width - 3 - tbar_data->tbar_smenu->rect.w - 3 - 3 - tbar_data->tbar_clock->rect.w - 3; tbar_data->tbar_progs->rect.h = window->surface->height - 6; s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = tbar_data->tbar_progs->rect.x; hndl->mouse.y = tbar_data->tbar_progs->rect.y; hndl->mouse.w = tbar_data->tbar_progs->rect.w; hndl->mouse.h = tbar_data->tbar_progs->rect.h; hndl->mouse.r = taskbar_progs_handler_r; hndl->mouse.button = MOUSE_BUTTON_LEFT; s_handler_add(window, hndl); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = tbar_data->tbar_smenu->rect.x; hndl->mouse.y = tbar_data->tbar_smenu->rect.y; hndl->mouse.w = tbar_data->tbar_smenu->rect.w; hndl->mouse.h = tbar_data->tbar_smenu->rect.h; hndl->mouse.p = taskbar_start_menu_handler_p; hndl->mouse.button = MOUSE_BUTTON_LEFT; s_handler_add(window, hndl); taskbar_start_menu_icon(window); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = tbar_data->tbar_clock->rect.x; hndl->mouse.y = tbar_data->tbar_clock->rect.y; hndl->mouse.w = tbar_data->tbar_clock->rect.w; hndl->mouse.h = tbar_data->tbar_clock->rect.h; hndl->mouse.o = taskbar_clock_handler_o; hndl->mouse.oh = taskbar_clock_handler_oh; hndl->data = NULL; s_handler_add(window, hndl); start_menu_setup(window, cfg); s_timer_init(&timer); timer->timeval = 1000; timer->cb = taskbar_clock_draw; s_timer_add(window, timer); taskbar_clock_draw(window, timer); s_window_show(window); s_window_main(window); }