Allow windows to disable alpha transparency.

Also add functionality to the terminal to toggle it on and off.
There's a small, but nice-to-have performance increase from disabling
alpha transparency in the terminal.

Also, the display server sets DISPLAY=... to the shmem endpoint for the
compositor, so if getenv("DISPLAY") returns a pointer, you can assume
you are in a graphical environment, instead of having to rely on things
like arguments. Good for those applications that want to be able to run
both full-screen and windowed.
This commit is contained in:
Kevin Lange 2012-10-11 23:55:53 -07:00
parent a60a78d157
commit 0387b2d2c3
5 changed files with 36 additions and 37 deletions

View File

@ -526,7 +526,7 @@ void process_window_command (int sig) {
{
read(pw->command_pipe, &wwt, sizeof(w_window_t));
window_t * window = get_window_with_process(pw, wwt.wid);
window->use_alpha = 1;
window->use_alpha = wwt.left;
}
break;
@ -899,27 +899,6 @@ void init_base_windows () {
pw->windows = list_create();
list_insert(process_list, pw);
#if 1
/* Create the background window */
#if 0
window_t * root = init_window(pw, _next_wid++, 0, 0, ctx->width, ctx->height, 0);
window_draw_sprite(root, sprites[1], 0, 0);
redraw_full_window(root);
#endif
#if 0
/* Create the panel */
window_t * panel = init_window(pw, _next_wid++, 0, 0, ctx->width, 24, 0xFFFF);
window_fill(panel, rgb(0,120,230));
init_sprite(2, "/usr/share/panel.bmp", NULL);
for (uint32_t i = 0; i < ctx->width; i += sprites[2]->width) {
window_draw_sprite(panel, sprites[2], i, 0);
}
redraw_full_window(panel);
redraw_region_slow(0,0,ctx->width,ctx->height);
#endif
#endif
init_sprite(3, "/usr/share/arrow.bmp","/usr/share/arrow_alpha.bmp");
}
@ -1211,7 +1190,6 @@ int main(int argc, char ** argv) {
/* Count startup items */
startup_items = list_create();
add_startup_item("Initializing FreeType", _init_freetype, 1);
#if 1
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);
@ -1220,26 +1198,14 @@ int main(int argc, char ** argv) {
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);
#endif
foreach(node, startup_items) {
run_startup_item((startup_item *)node->value);
display();
}
#if 0
/* Reinitialize for single buffering */
init_graphics();
#endif
/* Create the root and panel */
init_base_windows();
process_windows_t * rootpw = get_process_windows(getpid());
if (!rootpw) {
printf("[compositor] SEVERE: No root process windows!\n");
return 1;
}
/* load the mouse cursor */
init_sprite(3, "/usr/share/arrow.bmp","/usr/share/arrow_alpha.bmp");
/* Grab the mouse */
int mfd = syscall_mousedevice();
@ -1249,6 +1215,8 @@ int main(int argc, char ** argv) {
pthread_t redraw_everything_thread;
pthread_create(&redraw_everything_thread, NULL, redraw_thread, NULL);
setenv("DISPLAY", WINS_SERVER_IDENTIFIER, 1);
if (!fork()) {
char * args[] = {"/bin/glogin", NULL};
execvp(args[0], args);

View File

@ -269,6 +269,10 @@ void window_reorder (window_t * window, uint16_t new_zed) {
}
void window_enable_alpha (window_t * window) {
wins_send_command(window->wid, 1, 0, 0, 0, WC_SET_ALPHA, 0);
}
void window_disable_alpha (window_t * window) {
wins_send_command(window->wid, 0, 0, 0, 0, WC_SET_ALPHA, 0);
}

View File

@ -159,6 +159,7 @@ void window_redraw_wait (window_t * window);
void window_destroy (window_t * window);
void window_reorder (window_t * window, uint16_t new_zed);
void window_enable_alpha (window_t * window);
void window_disable_alpha (window_t * window);
w_keyboard_t * poll_keyboard();
w_mouse_t * poll_mouse();

16
userspace/setalpha.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv) {
if (argc > 1) {
int i = atoi(argv[1]);
if (i) {
printf("\033[2001z");
} else {
printf("\033[2000z");
}
fflush(stdout);
}
return 0;
return 0;
}

View File

@ -302,6 +302,16 @@ ansi_put(
case 1561:
_unbuffered = 0;
break;
case 2000:
if (_windowed) {
window_disable_alpha(window);
}
break;
case 2001:
if (_windowed) {
window_enable_alpha(window);
}
break;
default:
break;
}