Mercurial > MadButterfly
annotate src/X_main.c @ 1441:9bd8e814f730
Handle the utf-8 string correctly.
author | wycc |
---|---|
date | Mon, 11 Apr 2011 13:09:11 +0800 |
parents | d09f603438d8 |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <stdio.h> |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <unistd.h> |
39 | 5 #include <sys/time.h> |
6 #include <sys/select.h> | |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 #include <X11/Xlib.h> |
6
772511b8b9be
Cairo specify RGB values in range 0.0 ~ 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
5
diff
changeset
|
8 #include <X11/Xutil.h> |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
9 #include "mb_graph_engine.h" |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
186
diff
changeset
|
10 #include <pango/pangocairo.h> |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
12 #include <string.h> |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
13 #include "mb_shapes.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
14 #include "mb_redraw_man.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
15 #include "mb_paint.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
16 #include "mb_timer.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
17 #include "mb_animate.h" |
1021
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
18 #include "mb_backend_utils.h" |
39 | 19 |
20 #define OK 0 | |
21 #define ERR -1 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
22 |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
23 Display *display; |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
24 Window win; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
25 |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
26 void hint_shape(redraw_man_t *rdman, shape_t *shape) { |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
27 static shape_t *last_shape = NULL; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
28 if(last_shape != shape) { |
33
d82749f77108
Fix bug of demo and remove *_fill() and *_stroke().
Thinker K.F. Li <thinker@branda.to>
parents:
32
diff
changeset
|
29 if(last_shape != NULL && last_shape->stroke != NULL) { |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
30 last_shape->stroke_width -= 2; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
31 rdman_shape_changed(rdman, last_shape); |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
32 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
33 if(shape != NULL && shape->stroke != NULL) { |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
34 shape->stroke_width += 2; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
35 rdman_shape_changed(rdman, shape); |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
36 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
37 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
38 last_shape = shape; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
39 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
40 |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
41 void event_interaction(Display *display, |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
42 redraw_man_t *rdman, int w, int h) { |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
43 XEvent evt; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
44 XMotionEvent *mevt; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
45 int r; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
46 co_aix x, y; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
47 shape_t *shape = NULL; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
48 int in_stroke; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
49 |
39 | 50 while(XEventsQueued(display, QueuedAfterReading) > 0) { |
51 r = XNextEvent(display, &evt); | |
52 if(r == -1) | |
53 break; | |
54 | |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
55 switch(evt.type) { |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
56 case MotionNotify: |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
57 mevt = (XMotionEvent *)&evt; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
58 x = mevt->x; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
59 y = mevt->y; |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
60 shape = find_shape_at_pos(rdman, x, y, &in_stroke); |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
61 hint_shape(rdman, shape); |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
62 break; |
37 | 63 case Expose: |
77 | 64 rdman_redraw_area(rdman, evt.xexpose.x, evt.xexpose.y, |
65 evt.xexpose.width, evt.xexpose.height); | |
37 | 66 break; |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
67 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
68 } |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
69 rdman_redraw_changed(rdman); |
39 | 70 XFlush(display); |
71 } | |
72 | |
1024
63f2f1daf5d3
X_main.c works with new backend definition
Thinker K.F. Li <thinker@codemud.net>
parents:
1021
diff
changeset
|
73 void handle_connection(Display *display, mb_timer_man_t *timer_man, |
39 | 74 redraw_man_t *rdman, int w, int h) { |
75 int xcon; | |
76 fd_set rds; | |
77 int nfds; | |
78 struct timeval tmo; | |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
79 mb_timeval_t mb_tmo, next_mb_tmo; |
1024
63f2f1daf5d3
X_main.c works with new backend definition
Thinker K.F. Li <thinker@codemud.net>
parents:
1021
diff
changeset
|
80 mb_tman_t *tman; |
54 | 81 int r; |
39 | 82 |
1024
63f2f1daf5d3
X_main.c works with new backend definition
Thinker K.F. Li <thinker@codemud.net>
parents:
1021
diff
changeset
|
83 tman = tman_timer_man_get_tman(timer_man); |
63f2f1daf5d3
X_main.c works with new backend definition
Thinker K.F. Li <thinker@codemud.net>
parents:
1021
diff
changeset
|
84 |
39 | 85 XSelectInput(display, win, PointerMotionMask | ExposureMask); |
86 XFlush(display); | |
87 | |
88 xcon = XConnectionNumber(display); | |
89 nfds = xcon + 1; | |
49
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
90 |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
91 r = gettimeofday(&tmo, NULL); |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
92 if(r == -1) { |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
93 perror("gettimeofday"); |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
94 return; |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
95 } |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
96 MB_TIMEVAL_SET(&mb_tmo, tmo.tv_sec, tmo.tv_usec); |
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
97 |
39 | 98 while(1) { |
99 FD_ZERO(&rds); | |
100 FD_SET(xcon, &rds); | |
101 | |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
102 r = mb_tman_next_timeout(tman, &mb_tmo, &next_mb_tmo); |
39 | 103 if(r != OK) |
104 r = select(nfds, &rds, NULL, NULL, NULL); | |
41 | 105 else { |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
106 tmo.tv_sec = MB_TIMEVAL_SEC(&next_mb_tmo); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
107 tmo.tv_usec = MB_TIMEVAL_USEC(&next_mb_tmo); |
39 | 108 r = select(nfds, &rds, NULL, NULL, &tmo); |
41 | 109 } |
39 | 110 |
111 if(r == -1) { | |
112 perror("select"); | |
113 return; | |
114 } | |
49
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
115 |
54 | 116 if(r == 0) { |
117 MB_TIMEVAL_ADD(&mb_tmo, &next_mb_tmo); | |
49
6a3726fa7aad
Reduce times of invoking gettimeofday()
Thinker K.F. Li <thinker@branda.to>
parents:
48
diff
changeset
|
118 |
41 | 119 mb_tman_handle_timeout(tman, &mb_tmo); |
42 | 120 rdman_redraw_changed(rdman); |
39 | 121 XFlush(display); |
122 } else if(FD_ISSET(xcon, &rds)) { | |
123 event_interaction(display, rdman, w, h); | |
124 } | |
125 } | |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
126 } |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
127 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
128 void draw_path(mbe_t *cr, int w, int h) { |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
129 mbe_t *tmpcr; |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
130 mbe_surface_t *tmpsuf; |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
451
diff
changeset
|
131 mbe_pattern_t *tmpptn; |
12 | 132 redraw_man_t rdman; |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
133 shape_t *path1, *path2, *rect; |
27 | 134 coord_t *coord1, *coord2, *coord3; |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
135 paint_t *fill1, *fill2, *fill3; |
55 | 136 paint_t *text_fill; |
137 grad_stop_t text_stops[2]; | |
27 | 138 paint_t *stroke, *text_stroke; |
139 shape_t *text; | |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
140 grad_stop_t fill3_stops[3]; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
141 mbe_font_face_t *face; |
39 | 142 struct timeval tv; |
1021
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
143 mb_timer_man_t *timer_man; |
42 | 144 mb_timeval_t mbtv, start, playing; |
145 mb_progm_t *progm; | |
146 mb_word_t *word; | |
147 mb_action_t *act; | |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
186
diff
changeset
|
148 PangoAttrList *attrs = pango_attr_list_new(); |
12 | 149 |
450
a417fd980228
Replace cairo_format_t with mb_img_fmt_t.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
150 tmpsuf = mbe_image_surface_create(MB_IFMT_ARGB32, w, h); |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
451
diff
changeset
|
151 tmpptn = mbe_pattern_create_for_surface(tmpsuf); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
152 tmpcr = mbe_create(tmpsuf); |
27 | 153 |
471
e98ae1407ca2
Remove mbe_set_source_surface() from graphic engine.
Thinker K.F. Li <thinker@branda.to>
parents:
451
diff
changeset
|
154 mbe_set_source(cr, tmpptn); |
24
e598bc809c0f
No more flash when animation.
Thinker K.F. Li <thinker@branda.to>
parents:
23
diff
changeset
|
155 redraw_man_init(&rdman, tmpcr, cr); |
19 | 156 coord1 = rdman_coord_new(&rdman, rdman.root_coord); |
157 coord2 = rdman_coord_new(&rdman, rdman.root_coord); | |
27 | 158 coord3 = rdman_coord_new(&rdman, rdman.root_coord); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
159 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
160 fill1 = rdman_paint_color_new(&rdman, 1, 1, 0, 0.5); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
161 fill2 = rdman_paint_color_new(&rdman, 0, 1, 1, 0.5); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
162 stroke = rdman_paint_color_new(&rdman, 0.4, 0.4, 0.4, 1); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
163 text_stroke = rdman_paint_color_new(&rdman, 0.5, 0.5, 0.5, 1); |
27 | 164 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
165 face = mbe_get_font_face(tmpcr); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
166 text = rdman_shape_text_new(&rdman, "hello \xe6\xbc\xa2\xe5\xad\x97", |
278
a90fd749af82
Implement the whole tspan attribute. Currently, we can accept font family/font style/font weight and font size.
wycc
parents:
186
diff
changeset
|
167 10, h / 4, 36.0, face, attrs); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
168 text_fill = rdman_paint_radial_new(&rdman, 100, h / 4, 70); |
55 | 169 grad_stop_init(text_stops, 0, 0.2, 0.9, 0.2, 1); |
170 grad_stop_init(text_stops + 1, 1, 0.9, 0.2, 0.2, 0.1); | |
56
e444a8c01735
Change interface of paint_radial_new()
Thinker K.F. Li <thinker@branda.to>
parents:
55
diff
changeset
|
171 paint_radial_stops(text_fill, 2, text_stops); |
27 | 172 rdman_paint_stroke(&rdman, text_stroke, text); |
173 text->stroke_width = 0.5; | |
55 | 174 rdman_paint_fill(&rdman, text_fill, text); |
27 | 175 rdman_add_shape(&rdman, text, coord3); |
176 | |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
177 path1 = rdman_shape_path_new(&rdman, "M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z "); |
19 | 178 rdman_paint_fill(&rdman, fill1, path1); |
22 | 179 rdman_paint_stroke(&rdman, stroke, path1); |
19 | 180 coord1->matrix[0] = 0.8; |
181 coord1->matrix[1] = 0; | |
182 coord1->matrix[2] = 20; | |
183 coord1->matrix[4] = 0.8; | |
184 coord1->matrix[5] = 20; | |
27 | 185 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
186 path2 = rdman_shape_path_new(&rdman, "M 22,89.36218 C -34,-0.63782 39,-9.637817 82,12.36218 C 125,34.36218 142,136.36218 142,136.36218 C 100.66667,125.36218 74.26756,123.42795 22,89.36218 z "); |
19 | 187 rdman_paint_fill(&rdman, fill2, path2); |
22 | 188 rdman_paint_stroke(&rdman, stroke, path2); |
19 | 189 coord2->matrix[0] = -0.8; |
190 coord2->matrix[1] = 0; | |
20
74d3d5dc9aaa
rename XXX_draw() to XXX_fill()
Thinker K.F. Li <thinker@branda.to>
parents:
19
diff
changeset
|
191 coord2->matrix[2] = 180; |
19 | 192 coord2->matrix[4] = 0.8; |
193 coord2->matrix[5] = 20; | |
27 | 194 |
19 | 195 rdman_coord_changed(&rdman, coord1); |
196 rdman_coord_changed(&rdman, coord2); | |
197 rdman_add_shape(&rdman, (shape_t *)path1, coord1); | |
198 rdman_add_shape(&rdman, (shape_t *)path2, coord2); | |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
13
diff
changeset
|
199 |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
200 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
201 fill3 = rdman_paint_linear_new(&rdman, 50, 50, 150, 150); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
202 grad_stop_init(fill3_stops, 0, 1, 0, 0, 0.5); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
203 grad_stop_init(fill3_stops + 1, 0.5, 0, 1, 0, 0.5); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
204 grad_stop_init(fill3_stops + 2, 1, 0, 0, 1, 0.5); |
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
205 paint_linear_stops(fill3, 3, fill3_stops); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
206 rect = rdman_shape_rect_new(&rdman, 50, 50, 100, 100, 20, 20); |
35
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
207 rdman_paint_fill(&rdman, fill3, rect); |
581a03196093
Support rectangle tag of SVG.
Thinker K.F. Li <thinker@branda.to>
parents:
33
diff
changeset
|
208 rdman_add_shape(&rdman, (shape_t *)rect, rdman.root_coord); |
23
56f592f56ff7
Fix bug and add linear gradient paint.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
209 |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
13
diff
changeset
|
210 rdman_redraw_all(&rdman); |
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
13
diff
changeset
|
211 |
16
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
212 XFlush(display); |
e17e12b112c4
A simple animation using rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
213 |
1021
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
214 timer_man = mb_timer_man_new(&tman_timer_factory); |
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
215 if(timer_man) { |
58 | 216 /* Prepare an animation program. */ |
863
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
217 progm = mb_progm_new(30, &rdman); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
218 |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
219 MB_TIMEVAL_SET(&start, 0, 0); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
220 MB_TIMEVAL_SET(&playing, 1, 0); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
221 word = mb_progm_next_word(progm, &start, &playing); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
222 |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
223 act = mb_shift_new(50, 50, coord1, word); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
224 act = mb_shift_new(-50, 50, coord2, word); |
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
225 |
42 | 226 MB_TIMEVAL_SET(&start, 1, 0); |
227 MB_TIMEVAL_SET(&playing, 2, 0); | |
228 word = mb_progm_next_word(progm, &start, &playing); | |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
229 |
47
f3818d996f4f
change interface of creating a animation action
Thinker K.F. Li <thinker@branda.to>
parents:
44
diff
changeset
|
230 act = mb_shift_new(0, 20, coord1, word); |
48
bdf711cbf0fb
Use absolute time to dispatch animation actions.
Thinker K.F. Li <thinker@branda.to>
parents:
47
diff
changeset
|
231 act = mb_shift_new(0, -20, coord2, word); |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
56
diff
changeset
|
232 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
233 |
44
7d9af44f095b
Demo of concurrent words
Thinker K.F. Li <thinker@branda.to>
parents:
42
diff
changeset
|
234 MB_TIMEVAL_SET(&start, 3, 0); |
7d9af44f095b
Demo of concurrent words
Thinker K.F. Li <thinker@branda.to>
parents:
42
diff
changeset
|
235 MB_TIMEVAL_SET(&playing, 2, 0); |
42 | 236 word = mb_progm_next_word(progm, &start, &playing); |
53
ffed18510d55
Use animate feacilities to demo all animation.
Thinker K.F. Li <thinker@branda.to>
parents:
52
diff
changeset
|
237 |
47
f3818d996f4f
change interface of creating a animation action
Thinker K.F. Li <thinker@branda.to>
parents:
44
diff
changeset
|
238 act = mb_shift_new(0, -20, coord1, word); |
48
bdf711cbf0fb
Use absolute time to dispatch animation actions.
Thinker K.F. Li <thinker@branda.to>
parents:
47
diff
changeset
|
239 act = mb_shift_new(0, 20, coord2, word); |
52
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
49
diff
changeset
|
240 act = mb_chgcolor_new(0, 0, 1, 0.5, fill1, word); |
59a295651480
Add action mb_chgcolor_t to change color of paints.
Thinker K.F. Li <thinker@branda.to>
parents:
49
diff
changeset
|
241 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
56
diff
changeset
|
242 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
471
diff
changeset
|
243 |
863
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
244 MB_TIMEVAL_SET(&start, 5, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
245 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
246 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
247 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
248 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
249 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
250 act = mb_chgcolor_new(1, 0, 0, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
251 act = mb_chgcolor_new(0, 0, 1, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
252 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
253 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
254 MB_TIMEVAL_SET(&start, 7, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
255 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
256 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
257 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
258 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
259 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
260 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
261 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
262 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
263 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
264 MB_TIMEVAL_SET(&start, 9, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
265 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
266 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
267 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
268 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
269 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
270 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
271 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
272 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
273 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
274 MB_TIMEVAL_SET(&start, 11, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
275 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
276 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
277 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
278 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
279 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
280 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
281 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
282 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
283 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
284 MB_TIMEVAL_SET(&start, 13, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
285 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
286 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
287 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
288 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
289 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
290 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
291 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
292 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
293 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
294 MB_TIMEVAL_SET(&start, 15, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
295 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
296 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
297 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
298 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
299 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
300 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
301 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
302 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
303 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
304 MB_TIMEVAL_SET(&start, 17, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
305 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
306 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
307 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
308 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
309 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
310 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
311 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
312 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
313 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
314 MB_TIMEVAL_SET(&start, 19, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
315 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
316 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
317 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
318 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
319 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
320 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
321 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
322 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
323 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
324 MB_TIMEVAL_SET(&start, 21, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
325 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
326 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
327 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
328 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
329 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
330 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
331 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
332 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
333 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
334 MB_TIMEVAL_SET(&start, 23, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
335 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
336 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
337 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
338 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
339 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
340 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
341 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
342 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
343 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
344 MB_TIMEVAL_SET(&start, 25, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
345 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
346 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
347 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
348 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
349 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
350 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
351 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
352 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
353 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
354 MB_TIMEVAL_SET(&start, 27, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
355 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
356 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
357 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
358 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
359 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
360 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
361 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
362 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
363 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
364 MB_TIMEVAL_SET(&start, 29, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
365 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
366 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
367 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
368 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
369 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
370 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
371 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
372 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
373 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
374 MB_TIMEVAL_SET(&start, 31, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
375 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
376 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
377 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
378 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
379 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
380 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
381 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
382 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
383 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
384 MB_TIMEVAL_SET(&start, 33, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
385 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
386 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
387 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
388 act = mb_shift_new(0, 20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
389 act = mb_shift_new(0, -20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
390 act = mb_chgcolor_new(0, 0, 1, 1, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
391 act = mb_chgcolor_new(1, 0, 0, 1, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
392 act = mb_visibility_new(VIS_HIDDEN, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
393 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
394 MB_TIMEVAL_SET(&start, 35, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
395 MB_TIMEVAL_SET(&playing, 2, 0); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
396 word = mb_progm_next_word(progm, &start, &playing); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
397 |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
398 act = mb_shift_new(0, -20, coord1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
399 act = mb_shift_new(0, 20, coord2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
400 act = mb_chgcolor_new(0, 1, 0, 0.5, fill1, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
401 act = mb_chgcolor_new(1, 0, 0, 0.5, fill2, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
402 act = mb_visibility_new(VIS_VISIBLE, coord3, word); |
e6c107b2e271
Do more works in X_main.c for profiling
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
403 |
58 | 404 /* Start playing the program. */ |
42 | 405 gettimeofday(&tv, NULL); |
406 MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec); | |
1021
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
407 mb_progm_start(progm, timer_man, &mbtv); |
42 | 408 |
1024
63f2f1daf5d3
X_main.c works with new backend definition
Thinker K.F. Li <thinker@codemud.net>
parents:
1021
diff
changeset
|
409 handle_connection(display, timer_man, &rdman, w, h); |
41 | 410 |
57
ab028c9f0930
Ability to hidden shapes and action of visibility.
Thinker K.F. Li <thinker@branda.to>
parents:
56
diff
changeset
|
411 mb_progm_free(progm); |
1021
4f4abce1b5df
Move X_main.c to mb_timer_man_t
Thinker K.F. Li <thinker@codemud.net>
parents:
863
diff
changeset
|
412 mb_timer_man_free(&tman_timer_factory, timer_man); |
39 | 413 } |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
27
diff
changeset
|
414 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
415 rdman_paint_free(&rdman, fill1); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
416 rdman_paint_free(&rdman, fill2); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
417 rdman_paint_free(&rdman, stroke); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
418 rdman_paint_free(&rdman, text_stroke); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
419 rdman_paint_free(&rdman, text_fill); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
420 rdman_shape_free(&rdman, path1); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
421 rdman_shape_free(&rdman, path2); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
422 rdman_shape_free(&rdman, rect); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
77
diff
changeset
|
423 rdman_shape_free(&rdman, text); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
13
diff
changeset
|
424 redraw_man_destroy(&rdman); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
425 mbe_destroy(tmpcr); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
426 mbe_surface_destroy(tmpsuf); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
427 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
428 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
429 void drawing(mbe_surface_t *surface, int w, int h) { |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
430 mbe_t *cr; |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
431 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
432 cr = mbe_create(surface); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
433 mbe_set_source_rgb(cr, 0, 0, 0); |
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
434 mbe_paint(cr); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
3
diff
changeset
|
435 draw_path(cr, w, h); |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
436 mbe_destroy(cr); |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
437 } |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
438 |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
439 int |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
440 main(int argc, char * const argv[]) { |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
441 Window root; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
442 Visual *visual; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
443 int screen; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
444 XSetWindowAttributes wattr; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
445 int depth; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
278
diff
changeset
|
446 mbe_surface_t *surface; |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
447 int w, h; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
448 int x, y; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
449 int r; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
450 |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
451 display = XOpenDisplay(":0.0"); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
452 if(display == NULL) |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
453 printf("XOpenDisplay\n"); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
454 screen = DefaultScreen(display); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
455 root = DefaultRootWindow(display); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
456 visual = DefaultVisual(display, screen); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
457 depth = DefaultDepth(display, screen); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
458 wattr.override_redirect = False; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
459 x = 10; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
460 y = 10; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
461 w = 200; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
462 h = 200; |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
463 win = XCreateWindow(display, root, |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
464 x, y, |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
465 w, h, |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
466 1, depth, InputOutput, visual, |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
467 CWOverrideRedirect, &wattr); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
468 r = XMapWindow(display, win); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
469 |
1073
d09f603438d8
Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents:
1024
diff
changeset
|
470 surface = mbe_win_surface_create(display, win, visual, w, h); |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
471 if(surface == NULL) |
1073
d09f603438d8
Merge the work of improvement for graphic engine of openvg branch
Thinker K.F. Li <thinker@codemud.net>
parents:
1024
diff
changeset
|
472 printf("mbe_win_surface_create\n"); |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
473 |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
474 drawing(surface, w, h); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
475 |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
476 XFlush(display); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
477 sleep(10); |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
478 |
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
479 XCloseDisplay(display); |
10 | 480 return 0; |
3
164162781a7a
Test cairo with Xlib surface
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
481 } |