comparison src/X_main.c @ 1044:5d4bc2a93c09

Merge from refine_backend_if branch
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 23 Nov 2010 11:58:04 +0800
parents 63f2f1daf5d3
children d09f603438d8
comparison
equal deleted inserted replaced
1035:18329b6f77a4 1044:5d4bc2a93c09
13 #include "mb_shapes.h" 13 #include "mb_shapes.h"
14 #include "mb_redraw_man.h" 14 #include "mb_redraw_man.h"
15 #include "mb_paint.h" 15 #include "mb_paint.h"
16 #include "mb_timer.h" 16 #include "mb_timer.h"
17 #include "mb_animate.h" 17 #include "mb_animate.h"
18 #include "mb_backend_utils.h"
18 19
19 #define OK 0 20 #define OK 0
20 #define ERR -1 21 #define ERR -1
21 22
22 Display *display; 23 Display *display;
67 } 68 }
68 rdman_redraw_changed(rdman); 69 rdman_redraw_changed(rdman);
69 XFlush(display); 70 XFlush(display);
70 } 71 }
71 72
72 void handle_connection(Display *display, mb_tman_t *tman, 73 void handle_connection(Display *display, mb_timer_man_t *timer_man,
73 redraw_man_t *rdman, int w, int h) { 74 redraw_man_t *rdman, int w, int h) {
74 int xcon; 75 int xcon;
75 fd_set rds; 76 fd_set rds;
76 int nfds; 77 int nfds;
77 struct timeval tmo; 78 struct timeval tmo;
78 mb_timeval_t mb_tmo, next_mb_tmo; 79 mb_timeval_t mb_tmo, next_mb_tmo;
80 mb_tman_t *tman;
79 int r; 81 int r;
82
83 tman = tman_timer_man_get_tman(timer_man);
80 84
81 XSelectInput(display, win, PointerMotionMask | ExposureMask); 85 XSelectInput(display, win, PointerMotionMask | ExposureMask);
82 XFlush(display); 86 XFlush(display);
83 87
84 xcon = XConnectionNumber(display); 88 xcon = XConnectionNumber(display);
134 paint_t *stroke, *text_stroke; 138 paint_t *stroke, *text_stroke;
135 shape_t *text; 139 shape_t *text;
136 grad_stop_t fill3_stops[3]; 140 grad_stop_t fill3_stops[3];
137 mbe_font_face_t *face; 141 mbe_font_face_t *face;
138 struct timeval tv; 142 struct timeval tv;
139 mb_tman_t *tman; 143 mb_timer_man_t *timer_man;
140 mb_timeval_t mbtv, start, playing; 144 mb_timeval_t mbtv, start, playing;
141 mb_progm_t *progm; 145 mb_progm_t *progm;
142 mb_word_t *word; 146 mb_word_t *word;
143 mb_action_t *act; 147 mb_action_t *act;
144 PangoAttrList *attrs = pango_attr_list_new(); 148 PangoAttrList *attrs = pango_attr_list_new();
205 209
206 rdman_redraw_all(&rdman); 210 rdman_redraw_all(&rdman);
207 211
208 XFlush(display); 212 XFlush(display);
209 213
210 tman = mb_tman_new(); 214 timer_man = mb_timer_man_new(&tman_timer_factory);
211 if(tman) { 215 if(timer_man) {
212 /* Prepare an animation program. */ 216 /* Prepare an animation program. */
213 progm = mb_progm_new(30, &rdman); 217 progm = mb_progm_new(30, &rdman);
214 218
215 MB_TIMEVAL_SET(&start, 0, 0); 219 MB_TIMEVAL_SET(&start, 0, 0);
216 MB_TIMEVAL_SET(&playing, 1, 0); 220 MB_TIMEVAL_SET(&playing, 1, 0);
398 act = mb_visibility_new(VIS_VISIBLE, coord3, word); 402 act = mb_visibility_new(VIS_VISIBLE, coord3, word);
399 403
400 /* Start playing the program. */ 404 /* Start playing the program. */
401 gettimeofday(&tv, NULL); 405 gettimeofday(&tv, NULL);
402 MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec); 406 MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec);
403 mb_progm_start(progm, tman, &mbtv); 407 mb_progm_start(progm, timer_man, &mbtv);
404 408
405 handle_connection(display, tman, &rdman, w, h); 409 handle_connection(display, timer_man, &rdman, w, h);
406 410
407 mb_progm_free(progm); 411 mb_progm_free(progm);
408 mb_tman_free(tman); 412 mb_timer_man_free(&tman_timer_factory, timer_man);
409 } 413 }
410 414
411 rdman_paint_free(&rdman, fill1); 415 rdman_paint_free(&rdman, fill1);
412 rdman_paint_free(&rdman, fill2); 416 rdman_paint_free(&rdman, fill2);
413 rdman_paint_free(&rdman, stroke); 417 rdman_paint_free(&rdman, stroke);