Mercurial > MadButterfly
comparison src/X_supp.c @ 1016:7b503c7ed46f refine_backend_if
Change naming convention from X_MB to X_supp or x_supp
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 22 Nov 2010 10:29:36 +0800 |
parents | c4a567112d29 |
children | 7ccc094bdbe5 |
comparison
equal
deleted
inserted
replaced
1015:c4a567112d29 | 1016:7b503c7ed46f |
---|---|
38 ob_factory_t *ob_factory; | 38 ob_factory_t *ob_factory; |
39 }; | 39 }; |
40 | 40 |
41 /* @} */ | 41 /* @} */ |
42 | 42 |
43 struct _X_MB_runtime { | 43 struct _X_supp_runtime { |
44 Display *display; | 44 Display *display; |
45 Window win; | 45 Window win; |
46 Visual *visual; | 46 Visual *visual; |
47 mbe_surface_t *surface, *backend_surface; | 47 mbe_surface_t *surface, *backend_surface; |
48 mbe_pattern_t *surface_ptn; | 48 mbe_pattern_t *surface_ptn; |
77 int mflag; | 77 int mflag; |
78 int mx, my; /* Position of last motion event */ | 78 int mx, my; /* Position of last motion event */ |
79 int mbut_state; /* Button state of last motion event */ | 79 int mbut_state; /* Button state of last motion event */ |
80 }; | 80 }; |
81 | 81 |
82 /*! \defgroup x_mb_timer Timer manager for X. | 82 /*! \defgroup x_supp_timer Timer manager for X. |
83 * | 83 * |
84 * This implmentation of timer manager is based on mb_tman_t. | 84 * This implmentation of timer manager is based on mb_tman_t. |
85 * @{ | 85 * @{ |
86 */ | 86 */ |
87 struct _X_supp_timer_man { | 87 struct _X_supp_timer_man { |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 /* @} */ | 173 /* @} */ |
174 | 174 |
175 static void handle_x_event(X_MB_runtime_t *rt); | 175 static void _x_supp_handle_x_event(X_supp_runtime_t *rt); |
176 | 176 |
177 /*! \defgroup x_mb_io IO manager for X. | 177 /*! \defgroup x_supp_io IO manager for X. |
178 * @{ | 178 * @{ |
179 */ | 179 */ |
180 #define MAX_MONITORS 200 | 180 #define MAX_MONITORS 200 |
181 | 181 |
182 typedef struct { | 182 typedef struct { |
259 * | 259 * |
260 * The display is managed by specified rdman and tman. rdman draws | 260 * The display is managed by specified rdman and tman. rdman draws |
261 * on the display, and tman trigger actions according timers. | 261 * on the display, and tman trigger actions according timers. |
262 */ | 262 */ |
263 static void | 263 static void |
264 _x_mb_event_loop(mb_rt_t *rt) { | 264 _x_supp_event_loop(mb_rt_t *rt) { |
265 struct _X_MB_runtime *xmb_rt = (struct _X_MB_runtime *)rt; | 265 struct _X_supp_runtime *xmb_rt = (struct _X_supp_runtime *)rt; |
266 struct _X_supp_IO_man *io_man = (struct _X_supp_IO_man *)xmb_rt->io_man; | 266 struct _X_supp_IO_man *io_man = (struct _X_supp_IO_man *)xmb_rt->io_man; |
267 struct _X_supp_timer_man *timer_man = | 267 struct _X_supp_timer_man *timer_man = |
268 (struct _X_supp_timer_man *)xmb_rt->timer_man; | 268 (struct _X_supp_timer_man *)xmb_rt->timer_man; |
269 mb_tman_t *tman = timer_man->tman; | 269 mb_tman_t *tman = timer_man->tman; |
270 int fd; | 270 int fd; |
272 struct timeval tv; | 272 struct timeval tv; |
273 fd_set rfds, wfds; | 273 fd_set rfds, wfds; |
274 int nfds = 0; | 274 int nfds = 0; |
275 int r, r1,i; | 275 int r, r1,i; |
276 | 276 |
277 handle_x_event(rt); | 277 _x_supp_handle_x_event(rt); |
278 | 278 |
279 while(1) { | 279 while(1) { |
280 FD_ZERO(&rfds); | 280 FD_ZERO(&rfds); |
281 FD_ZERO(&wfds); | 281 FD_ZERO(&wfds); |
282 for(i = 0; i < io_man->n_monitor; i++) { | 282 for(i = 0; i < io_man->n_monitor; i++) { |
333 | 333 |
334 /* @} */ | 334 /* @} */ |
335 | 335 |
336 #ifdef XSHM | 336 #ifdef XSHM |
337 static void | 337 static void |
338 XSHM_update(X_MB_runtime_t *xmb_rt) { | 338 XSHM_update(X_supp_runtime_t *xmb_rt) { |
339 GC gc; | 339 GC gc; |
340 | 340 |
341 gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display)); | 341 gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display)); |
342 if(xmb_rt->ximage) { /* support XSHM */ | 342 if(xmb_rt->ximage) { /* support XSHM */ |
343 XShmPutImage(xmb_rt->display, | 343 XShmPutImage(xmb_rt->display, |
398 static void X_kb_destroy(X_kb_info_t *kbinfo) { | 398 static void X_kb_destroy(X_kb_info_t *kbinfo) { |
399 subject_free(kbinfo->kbevents); | 399 subject_free(kbinfo->kbevents); |
400 XFree(kbinfo->syms); | 400 XFree(kbinfo->syms); |
401 } | 401 } |
402 | 402 |
403 /*! \brief Accept X keyboard events from handle_x_event() and dispatch it. | 403 /*! \brief Accept X keyboard events from _x_supp_handle_x_event() and |
404 * dispatch it. | |
404 */ | 405 */ |
405 static void X_kb_handle_event(X_kb_info_t *kbinfo, XKeyEvent *xkey) { | 406 static void X_kb_handle_event(X_kb_info_t *kbinfo, XKeyEvent *xkey) { |
406 unsigned int code; | 407 unsigned int code; |
407 int sym; | 408 int sym; |
408 X_kb_event_t event; | 409 X_kb_event_t event; |
476 } | 477 } |
477 | 478 |
478 /*! \brief Handle motion event. | 479 /*! \brief Handle motion event. |
479 */ | 480 */ |
480 static void | 481 static void |
481 handle_motion_event(X_MB_runtime_t *rt) { | 482 handle_motion_event(X_supp_runtime_t *rt) { |
482 redraw_man_t *rdman = rt->rdman; | 483 redraw_man_t *rdman = rt->rdman; |
483 int x, y; | 484 int x, y; |
484 int state; | 485 int state; |
485 shape_t *shape; | 486 shape_t *shape; |
486 coord_t *root; | 487 coord_t *root; |
526 } | 527 } |
527 | 528 |
528 /*! \brief Redraw exposed area. | 529 /*! \brief Redraw exposed area. |
529 */ | 530 */ |
530 static void | 531 static void |
531 handle_expose_event(X_MB_runtime_t *rt) { | 532 handle_expose_event(X_supp_runtime_t *rt) { |
532 redraw_man_t *rdman = rt->rdman; | 533 redraw_man_t *rdman = rt->rdman; |
533 int ex1, ey1, ex2, ey2; | 534 int ex1, ey1, ex2, ey2; |
534 | 535 |
535 ex1 = rt->ex1; | 536 ex1 = rt->ex1; |
536 ey1 = rt->ey1; | 537 ey1 = rt->ey1; |
545 /*! \brief Handle single X event and maintain internal states. | 546 /*! \brief Handle single X event and maintain internal states. |
546 * | 547 * |
547 * It keeps internal state in rt to improve performance. | 548 * It keeps internal state in rt to improve performance. |
548 */ | 549 */ |
549 static void | 550 static void |
550 handle_single_x_event(X_MB_runtime_t *rt, XEvent *evt) { | 551 handle_single_x_event(X_supp_runtime_t *rt, XEvent *evt) { |
551 redraw_man_t *rdman = rt->rdman; | 552 redraw_man_t *rdman = rt->rdman; |
552 XMotionEvent *mevt; | 553 XMotionEvent *mevt; |
553 XButtonEvent *bevt; | 554 XButtonEvent *bevt; |
554 XExposeEvent *eevt; | 555 XExposeEvent *eevt; |
555 XKeyEvent *xkey; | 556 XKeyEvent *xkey; |
639 * | 640 * |
640 * No more event means event queue is emplty. This function will | 641 * No more event means event queue is emplty. This function will |
641 * perform some actions according current internal state. | 642 * perform some actions according current internal state. |
642 */ | 643 */ |
643 static void | 644 static void |
644 no_more_event(X_MB_runtime_t *rt) { | 645 no_more_event(X_supp_runtime_t *rt) { |
645 if(rt->mflag) | 646 if(rt->mflag) |
646 handle_motion_event(rt); | 647 handle_motion_event(rt); |
647 if(rt->eflag) | 648 if(rt->eflag) |
648 handle_expose_event(rt); | 649 handle_expose_event(rt); |
649 } | 650 } |
650 | 651 |
651 /*! \brief Dispatch all X events in the queue. | 652 /*! \brief Dispatch all X events in the queue. |
652 */ | 653 */ |
653 static void handle_x_event(X_MB_runtime_t *rt) { | 654 static void _x_supp_handle_x_event(X_supp_runtime_t *rt) { |
654 Display *display = rt->display; | 655 Display *display = rt->display; |
655 XEvent evt; | 656 XEvent evt; |
656 int r; | 657 int r; |
657 | 658 |
658 /* XXX: For some unknown reason, it causes a segmentation fault to | 659 /* XXX: For some unknown reason, it causes a segmentation fault to |
673 #endif | 674 #endif |
674 XFlush(display); | 675 XFlush(display); |
675 } | 676 } |
676 | 677 |
677 static void | 678 static void |
678 _x_mb_handle_connection(int hdl, int fd, MB_IO_TYPE type, void *data) { | 679 _x_supp_handle_connection(int hdl, int fd, MB_IO_TYPE type, void *data) { |
679 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)data; | 680 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *)data; |
680 | 681 |
681 handle_x_event(xmb_rt); | 682 _x_supp_handle_x_event(xmb_rt); |
682 } | 683 } |
683 | 684 |
684 static int X_init_connection(const char *display_name, | 685 static int X_init_connection(const char *display_name, |
685 int w, int h, | 686 int w, int h, |
686 Display **displayp, | 687 Display **displayp, |
751 return OK; | 752 return OK; |
752 } | 753 } |
753 | 754 |
754 #ifdef XSHM | 755 #ifdef XSHM |
755 static void | 756 static void |
756 xshm_destroy(X_MB_runtime_t *xmb_rt) { | 757 xshm_destroy(X_supp_runtime_t *xmb_rt) { |
757 XShmSegmentInfo *shminfo; | 758 XShmSegmentInfo *shminfo; |
758 | 759 |
759 shminfo = &xmb_rt->shminfo; | 760 shminfo = &xmb_rt->shminfo; |
760 | 761 |
761 if(xmb_rt->shminfo.shmaddr) { | 762 if(xmb_rt->shminfo.shmaddr) { |
777 shminfo->shmid = 0; | 778 shminfo->shmid = 0; |
778 } | 779 } |
779 } | 780 } |
780 | 781 |
781 static void | 782 static void |
782 xshm_init(X_MB_runtime_t *xmb_rt) { | 783 xshm_init(X_supp_runtime_t *xmb_rt) { |
783 Display *display; | 784 Display *display; |
784 Visual *visual; | 785 Visual *visual; |
785 XImage *ximage; | 786 XImage *ximage; |
786 int screen; | 787 int screen; |
787 int depth; | 788 int depth; |
839 } | 840 } |
840 #endif /* XSHM */ | 841 #endif /* XSHM */ |
841 | 842 |
842 /*! \brief Initialize a MadButterfy runtime for Xlib. | 843 /*! \brief Initialize a MadButterfy runtime for Xlib. |
843 * | 844 * |
844 * This one is very like X_MB_init(), except it accepts a | 845 * This one is very like _x_supp_init(), except it accepts a |
845 * X_MB_runtime_t object initialized with a display connected to a X | 846 * X_supp_runtime_t object initialized with a display connected to a X |
846 * server and an opened window. | 847 * server and an opened window. |
847 * | 848 * |
848 * Following field of the X_MB_runtime_t object should be initialized. | 849 * Following field of the X_supp_runtime_t object should be initialized. |
849 * - w, h | 850 * - w, h |
850 * - win | 851 * - win |
851 * - display | 852 * - display |
852 * - visual | 853 * - visual |
853 */ | 854 */ |
854 static int | 855 static int |
855 X_MB_init_with_win_internal(X_MB_runtime_t *xmb_rt) { | 856 _x_supp_init_with_win_internal(X_supp_runtime_t *xmb_rt) { |
856 mb_img_ldr_t *img_ldr; | 857 mb_img_ldr_t *img_ldr; |
857 int w, h; | 858 int w, h; |
858 int disp_fd; | 859 int disp_fd; |
859 | 860 |
860 w = xmb_rt->w; | 861 w = xmb_rt->w; |
904 X_kb_init(&xmb_rt->kbinfo, xmb_rt->display, xmb_rt->rdman); | 905 X_kb_init(&xmb_rt->kbinfo, xmb_rt->display, xmb_rt->rdman); |
905 | 906 |
906 disp_fd = XConnectionNumber(xmb_rt->display); | 907 disp_fd = XConnectionNumber(xmb_rt->display); |
907 xmb_rt->io_hdl = xmb_rt->io_man->reg(xmb_rt->io_man, disp_fd, | 908 xmb_rt->io_hdl = xmb_rt->io_man->reg(xmb_rt->io_man, disp_fd, |
908 MB_IO_R, | 909 MB_IO_R, |
909 _x_mb_handle_connection, | 910 _x_supp_handle_connection, |
910 xmb_rt); | 911 xmb_rt); |
911 | 912 |
912 return OK; | 913 return OK; |
913 } | 914 } |
914 | 915 |
915 /*! \brief Initialize a MadButterfy runtime for Xlib. | 916 /*! \brief Initialize a MadButterfy runtime for Xlib. |
916 * | 917 * |
917 * It setups a runtime environment to run MadButterfly with Xlib. | 918 * It setups a runtime environment to run MadButterfly with Xlib. |
918 * Users should specify width and height of the opening window. | 919 * Users should specify width and height of the opening window. |
919 */ | 920 */ |
920 static int X_MB_init(X_MB_runtime_t *xmb_rt, const char *display_name, | 921 static int _x_supp_init(X_supp_runtime_t *xmb_rt, const char *display_name, |
921 int w, int h) { | 922 int w, int h) { |
922 int r; | 923 int r; |
923 | 924 |
924 memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); | 925 memset(xmb_rt, 0, sizeof(X_supp_runtime_t)); |
925 | 926 |
926 xmb_rt->w = w; | 927 xmb_rt->w = w; |
927 xmb_rt->h = h; | 928 xmb_rt->h = h; |
928 r = X_init_connection(display_name, w, h, &xmb_rt->display, | 929 r = X_init_connection(display_name, w, h, &xmb_rt->display, |
929 &xmb_rt->visual, &xmb_rt->win); | 930 &xmb_rt->visual, &xmb_rt->win); |
930 if(r != OK) | 931 if(r != OK) |
931 return ERR; | 932 return ERR; |
932 | 933 |
933 r = X_MB_init_with_win_internal(xmb_rt); | 934 r = _x_supp_init_with_win_internal(xmb_rt); |
934 | 935 |
935 return r; | 936 return r; |
936 } | 937 } |
937 | 938 |
938 /*! \brief Initialize a MadButterfly runtime for a window of X. | 939 /*! \brief Initialize a MadButterfly runtime for a window of X. |
939 * | 940 * |
940 * Runtimes initialized with this function should be destroyed with | 941 * Runtimes initialized with this function should be destroyed with |
941 * X_MB_destroy_keep_win(). | 942 * x_supp_destroy_keep_win(). |
942 */ | 943 */ |
943 static int | 944 static int |
944 X_MB_init_with_win(X_MB_runtime_t *xmb_rt, | 945 _x_supp_init_with_win(X_supp_runtime_t *xmb_rt, |
945 Display *display, Window win) { | 946 Display *display, Window win) { |
946 XWindowAttributes attrs; | 947 XWindowAttributes attrs; |
947 int r; | 948 int r; |
948 | 949 |
949 r = XGetWindowAttributes(display, win, &attrs); | 950 r = XGetWindowAttributes(display, win, &attrs); |
950 if(r == 0) | 951 if(r == 0) |
951 return ERR; | 952 return ERR; |
952 | 953 |
953 memset(xmb_rt, 0, sizeof(X_MB_runtime_t)); | 954 memset(xmb_rt, 0, sizeof(X_supp_runtime_t)); |
954 | 955 |
955 xmb_rt->display = display; | 956 xmb_rt->display = display; |
956 xmb_rt->win = win; | 957 xmb_rt->win = win; |
957 xmb_rt->visual = attrs.visual; | 958 xmb_rt->visual = attrs.visual; |
958 xmb_rt->w = attrs.width; | 959 xmb_rt->w = attrs.width; |
959 xmb_rt->h = attrs.height; | 960 xmb_rt->h = attrs.height; |
960 | 961 |
961 r = X_MB_init_with_win_internal(xmb_rt); | 962 r = _x_supp_init_with_win_internal(xmb_rt); |
962 | 963 |
963 return r; | 964 return r; |
964 } | 965 } |
965 | 966 |
966 static void X_MB_destroy(X_MB_runtime_t *xmb_rt) { | 967 static void x_supp_destroy(X_supp_runtime_t *xmb_rt) { |
967 if(xmb_rt->rdman) { | 968 if(xmb_rt->rdman) { |
968 redraw_man_destroy(xmb_rt->rdman); | 969 redraw_man_destroy(xmb_rt->rdman); |
969 free(xmb_rt->rdman); | 970 free(xmb_rt->rdman); |
970 } | 971 } |
971 | 972 |
997 | 998 |
998 X_kb_destroy(&xmb_rt->kbinfo); | 999 X_kb_destroy(&xmb_rt->kbinfo); |
999 } | 1000 } |
1000 | 1001 |
1001 /*! \brief Destroy a MadButterfly runtime initialized with | 1002 /*! \brief Destroy a MadButterfly runtime initialized with |
1002 * X_MB_init_with_win(). | 1003 * _x_supp_init_with_win(). |
1003 * | 1004 * |
1004 * Destroying a runtime with this function prevent the window and | 1005 * Destroying a runtime with this function prevent the window and |
1005 * display associated with the runtime being closed. | 1006 * display associated with the runtime being closed. |
1006 */ | 1007 */ |
1007 static void | 1008 static void |
1008 X_MB_destroy_keep_win(X_MB_runtime_t *xmb_rt) { | 1009 x_supp_destroy_keep_win(X_supp_runtime_t *xmb_rt) { |
1009 Display *display; | 1010 Display *display; |
1010 Window win; | 1011 Window win; |
1011 | 1012 |
1012 display = xmb_rt->display; | 1013 display = xmb_rt->display; |
1013 xmb_rt->display = NULL; | 1014 xmb_rt->display = NULL; |
1014 win = xmb_rt->win; | 1015 win = xmb_rt->win; |
1015 xmb_rt->win = 0; | 1016 xmb_rt->win = 0; |
1016 | 1017 |
1017 X_MB_destroy(xmb_rt); | 1018 x_supp_destroy(xmb_rt); |
1018 | 1019 |
1019 xmb_rt->display = display; | 1020 xmb_rt->display = display; |
1020 xmb_rt->win = win; | 1021 xmb_rt->win = win; |
1021 } | 1022 } |
1022 | 1023 |
1023 static mb_rt_t * | 1024 static mb_rt_t * |
1024 X_MB_new(const char *display_name, int w, int h) { | 1025 _x_supp_new(const char *display_name, int w, int h) { |
1025 X_MB_runtime_t *rt; | 1026 X_supp_runtime_t *rt; |
1026 int r; | 1027 int r; |
1027 | 1028 |
1028 rt = O_ALLOC(X_MB_runtime_t); | 1029 rt = O_ALLOC(X_supp_runtime_t); |
1029 if(rt == NULL) | 1030 if(rt == NULL) |
1030 return NULL; | 1031 return NULL; |
1031 | 1032 |
1032 r = X_MB_init(rt, display_name, w, h); | 1033 r = _x_supp_init(rt, display_name, w, h); |
1033 if(r != OK) { | 1034 if(r != OK) { |
1034 free(rt); | 1035 free(rt); |
1035 return NULL; | 1036 return NULL; |
1036 } | 1037 } |
1037 | 1038 |
1039 } | 1040 } |
1040 | 1041 |
1041 /*! \brief Create a new runtime for existed window for X. | 1042 /*! \brief Create a new runtime for existed window for X. |
1042 * | 1043 * |
1043 * The object returned by this function must be free with | 1044 * The object returned by this function must be free with |
1044 * X_MB_free_keep_win() to prevent the window from closed. | 1045 * _x_supp_free_keep_win() to prevent the window from closed. |
1045 */ | 1046 */ |
1046 static mb_rt_t * | 1047 static mb_rt_t * |
1047 X_MB_new_with_win(MB_DISPLAY display, MB_WINDOW win) { | 1048 _x_supp_new_with_win(MB_DISPLAY display, MB_WINDOW win) { |
1048 X_MB_runtime_t *rt; | 1049 X_supp_runtime_t *rt; |
1049 int r; | 1050 int r; |
1050 | 1051 |
1051 rt = O_ALLOC(X_MB_runtime_t); | 1052 rt = O_ALLOC(X_supp_runtime_t); |
1052 if(rt == NULL) | 1053 if(rt == NULL) |
1053 return NULL; | 1054 return NULL; |
1054 | 1055 |
1055 r = X_MB_init_with_win(rt, display, win); | 1056 r = _x_supp_init_with_win(rt, display, win); |
1056 if(r != OK) { | 1057 if(r != OK) { |
1057 free(rt); | 1058 free(rt); |
1058 return NULL; | 1059 return NULL; |
1059 } | 1060 } |
1060 | 1061 |
1061 return rt; | 1062 return rt; |
1062 } | 1063 } |
1063 | 1064 |
1064 static void | 1065 static void |
1065 X_MB_free(mb_rt_t *rt) { | 1066 _x_supp_free(mb_rt_t *rt) { |
1066 X_MB_destroy((X_MB_runtime_t *) rt); | 1067 x_supp_destroy((X_supp_runtime_t *) rt); |
1067 free(rt); | 1068 free(rt); |
1068 } | 1069 } |
1069 | 1070 |
1070 /*! \brief Free runtime created with X_MB_new_with_win(). | 1071 /*! \brief Free runtime created with _x_supp_new_with_win(). |
1071 */ | 1072 */ |
1072 static void | 1073 static void |
1073 X_MB_free_keep_win(mb_rt_t *rt) { | 1074 _x_supp_free_keep_win(mb_rt_t *rt) { |
1074 X_MB_destroy_keep_win((X_MB_runtime_t *) rt); | 1075 x_supp_destroy_keep_win((X_supp_runtime_t *) rt); |
1075 free(rt); | 1076 free(rt); |
1076 } | 1077 } |
1077 | 1078 |
1078 static subject_t * | 1079 static subject_t * |
1079 X_MB_kbevents(mb_rt_t *rt) { | 1080 _x_supp_kbevents(mb_rt_t *rt) { |
1080 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1081 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1081 return xmb_rt->kbinfo.kbevents; | 1082 return xmb_rt->kbinfo.kbevents; |
1082 } | 1083 } |
1083 | 1084 |
1084 static redraw_man_t * | 1085 static redraw_man_t * |
1085 X_MB_rdman(mb_rt_t *rt) { | 1086 _x_supp_rdman(mb_rt_t *rt) { |
1086 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1087 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1087 return xmb_rt->rdman; | 1088 return xmb_rt->rdman; |
1088 } | 1089 } |
1089 | 1090 |
1090 static mb_timer_man_t * | 1091 static mb_timer_man_t * |
1091 X_MB_timer_man(mb_rt_t *rt) { | 1092 _x_supp_timer_man(mb_rt_t *rt) { |
1092 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1093 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1093 return xmb_rt->timer_man; | 1094 return xmb_rt->timer_man; |
1094 } | 1095 } |
1095 | 1096 |
1096 static ob_factory_t * | 1097 static ob_factory_t * |
1097 X_MB_ob_factory(mb_rt_t *rt) { | 1098 _x_supp_ob_factory(mb_rt_t *rt) { |
1098 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1099 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1099 ob_factory_t *factory; | 1100 ob_factory_t *factory; |
1100 | 1101 |
1101 factory = rdman_get_ob_factory(xmb_rt->rdman); | 1102 factory = rdman_get_ob_factory(xmb_rt->rdman); |
1102 return factory; | 1103 return factory; |
1103 } | 1104 } |
1104 | 1105 |
1105 static mb_img_ldr_t * | 1106 static mb_img_ldr_t * |
1106 X_MB_img_ldr(mb_rt_t *rt) { | 1107 _x_supp_img_ldr(mb_rt_t *rt) { |
1107 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1108 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1108 mb_img_ldr_t *img_ldr; | 1109 mb_img_ldr_t *img_ldr; |
1109 | 1110 |
1110 img_ldr = xmb_rt->img_ldr; | 1111 img_ldr = xmb_rt->img_ldr; |
1111 | 1112 |
1112 return img_ldr; | 1113 return img_ldr; |
1113 } | 1114 } |
1114 | 1115 |
1115 static int | 1116 static int |
1116 X_MB_add_event(mb_rt_t *rt, int fd, MB_IO_TYPE type, | 1117 _x_supp_add_event(mb_rt_t *rt, int fd, MB_IO_TYPE type, |
1117 mb_IO_cb_t cb, void *data) | 1118 mb_IO_cb_t cb, void *data) |
1118 { | 1119 { |
1119 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1120 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1120 mb_IO_man_t *io_man = xmb_rt->io_man; | 1121 mb_IO_man_t *io_man = xmb_rt->io_man; |
1121 int hdl; | 1122 int hdl; |
1122 | 1123 |
1123 hdl = io_man->reg(io_man, fd, type, cb, data); | 1124 hdl = io_man->reg(io_man, fd, type, cb, data); |
1124 return hdl; | 1125 return hdl; |
1125 } | 1126 } |
1126 | 1127 |
1127 static void | 1128 static void |
1128 X_MB_remove_event(mb_rt_t *rt, int hdl) | 1129 _x_supp_remove_event(mb_rt_t *rt, int hdl) |
1129 { | 1130 { |
1130 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1131 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1131 mb_IO_man_t *io_man = xmb_rt->io_man; | 1132 mb_IO_man_t *io_man = xmb_rt->io_man; |
1132 | 1133 |
1133 io_man->unreg(io_man, hdl); | 1134 io_man->unreg(io_man, hdl); |
1134 } | 1135 } |
1135 | 1136 |
1136 static int | 1137 static int |
1137 _x_mb_flush(mb_rt_t *rt) { | 1138 _x_supp_flush(mb_rt_t *rt) { |
1138 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt; | 1139 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *) rt; |
1139 int r; | 1140 int r; |
1140 | 1141 |
1141 #ifdef XSHM | 1142 #ifdef XSHM |
1142 XSHM_update(xmb_rt); | 1143 XSHM_update(xmb_rt); |
1143 #endif | 1144 #endif |
1144 r = XFlush(xmb_rt->display); | 1145 r = XFlush(xmb_rt->display); |
1145 return r == 0? ERR: OK; | 1146 return r == 0? ERR: OK; |
1146 } | 1147 } |
1147 | 1148 |
1148 mb_backend_t backend = { X_MB_new, | 1149 mb_backend_t backend = { _x_supp_new, |
1149 X_MB_new_with_win, | 1150 _x_supp_new_with_win, |
1150 | 1151 |
1151 X_MB_free, | 1152 _x_supp_free, |
1152 X_MB_free_keep_win, | 1153 _x_supp_free_keep_win, |
1153 X_MB_add_event, | 1154 _x_supp_add_event, |
1154 X_MB_remove_event, | 1155 _x_supp_remove_event, |
1155 _x_mb_event_loop, | 1156 _x_supp_event_loop, |
1156 _x_mb_flush, | 1157 _x_supp_flush, |
1157 | 1158 |
1158 X_MB_kbevents, | 1159 _x_supp_kbevents, |
1159 X_MB_rdman, | 1160 _x_supp_rdman, |
1160 X_MB_timer_man, | 1161 _x_supp_timer_man, |
1161 X_MB_ob_factory, | 1162 _x_supp_ob_factory, |
1162 X_MB_img_ldr | 1163 _x_supp_img_ldr |
1163 }; | 1164 }; |
1164 | 1165 |
1165 #if 0 | 1166 #if 0 |
1166 /*! \defgroup x_supp_nodejs_sup Export functions for supporting nodejs plugin. | 1167 /*! \defgroup x_supp_nodejs_sup Export functions for supporting nodejs plugin. |
1167 * | 1168 * |
1168 * These functions are for internal using. | 1169 * These functions are for internal using. |
1169 * @{ | 1170 * @{ |
1170 */ | 1171 */ |
1171 /*! \brief Exported for nodejs plugin to call handle_x_event. | 1172 /*! \brief Exported for nodejs plugin to call _x_supp_handle_x_event. |
1172 */ | 1173 */ |
1173 void _X_MB_handle_x_event_for_nodejs(mb_rt_t *rt) { | 1174 void _x_supp_handle_x_event_for_nodejs(mb_rt_t *rt) { |
1174 handle_x_event((X_MB_runtime_t *)rt); | 1175 _x_supp_handle_x_event((X_supp_runtime_t *)rt); |
1175 } | 1176 } |
1176 | 1177 |
1177 /*! \brief Get X connect for nodejs plugin. | 1178 /*! \brief Get X connect for nodejs plugin. |
1178 */ | 1179 */ |
1179 int _X_MB_get_x_conn_for_nodejs(mb_rt_t *rt) { | 1180 int _x_supp_get_x_conn_for_nodejs(mb_rt_t *rt) { |
1180 return XConnectionNumber(((X_MB_runtime_t *)rt)->display); | 1181 return XConnectionNumber(((X_supp_runtime_t *)rt)->display); |
1181 } | 1182 } |
1182 | 1183 |
1183 /*! \brief Flush buffer for the X connection of a runtime object. | 1184 /*! \brief Flush buffer for the X connection of a runtime object. |
1184 */ | 1185 */ |
1185 int _X_MB_flush_x_conn_for_nodejs(mb_rt_t *rt) { | 1186 int _x_supp_flush_x_conn_for_nodejs(mb_rt_t *rt) { |
1186 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; | 1187 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *)rt; |
1187 #ifdef XSHM | 1188 #ifdef XSHM |
1188 XSHM_update(xmb_rt); | 1189 XSHM_update(xmb_rt); |
1189 #endif | 1190 #endif |
1190 return XFlush(xmb_rt->display); | 1191 return XFlush(xmb_rt->display); |
1191 } | 1192 } |
1192 | 1193 |
1193 /*! \brief Handle single X event. | 1194 /*! \brief Handle single X event. |
1194 */ | 1195 */ |
1195 void | 1196 void |
1196 _X_MB_handle_single_event(mb_rt_t *rt, void *evt) { | 1197 _x_supp_handle_single_event(mb_rt_t *rt, void *evt) { |
1197 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; | 1198 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *)rt; |
1198 | 1199 |
1199 handle_single_x_event(xmb_rt, (XEvent *)evt); | 1200 handle_single_x_event(xmb_rt, (XEvent *)evt); |
1200 } | 1201 } |
1201 | 1202 |
1202 /*! \brief Called at end of an iteration of X event loop. | 1203 /*! \brief Called at end of an iteration of X event loop. |
1203 */ | 1204 */ |
1204 void | 1205 void |
1205 _X_MB_no_more_event(mb_rt_t *rt) { | 1206 _x_supp_no_more_event(mb_rt_t *rt) { |
1206 X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; | 1207 X_supp_runtime_t *xmb_rt = (X_supp_runtime_t *)rt; |
1207 | 1208 |
1208 no_more_event(xmb_rt); | 1209 no_more_event(xmb_rt); |
1209 } | 1210 } |
1210 | 1211 |
1211 /* @} */ | 1212 /* @} */ |