[userspace] Various. BOOT TO TERMINAL

This commit is contained in:
Kevin Lange 2012-03-23 17:44:37 -05:00
parent 103dccf604
commit 182de81a79
5 changed files with 53 additions and 41 deletions

View File

@ -355,7 +355,7 @@ void redraw_bounding_box_r(window_t *window, int32_t width, int32_t height, uint
wid_t volatile _next_wid = 0;
void send_window_event (process_windows_t * pw, uint8_t event, w_window_t packet) {
void send_window_event (process_windows_t * pw, uint8_t event, w_window_t * packet) {
/* Construct the header */
wins_packet_t header;
header.magic = WINS_MAGIC;
@ -365,7 +365,7 @@ void send_window_event (process_windows_t * pw, uint8_t event, w_window_t packet
/* 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_window_t));
write(pw->event_pipe, packet, sizeof(w_window_t));
syscall_send_signal(pw->pid, SIGWINEVENT); // SIGWINEVENT
syscall_yield();
}
@ -403,7 +403,9 @@ void process_window_command (int sig) {
#endif
w_window_t wwt;
wins_packet_t header;
printf("[compositor] read [%d] {\n", pw->pid);
int bytes_read = read(pw->command_pipe, &header, sizeof(wins_packet_t));
printf("[compositor] } read [%d] \n", pw->pid);
while (header.magic != WINS_MAGIC) {
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));
@ -420,26 +422,23 @@ void process_window_command (int sig) {
printf("[compositor] New window request\n");
read(pw->command_pipe, &wwt, sizeof(w_window_t));
wwt.wid = _next_wid;
init_window(pw, _next_wid++, wwt.left, wwt.top, wwt.width, wwt.height, _next_wid); //XXX: an actual index
send_window_event(pw, WE_NEWWINDOW, wwt);
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);
redraw_region_slow(0,0,graphics_width,graphics_height);
break;
case WC_RESIZE:
read(pw->command_pipe, &wwt, sizeof(w_window_t));
resize_window_buffer(get_window(wwt.wid), wwt.left, wwt.top, wwt.width, wwt.height);
send_window_event(pw, WE_RESIZED, wwt);
send_window_event(pw, WE_RESIZED, &wwt);
break;
case WC_DESTROY:
printf("[compositor] Destroying window!\n");
read(pw->command_pipe, &wwt, sizeof(w_window_t));
printf("Window to destroy is %d\n", wwt.wid);
window_t * win = get_window_with_process(pw, wwt.wid);
printf("Window = %p\n", win);
free_window(win);
printf("Redrawing...\n");
//send_window_event(pw, WE_DESTROYED, wwt);
send_window_event(pw, WE_DESTROYED, &wwt);
redraw_region_slow(0,0,graphics_width,graphics_height);
break;
@ -451,7 +450,7 @@ void process_window_command (int sig) {
case WC_REDRAW:
read(pw->command_pipe, &wwt, sizeof(w_window_t));
redraw_window(get_window_with_process(pw, wwt.wid), wwt.left, wwt.top, wwt.width, wwt.height);
send_window_event(pw, WE_REDRAWN, wwt);
send_window_event(pw, WE_REDRAWN, &wwt);
break;
case WC_REORDER:
@ -927,7 +926,7 @@ void * process_requests(void * garbage) {
tmp.wid = _mouse_window->wid;
tmp.width = _mouse_win_x_p;
tmp.height = _mouse_win_y_p;
send_window_event(_mouse_window->owner, WE_RESIZED, tmp);
send_window_event(_mouse_window->owner, WE_RESIZED, &tmp);
redraw_region_slow(0,0,graphics_width,graphics_height);
_mouse_state = 0;
#endif

View File

@ -13,6 +13,7 @@ DEFN_SYSCALL1(sethostname, 31, char *);
#define DEFAULT_HOSTNAME "toaru-test"
#define FORK_FOR_TERMINAL 1
#define TERMINAL 1
/* Set the hostname to whatever is in /etc/hostname */
void set_hostname() {
@ -36,13 +37,21 @@ void start_terminal() {
int pid = fork();
if (!pid) {
#endif
char * tokens[] = {
"/bin/compositor",
NULL
};
int i = execve(tokens[0], tokens, NULL);
exit(0);
#if TERMINAL == 1
char * tokens[] = {
"/bin/terminal",
"-F",
NULL
};
#else
char * tokens[] = {
"/bin/compositor",
NULL
};
#endif
int i = execve(tokens[0], tokens, NULL);
#if FORK_FOR_TERMINAL
exit(0);
} else {
syscall_wait(pid);
}

View File

@ -203,9 +203,10 @@ int main(int argc, char * argv[]) {
i+= 2;
} while ( i < width );
++j;
window_redraw_full(window);
} while ( j < height );
window_redraw_wait(window);
int playing = 1;
while (playing) {
char ch = 0;
@ -217,9 +218,6 @@ int main(int argc, char * argv[]) {
free(kbd);
}
} while (kbd != NULL);
if (ch) {
printf("Received a %d!\n", ch);
}
switch (ch) {
case 'q':
@ -234,6 +232,7 @@ int main(int argc, char * argv[]) {
printf("Closing down Julia Fractal Generate\n");
teardown_windowing();
printf("Exiting...\n");
return 0;
}

View File

@ -328,9 +328,7 @@ void window_redraw_wait (window_t * window) {
}
void window_destroy (window_t * window) {
printf("Sending window destroy command for window [%p] %d\n", window, window->wid);
wins_send_command(window->wid, 50, 50, 50, 50, WC_DESTROY, 0);
printf("Window destroyed.\n");
wins_send_command(window->wid, 0, 0, 0, 0, WC_DESTROY, 1);
free_window_client(window);
}
@ -536,7 +534,9 @@ int wins_connect() {
}
int wins_disconnect() {
#if 0
syscall_shm_release(WINS_SERVER_IDENTIFIER);
#endif
if (wins_globals) {
//free((wins_server_global_t *)wins_globals);
wins_globals = NULL;
@ -560,15 +560,22 @@ int setup_windowing () {
void teardown_windowing () {
if (process_windows) {
window_t * window;
while ((window = (window_t *)list_pop(process_windows->windows)) != NULL) {
node_t * node;
while ((node = list_pop(process_windows->windows)) != NULL) {
window = node->value;
if (!window) break;
printf("Have a window [%d, %dx%d]\n", window->wid, window->width, window->height);
window_destroy(window);
printf("Window destroy signal sent.\n");
}
printf("Freeing data...\n");
free(process_windows->windows);
printf("Freeing some more data...\n");
free(process_windows);
process_windows = NULL;
}
printf("Disconnecting...\n");
wins_disconnect();
}

View File

@ -791,10 +791,12 @@ uint32_t term_colors[256] = {
};
static void render_decors() {
if (terminal_title_length) {
render_decorations(window, window->buffer, terminal_title);
} else {
render_decorations(window, window->buffer, "Terminal");
if (_windowed) {
if (terminal_title_length) {
render_decorations(window, window->buffer, terminal_title);
} else {
render_decorations(window, window->buffer, "Terminal");
}
}
}
@ -804,21 +806,17 @@ term_set_point(
uint16_t y,
uint32_t color
) {
#if 0
if (graphics_depth == 32) {
#endif
if (_windowed) {
GFX((x+decor_left_width),(y+decor_top_height)) = color;
} else {
GFX(x,y) = color;
if (graphics_depth == 32) {
GFX(x,y) = color;
} else if (graphics_depth == 24) {
gfx_mem[((y) * graphics_width + x) * 3 + 2] = _RED(color);
gfx_mem[((y) * graphics_width + x) * 3 + 1] = _GRE(color);
gfx_mem[((y) * graphics_width + x) * 3 + 0] = _BLU(color);
}
}
#if 0
} else if (graphics_depth == 24) {
frame_mem[((y) * graphics_width + x) * 3 + 2] = _RED(color);
frame_mem[((y) * graphics_width + x) * 3 + 1] = _GRE(color);
frame_mem[((y) * graphics_width + x) * 3 + 0] = _BLU(color);
}
#endif
}
static inline void