Rev 1640 | Rev 1648 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1640 | Rev 1646 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | /* Auto-cursor position */ |
80 | /* Auto-cursor position */ |
81 | int cursor_active, cur_col, cur_row; |
81 | int cursor_active, cur_col, cur_row; |
82 | int cursor_shown; |
82 | int cursor_shown; |
83 | } viewport_t; |
83 | } viewport_t; |
84 | 84 | ||
- | 85 | #define MAX_ANIM_LEN 8 |
|
- | 86 | #define MAX_ANIMATIONS 4 |
|
- | 87 | typedef struct { |
|
- | 88 | int initialized; |
|
- | 89 | int enabled; |
|
- | 90 | unsigned int vp; |
|
- | 91 | ||
- | 92 | unsigned int pos; |
|
- | 93 | unsigned int animlen; |
|
- | 94 | unsigned int pixmaps[MAX_ANIM_LEN]; |
|
- | 95 | } animation_t; |
|
- | 96 | static animation_t animations[MAX_ANIMATIONS]; |
|
- | 97 | static int anims_enabled; |
|
- | 98 | ||
85 | /** Maximum number of saved pixmaps |
99 | /** Maximum number of saved pixmaps |
86 | * Pixmap is a saved rectangle |
100 | * Pixmap is a saved rectangle |
87 | */ |
101 | */ |
88 | #define MAX_PIXMAPS 256 |
102 | #define MAX_PIXMAPS 256 |
89 | typedef struct { |
103 | typedef struct { |
Line 318... | Line 332... | ||
318 | static int viewport_create(unsigned int x, unsigned int y,unsigned int width, |
332 | static int viewport_create(unsigned int x, unsigned int y,unsigned int width, |
319 | unsigned int height) |
333 | unsigned int height) |
320 | { |
334 | { |
321 | int i; |
335 | int i; |
322 | 336 | ||
323 | for (i=0; i < MAX_VIEWPORTS; i++) { |
337 | for (i=0; i < MAX_VIEWPORTS; i++) { |
324 | if (!viewports[i].initialized) |
338 | if (!viewports[i].initialized) |
325 | break; |
339 | break; |
326 | } |
340 | } |
327 | if (i == MAX_VIEWPORTS) |
341 | if (i == MAX_VIEWPORTS) |
328 | return ELIMIT; |
342 | return ELIMIT; |
Line 699... | Line 713... | ||
699 | memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize); |
713 | memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize); |
700 | } |
714 | } |
701 | return 0; |
715 | return 0; |
702 | } |
716 | } |
703 | 717 | ||
- | 718 | /** Tick animation one step forward */ |
|
- | 719 | static void anims_tick(void) |
|
- | 720 | { |
|
- | 721 | int i; |
|
- | 722 | static int counts = 0; |
|
- | 723 | ||
- | 724 | /* Limit redrawing */ |
|
- | 725 | counts = (counts+1) % 8; |
|
- | 726 | if (counts) |
|
- | 727 | return; |
|
- | 728 | ||
- | 729 | for (i=0; i < MAX_ANIMATIONS; i++) { |
|
- | 730 | if (!animations[i].animlen || !animations[i].initialized || !animations[i].enabled) |
|
- | 731 | continue; |
|
- | 732 | draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]); |
|
- | 733 | animations[i].pos = (animations[i].pos+1) % animations[i].animlen; |
|
- | 734 | } |
|
- | 735 | } |
|
- | 736 | ||
- | 737 | static int anim_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
|
- | 738 | { |
|
- | 739 | int handled = 1; |
|
- | 740 | int retval = 0; |
|
- | 741 | int i,nvp; |
|
- | 742 | int newval; |
|
- | 743 | ||
- | 744 | switch (IPC_GET_METHOD(*call)) { |
|
- | 745 | case FB_ANIM_CREATE: |
|
- | 746 | nvp = IPC_GET_ARG1(*call); |
|
- | 747 | if (nvp == -1) |
|
- | 748 | nvp = vp; |
|
- | 749 | if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { |
|
- | 750 | retval = EINVAL; |
|
- | 751 | break; |
|
- | 752 | } |
|
- | 753 | for (i=0; i < MAX_ANIMATIONS; i++) { |
|
- | 754 | if (! animations[i].initialized) |
|
- | 755 | break; |
|
- | 756 | } |
|
- | 757 | if (i == MAX_ANIMATIONS) { |
|
- | 758 | retval = ELIMIT; |
|
- | 759 | break; |
|
- | 760 | } |
|
- | 761 | animations[i].initialized = 1; |
|
- | 762 | animations[i].animlen = 0; |
|
- | 763 | animations[i].pos = 0; |
|
- | 764 | animations[i].enabled = 0; |
|
- | 765 | animations[i].vp = nvp; |
|
- | 766 | retval = i; |
|
- | 767 | break; |
|
- | 768 | case FB_ANIM_DROP: |
|
- | 769 | i = IPC_GET_ARG1(*call); |
|
- | 770 | if (nvp >= MAX_ANIMATIONS || i < 0) { |
|
- | 771 | retval = EINVAL; |
|
- | 772 | break; |
|
- | 773 | } |
|
- | 774 | animations[i].initialized = 0; |
|
- | 775 | break; |
|
- | 776 | case FB_ANIM_ADDPIXMAP: |
|
- | 777 | i = IPC_GET_ARG1(*call); |
|
- | 778 | if (i >= MAX_ANIMATIONS || i < 0 || !animations[i].initialized) { |
|
- | 779 | retval = EINVAL; |
|
- | 780 | break; |
|
- | 781 | } |
|
- | 782 | if (animations[i].animlen == MAX_ANIM_LEN) { |
|
- | 783 | retval = ELIMIT; |
|
- | 784 | break; |
|
- | 785 | } |
|
- | 786 | newval = IPC_GET_ARG2(*call); |
|
- | 787 | if (newval < 0 || newval > MAX_PIXMAPS || !pixmaps[newval].data) { |
|
- | 788 | retval = EINVAL; |
|
- | 789 | break; |
|
- | 790 | } |
|
- | 791 | animations[i].pixmaps[animations[i].animlen++] = newval; |
|
- | 792 | break; |
|
- | 793 | case FB_ANIM_CHGVP: |
|
- | 794 | i = IPC_GET_ARG1(*call); |
|
- | 795 | if (i >= MAX_ANIMATIONS || i < 0) { |
|
- | 796 | retval = EINVAL; |
|
- | 797 | break; |
|
- | 798 | } |
|
- | 799 | nvp = IPC_GET_ARG2(*call); |
|
- | 800 | if (nvp == -1) |
|
- | 801 | nvp = vp; |
|
- | 802 | if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) { |
|
- | 803 | retval = EINVAL; |
|
- | 804 | break; |
|
- | 805 | } |
|
- | 806 | animations[i].vp = nvp; |
|
- | 807 | break; |
|
- | 808 | case FB_ANIM_START: |
|
- | 809 | case FB_ANIM_STOP: |
|
- | 810 | i = IPC_GET_ARG1(*call); |
|
- | 811 | if (i >= MAX_ANIMATIONS || i < 0) { |
|
- | 812 | retval = EINVAL; |
|
- | 813 | break; |
|
- | 814 | } |
|
- | 815 | newval = (IPC_GET_METHOD(*call) == FB_ANIM_START); |
|
- | 816 | if (newval ^ animations[i].enabled) { |
|
- | 817 | animations[i].enabled = newval; |
|
- | 818 | anims_enabled += newval ? 1 : -1; |
|
- | 819 | } |
|
- | 820 | break; |
|
- | 821 | default: |
|
- | 822 | handled = 0; |
|
- | 823 | } |
|
- | 824 | if (handled) |
|
- | 825 | ipc_answer_fast(callid, retval, 0, 0); |
|
- | 826 | return handled; |
|
- | 827 | } |
|
- | 828 | ||
704 | /** Handler for messages concerning pixmap handling */ |
829 | /** Handler for messages concerning pixmap handling */ |
705 | static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
830 | static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
706 | { |
831 | { |
707 | int handled = 1; |
832 | int handled = 1; |
708 | int retval = 0; |
833 | int retval = 0; |
Line 771... | Line 896... | ||
771 | } |
896 | } |
772 | client_connected = 1; |
897 | client_connected = 1; |
773 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
898 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
774 | 899 | ||
775 | while (1) { |
900 | while (1) { |
776 | if (vport->cursor_shown) |
901 | if (vport->cursor_active || anims_enabled) |
777 | callid = async_get_call_timeout(&call,250000); |
902 | callid = async_get_call_timeout(&call,250000); |
778 | else |
903 | else |
779 | callid = async_get_call(&call); |
904 | callid = async_get_call(&call); |
780 | 905 | ||
781 | if (!callid) { |
906 | if (!callid) { |
782 | cursor_blink(vp); |
907 | cursor_blink(vp); |
- | 908 | anims_tick(); |
|
783 | continue; |
909 | continue; |
784 | } |
910 | } |
785 | if (shm_handle(callid, &call, vp)) |
911 | if (shm_handle(callid, &call, vp)) |
786 | continue; |
912 | continue; |
787 | if (pixmap_handle(callid, &call, vp)) |
913 | if (pixmap_handle(callid, &call, vp)) |
788 | continue; |
914 | continue; |
- | 915 | if (anim_handle(callid, &call, vp)) |
|
- | 916 | continue; |
|
789 | 917 | ||
790 | switch (IPC_GET_METHOD(call)) { |
918 | switch (IPC_GET_METHOD(call)) { |
791 | case IPC_M_PHONE_HUNGUP: |
919 | case IPC_M_PHONE_HUNGUP: |
792 | client_connected = 0; |
920 | client_connected = 0; |
793 | /* cleanup other viewports */ |
921 | /* cleanup other viewports */ |