2012-02-04 07:15:26 +04:00
|
|
|
/*
|
|
|
|
* The ToAru Sample Game
|
2012-01-30 03:05:42 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
2012-02-04 07:15:26 +04:00
|
|
|
#include <syscall.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <time.h>
|
2012-02-12 03:57:22 +04:00
|
|
|
#include <assert.h>
|
2012-02-11 09:26:30 +04:00
|
|
|
#include <sys/stat.h>
|
2012-02-04 07:15:26 +04:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
#include FT_CACHE_H
|
|
|
|
|
2012-01-30 03:05:42 +04:00
|
|
|
#include "lib/list.h"
|
2012-02-04 07:15:26 +04:00
|
|
|
#include "lib/graphics.h"
|
2012-02-12 04:54:34 +04:00
|
|
|
#include "lib/window.h"
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-13 04:47:01 +04:00
|
|
|
#include "../kernel/include/signal.h"
|
2012-02-16 06:50:31 +04:00
|
|
|
#include "../kernel/include/mouse.h"
|
2012-02-13 04:47:01 +04:00
|
|
|
|
2012-02-12 04:01:21 +04:00
|
|
|
DECL_SYSCALL0(mkpipe);
|
2012-02-16 06:50:31 +04:00
|
|
|
DEFN_SYSCALL0(mousedevice, 33);
|
2012-02-17 00:31:40 +04:00
|
|
|
DEFN_SYSCALL3(clone, 30, uintptr_t, uintptr_t, void *);
|
|
|
|
DEFN_SYSCALL0(gettid, 41);
|
|
|
|
|
2012-03-28 04:09:11 +04:00
|
|
|
void spin_lock(int volatile * lock) {
|
|
|
|
while(__sync_lock_test_and_set(lock, 0x01)) {
|
|
|
|
syscall_yield();
|
|
|
|
}
|
|
|
|
}
|
2012-02-26 09:52:09 +04:00
|
|
|
|
2012-03-28 04:09:11 +04:00
|
|
|
void spin_unlock(int volatile * lock) {
|
|
|
|
__sync_lock_release(lock);
|
|
|
|
}
|
2012-02-26 09:52:09 +04:00
|
|
|
|
2012-02-17 00:31:40 +04:00
|
|
|
int clone(uintptr_t,uintptr_t,void*) __attribute__((alias("syscall_clone")));
|
|
|
|
int gettid() __attribute__((alias("syscall_gettid")));
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t id;
|
|
|
|
char * stack;
|
|
|
|
void * ret_val;
|
|
|
|
} pthread_t;
|
|
|
|
typedef unsigned int pthread_attr_t;
|
|
|
|
|
|
|
|
#define PTHREAD_STACK_SIZE 10240
|
|
|
|
|
|
|
|
int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *(*start_routine)(void *), void * arg) {
|
|
|
|
char * stack = malloc(PTHREAD_STACK_SIZE);
|
|
|
|
uintptr_t stack_top = (uintptr_t)stack + PTHREAD_STACK_SIZE;
|
|
|
|
thread->stack = stack;
|
|
|
|
thread->id = clone(stack_top, (uintptr_t)start_routine, arg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pthread_exit(void * value) {
|
|
|
|
/* Perform nice cleanup */
|
|
|
|
#if 0
|
|
|
|
/* XXX: LOCK */
|
|
|
|
free(stack);
|
|
|
|
/* XXX: Return value!? */
|
|
|
|
#endif
|
|
|
|
__asm__ ("jmp 0xFFFFB00F"); /* Force thread exit */
|
|
|
|
}
|
2012-02-12 04:01:21 +04:00
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
sprite_t * sprites[128];
|
2012-01-30 03:05:42 +04:00
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
#define WIN_D 32
|
2012-02-12 04:01:21 +04:00
|
|
|
#define WIN_B (WIN_D / 8)
|
2012-02-11 09:26:30 +04:00
|
|
|
|
|
|
|
|
|
|
|
list_t * process_list;
|
|
|
|
|
2012-02-23 11:30:56 +04:00
|
|
|
int32_t mouse_x, mouse_y;
|
|
|
|
#define MOUSE_SCALE 10
|
|
|
|
#define MOUSE_OFFSET_X 26
|
|
|
|
#define MOUSE_OFFSET_Y 26
|
|
|
|
|
2012-03-15 07:03:55 +04:00
|
|
|
void redraw_region_slow(int32_t x, int32_t y, int32_t width, int32_t height);
|
|
|
|
void redraw_cursor() {
|
2012-03-28 01:52:46 +04:00
|
|
|
//redraw_region_slow(mouse_x / MOUSE_SCALE - 32, mouse_y / MOUSE_SCALE - 32, 64, 64);
|
2012-03-15 07:03:55 +04:00
|
|
|
draw_sprite(sprites[3], mouse_x / MOUSE_SCALE - MOUSE_OFFSET_X, mouse_y / MOUSE_SCALE - MOUSE_OFFSET_Y);
|
|
|
|
}
|
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
extern window_t * init_window (process_windows_t * pw, wid_t wid, int32_t x, int32_t y, uint16_t width, uint16_t height, uint16_t index);
|
|
|
|
extern void free_window (window_t * window);
|
2012-02-14 05:46:00 +04:00
|
|
|
extern void resize_window_buffer (window_t * window, int16_t left, int16_t top, uint16_t width, uint16_t height);
|
2012-02-12 04:54:34 +04:00
|
|
|
|
2012-02-26 10:45:46 +04:00
|
|
|
uint16_t * depth_map = NULL;
|
2012-03-27 22:58:21 +04:00
|
|
|
uintptr_t * top_map = NULL;
|
2012-02-26 10:45:46 +04:00
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
process_windows_t * get_process_windows (uint32_t pid) {
|
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
if (pw->pid == pid) {
|
|
|
|
return pw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
static window_t * get_window (wid_t wid) {
|
2012-02-11 09:26:30 +04:00
|
|
|
foreach (n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
foreach (m, pw->windows) {
|
|
|
|
window_t * w = (window_t *)m->value;
|
|
|
|
if (w->wid == wid) {
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-13 05:30:36 +04:00
|
|
|
static window_t * get_window_with_process (process_windows_t * pw, wid_t wid) {
|
|
|
|
foreach (m, pw->windows) {
|
|
|
|
window_t * w = (window_t *)m->value;
|
|
|
|
if (w->wid == wid) {
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
void init_process_list () {
|
|
|
|
process_list = list_create();
|
|
|
|
}
|
|
|
|
|
2012-01-30 03:05:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
int32_t min(int32_t a, int32_t b) {
|
|
|
|
return (a < b) ? a : b;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t max(int32_t a, int32_t b) {
|
|
|
|
return (a > b) ? a : b;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t is_between(int32_t lo, int32_t hi, int32_t val) {
|
|
|
|
if (val >= lo && val < hi) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t is_top(window_t *window, uint16_t x, uint16_t y) {
|
|
|
|
uint16_t index = window->z;
|
2012-02-11 09:26:30 +04:00
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
|
|
|
|
foreach(node, pw->windows) {
|
|
|
|
window_t * win = (window_t *)node->value;
|
|
|
|
if (win == window) continue;
|
|
|
|
if (win->z < index) continue;
|
|
|
|
if (is_between(win->x, win->x + win->width, x) && is_between(win->y, win->y + win->height, y)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-01-30 03:05:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-03-27 22:58:21 +04:00
|
|
|
uint8_t inline is_top_fast(window_t * window, uint16_t x, uint16_t y) {
|
2012-03-29 00:54:31 +04:00
|
|
|
if (x >= graphics_width || y >= graphics_height) {
|
2012-02-26 10:45:46 +04:00
|
|
|
return 0;
|
2012-03-29 00:54:31 +04:00
|
|
|
}
|
|
|
|
if (window->z == depth_map[x + y * graphics_width]) {
|
2012-02-26 10:45:46 +04:00
|
|
|
return 1;
|
2012-03-29 00:54:31 +04:00
|
|
|
}
|
2012-02-26 10:45:46 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-23 11:30:56 +04:00
|
|
|
window_t * top_at(uint16_t x, uint16_t y) {
|
|
|
|
uint32_t index_top = 0;
|
|
|
|
window_t * window_top = NULL;
|
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
foreach(node, pw->windows) {
|
|
|
|
window_t * win = (window_t *)node->value;
|
|
|
|
if (is_between(win->x, win->x + win->width, x) && is_between(win->y, win->y + win->height, y)) {
|
|
|
|
if (window_top == NULL) {
|
|
|
|
window_top = win;
|
|
|
|
index_top = win->z;
|
2012-02-23 11:40:37 +04:00
|
|
|
} else {
|
|
|
|
if (win->z < index_top) continue;
|
|
|
|
window_top = win;
|
|
|
|
index_top = win->z;
|
2012-02-23 11:30:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return window_top;
|
|
|
|
}
|
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
window_t * top_at_fast(uint16_t x, uint16_t y) {
|
|
|
|
uint32_t index_top = 0;
|
|
|
|
window_t * window_top = NULL;
|
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
foreach(node, pw->windows) {
|
|
|
|
window_t * win = (window_t *)node->value;
|
|
|
|
if (is_top_fast(win, x, y)) return win;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-23 11:30:56 +04:00
|
|
|
window_t * absolute_top() {
|
2012-02-17 11:28:12 +04:00
|
|
|
uint32_t index_top = 0;
|
|
|
|
window_t * window_top = NULL;
|
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
foreach(node, pw->windows) {
|
|
|
|
window_t * win = (window_t *)node->value;
|
|
|
|
if (win->z < index_top) continue;
|
|
|
|
window_top = win;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return window_top;
|
|
|
|
}
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-26 09:52:09 +04:00
|
|
|
void make_top(window_t * window) {
|
|
|
|
uint16_t index = window->z;
|
|
|
|
if (index == 0) return;
|
|
|
|
if (index == 0xFFFF) return;
|
|
|
|
uint16_t highest = 0;
|
|
|
|
|
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
foreach(node, pw->windows) {
|
|
|
|
window_t * win = (window_t *)node->value;
|
|
|
|
if (win->z == 0) continue;
|
|
|
|
if (win->z == 0xFFFF) continue;
|
|
|
|
if (highest < win->z) highest = win->z;
|
|
|
|
if (win == window) continue;
|
|
|
|
if (win->z > window->z) win->z--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window->z = highest;
|
|
|
|
}
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-23 11:30:56 +04:00
|
|
|
window_t * focused_window() {
|
2012-03-29 00:54:31 +04:00
|
|
|
#if 0
|
2012-03-02 07:13:52 +04:00
|
|
|
return top_at_fast(mouse_x / MOUSE_SCALE, mouse_y / MOUSE_SCALE);
|
2012-03-29 00:54:31 +04:00
|
|
|
#else
|
|
|
|
return top_at(mouse_x / MOUSE_SCALE, mouse_y / MOUSE_SCALE);
|
|
|
|
#endif
|
2012-02-23 11:30:56 +04:00
|
|
|
}
|
|
|
|
|
2012-03-28 04:09:11 +04:00
|
|
|
volatile int am_drawing = 0;
|
2012-03-28 03:19:35 +04:00
|
|
|
window_t * moving_window = NULL;
|
|
|
|
int32_t moving_window_l = 0;
|
|
|
|
int32_t moving_window_t = 0;
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
/* Internal drawing functions */
|
2012-02-11 09:26:30 +04:00
|
|
|
|
|
|
|
void redraw_window(window_t *window, uint16_t x, uint16_t y, uint16_t width, uint16_t height) {
|
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t _lo_x = max(window->x + x, 0);
|
2012-02-13 08:42:25 +04:00
|
|
|
uint16_t _hi_x = min(window->x + width, graphics_width);
|
2012-02-11 09:26:30 +04:00
|
|
|
uint16_t _lo_y = max(window->y + y, 0);
|
2012-02-13 08:42:25 +04:00
|
|
|
uint16_t _hi_y = min(window->y + height, graphics_height);
|
2012-01-30 03:05:42 +04:00
|
|
|
|
|
|
|
for (uint16_t y = _lo_y; y < _hi_y; ++y) {
|
|
|
|
for (uint16_t x = _lo_x; x < _hi_x; ++x) {
|
2012-02-26 10:45:46 +04:00
|
|
|
/* XXX MAKE THIS FASTER */
|
|
|
|
if (is_top_fast(window, x, y)) {
|
2012-02-26 09:52:09 +04:00
|
|
|
if (TO_WINDOW_OFFSET(x,y) >= window->width * window->height) continue;
|
2012-01-30 03:05:42 +04:00
|
|
|
GFX(x,y) = ((uint32_t *)window->buffer)[TO_WINDOW_OFFSET(x,y)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-15 07:03:55 +04:00
|
|
|
|
|
|
|
//redraw_region_slow(mouse_x / MOUSE_SCALE - 32, mouse_y / MOUSE_SCALE - 32, 64, 64);
|
2012-03-28 01:52:46 +04:00
|
|
|
//redraw_cursor();
|
2012-01-30 03:05:42 +04:00
|
|
|
}
|
|
|
|
|
2012-03-08 08:31:24 +04:00
|
|
|
void reorder_window (window_t * window, uint16_t new_zed) {
|
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
window->z = new_zed;
|
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
void redraw_full_window (window_t * window) {
|
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw_window(window, (uint16_t)0, (uint16_t)0, window->width, window->height);
|
|
|
|
}
|
|
|
|
|
2012-02-26 08:47:20 +04:00
|
|
|
void redraw_region_slow(int32_t x, int32_t y, int32_t width, int32_t height) {
|
|
|
|
uint16_t _lo_x = max(x, 0);
|
|
|
|
uint16_t _hi_x = min(x + width, graphics_width);
|
|
|
|
uint16_t _lo_y = max(y, 0);
|
|
|
|
uint16_t _hi_y = min(y + height, graphics_height);
|
|
|
|
|
|
|
|
for (uint32_t y = _lo_y; y < _hi_y; ++y) {
|
|
|
|
for (uint32_t x = _lo_x; x < _hi_x; ++x) {
|
|
|
|
window_t * window = top_at(x,y);
|
2012-03-02 07:13:52 +04:00
|
|
|
if (window) {
|
2012-03-28 01:52:46 +04:00
|
|
|
//GFX(x,y) = ((uint32_t *)window->buffer)[TO_WINDOW_OFFSET(x,y)];
|
2012-03-02 07:13:52 +04:00
|
|
|
depth_map[x + y * graphics_width] = window->z;
|
2012-03-27 22:58:21 +04:00
|
|
|
top_map[x + y * graphics_width] = (uintptr_t)window;
|
2012-03-02 07:13:52 +04:00
|
|
|
} else {
|
2012-03-28 01:52:46 +04:00
|
|
|
//GFX(x,y) = (y % 2 ^ x % 2) ? rgb(0,0,0) : rgb(255,255,255);
|
2012-03-08 08:31:24 +04:00
|
|
|
depth_map[x + y * graphics_width] = 0;
|
2012-03-27 22:58:21 +04:00
|
|
|
top_map[x + y * graphics_width] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void redraw_everything_fast() {
|
|
|
|
for (uint32_t y = 0; y < graphics_height; ++y) {
|
|
|
|
for (uint32_t x = 0; x < graphics_width; ++x) {
|
|
|
|
window_t * window = (window_t *)top_map[x + y * graphics_width];
|
|
|
|
if (window) {
|
|
|
|
/* UGGGG */
|
|
|
|
if (TO_WINDOW_OFFSET(x,y) >= window->width * window->height) continue;
|
|
|
|
GFX(x,y) = ((uint32_t *)window->buffer)[TO_WINDOW_OFFSET(x,y)];
|
2012-03-02 07:13:52 +04:00
|
|
|
}
|
2012-02-26 08:47:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-28 03:19:35 +04:00
|
|
|
void draw_bounding_box(window_t * window, int32_t left, int32_t top) {
|
|
|
|
if (!window) return;
|
|
|
|
|
|
|
|
uint16_t _lo_x = max(left, 0);
|
|
|
|
uint16_t _hi_x = min(left + window->width, graphics_width);
|
|
|
|
uint16_t _lo_y = max(top, 0);
|
|
|
|
uint16_t _hi_y = min(top + window->height, graphics_height);
|
|
|
|
#define TO_DERPED_OFFSET(x,y) (((x) - left) + ((y) - top) * window->width)
|
|
|
|
|
|
|
|
for (uint16_t y = _lo_y; y < _hi_y; ++y) {
|
|
|
|
for (uint16_t x = _lo_x; x < _hi_x; ++x) {
|
|
|
|
/* XXX MAKE THIS FASTER */
|
2012-03-28 04:09:11 +04:00
|
|
|
//if (TO_DERPED_OFFSET(x,y) >= window->width * window->height) continue;
|
2012-03-28 03:19:35 +04:00
|
|
|
GFX(x,y) = alpha_blend(GFX(x,y), ((uint32_t *)window->buffer)[TO_DERPED_OFFSET(x,y)], rgb(127,0,0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-26 09:52:09 +04:00
|
|
|
void redraw_bounding_box(window_t *window, int32_t left, int32_t top, uint32_t derped) {
|
2012-03-28 01:52:46 +04:00
|
|
|
return;
|
2012-02-26 09:52:09 +04:00
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t _min_x = max(left, 0);
|
|
|
|
int32_t _min_y = max(top, 0);
|
|
|
|
int32_t _max_x = min(left + window->width - 1, graphics_width - 1);
|
|
|
|
int32_t _max_y = min(top + window->height - 1, graphics_height - 1);
|
|
|
|
|
|
|
|
if (!derped) {
|
|
|
|
redraw_region_slow(_min_x, _min_y, (_max_x - _min_x + 1), 1);
|
|
|
|
redraw_region_slow(_min_x, _max_y, (_max_x - _min_x + 1), 1);
|
|
|
|
redraw_region_slow(_min_x, _min_y, 1, (_max_y - _min_y + 1));
|
|
|
|
redraw_region_slow(_max_x, _min_y, 1, (_max_y - _min_y + 1));
|
|
|
|
} else {
|
|
|
|
uint32_t color = rgb(255,0,0);
|
|
|
|
draw_line(_min_x, _max_x, _min_y, _min_y, color);
|
|
|
|
draw_line(_min_x, _max_x, _max_y, _max_y, color);
|
|
|
|
draw_line(_min_x, _min_x, _min_y, _max_y, color);
|
|
|
|
draw_line(_max_x, _max_x, _min_y, _max_y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
void redraw_bounding_box_r(window_t *window, int32_t width, int32_t height, uint32_t derped) {
|
2012-03-28 01:52:46 +04:00
|
|
|
return;
|
2012-03-02 07:13:52 +04:00
|
|
|
if (!window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t _min_x = max(window->x, 0);
|
|
|
|
int32_t _min_y = max(window->y, 0);
|
|
|
|
int32_t _max_x = min(window->x + width - 1, graphics_width - 1);
|
|
|
|
int32_t _max_y = min(window->y + height - 1, graphics_height - 1);
|
|
|
|
|
|
|
|
if (!derped) {
|
|
|
|
redraw_region_slow(_min_x, _min_y, (_max_x - _min_x + 1), 1);
|
|
|
|
redraw_region_slow(_min_x, _max_y, (_max_x - _min_x + 1), 1);
|
|
|
|
redraw_region_slow(_min_x, _min_y, 1, (_max_y - _min_y + 1));
|
|
|
|
redraw_region_slow(_max_x, _min_y, 1, (_max_y - _min_y + 1));
|
|
|
|
} else {
|
|
|
|
uint32_t color = rgb(0,255,0);
|
|
|
|
draw_line(_min_x, _max_x, _min_y, _min_y, color);
|
|
|
|
draw_line(_min_x, _max_x, _max_y, _max_y, color);
|
|
|
|
draw_line(_min_x, _min_x, _min_y, _max_y, color);
|
|
|
|
draw_line(_max_x, _max_x, _min_y, _max_y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
wid_t volatile _next_wid = 0;
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-03-24 02:44:37 +04:00
|
|
|
void send_window_event (process_windows_t * pw, uint8_t event, w_window_t * packet) {
|
2012-02-12 04:54:34 +04:00
|
|
|
/* Construct the header */
|
|
|
|
wins_packet_t header;
|
2012-02-21 09:31:00 +04:00
|
|
|
header.magic = WINS_MAGIC;
|
2012-02-12 04:54:34 +04:00
|
|
|
header.command_type = event;
|
|
|
|
header.packet_size = sizeof(w_window_t);
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
/* Send them */
|
|
|
|
// XXX: we have a race condition here
|
|
|
|
write(pw->event_pipe, &header, sizeof(wins_packet_t));
|
2012-03-24 02:44:37 +04:00
|
|
|
write(pw->event_pipe, packet, sizeof(w_window_t));
|
2012-02-14 02:21:52 +04:00
|
|
|
syscall_send_signal(pw->pid, SIGWINEVENT); // SIGWINEVENT
|
2012-03-14 02:44:19 +04:00
|
|
|
syscall_yield();
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
|
|
|
|
2012-02-17 11:28:12 +04:00
|
|
|
void send_keyboard_event (process_windows_t * pw, uint8_t event, w_keyboard_t packet) {
|
|
|
|
/* Construct the header */
|
|
|
|
wins_packet_t header;
|
2012-02-21 09:31:00 +04:00
|
|
|
header.magic = WINS_MAGIC;
|
2012-02-17 11:28:12 +04:00
|
|
|
header.command_type = event;
|
|
|
|
header.packet_size = sizeof(w_keyboard_t);
|
|
|
|
|
|
|
|
/* Send them */
|
|
|
|
// XXX: we have a race condition here
|
|
|
|
write(pw->event_pipe, &header, sizeof(wins_packet_t));
|
|
|
|
write(pw->event_pipe, &packet, sizeof(w_keyboard_t));
|
|
|
|
syscall_send_signal(pw->pid, SIGWINEVENT); // SIGWINEVENT
|
|
|
|
}
|
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
void process_window_command (int sig) {
|
2012-02-11 09:26:30 +04:00
|
|
|
foreach(n, process_list) {
|
|
|
|
process_windows_t * pw = (process_windows_t *)n->value;
|
|
|
|
|
|
|
|
/* Are there any messages in this process's command pipe? */
|
|
|
|
struct stat buf;
|
|
|
|
fstat(pw->command_pipe, &buf);
|
2012-02-14 02:21:52 +04:00
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
int max_requests_per_cycle = 1;
|
2012-02-14 02:21:52 +04:00
|
|
|
|
|
|
|
while ((buf.st_size > 0) && (max_requests_per_cycle > 0)) {
|
2012-03-02 07:13:52 +04:00
|
|
|
#if 0
|
2012-02-26 10:45:46 +04:00
|
|
|
if (!(buf.st_size > sizeof(wins_packet_t))) {
|
|
|
|
fstat(pw->command_pipe, &buf);
|
|
|
|
continue;
|
|
|
|
}
|
2012-03-02 07:13:52 +04:00
|
|
|
#endif
|
2012-02-11 09:26:30 +04:00
|
|
|
w_window_t wwt;
|
|
|
|
wins_packet_t header;
|
2012-03-24 02:44:37 +04:00
|
|
|
printf("[compositor] read [%d] {\n", pw->pid);
|
2012-02-26 08:47:20 +04:00
|
|
|
int bytes_read = read(pw->command_pipe, &header, sizeof(wins_packet_t));
|
2012-03-24 02:44:37 +04:00
|
|
|
printf("[compositor] } read [%d] \n", pw->pid);
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-23 11:30:56 +04:00
|
|
|
while (header.magic != WINS_MAGIC) {
|
2012-02-26 10:45:46 +04:00
|
|
|
printf("Magic is wrong from pid %d, expected 0x%x but got 0x%x [read %d bytes of %d]\n", pw->pid, WINS_MAGIC, header.magic, bytes_read, sizeof(header));
|
2012-03-02 07:13:52 +04:00
|
|
|
max_requests_per_cycle--;
|
2012-02-26 07:28:33 +04:00
|
|
|
goto bad_magic;
|
2012-02-23 11:30:56 +04:00
|
|
|
memcpy(&header, (void *)((uintptr_t)&header + 1), (sizeof(header) - 1));
|
|
|
|
read(pw->event_pipe, (char *)((uintptr_t)&header + sizeof(header) - 1), 1);
|
|
|
|
}
|
|
|
|
|
2012-02-14 02:21:52 +04:00
|
|
|
max_requests_per_cycle--;
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
switch (header.command_type) {
|
|
|
|
case WC_NEWWINDOW:
|
2012-02-13 04:47:01 +04:00
|
|
|
printf("[compositor] New window request\n");
|
2012-02-11 09:26:30 +04:00
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
2012-02-13 05:30:36 +04:00
|
|
|
wwt.wid = _next_wid;
|
2012-03-24 02:44:37 +04:00
|
|
|
init_window(pw, _next_wid, wwt.left, wwt.top, wwt.width, wwt.height, _next_wid); //XXX: an actual index
|
|
|
|
_next_wid++;
|
|
|
|
send_window_event(pw, WE_NEWWINDOW, &wwt);
|
2012-03-02 07:13:52 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
2012-02-11 09:26:30 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WC_RESIZE:
|
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
2012-02-12 04:54:34 +04:00
|
|
|
resize_window_buffer(get_window(wwt.wid), wwt.left, wwt.top, wwt.width, wwt.height);
|
2012-03-24 02:44:37 +04:00
|
|
|
send_window_event(pw, WE_RESIZED, &wwt);
|
2012-02-11 09:26:30 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WC_DESTROY:
|
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
2012-03-21 01:23:24 +04:00
|
|
|
window_t * win = get_window_with_process(pw, wwt.wid);
|
2012-03-28 04:09:11 +04:00
|
|
|
win->x = 0xFFFF;
|
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
|
|
|
/* Wait until we're done drawing */
|
|
|
|
spin_lock(&am_drawing);
|
|
|
|
spin_unlock(&am_drawing);
|
2012-03-21 01:23:24 +04:00
|
|
|
free_window(win);
|
2012-03-24 02:44:37 +04:00
|
|
|
send_window_event(pw, WE_DESTROYED, &wwt);
|
2012-02-11 09:26:30 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WC_DAMAGE:
|
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
2012-03-27 22:58:21 +04:00
|
|
|
//redraw_window(get_window_with_process(pw, wwt.wid), wwt.left, wwt.top, wwt.width, wwt.height);
|
2012-02-11 09:26:30 +04:00
|
|
|
break;
|
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
case WC_REDRAW:
|
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
2012-03-27 22:58:21 +04:00
|
|
|
//redraw_window(get_window_with_process(pw, wwt.wid), wwt.left, wwt.top, wwt.width, wwt.height);
|
2012-03-24 02:44:37 +04:00
|
|
|
send_window_event(pw, WE_REDRAWN, &wwt);
|
2012-03-02 07:13:52 +04:00
|
|
|
break;
|
|
|
|
|
2012-03-08 08:31:24 +04:00
|
|
|
case WC_REORDER:
|
|
|
|
read(pw->command_pipe, &wwt, sizeof(w_window_t));
|
|
|
|
reorder_window(get_window_with_process(pw, wwt.wid), wwt.left);
|
2012-03-09 09:36:40 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
2012-03-08 08:31:24 +04:00
|
|
|
break;
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
default:
|
2012-02-12 04:54:34 +04:00
|
|
|
printf("[compositor] WARN: Unknown command type %d...\n", header.command_type);
|
2012-02-11 09:26:30 +04:00
|
|
|
void * nullbuf = malloc(header.packet_size);
|
|
|
|
read(pw->command_pipe, nullbuf, header.packet_size);
|
|
|
|
free(nullbuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-02-26 07:28:33 +04:00
|
|
|
bad_magic:
|
2012-02-11 09:26:30 +04:00
|
|
|
fstat(pw->command_pipe, &buf);
|
|
|
|
}
|
|
|
|
}
|
2012-03-02 07:13:52 +04:00
|
|
|
syscall_yield();
|
2012-01-30 03:05:42 +04:00
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
|
2012-01-30 03:05:42 +04:00
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
void waitabit() {
|
|
|
|
int x = time(NULL);
|
|
|
|
while (time(NULL) < x + 1) {
|
2012-03-02 07:13:52 +04:00
|
|
|
syscall_yield();
|
2012-02-04 07:15:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
|
|
|
|
/* Request page system */
|
|
|
|
|
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
wins_server_global_t volatile * _request_page;
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
void reset_request_system () {
|
2012-02-12 04:54:34 +04:00
|
|
|
_request_page->lock = 0;
|
|
|
|
_request_page->server_done = 0;
|
|
|
|
_request_page->client_done = 0;
|
|
|
|
_request_page->client_pid = 0;
|
|
|
|
_request_page->event_pipe = 0;
|
|
|
|
_request_page->command_pipe = 0;
|
|
|
|
|
|
|
|
_request_page->server_pid = getpid();
|
|
|
|
_request_page->server_width = graphics_width;
|
|
|
|
_request_page->server_height = graphics_height;
|
|
|
|
_request_page->server_depth = graphics_depth;
|
|
|
|
|
|
|
|
_request_page->magic = WINS_MAGIC;
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
void init_request_system () {
|
|
|
|
size_t size = sizeof(wins_server_global_t);
|
|
|
|
_request_page = (wins_server_global_t *)syscall_shm_obtain(WINS_SERVER_IDENTIFIER, &size);
|
|
|
|
if (!_request_page) {
|
|
|
|
fprintf(stderr, "[wins] Could not get a shm block for its request page! Bailing...");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_request_system();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
void process_request () {
|
2012-02-14 02:21:52 +04:00
|
|
|
fflush(stdout);
|
2012-02-11 09:26:30 +04:00
|
|
|
if (_request_page->client_done) {
|
|
|
|
process_windows_t * pw = malloc(sizeof(process_windows_t));
|
|
|
|
pw->pid = _request_page->client_pid;
|
|
|
|
pw->event_pipe = syscall_mkpipe();
|
|
|
|
pw->command_pipe = syscall_mkpipe();
|
|
|
|
pw->windows = list_create();
|
|
|
|
|
|
|
|
_request_page->event_pipe = syscall_share_fd(pw->event_pipe, pw->pid);
|
|
|
|
_request_page->command_pipe = syscall_share_fd(pw->command_pipe, pw->pid);
|
2012-02-14 02:21:52 +04:00
|
|
|
_request_page->client_done = 0;
|
2012-02-11 09:26:30 +04:00
|
|
|
_request_page->server_done = 1;
|
2012-02-12 04:54:34 +04:00
|
|
|
|
|
|
|
list_insert(process_list, pw);
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
2012-03-02 07:13:52 +04:00
|
|
|
|
|
|
|
if (!_request_page->lock) {
|
|
|
|
reset_request_system();
|
|
|
|
}
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void delete_process (process_windows_t * pw) {
|
|
|
|
list_destroy(pw->windows);
|
|
|
|
list_free(pw->windows);
|
|
|
|
free(pw->windows);
|
|
|
|
|
|
|
|
close(pw->command_pipe);
|
|
|
|
close(pw->event_pipe);
|
|
|
|
|
|
|
|
node_t * n = list_find(process_list, pw);
|
|
|
|
list_delete(process_list, n);
|
|
|
|
free(n);
|
|
|
|
free(pw);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Signals */
|
|
|
|
|
2012-03-02 07:13:52 +04:00
|
|
|
void * ignore(void * value) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-02-11 09:26:30 +04:00
|
|
|
|
|
|
|
void init_signal_handlers () {
|
2012-03-02 07:13:52 +04:00
|
|
|
#if 0
|
2012-02-13 04:47:01 +04:00
|
|
|
syscall_sys_signal(SIGWINEVENT, (uintptr_t)process_window_command); // SIGWINEVENT
|
2012-03-02 07:13:52 +04:00
|
|
|
#else
|
|
|
|
syscall_sys_signal(SIGWINEVENT, (uintptr_t)ignore); // SIGWINEVENT
|
|
|
|
#endif
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Sprite stuff */
|
|
|
|
|
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
sprite_t alpha_tmp;
|
|
|
|
|
|
|
|
void init_sprite(int i, char * filename, char * alpha) {
|
|
|
|
sprites[i] = malloc(sizeof(sprite_t));
|
|
|
|
load_sprite(sprites[i], filename);
|
|
|
|
if (alpha) {
|
|
|
|
sprites[i]->alpha = 1;
|
|
|
|
load_sprite(&alpha_tmp, alpha);
|
|
|
|
sprites[i]->masks = alpha_tmp.bitmap;
|
|
|
|
} else {
|
|
|
|
sprites[i]->alpha = 0;
|
|
|
|
}
|
|
|
|
sprites[i]->blank = 0x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int center_x(int x) {
|
|
|
|
return (graphics_width - x) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int center_y(int y) {
|
|
|
|
return (graphics_height - y) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int progress = 0;
|
|
|
|
static int progress_width = 0;
|
|
|
|
|
|
|
|
#define PROGRESS_WIDTH 120
|
|
|
|
#define PROGRESS_HEIGHT 6
|
|
|
|
#define PROGRESS_OFFSET 50
|
|
|
|
|
|
|
|
void draw_progress() {
|
|
|
|
int x = center_x(PROGRESS_WIDTH);
|
|
|
|
int y = center_y(0);
|
|
|
|
uint32_t color = rgb(0,120,230);
|
|
|
|
uint32_t fill = rgb(0,70,160);
|
|
|
|
draw_line(x, x + PROGRESS_WIDTH, y + PROGRESS_OFFSET, y + PROGRESS_OFFSET, color);
|
|
|
|
draw_line(x, x + PROGRESS_WIDTH, y + PROGRESS_OFFSET + PROGRESS_HEIGHT, y + PROGRESS_OFFSET + PROGRESS_HEIGHT, color);
|
|
|
|
draw_line(x, x, y + PROGRESS_OFFSET, y + PROGRESS_OFFSET + PROGRESS_HEIGHT, color);
|
|
|
|
draw_line(x + PROGRESS_WIDTH, x + PROGRESS_WIDTH, y + PROGRESS_OFFSET, y + PROGRESS_OFFSET + PROGRESS_HEIGHT, color);
|
|
|
|
|
|
|
|
if (progress_width > 0) {
|
|
|
|
int width = ((PROGRESS_WIDTH - 2) * progress) / progress_width;
|
|
|
|
for (int8_t i = 0; i < PROGRESS_HEIGHT - 1; ++i) {
|
|
|
|
draw_line(x + 1, x + 1 + width, y + PROGRESS_OFFSET + i + 1, y + PROGRESS_OFFSET + i + 1, fill);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-04 11:20:33 +04:00
|
|
|
uint32_t gradient_at(uint16_t j) {
|
|
|
|
float x = j * 80;
|
|
|
|
x = x / graphics_height;
|
|
|
|
return rgb(0, 1 * x, 2 * x);
|
|
|
|
}
|
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
void display() {
|
2012-02-04 11:20:33 +04:00
|
|
|
for (uint16_t j = 0; j < graphics_height; ++j) {
|
|
|
|
draw_line(0, graphics_width, j, j, gradient_at(j));
|
|
|
|
}
|
2012-02-04 07:15:26 +04:00
|
|
|
draw_sprite(sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height));
|
|
|
|
draw_progress();
|
|
|
|
flip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void (*func)();
|
|
|
|
char * name;
|
|
|
|
int time;
|
|
|
|
} startup_item;
|
|
|
|
|
|
|
|
list_t * startup_items;
|
|
|
|
|
|
|
|
void add_startup_item(char * name, void (*func)(), int time) {
|
|
|
|
progress_width += time;
|
|
|
|
startup_item * item = malloc(sizeof(startup_item));
|
|
|
|
|
|
|
|
item->name = name;
|
|
|
|
item->func = func;
|
|
|
|
item->time = time;
|
|
|
|
|
|
|
|
list_insert(startup_items, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test() {
|
|
|
|
/* Do Nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
void run_startup_item(startup_item * item) {
|
|
|
|
item->func();
|
|
|
|
progress += item->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_Library library;
|
|
|
|
FT_Face face;
|
|
|
|
FT_Face face_bold;
|
|
|
|
FT_Face face_italic;
|
|
|
|
FT_Face face_bold_italic;
|
|
|
|
FT_Face face_extra;
|
|
|
|
FT_GlyphSlot slot;
|
|
|
|
FT_UInt glyph_index;
|
|
|
|
|
2012-02-20 22:18:13 +04:00
|
|
|
char * loadMemFont(char * ident, char * name, size_t * size) {
|
2012-02-04 07:15:26 +04:00
|
|
|
FILE * f = fopen(name, "r");
|
|
|
|
size_t s = 0;
|
|
|
|
fseek(f, 0, SEEK_END);
|
|
|
|
s = ftell(f);
|
|
|
|
fseek(f, 0, SEEK_SET);
|
2012-02-16 13:34:42 +04:00
|
|
|
|
|
|
|
size_t shm_size = s;
|
|
|
|
char * font = (char *)syscall_shm_obtain(ident, &shm_size); //malloc(s);
|
|
|
|
assert((shm_size >= s) && "shm_obtain returned too little memory to load a font into!");
|
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
fread(font, s, 1, f);
|
2012-02-21 04:33:09 +04:00
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
fclose(f);
|
|
|
|
*size = s;
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _init_freetype() {
|
|
|
|
int error;
|
|
|
|
error = FT_Init_FreeType(&library);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FONT_SIZE 13
|
2012-02-26 08:47:20 +04:00
|
|
|
#define ACTUALLY_LOAD_FONTS 0
|
2012-02-04 07:15:26 +04:00
|
|
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
void _load_dejavu() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
2012-02-20 22:18:13 +04:00
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.sans-serif", "/usr/share/fonts/DejaVuSans.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-04 07:15:26 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face);
|
|
|
|
error = FT_Set_Pixel_Sizes(face, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-04 07:15:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejavubold() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
2012-02-20 22:18:13 +04:00
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.sans-serif.bold", "/usr/share/fonts/DejaVuSans-Bold.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-04 07:15:26 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_bold);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_bold, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-04 07:15:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejavuitalic() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
2012-02-20 22:18:13 +04:00
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.sans-serif.italic", "/usr/share/fonts/DejaVuSans-Oblique.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-04 07:15:26 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_italic);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_italic, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-04 07:15:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejavubolditalic() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
2012-02-20 22:18:13 +04:00
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.sans-serif.bolditalic", "/usr/share/fonts/DejaVuSans-BoldOblique.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-04 07:15:26 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_bold_italic);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_bold_italic, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-04 07:15:26 +04:00
|
|
|
}
|
|
|
|
|
2012-02-26 07:28:33 +04:00
|
|
|
void _load_dejamonovu() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.monospace", "/usr/share/fonts/DejaVuSansMono.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-26 07:28:33 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face);
|
|
|
|
error = FT_Set_Pixel_Sizes(face, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-26 07:28:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejamonovubold() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.monospace.bold", "/usr/share/fonts/DejaVuSansMono-Bold.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-26 07:28:33 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_bold);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_bold, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-26 07:28:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejamonovuitalic() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.monospace.italic", "/usr/share/fonts/DejaVuSansMono-Oblique.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-26 07:28:33 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_italic);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_italic, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-26 07:28:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _load_dejamonovubolditalic() {
|
|
|
|
char * font;
|
|
|
|
size_t s;
|
|
|
|
font = loadMemFont(WINS_SERVER_IDENTIFIER ".fonts.monospace.bolditalic", "/usr/share/fonts/DejaVuSansMono-BoldOblique.ttf", &s);
|
2012-02-26 08:47:20 +04:00
|
|
|
#if ACTUALLY_LOAD_FONTS
|
2012-02-26 07:28:33 +04:00
|
|
|
error = FT_New_Memory_Face(library, font, s, 0, &face_bold_italic);
|
|
|
|
error = FT_Set_Pixel_Sizes(face_bold_italic, FONT_SIZE, FONT_SIZE);
|
2012-02-26 08:47:20 +04:00
|
|
|
#endif
|
2012-02-26 07:28:33 +04:00
|
|
|
}
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
void init_base_windows () {
|
|
|
|
process_windows_t * pw = malloc(sizeof(process_windows_t));
|
|
|
|
pw->pid = getpid();
|
|
|
|
pw->command_pipe = syscall_mkpipe(); /* nothing in here */
|
|
|
|
pw->event_pipe = syscall_mkpipe(); /* nothing in here */
|
|
|
|
pw->windows = list_create();
|
2012-02-12 03:57:22 +04:00
|
|
|
list_insert(process_list, pw);
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-02-26 08:47:20 +04:00
|
|
|
#if 1
|
2012-02-11 09:26:30 +04:00
|
|
|
/* Create the background window */
|
2012-03-08 08:31:24 +04:00
|
|
|
#if 0
|
2012-02-12 04:54:34 +04:00
|
|
|
window_t * root = init_window(pw, _next_wid++, 0, 0, graphics_width, graphics_height, 0);
|
2012-02-11 09:26:30 +04:00
|
|
|
window_draw_sprite(root, sprites[1], 0, 0);
|
2012-02-13 05:34:19 +04:00
|
|
|
redraw_full_window(root);
|
2012-03-08 08:31:24 +04:00
|
|
|
#endif
|
2012-02-11 09:26:30 +04:00
|
|
|
|
2012-03-08 09:44:02 +04:00
|
|
|
#if 0
|
2012-02-11 09:26:30 +04:00
|
|
|
/* Create the panel */
|
2012-02-26 09:52:09 +04:00
|
|
|
window_t * panel = init_window(pw, _next_wid++, 0, 0, graphics_width, 24, 0xFFFF);
|
2012-02-11 09:26:30 +04:00
|
|
|
window_fill(panel, rgb(0,120,230));
|
|
|
|
init_sprite(2, "/usr/share/panel.bmp", NULL);
|
|
|
|
for (uint32_t i = 0; i < graphics_width; i += sprites[2]->width) {
|
|
|
|
window_draw_sprite(panel, sprites[2], i, 0);
|
|
|
|
}
|
|
|
|
redraw_full_window(panel);
|
2012-02-26 10:45:46 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
2012-03-08 09:44:02 +04:00
|
|
|
#endif
|
2012-02-20 07:29:40 +04:00
|
|
|
#endif
|
2012-02-16 06:50:31 +04:00
|
|
|
|
|
|
|
init_sprite(3, "/usr/share/arrow.bmp","/usr/share/arrow_alpha.bmp");
|
2012-02-11 09:26:30 +04:00
|
|
|
}
|
|
|
|
|
2012-02-17 00:31:40 +04:00
|
|
|
void * process_requests(void * garbage) {
|
|
|
|
int mfd = *((int *)garbage);
|
2012-02-17 00:38:50 +04:00
|
|
|
|
|
|
|
mouse_x = MOUSE_SCALE * graphics_width / 2;
|
|
|
|
mouse_y = MOUSE_SCALE * graphics_height / 2;
|
|
|
|
|
2012-02-26 09:52:09 +04:00
|
|
|
uint16_t _mouse_state = 0;
|
|
|
|
window_t * _mouse_window = NULL;
|
|
|
|
int32_t _mouse_init_x;
|
|
|
|
int32_t _mouse_init_y;
|
|
|
|
int32_t _mouse_win_x;
|
|
|
|
int32_t _mouse_win_y;
|
|
|
|
|
|
|
|
int32_t _mouse_win_x_p;
|
|
|
|
int32_t _mouse_win_y_p;
|
|
|
|
|
2012-02-17 00:31:40 +04:00
|
|
|
struct stat _stat;
|
2012-02-17 11:28:12 +04:00
|
|
|
char buf[1024];
|
2012-02-17 00:31:40 +04:00
|
|
|
while (1) {
|
2012-02-17 11:28:12 +04:00
|
|
|
fstat(mfd, &_stat);
|
|
|
|
while (_stat.st_size >= sizeof(mouse_device_packet_t)) {
|
|
|
|
mouse_device_packet_t * packet = (mouse_device_packet_t *)&buf;
|
|
|
|
int r = read(mfd, &buf, sizeof(mouse_device_packet_t));
|
2012-02-17 00:31:40 +04:00
|
|
|
#if 1
|
2012-02-17 11:28:12 +04:00
|
|
|
if (packet->magic != MOUSE_MAGIC) {
|
|
|
|
int r = read(mfd, buf, 1);
|
|
|
|
break;
|
|
|
|
}
|
2012-03-28 01:52:46 +04:00
|
|
|
//redraw_region_slow(mouse_x / MOUSE_SCALE - 32, mouse_y / MOUSE_SCALE - 32, 64, 64);
|
2012-02-17 11:28:12 +04:00
|
|
|
/* Apply mouse movement */
|
|
|
|
int c, l;
|
|
|
|
c = abs(packet->x_difference);
|
|
|
|
l = 0;
|
|
|
|
while (c >>= 1) {
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
mouse_x += packet->x_difference * l;
|
|
|
|
c = abs(packet->y_difference);
|
|
|
|
l = 0;
|
|
|
|
while (c >>= 1) {
|
|
|
|
l++;
|
|
|
|
}
|
|
|
|
mouse_y -= packet->y_difference * l;
|
|
|
|
if (mouse_x < 0) mouse_x = 0;
|
|
|
|
if (mouse_y < 0) mouse_y = 0;
|
|
|
|
if (mouse_x >= graphics_width * MOUSE_SCALE) mouse_x = (graphics_width) * MOUSE_SCALE;
|
|
|
|
if (mouse_y >= graphics_height * MOUSE_SCALE) mouse_y = (graphics_height) * MOUSE_SCALE;
|
2012-03-28 01:52:46 +04:00
|
|
|
//draw_sprite(sprites[3], mouse_x / MOUSE_SCALE - MOUSE_OFFSET_X, mouse_y / MOUSE_SCALE - MOUSE_OFFSET_Y);
|
2012-04-11 07:34:36 +04:00
|
|
|
if (_mouse_state == 0 && (packet->buttons & MOUSE_BUTTON_RIGHT)) {
|
2012-02-26 09:52:09 +04:00
|
|
|
_mouse_window = focused_window();
|
|
|
|
if (_mouse_window) {
|
|
|
|
if (_mouse_window->z == 0 || _mouse_window->z == 0xFFFF) {
|
2012-03-29 00:54:31 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
2012-02-26 09:52:09 +04:00
|
|
|
/* *sigh* */
|
|
|
|
} else {
|
|
|
|
_mouse_state = 1;
|
|
|
|
_mouse_init_x = mouse_x;
|
|
|
|
_mouse_init_y = mouse_y;
|
|
|
|
_mouse_win_x = _mouse_window->x;
|
|
|
|
_mouse_win_y = _mouse_window->y;
|
|
|
|
_mouse_win_x_p = _mouse_win_x;
|
|
|
|
_mouse_win_y_p = _mouse_win_y;
|
2012-03-28 03:19:35 +04:00
|
|
|
moving_window = _mouse_window;
|
|
|
|
moving_window_l = _mouse_win_x_p;
|
|
|
|
moving_window_t = _mouse_win_y_p;
|
2012-02-26 09:52:09 +04:00
|
|
|
make_top(_mouse_window);
|
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
|
|
|
}
|
|
|
|
}
|
2012-04-11 07:34:36 +04:00
|
|
|
} else if (_mouse_state == 0 && (packet->buttons & MOUSE_BUTTON_LEFT)) {
|
|
|
|
_mouse_window = focused_window();
|
|
|
|
if (_mouse_window) {
|
|
|
|
_mouse_state = 2; /* Dragging */
|
|
|
|
/* In window coordinates, that's... */
|
|
|
|
_mouse_win_x = _mouse_window->x;
|
|
|
|
_mouse_win_y = _mouse_window->y;
|
|
|
|
|
|
|
|
int32_t click_x = mouse_x / MOUSE_SCALE - _mouse_win_x;
|
|
|
|
int32_t click_y = mouse_y / MOUSE_SCALE - _mouse_win_y;
|
|
|
|
|
|
|
|
printf("Mouse down at @ %d,%d = %d,%d\n", mouse_x, mouse_y, click_x, click_y);
|
|
|
|
}
|
2012-03-10 22:39:13 +04:00
|
|
|
#if 0
|
2012-03-02 07:13:52 +04:00
|
|
|
_mouse_window = focused_window();
|
|
|
|
if (_mouse_window) {
|
|
|
|
if (_mouse_window->z == 0 || _mouse_window->z == 0xFFFF) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
_mouse_state = 2;
|
|
|
|
_mouse_init_x = mouse_x;
|
|
|
|
_mouse_init_y = mouse_y;
|
|
|
|
_mouse_win_x = _mouse_window->width;
|
|
|
|
_mouse_win_y = _mouse_window->height;
|
|
|
|
_mouse_win_x_p= _mouse_win_x;
|
|
|
|
_mouse_win_y_p= _mouse_win_y;
|
|
|
|
make_top(_mouse_window);
|
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
|
|
|
}
|
|
|
|
}
|
2012-03-10 22:39:13 +04:00
|
|
|
#endif
|
2012-02-26 09:52:09 +04:00
|
|
|
} else if (_mouse_state == 1) {
|
2012-04-11 07:34:36 +04:00
|
|
|
if (!(packet->buttons & MOUSE_BUTTON_RIGHT)) {
|
2012-02-26 09:52:09 +04:00
|
|
|
_mouse_window->x = _mouse_win_x + (mouse_x - _mouse_init_x) / MOUSE_SCALE;
|
|
|
|
_mouse_window->y = _mouse_win_y + (mouse_y - _mouse_init_y) / MOUSE_SCALE;
|
2012-03-28 03:19:35 +04:00
|
|
|
moving_window = NULL;
|
2012-02-26 09:52:09 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
|
|
|
_mouse_state = 0;
|
|
|
|
} else {
|
|
|
|
redraw_bounding_box(_mouse_window, _mouse_win_x_p, _mouse_win_y_p, 0);
|
|
|
|
_mouse_win_x_p = _mouse_win_x + (mouse_x - _mouse_init_x) / MOUSE_SCALE;
|
|
|
|
_mouse_win_y_p = _mouse_win_y + (mouse_y - _mouse_init_y) / MOUSE_SCALE;
|
2012-03-28 03:19:35 +04:00
|
|
|
moving_window = _mouse_window;
|
|
|
|
moving_window_l = _mouse_win_x_p;
|
|
|
|
moving_window_t = _mouse_win_y_p;
|
2012-02-26 09:52:09 +04:00
|
|
|
redraw_bounding_box(_mouse_window, _mouse_win_x_p, _mouse_win_y_p, 1);
|
|
|
|
}
|
2012-03-02 07:13:52 +04:00
|
|
|
} else if (_mouse_state == 2) {
|
2012-04-11 07:34:36 +04:00
|
|
|
if (!(packet->buttons & MOUSE_BUTTON_LEFT)) {
|
|
|
|
/* Released */
|
|
|
|
_mouse_state = 0;
|
|
|
|
_mouse_win_x = _mouse_window->x;
|
|
|
|
_mouse_win_y = _mouse_window->y;
|
|
|
|
|
|
|
|
int32_t click_x = mouse_x / MOUSE_SCALE - _mouse_win_x;
|
|
|
|
int32_t click_y = mouse_y / MOUSE_SCALE - _mouse_win_y;
|
|
|
|
|
|
|
|
printf("Mouse up at @ %d,%d = %d,%d\n", mouse_x, mouse_y, click_x, click_y);
|
|
|
|
#if 0 /* Resizing */
|
2012-03-02 07:13:52 +04:00
|
|
|
_mouse_win_x_p = _mouse_win_x + (mouse_x - _mouse_init_x) / MOUSE_SCALE;
|
|
|
|
_mouse_win_y_p = _mouse_win_y + (mouse_y - _mouse_init_y) / MOUSE_SCALE;
|
|
|
|
if (_mouse_win_x_p < 10) _mouse_win_x_p = 10;
|
|
|
|
if (_mouse_win_y_p < 10) _mouse_win_y_p = 10;
|
|
|
|
printf("resizing window to %d x %d\n", _mouse_win_x_p, _mouse_win_y_p);
|
|
|
|
resize_window_buffer(_mouse_window, _mouse_window->x, _mouse_window->y, _mouse_win_x_p, _mouse_win_y_p);
|
|
|
|
w_window_t tmp;
|
|
|
|
tmp.left = _mouse_window->x;
|
|
|
|
tmp.top = _mouse_window->y;
|
|
|
|
tmp.wid = _mouse_window->wid;
|
|
|
|
tmp.width = _mouse_win_x_p;
|
|
|
|
tmp.height = _mouse_win_y_p;
|
2012-03-24 02:44:37 +04:00
|
|
|
send_window_event(_mouse_window->owner, WE_RESIZED, &tmp);
|
2012-03-02 07:13:52 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
|
|
|
_mouse_state = 0;
|
2012-03-10 22:39:13 +04:00
|
|
|
#endif
|
2012-03-02 07:13:52 +04:00
|
|
|
} else {
|
2012-04-11 07:34:36 +04:00
|
|
|
/* Still down */
|
|
|
|
_mouse_win_x = _mouse_window->x;
|
|
|
|
_mouse_win_y = _mouse_window->y;
|
|
|
|
|
|
|
|
int32_t click_x = mouse_x / MOUSE_SCALE - _mouse_win_x;
|
|
|
|
int32_t click_y = mouse_y / MOUSE_SCALE - _mouse_win_y;
|
|
|
|
|
|
|
|
printf("Mouse move to @ %d,%d = %d,%d\n", mouse_x, mouse_y, click_x, click_y);
|
|
|
|
#if 0
|
2012-03-02 07:13:52 +04:00
|
|
|
redraw_bounding_box_r(_mouse_window, _mouse_win_x_p, _mouse_win_y_p, 0);
|
|
|
|
_mouse_win_x_p = _mouse_win_x + (mouse_x - _mouse_init_x) / MOUSE_SCALE;
|
|
|
|
_mouse_win_y_p = _mouse_win_y + (mouse_y - _mouse_init_y) / MOUSE_SCALE;
|
|
|
|
if (_mouse_win_x_p < 10) _mouse_win_x_p = 10;
|
|
|
|
if (_mouse_win_y_p < 10) _mouse_win_y_p = 10;
|
|
|
|
redraw_bounding_box_r(_mouse_window, _mouse_win_x_p, _mouse_win_y_p, 1);
|
2012-04-11 07:34:36 +04:00
|
|
|
#endif
|
2012-03-02 07:13:52 +04:00
|
|
|
}
|
|
|
|
|
2012-02-26 09:52:09 +04:00
|
|
|
}
|
2012-03-10 22:39:13 +04:00
|
|
|
#if 1
|
2012-03-02 07:13:52 +04:00
|
|
|
if (packet->buttons & MOUSE_BUTTON_MIDDLE) {
|
|
|
|
printf("middle click @%dx%d!\n", mouse_x / MOUSE_SCALE, mouse_y / MOUSE_SCALE);
|
2012-02-26 08:47:20 +04:00
|
|
|
window_t * focused = focused_window();
|
|
|
|
if (focused) {
|
2012-03-10 22:39:13 +04:00
|
|
|
if (focused->z != 0 && focused->z != 0xFFFF) {
|
|
|
|
free_window(focused);
|
|
|
|
}
|
2012-02-26 09:52:09 +04:00
|
|
|
redraw_region_slow(0,0,graphics_width,graphics_height);
|
2012-02-26 08:47:20 +04:00
|
|
|
}
|
2012-02-17 11:28:12 +04:00
|
|
|
}
|
2012-03-10 22:39:13 +04:00
|
|
|
#endif
|
2012-02-17 11:28:12 +04:00
|
|
|
#endif
|
|
|
|
fstat(mfd, &_stat);
|
|
|
|
}
|
|
|
|
fstat(0, &_stat);
|
|
|
|
if (_stat.st_size) {
|
|
|
|
int r = read(0, buf, 1);
|
|
|
|
if (r > 0) {
|
|
|
|
w_keyboard_t packet;
|
|
|
|
window_t * focused = focused_window();
|
|
|
|
if (focused) {
|
|
|
|
packet.wid = focused->wid;
|
|
|
|
packet.command = 0;
|
|
|
|
packet.key = (uint16_t)buf[0];
|
|
|
|
send_keyboard_event(focused->owner, WE_KEYDOWN, packet);
|
2012-02-17 00:31:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-27 22:58:21 +04:00
|
|
|
void * redraw_thread(void * derp) {
|
|
|
|
while (1) {
|
2012-03-28 04:09:11 +04:00
|
|
|
spin_lock(&am_drawing);
|
2012-03-27 22:58:21 +04:00
|
|
|
redraw_everything_fast();
|
2012-03-28 03:19:35 +04:00
|
|
|
/* Other stuff */
|
|
|
|
draw_bounding_box(moving_window, moving_window_l, moving_window_t);
|
2012-03-27 22:58:21 +04:00
|
|
|
redraw_cursor();
|
2012-03-28 04:09:11 +04:00
|
|
|
spin_unlock(&am_drawing);
|
2012-03-27 22:58:21 +04:00
|
|
|
flip();
|
|
|
|
syscall_yield();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
|
|
|
|
/* Initialize graphics setup */
|
|
|
|
init_graphics_double_buffer();
|
|
|
|
|
2012-03-27 22:58:21 +04:00
|
|
|
depth_map = malloc(sizeof(uint16_t) * graphics_width * graphics_height);
|
|
|
|
top_map = malloc(sizeof(uintptr_t) * graphics_width * graphics_height);
|
2012-02-26 10:45:46 +04:00
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
/* Initialize the client request system */
|
|
|
|
init_request_system();
|
|
|
|
|
|
|
|
/* Initialize process list */
|
|
|
|
init_process_list();
|
|
|
|
|
|
|
|
/* Initialize signal handlers */
|
|
|
|
init_signal_handlers();
|
|
|
|
|
2012-02-04 07:15:26 +04:00
|
|
|
/* Load sprites */
|
2012-02-04 11:20:33 +04:00
|
|
|
init_sprite(0, "/usr/share/bs.bmp", "/usr/share/bs-alpha.bmp");
|
2012-02-04 07:15:26 +04:00
|
|
|
display();
|
|
|
|
|
|
|
|
/* Count startup items */
|
|
|
|
startup_items = list_create();
|
|
|
|
add_startup_item("Initializing FreeType", _init_freetype, 1);
|
2012-02-20 22:18:13 +04:00
|
|
|
#if 1
|
2012-02-04 07:15:26 +04:00
|
|
|
add_startup_item("Loading font: Deja Vu Sans", _load_dejavu, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Bold", _load_dejavubold, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Oblique", _load_dejavuitalic, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Bold+Oblique", _load_dejavubolditalic, 2);
|
2012-02-26 07:28:33 +04:00
|
|
|
add_startup_item("Loading font: Deja Vu Sans Mono", _load_dejamonovu, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Mono Bold", _load_dejamonovubold, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Mono Oblique", _load_dejamonovuitalic, 2);
|
|
|
|
add_startup_item("Loading font: Deja Vu Sans Mono Bold+Oblique", _load_dejamonovubolditalic, 2);
|
2012-02-11 09:23:20 +04:00
|
|
|
#endif
|
2012-02-04 07:15:26 +04:00
|
|
|
|
|
|
|
foreach(node, startup_items) {
|
|
|
|
run_startup_item((startup_item *)node->value);
|
|
|
|
display();
|
|
|
|
}
|
|
|
|
|
2012-03-27 22:58:21 +04:00
|
|
|
#if 0
|
2012-02-04 07:15:26 +04:00
|
|
|
/* Reinitialize for single buffering */
|
2012-01-30 03:05:42 +04:00
|
|
|
init_graphics();
|
2012-02-04 07:15:26 +04:00
|
|
|
#endif
|
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
/* Create the root and panel */
|
|
|
|
init_base_windows();
|
2012-01-30 03:05:42 +04:00
|
|
|
|
2012-02-11 09:26:30 +04:00
|
|
|
process_windows_t * rootpw = get_process_windows(getpid());
|
2012-02-12 04:01:21 +04:00
|
|
|
if (!rootpw) {
|
2012-02-12 04:54:34 +04:00
|
|
|
printf("[compositor] SEVERE: No root process windows!\n");
|
|
|
|
return 1;
|
2012-02-12 04:01:21 +04:00
|
|
|
}
|
|
|
|
|
2012-02-17 00:31:40 +04:00
|
|
|
/* Grab the mouse */
|
|
|
|
int mfd = syscall_mousedevice();
|
|
|
|
pthread_t input_thread;
|
|
|
|
pthread_create(&input_thread, NULL, process_requests, (void *)&mfd);
|
|
|
|
|
2012-03-27 22:58:21 +04:00
|
|
|
pthread_t redraw_everything_thread;
|
|
|
|
pthread_create(&redraw_everything_thread, NULL, redraw_thread, NULL);
|
|
|
|
|
2012-02-17 00:31:40 +04:00
|
|
|
|
2012-02-20 07:29:40 +04:00
|
|
|
#if 0
|
2012-02-12 04:54:34 +04:00
|
|
|
if (!fork()) {
|
2012-02-17 01:09:56 +04:00
|
|
|
waitabit();
|
|
|
|
waitabit();
|
2012-02-13 08:24:02 +04:00
|
|
|
waitabit();
|
2012-02-13 02:45:23 +04:00
|
|
|
char * args[] = {"/bin/drawlines", "100","100","300","300",NULL};
|
2012-02-12 04:54:34 +04:00
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-02-13 08:24:02 +04:00
|
|
|
|
|
|
|
if (!fork()) {
|
2012-02-14 05:46:00 +04:00
|
|
|
waitabit();
|
|
|
|
char * args[] = {"/bin/julia-win", "200","200","400","400",NULL};
|
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fork()) {
|
2012-02-13 08:24:02 +04:00
|
|
|
waitabit();
|
|
|
|
waitabit();
|
2012-02-14 05:46:00 +04:00
|
|
|
char * args[] = {"/bin/julia-win", "20","20","500","300",NULL};
|
2012-02-13 08:24:02 +04:00
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-02-20 07:29:40 +04:00
|
|
|
#else
|
|
|
|
|
2012-03-08 08:31:24 +04:00
|
|
|
if (!fork()) {
|
2012-03-08 08:40:58 +04:00
|
|
|
char * args[] = {"/bin/wallpaper", NULL};
|
2012-03-08 08:31:24 +04:00
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-03-08 09:44:02 +04:00
|
|
|
if (!fork()) {
|
|
|
|
char * args[] = {"/bin/panel", NULL};
|
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-03-08 08:31:24 +04:00
|
|
|
|
2012-02-23 10:36:49 +04:00
|
|
|
#if 0
|
2012-02-20 07:29:40 +04:00
|
|
|
if (!fork()) {
|
|
|
|
char arg_width[10], arg_height[10];
|
|
|
|
sprintf(arg_width, "%d", graphics_width);
|
|
|
|
sprintf(arg_height, "%d", graphics_height);
|
|
|
|
char * args[] = {"/bin/glogin", arg_width, arg_height, NULL};
|
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-02-23 10:36:49 +04:00
|
|
|
#else
|
2012-03-15 00:04:12 +04:00
|
|
|
#if 0
|
2012-02-23 10:58:14 +04:00
|
|
|
if (!fork()) {
|
2012-03-08 08:31:24 +04:00
|
|
|
waitabit();
|
2012-02-23 10:58:14 +04:00
|
|
|
char * args[] = {"/bin/julia-win", "200","400","400","400",NULL};
|
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-03-15 00:04:12 +04:00
|
|
|
#endif
|
2012-02-23 10:58:14 +04:00
|
|
|
|
2012-02-23 10:36:49 +04:00
|
|
|
if (!fork()) {
|
2012-03-17 02:09:00 +04:00
|
|
|
char * args[] = {"/bin/terminal", NULL};
|
2012-02-23 11:30:56 +04:00
|
|
|
execve(args[0], args, NULL);
|
|
|
|
}
|
2012-02-23 10:36:49 +04:00
|
|
|
|
|
|
|
#endif
|
2012-02-20 07:29:40 +04:00
|
|
|
|
|
|
|
#endif
|
2012-02-14 02:21:52 +04:00
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
/* Sit in a run loop */
|
2012-02-08 12:45:47 +04:00
|
|
|
while (1) {
|
2012-02-12 04:54:34 +04:00
|
|
|
process_request();
|
2012-02-17 00:31:40 +04:00
|
|
|
process_window_command(0);
|
2012-03-11 04:20:34 +04:00
|
|
|
syscall_yield();
|
2012-01-30 03:05:42 +04:00
|
|
|
}
|
2012-02-04 07:15:26 +04:00
|
|
|
|
2012-02-12 04:54:34 +04:00
|
|
|
// XXX: Better have SIGINT/SIGSTOP handlers
|
2012-02-04 07:15:26 +04:00
|
|
|
return 0;
|
2012-01-30 03:05:42 +04:00
|
|
|
}
|