int main (int argc, char ** argv) { setup_windowing(); int width = wins_globals->server_width; int height = wins_globals->server_height; win_width = width; win_height = height; init_shmemfonts(); set_font_size(14); /* Create the panel */ window_t * panel = window_create(0, 0, width, PANEL_HEIGHT); window_reorder (panel, 0xFFFF); ctx = init_graphics_window_double_buffer(panel); draw_fill(ctx, rgba(0,0,0,0)); flip(ctx); init_sprite_png(0, "/usr/share/panel.png"); init_sprite_png(1, "/usr/share/icons/panel-shutdown.png"); for (uint32_t i = 0; i < width; i += sprites[0]->width) { draw_sprite(ctx, sprites[0], i, 0); } size_t buf_size = panel->width * panel->height * sizeof(uint32_t); char * buf = malloc(buf_size); memcpy(buf, ctx->backbuffer, buf_size); flip(ctx); struct timeval now; int last = 0; struct tm * timeinfo; char buffer[80]; struct utsname u; uname(&u); /* UTF-8 Strings FTW! */ uint8_t * os_name_ = "PonyOS"; uint8_t final[512]; uint32_t l = snprintf(final, 512, "%s %s", os_name_, u.release); syscall_signal(2, sig_int); /* Enable mouse */ win_use_threaded_handler(); mouse_action_callback = panel_check_click; while (_continue) { /* Redraw the background by memcpy (super speedy) */ memcpy(ctx->backbuffer, buf, buf_size); syscall_gettimeofday(&now, NULL); //time(NULL); if (now.tv_sec != last) { last = now.tv_sec; timeinfo = localtime((time_t *)&now.tv_sec); strftime(buffer, 80, "%I:%M:%S %p", timeinfo); draw_string(ctx, width - 120, 17, rgb(255,255,255), buffer); draw_string(ctx, 10, 17, rgb(255,255,255), final); draw_sprite(ctx, sprites[1], win_width - 23, 1); /* Logout button */ flip(ctx); } syscall_nanosleep(0,50); }
int usleep(useconds_t time) { syscall_nanosleep(0, time / 10000); }