/uspace/trunk/fb/fb.c |
---|
82,6 → 82,20 |
int cursor_shown; |
} viewport_t; |
#define MAX_ANIM_LEN 8 |
#define MAX_ANIMATIONS 4 |
typedef struct { |
int initialized; |
int enabled; |
unsigned int vp; |
unsigned int pos; |
unsigned int animlen; |
unsigned int pixmaps[MAX_ANIM_LEN]; |
} animation_t; |
static animation_t animations[MAX_ANIMATIONS]; |
static int anims_enabled; |
/** Maximum number of saved pixmaps |
* Pixmap is a saved rectangle |
*/ |
320,7 → 334,7 |
{ |
int i; |
for (i=0; i < MAX_VIEWPORTS; i++) { |
for (i=0; i < MAX_VIEWPORTS; i++) { |
if (!viewports[i].initialized) |
break; |
} |
701,6 → 715,117 |
return 0; |
} |
/** Tick animation one step forward */ |
static void anims_tick(void) |
{ |
int i; |
static int counts = 0; |
/* Limit redrawing */ |
counts = (counts+1) % 8; |
if (counts) |
return; |
for (i=0; i < MAX_ANIMATIONS; i++) { |
if (!animations[i].animlen || !animations[i].initialized || !animations[i].enabled) |
continue; |
draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]); |
animations[i].pos = (animations[i].pos+1) % animations[i].animlen; |
} |
} |
static int anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
{ |
int handled = 1; |
int retval = 0; |
int i,nvp; |
int newval; |
switch (IPC_GET_METHOD(*call)) { |
case FB_ANIM_CREATE: |
nvp = IPC_GET_ARG1(*call); |
if (nvp == -1) |
nvp = vp; |
if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { |
retval = EINVAL; |
break; |
} |
for (i=0; i < MAX_ANIMATIONS; i++) { |
if (! animations[i].initialized) |
break; |
} |
if (i == MAX_ANIMATIONS) { |
retval = ELIMIT; |
break; |
} |
animations[i].initialized = 1; |
animations[i].animlen = 0; |
animations[i].pos = 0; |
animations[i].enabled = 0; |
animations[i].vp = nvp; |
retval = i; |
break; |
case FB_ANIM_DROP: |
i = IPC_GET_ARG1(*call); |
if (nvp >= MAX_ANIMATIONS || i < 0) { |
retval = EINVAL; |
break; |
} |
animations[i].initialized = 0; |
break; |
case FB_ANIM_ADDPIXMAP: |
i = IPC_GET_ARG1(*call); |
if (i >= MAX_ANIMATIONS || i < 0 || !animations[i].initialized) { |
retval = EINVAL; |
break; |
} |
if (animations[i].animlen == MAX_ANIM_LEN) { |
retval = ELIMIT; |
break; |
} |
newval = IPC_GET_ARG2(*call); |
if (newval < 0 || newval > MAX_PIXMAPS || !pixmaps[newval].data) { |
retval = EINVAL; |
break; |
} |
animations[i].pixmaps[animations[i].animlen++] = newval; |
break; |
case FB_ANIM_CHGVP: |
i = IPC_GET_ARG1(*call); |
if (i >= MAX_ANIMATIONS || i < 0) { |
retval = EINVAL; |
break; |
} |
nvp = IPC_GET_ARG2(*call); |
if (nvp == -1) |
nvp = vp; |
if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { |
retval = EINVAL; |
break; |
} |
animations[i].vp = nvp; |
break; |
case FB_ANIM_START: |
case FB_ANIM_STOP: |
i = IPC_GET_ARG1(*call); |
if (i >= MAX_ANIMATIONS || i < 0) { |
retval = EINVAL; |
break; |
} |
newval = (IPC_GET_METHOD(*call) == FB_ANIM_START); |
if (newval ^ animations[i].enabled) { |
animations[i].enabled = newval; |
anims_enabled += newval ? 1 : -1; |
} |
break; |
default: |
handled = 0; |
} |
if (handled) |
ipc_answer_fast(callid, retval, 0, 0); |
return handled; |
} |
/** Handler for messages concerning pixmap handling */ |
static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
{ |
773,7 → 898,7 |
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
while (1) { |
if (vport->cursor_shown) |
if (vport->cursor_active || anims_enabled) |
callid = async_get_call_timeout(&call,250000); |
else |
callid = async_get_call(&call); |
780,6 → 905,7 |
if (!callid) { |
cursor_blink(vp); |
anims_tick(); |
continue; |
} |
if (shm_handle(callid, &call, vp)) |
786,6 → 912,8 |
continue; |
if (pixmap_handle(callid, &call, vp)) |
continue; |
if (anim_handle(callid, &call, vp)) |
continue; |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
/uspace/trunk/console/gcons.c |
---|
70,6 → 70,7 |
/** List of pixmaps identifying these icons */ |
static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
static int animation = -1; |
static int active_console = 0; |
319,6 → 320,40 |
return pxid; |
} |
extern char _binary_anim_1_ppm_start[0]; |
extern int _binary_anim_1_ppm_size; |
extern char _binary_anim_2_ppm_start[0]; |
extern int _binary_anim_2_ppm_size; |
extern char _binary_anim_3_ppm_start[0]; |
extern int _binary_anim_3_ppm_size; |
extern char _binary_anim_4_ppm_start[0]; |
extern int _binary_anim_4_ppm_size; |
static void make_anim(void) |
{ |
int an; |
int pm; |
an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
if (an < 0) |
return; |
pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
async_msg(fbphone, FB_ANIM_START, an); |
animation = an; |
} |
extern char _binary_cons_selected_ppm_start[0]; |
extern int _binary_cons_selected_ppm_size; |
extern char _binary_cons_idle_ppm_start[0]; |
332,6 → 367,7 |
{ |
int rc; |
int i; |
int status_start = STATUS_START; |
fbphone = phone; |
351,8 → 387,9 |
return; |
/* Create status buttons */ |
status_start += (xres-800) / 2; |
for (i=0; i < CONSOLE_COUNT; i++) { |
cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
if (cstatus_vp[i] < 0) |
return; |
372,6 → 409,8 |
ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
(int)&_binary_cons_kernel_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
make_anim(); |
use_gcons = 1; |
console_state[0] = CONS_DISCONNECTED_SEL; |
/uspace/trunk/console/cons_kernel.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/uspace/trunk/console/anim_1.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/uspace/trunk/console/anim_2.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/uspace/trunk/console/anim_3.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/uspace/trunk/console/anim_4.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/uspace/trunk/console/Makefile |
---|
48,7 → 48,8 |
gcons.c |
IMAGES = helenos.ppm nameic.ppm cons_selected.ppm cons_idle.ppm \ |
cons_has_data.ppm cons_kernel.ppm |
cons_has_data.ppm cons_kernel.ppm anim_1.ppm anim_2.ppm anim_3.ppm \ |
anim_4.ppm |
ARCH_SOURCES = |
/uspace/trunk/libc/include/ipc/fb.h |
---|
31,4 → 31,11 |
#define FB_TRANS_PUTCHAR 1045 |
#define FB_ANIM_CREATE 1046 |
#define FB_ANIM_DROP 1047 |
#define FB_ANIM_ADDPIXMAP 1048 |
#define FB_ANIM_CHGVP 1049 |
#define FB_ANIM_START 1050 |
#define FB_ANIM_STOP 1051 |
#endif |