Ejemplo n.º 1
0
void init_decorations() {
	init_shmemfonts();

	char * theme = getenv("WM_THEME");
	if (theme && !strcmp(theme, "simple")) {
		initialize_simple();
	} else {
		initialize_fancy();
	}
}
Ejemplo n.º 2
0
int main (int argc, char ** argv) {
	init_shmemfonts();

	yutani_t * y = yutani_init();

	if (!y) {
		fprintf(stderr, "[glogin] Connection to server failed.\n");
		return 1;
	}

	/* Load config */
	{
		confreader_t * conf = confreader_load("/etc/glogin.conf");

		LOGO_FINAL_OFFSET = confreader_intd(conf, "style", "logo_padding", LOGO_FINAL_OFFSET);
		BOX_WIDTH = confreader_intd(conf, "style", "box_width", BOX_WIDTH);
		BOX_HEIGHT = confreader_intd(conf, "style", "box_height", BOX_HEIGHT);
		BOX_ROUNDNESS = confreader_intd(conf, "style", "box_roundness", BOX_ROUNDNESS);
		CENTER_BOX_X = confreader_intd(conf, "style", "center_box_x", CENTER_BOX_X);
		CENTER_BOX_Y = confreader_intd(conf, "style", "center_box_y", CENTER_BOX_Y);
		BOX_LEFT = confreader_intd(conf, "style", "box_left", BOX_LEFT);
		BOX_RIGHT = confreader_intd(conf, "style", "box_right", BOX_RIGHT);
		BOX_TOP = confreader_intd(conf, "style", "box_top", BOX_TOP);
		BOX_BOTTOM = confreader_intd(conf, "style", "box_bottom", BOX_BOTTOM);
		BOX_COLOR_R = confreader_intd(conf, "style", "box_color_r", BOX_COLOR_R);
		BOX_COLOR_G = confreader_intd(conf, "style", "box_color_g", BOX_COLOR_G);
		BOX_COLOR_B = confreader_intd(conf, "style", "box_color_b", BOX_COLOR_B);
		BOX_COLOR_A = confreader_intd(conf, "style", "box_color_a", BOX_COLOR_A);

		WALLPAPER = confreader_getd(conf, "image", "wallpaper", WALLPAPER);
		LOGO = confreader_getd(conf, "image", "logo", LOGO);

		confreader_free(conf);

		TRACE("Loading complete");
	}

	TRACE("Loading logo...");
	load_sprite_png(&logo, LOGO);
	TRACE("... done.");

	/* Generate surface for background */
	sprite_t * bg_sprite;

	int width  = y->display_width;
	int height = y->display_height;
	int skip_animation = 0;

	/* Do something with a window */
	TRACE("Connecting to window server...");
	yutani_window_t * wina = yutani_window_create(y, width, height);
	assert(wina);
	yutani_set_stack(y, wina, 0);
	ctx = init_graphics_yutani_double_buffer(wina);
	draw_fill(ctx, rgba(0,0,0,255));
	yutani_flip(y, wina);
	TRACE("... done.");


redo_everything:
	win_width = width;
	win_height = height;

	cairo_surface_t * cs = cairo_image_surface_create_for_data((void*)ctx->backbuffer, CAIRO_FORMAT_ARGB32, ctx->width, ctx->height, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ctx->width));
	cairo_t * cr = cairo_create(cs);


	TRACE("Loading wallpaper...");
	{
		sprite_t * wallpaper = malloc(sizeof(sprite_t));
		load_sprite_png(wallpaper, WALLPAPER);

		float x = (float)width  / (float)wallpaper->width;
		float y = (float)height / (float)wallpaper->height;

		int nh = (int)(x * (float)wallpaper->height);
		int nw = (int)(y * (float)wallpaper->width);;

		bg_sprite = create_sprite(width, height, ALPHA_OPAQUE);
		gfx_context_t * bg = init_graphics_sprite(bg_sprite);

		if (nw > width) {
			draw_sprite_scaled(bg, wallpaper, (width - nw) / 2, 0, nw, height);
		} else {
			draw_sprite_scaled(bg, wallpaper, 0, (height - nh) / 2, width, nh);
		}

		/* Three box blurs = good enough approximation of a guassian, but faster*/
		blur_context_box(bg, 20);
		blur_context_box(bg, 20);
		blur_context_box(bg, 20);

		free(bg);
		free(wallpaper);
	}
	TRACE("... done.");

	while (1) {

		yutani_set_stack(y, wina, 0);
		yutani_focus_window(y, wina->wid);

		draw_fill(ctx, rgb(0,0,0));
		draw_sprite(ctx, bg_sprite, center_x(width), center_y(height));
		flip(ctx);
		yutani_flip(y, wina);

		char * foo = malloc(sizeof(uint32_t) * width * height);
		memcpy(foo, ctx->backbuffer, sizeof(uint32_t) * width * height);

		TRACE("Begin animation.");
		if (!skip_animation) {
			struct timeval start;
			gettimeofday(&start, NULL);

			while (1) {
				uint32_t tick;
				struct timeval t;
				gettimeofday(&t, NULL);

				uint32_t sec_diff = t.tv_sec - start.tv_sec;
				uint32_t usec_diff = t.tv_usec - start.tv_usec;

				if (t.tv_usec < start.tv_usec) {
					sec_diff -= 1;
					usec_diff = (1000000 + t.tv_usec) - start.tv_usec;
				}

				tick = (uint32_t)(sec_diff * 1000 + usec_diff / 1000);
				int i = (float)LOGO_FINAL_OFFSET * (float)tick / 700.0f;
				if (i >= LOGO_FINAL_OFFSET) break;

				memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
				draw_sprite(ctx, &logo, center_x(logo.width), center_y(logo.height) - i);
				flip(ctx);
				yutani_flip_region(y, wina, center_x(logo.width), center_y(logo.height) - i, logo.width, logo.height + 5);
				usleep(10000);
			}
		}
		TRACE("End animation.");
		skip_animation = 0;

		size_t buf_size = wina->width * wina->height * sizeof(uint32_t);
		char * buf = malloc(buf_size);

		uint32_t i = 0;

		uint32_t black = rgb(0,0,0);
		uint32_t white = rgb(255,255,255);

		int x_offset = 65;
		int y_offset = 64;

		int fuzz = 3;

		char username[INPUT_SIZE] = {0};
		char password[INPUT_SIZE] = {0};
		char hostname[512];

		// we do it here to calculate the final string position
		get_updated_hostname_with_time_info(hostname);

		char kernel_v[512];

		{
			struct utsname u;
			uname(&u);
			/* UTF-8 Strings FTW! */
			uint8_t * os_name_ = "とあるOS";
			uint32_t l = snprintf(kernel_v, 512, "%s %s", os_name_, u.release);
		}

		uid = 0;

		int box_x, box_y;

		if (CENTER_BOX_X) {
			box_x = center_x(BOX_WIDTH);
		} else if (BOX_LEFT == -1) {
			box_x = win_width - BOX_RIGHT - BOX_WIDTH;
		} else {
			box_x = BOX_LEFT;
		}
		if (CENTER_BOX_Y) {
			box_y = center_y(0) + 8;
		} else if (BOX_TOP == -1) {
			box_y = win_width - BOX_BOTTOM - BOX_HEIGHT;
		} else {
			box_y = BOX_TOP;
		}

		int focus = 0;

		set_font_size(11);
		int hostname_label_left = width - 10 - draw_string_width(hostname);
		int kernel_v_label_left = 10;

		struct text_box username_box = { (BOX_WIDTH - 170) / 2, 30, 170, 20, rgb(0,0,0), NULL, 0, 0, 0, username, "Username" };
		struct text_box password_box = { (BOX_WIDTH - 170) / 2, 58, 170, 20, rgb(0,0,0), NULL, 0, 1, 0, password, "Password" };

		struct login_container lc = { box_x, box_y, BOX_WIDTH, BOX_HEIGHT, &username_box, &password_box, 0 };

		username_box.parent = &lc;
		password_box.parent = &lc;

		while (1) {
			focus = 0;
			memset(username, 0x0, INPUT_SIZE);
			memset(password, 0x0, INPUT_SIZE);

			while (1) {

				// update time info
				get_updated_hostname_with_time_info(hostname);

				memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
				draw_sprite(ctx, &logo, center_x(logo.width), center_y(logo.height) - LOGO_FINAL_OFFSET);

				set_font_size(11);
				draw_string_shadow(ctx, hostname_label_left, height - 12, white, hostname, rgb(0,0,0), 2, 1, 1, 3.0);
				draw_string_shadow(ctx, kernel_v_label_left, height - 12, white, kernel_v, rgb(0,0,0), 2, 1, 1, 3.0);

				if (focus == USERNAME_BOX) {
					username_box.is_focused = 1;
					password_box.is_focused = 0;
				} else if (focus == PASSWORD_BOX) {
					username_box.is_focused = 0;
					password_box.is_focused = 1;
				} else {
					username_box.is_focused = 0;
					password_box.is_focused = 0;
				}

				draw_login_container(cr, &lc);

				flip(ctx);
				yutani_flip(y, wina);

				struct yutani_msg_key_event kbd;
				struct yutani_msg_window_mouse_event mou;
				int msg_type = 0;
collect_events:
				do {
					yutani_msg_t * msg = yutani_poll(y);
					switch (msg->type) {
						case YUTANI_MSG_KEY_EVENT:
							{
								struct yutani_msg_key_event * ke = (void*)msg->data;
								if (ke->event.action == KEY_ACTION_DOWN) {
									memcpy(&kbd, ke, sizeof(struct yutani_msg_key_event));
									msg_type = 1;
								}
							}
							break;
						case YUTANI_MSG_WINDOW_MOUSE_EVENT:
							{
								struct yutani_msg_window_mouse_event * me = (void*)msg->data;
								memcpy(&mou, me, sizeof(struct yutani_msg_mouse_event));
								msg_type = 2;
							}
							break;
						case YUTANI_MSG_WELCOME:
							{
								struct yutani_msg_welcome * mw = (void*)msg->data;
								yutani_window_resize(y, wina, mw->display_width, mw->display_height);
							}
							break;
						case YUTANI_MSG_RESIZE_OFFER:
							{
								struct yutani_msg_window_resize * wr = (void*)msg->data;
								width = wr->width;
								height = wr->height;
								yutani_window_resize_accept(y, wina, width, height);
								reinit_graphics_yutani(ctx, wina);
								yutani_window_resize_done(y, wina);

								sprite_free(bg_sprite);
								cairo_destroy(cr);
								cairo_surface_destroy(cs);

								skip_animation = 1;
								goto redo_everything;
							}
							break;
					}
					free(msg);
				} while (!msg_type);

				if (msg_type == 1) {

					if (kbd.event.keycode == '\n') {
						if (focus == USERNAME_BOX) {
							focus = PASSWORD_BOX;
							continue;
						} else if (focus == PASSWORD_BOX) {
							break;
						} else {
							focus = USERNAME_BOX;
							continue;
						}
					}

					if (kbd.event.keycode == '\t') {
						if (focus == USERNAME_BOX) {
							focus = PASSWORD_BOX;
						} else {
							focus = USERNAME_BOX;
						}
						continue;
					}

					if (kbd.event.key) {

						if (!focus) {
							focus = USERNAME_BOX;
						}

						if (focus == USERNAME_BOX) {
							buffer_put(username, kbd.event.key);
						} else if (focus == PASSWORD_BOX) {
							buffer_put(password, kbd.event.key);
						}

					}

				} else if (msg_type == 2) {

					if ((mou.command == YUTANI_MOUSE_EVENT_DOWN
					     && mou.buttons & YUTANI_MOUSE_BUTTON_LEFT)
					    || (mou.command == YUTANI_MOUSE_EVENT_CLICK)) {
						/* Determine if we were inside of a text box */

						if (mou.new_x >= lc.x + username_box.x &&
						    mou.new_x <= lc.x + username_box.x + username_box.width &&
						    mou.new_y >= lc.y + username_box.y &&
						    mou.new_y <= lc.y + username_box.y + username_box.height) {
							/* Ensure this box is focused. */
							focus = USERNAME_BOX;
							continue;
						} else if (mou.new_x >= lc.x + password_box.x &&
						    mou.new_x <= lc.x + password_box.x + password_box.width &&
						    mou.new_y >= lc.y + password_box.y &&
						    mou.new_y <= lc.y + password_box.y + password_box.height) {
							/* Ensure this box is focused. */
							focus = PASSWORD_BOX;
							continue;
						} else {
							focus = 0;
							continue;
						}

					} else {
						goto collect_events;
					}
				}

			}

			uid = toaru_auth_check_pass(username, password);

			if (uid >= 0) {
				break;
			}
			lc.show_error = 1;
		}

		memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
		flip(ctx);
		yutani_flip(y, wina);
		syscall_yield();

		pid_t _session_pid = fork();
		if (!_session_pid) {
			setuid(uid);
			toaru_auth_set_vars();
			char * args[] = {"/bin/gsession", NULL};
			execvp(args[0], args);
		}

		free(foo);
		free(buf);

		waitpid(_session_pid, NULL, 0);
	}

	yutani_close(y, wina);


	return 0;
}
Ejemplo n.º 3
0
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;

	event_pipe = syscall_mkpipe();

	/* Do something with a window */
	window_t * wina = window_create(0,0, width, height);
	assert(wina);
	window_reorder (wina, 0);
	ctx = init_graphics_window_double_buffer(wina);
	draw_fill(ctx, rgb(127,127,127));
	flip(ctx);

	syscall_signal(2, sig_int);

	char f_name[512];
	sprintf(f_name, "%s/.wallpaper.png", getenv("HOME"));
	FILE * f = fopen(f_name, "r");
	if (f) {
		fclose(f);
		init_sprite_png(0, f_name);
	} else {
		init_sprite_png(0, "/usr/share/wallpaper.png");
	}

	float x = (float)width  / (float)sprites[0]->width;
	float y = (float)height / (float)sprites[0]->height;

	int nh = (int)(x * (float)sprites[0]->height);
	int nw = (int)(y * (float)sprites[0]->width);;

	if (nw > width) {
		draw_sprite_scaled(ctx, sprites[0], (width - nw) / 2, 0, nw, height);
	} else {
		draw_sprite_scaled(ctx, sprites[0], 0, (height - nh) / 2, width, nh);
	}
	flip(ctx);

	init_shmemfonts();

	/* Load Application Shortcuts */
	uint32_t i = 0;
	while (1) {
		if (!applications[i].icon) {
			break;
		}
		printf("Loading png %s\n", applications[i].icon);
		init_sprite_png(i+1, applications[i].icon);
		draw_sprite(ctx, sprites[i+1], ICON_X, ICON_TOP_Y + ICON_SPACING_Y * i);

		int str_w = draw_string_width(applications[i].title) / 2;
		int str_x = ICON_X + ICON_WIDTH / 2 - str_w;
		int str_y = ICON_TOP_Y + ICON_SPACING_Y * i + ICON_WIDTH + 14;
		draw_string_shadow(ctx, str_x, str_y, rgb(255,255,255), applications[i].title, rgb(0,0,0), 2, 1, 1, 3.0);

		++i;
	}

	flip(ctx);

	/* Enable mouse */
	win_use_threaded_handler();
	mouse_action_callback = wallpaper_check_click;

	while (_continue) {
		char buf;
		read(event_pipe, &buf, 1);
		if (next_run_activate) {
			launch_application(next_run_activate);
			next_run_activate = NULL;
		}
	}

	teardown_windowing();

	return 0;
}
Ejemplo n.º 4
0
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);
	}
Ejemplo n.º 5
0
int main (int argc, char ** argv) {
	init_sprite_png(0, "/usr/share/logo_login.png");
	init_shmemfonts();

	while (1) {
		syscall_print("Setup...\n");
		setup_windowing();

		int width  = wins_globals->server_width;
		int height = wins_globals->server_height;

		win_width = width;
		win_height = height;

		/* Do something with a window */
		window_t * wina = window_create(0,0, width, height);
		assert(wina);
		window_reorder (wina, 0); /* Disables movement */
		ctx = init_graphics_window_double_buffer(wina);

		for (int i = 0; i < LOGO_FINAL_OFFSET; ++i) {
			draw_fill(ctx, rgb(39,55,113));
			draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - i);
			flip(ctx);
		}

		size_t buf_size = wina->width * wina->height * sizeof(uint32_t);
		char * buf = malloc(buf_size);

		uint32_t i = 0;

		uint32_t black = rgb(0,0,0);
		uint32_t white = rgb(255,255,255);
		uint32_t red   = rgb(240, 20, 20);

		int x_offset = 65;
		int y_offset = 64;

		int fuzz = 3;

		char username[INPUT_SIZE] = {0};
		char password[INPUT_SIZE] = {0};
		char hostname[512];

		{
			char _hostname[256];
			syscall_gethostname(_hostname);

			struct tm * timeinfo;
			struct timeval now;
			syscall_gettimeofday(&now, NULL); //time(NULL);
			timeinfo = localtime((time_t *)&now.tv_sec);

			char _date[256];
			strftime(_date, 256, "%a %B %d %Y", timeinfo);

			sprintf(hostname, "%s // %s", _hostname, _date);
		}

		char kernel_v[512];

		{
			struct utsname u;
			uname(&u);
			/* UTF-8 Strings FTW! */
			uint8_t * os_name_ = "PonyOS";
			uint32_t l = snprintf(kernel_v, 512, "%s %s", os_name_, u.release);
		}

		uid = 0;

#define BOX_WIDTH  272
#define BOX_HEIGHT 104
#define USERNAME_BOX 1
#define PASSWORD_BOX 2
#define EXTRA_TEXT_OFFSET 12
#define TEXTBOX_INTERIOR_LEFT 4
#define LEFT_OFFSET 80
		int box_x = center_x(BOX_WIDTH);
		int box_y = center_y(0) + 8;

		int focus = USERNAME_BOX;

		set_font_size(11);

		int username_label_left = LEFT_OFFSET - 2 - draw_string_width("Username:"******"Password:"******"");
				for (int i = 0; i < strlen(password); ++i) {
					strcat(password_circles, "●");
				}

				/* Redraw the background */
				draw_fill(ctx, rgb(39,55,113));
				draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - LOGO_FINAL_OFFSET);

				draw_string(ctx, hostname_label_left, height - 12, white, hostname);
				draw_string(ctx, kernel_v_label_left, height - 12, white, kernel_v);

				/* Draw backdrops */
				draw_box(ctx, box_x, box_y, BOX_WIDTH, BOX_HEIGHT, rgb(180,124,205));
				draw_box(ctx, box_x + LEFT_OFFSET, box_y + 32, 168, 16, rgb(255,255,255));
				draw_box(ctx, box_x + LEFT_OFFSET, box_y + 56, 168, 16, rgb(255,255,255));

				/* Draw labels */
				draw_string(ctx, box_x + username_label_left, box_y + 32 + EXTRA_TEXT_OFFSET, white, "Username:"******"Password:"******"Incorrect username or password.";
					
					draw_string(ctx, box_x + (BOX_WIDTH - draw_string_width(error_message)) / 2, box_y + 8 + EXTRA_TEXT_OFFSET, red, error_message);
				}

				if (focus == USERNAME_BOX) {
					draw_box_border(ctx, box_x + LEFT_OFFSET, box_y + 32, 168, 16, rgb(229, 68, 138));
				} else if (focus == PASSWORD_BOX) {
					draw_box_border(ctx, box_x + LEFT_OFFSET, box_y + 56, 168, 16, rgb(229, 68, 138));
				}

				flip(ctx);

				w_keyboard_t * kbd = NULL;
				do {
					kbd = poll_keyboard();
				} while (!kbd);

				if (kbd->key == '\n') {
					if (focus == USERNAME_BOX) {
						free(kbd);
						focus = PASSWORD_BOX;
						continue;
					} else if (focus == PASSWORD_BOX) {
						free(kbd);
						break;
					}
				}

				if (kbd->key == '\t') {
					if (focus == USERNAME_BOX) {
						focus = PASSWORD_BOX;
					} else if (focus == PASSWORD_BOX) {
						focus = USERNAME_BOX;
					}
					free(kbd);
					continue;
				}

				if (focus == USERNAME_BOX) {
					buffer_put(username, kbd->key);
				} else if (focus == PASSWORD_BOX) {
					buffer_put(password, kbd->key);
				}
				free(kbd);

			}

			uid = checkUserPass(username, password);

			if (uid >= 0) {
				break;
			}
			show_error = 1;
		}

		draw_fill(ctx, rgb(39,55,113));
		draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - LOGO_FINAL_OFFSET);
		flip(ctx);

		teardown_windowing();

		pid_t _session_pid = fork();
		if (!_session_pid) {
			setenv("PATH", "/usr/bin:/bin", 0);
			syscall_setuid(uid);
			char * args[] = {"/bin/gsession", NULL};
			execvp(args[0], args);
		}

		free(buf);
		free(ctx->backbuffer);
		free(ctx);

		syscall_wait(_session_pid);
	}

	return 0;
}
Ejemplo n.º 6
0
int main (int argc, char ** argv) {
	yctx = yutani_init();

	int width  = yctx->display_width;
	int height = yctx->display_height;

	sprite_t * wallpaper_tmp = malloc(sizeof(sprite_t));

	char f_name[512];
	sprintf(f_name, "%s/.wallpaper.png", getenv("HOME"));
	FILE * f = fopen(f_name, "r");
	if (f) {
		fclose(f);
		load_sprite_png(wallpaper_tmp, f_name);
	} else {
		load_sprite_png(wallpaper_tmp, "/usr/share/wallpaper.png");
	}

	/* Initialize hashmap for icon cache */
	icon_cache = hashmap_create(10);

	{ /* Generic fallback icon */
		sprite_t * app_icon = malloc(sizeof(sprite_t));
		load_sprite_png(app_icon, "/usr/share/icons/48/applications-generic.png");
		hashmap_set(icon_cache, "generic", app_icon);
	}

	sprintf(f_name, "%s/.desktop", getenv("HOME"));
	f = fopen(f_name, "r");
	if (!f) {
		f = fopen("/etc/default.desktop", "r");
	}
	read_applications(f);

	/* Load applications */
	uint32_t i = 0;
	while (applications[i].icon) {
		applications[i].icon_sprite = icon_get(applications[i].icon);
		++i;
	}

	float x = (float)width  / (float)wallpaper_tmp->width;
	float y = (float)height / (float)wallpaper_tmp->height;

	int nh = (int)(x * (float)wallpaper_tmp->height);
	int nw = (int)(y * (float)wallpaper_tmp->width);;

	wallpaper = create_sprite(width, height, ALPHA_OPAQUE);
	gfx_context_t * tmp = init_graphics_sprite(wallpaper);

	if (nw > width) {
		draw_sprite_scaled(tmp, wallpaper_tmp, (width - nw) / 2, 0, nw, height);
	} else {
		draw_sprite_scaled(tmp, wallpaper_tmp, 0, (height - nh) / 2, width, nh);
	}

	free(tmp);

	win_width = width;
	win_height = height;

	wina = yutani_window_create(yctx, width, height);
	assert(wina);
	yutani_set_stack(yctx, wina, YUTANI_ZORDER_BOTTOM);
	ctx = init_graphics_yutani_double_buffer(wina);
	init_shmemfonts();

	redraw_apps();
	yutani_flip(yctx, wina);

	while (_continue) {
		yutani_msg_t * m = yutani_poll(yctx);
		waitpid(-1, NULL, WNOHANG);
		if (m) {
			switch (m->type) {
				case YUTANI_MSG_WINDOW_MOUSE_EVENT:
					wallpaper_check_click((struct yutani_msg_window_mouse_event *)m->data);
					break;
				case YUTANI_MSG_SESSION_END:
					_continue = 0;
					break;
			}
			free(m);
		}
	}

	yutani_close(yctx, wina);

	return 0;
}