annotate src/X_supp.c @ 101:d6f9af55b0d0

More documentation. 1. main page 2. copyright
author Thinker K.F. Li <thinker@branda.to>
date Wed, 10 Sep 2008 13:35:56 +0800
parents 42698de1f653
children 5df7403b6fbc
rev   line source
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include <stdio.h>
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
2 #include <stdlib.h>
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
3 #include <string.h>
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #include <X11/Xlib.h>
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 #include <X11/Xutil.h>
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
6 #include <cairo.h>
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
7 #include <cairo-xlib.h>
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 #include "redraw_man.h"
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 #include "mb_timer.h"
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
10 #include "X_supp.h"
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
13 static unsigned int get_button_state(unsigned int state) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
14 unsigned int but = 0;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
15
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
16 if(state & Button1Mask)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
17 but |= MOUSE_BUT1;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
18 if(state & Button2Mask)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
19 but |= MOUSE_BUT2;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
20 if(state & Button3Mask)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
21 but |= MOUSE_BUT3;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
22
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
23 return but;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
24 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
25
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
26 static unsigned int get_button(unsigned int button) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
27 switch(button) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
28 case Button1:
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
29 return MOUSE_BUT1;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
30 case Button2:
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
31 return MOUSE_BUT2;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
32 case Button3:
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
33 return MOUSE_BUT3;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
34 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
35 return 0;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
36 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
37
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
38 /*! \brief Notify observers of the shape at specified
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
39 * position for mouse event.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
40 *
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
41 * Observers of parent shapes may be called if the subject is not
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
42 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
43 * for a shape is returned by sh_get_mouse_event_subject().
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
44 */
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
45 static void notify_shapes(redraw_man_t *rdman,
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
46 shape_t *shape,
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
47 co_aix x, co_aix y, int etype,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
48 unsigned int state,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
49 unsigned int button) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
50 mouse_event_t mouse_event;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
51 subject_t *subject;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
52 ob_factory_t *factory;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
53
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
54 mouse_event.event.type = etype;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
55 mouse_event.x = x;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
56 mouse_event.y = y;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
57 mouse_event.but_state = state;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
58 mouse_event.button = button;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
59
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
60 subject = sh_get_mouse_event_subject(shape);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
61 factory = rdman_get_ob_factory(rdman);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
62
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
63 subject_notify(factory, subject, (event_t *)&mouse_event);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
64 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
65
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
66 /*! \brief Dispatch all X events in the queue.
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
67 */
83
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
68 static void handle_x_event(X_MB_runtime_t *rt) {
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
69 Display *display = rt->display;
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
70 redraw_man_t *rdman = rt->rdman;
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 XEvent evt;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
72 XMotionEvent *mevt;
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
73 XButtonEvent *bevt;
81
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
74 XExposeEvent *eevt;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
75 co_aix x, y, w, h;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
76
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
77 int eflag = 0;
82
Thinker K.F. Li <thinker@branda.to>
parents: 81
diff changeset
78 int ex1=0, ey1=0, ex2=0, ey2=0;
81
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
79
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
80 shape_t *shape;
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
81
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
82 unsigned int state, button;
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
83 int in_stroke;
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 int r;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 while(XEventsQueued(display, QueuedAfterReading) > 0) {
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87 r = XNextEvent(display, &evt);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 if(r == -1)
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 break;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
90
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 switch(evt.type) {
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
92 case ButtonPress:
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
93 bevt = (XButtonEvent *)&evt;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
94 x = bevt->x;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
95 y = bevt->y;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
96 state = get_button_state(bevt->state);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
97 button = get_button(bevt->button);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
98
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
99 shape = find_shape_at_pos(rdman, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
100 &in_stroke);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
101 if(shape)
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
102 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_PRESS,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
103 state, button);
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
104 break;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
105
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
106 case ButtonRelease:
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
107 bevt = (XButtonEvent *)&evt;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
108 x = bevt->x;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
109 y = bevt->y;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
110 state = get_button_state(bevt->state);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
111 button = get_button(bevt->button);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
112
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
113 shape = find_shape_at_pos(rdman, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
114 &in_stroke);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
115 if(shape)
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
116 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_RELEASE,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
117 state, button);
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
118 break;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
119
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
120 case MotionNotify:
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
121 mevt = (XMotionEvent *)&evt;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
122 x = mevt->x;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
123 y = mevt->y;
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
124 state = get_button_state(mevt->state);
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
125
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
126 shape = find_shape_at_pos(rdman, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
127 &in_stroke);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
128 if(shape != NULL) {
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
129 if(rt->last != shape) {
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
130 if(rt->last)
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
131 notify_shapes(rdman, rt->last, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
132 EVT_MOUSE_OUT, state, 0);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
133 notify_shapes(rdman, shape, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
134 EVT_MOUSE_OVER, state, 0);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
135 rt->last = shape;
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
136 } else
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
137 notify_shapes(rdman, shape, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
138 EVT_MOUSE_MOVE, state, 0);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
139 } else {
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
140 if(rt->last) {
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
141 notify_shapes(rdman, rt->last, x, y,
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
142 EVT_MOUSE_OUT, state, 0);
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
143 rt->last = NULL;
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
144 }
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
145 }
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
146 break;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
147
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
148 case Expose:
81
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
149 eevt = &evt.xexpose;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
150 x = eevt->x;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
151 y = eevt->y;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
152 w = eevt->width;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
153 h = eevt->height;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
154
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
155 if(eflag) {
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
156 if(x < ex1)
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
157 ex1 = x;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
158 if(y < ey1)
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
159 ey1 = y;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
160 if((x + w) > ex2)
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
161 ex2 = x + w;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
162 if((y + h) > ey2)
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
163 ey2 = y + h;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
164 } else {
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
165 ex1 = x;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
166 ey1 = y;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
167 ex2 = x + w;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
168 ey2 = y + h;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
169 eflag = 1;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
170 }
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
171 break;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
172 }
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
173 }
81
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
174 if(eflag) {
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
175 rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1));
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
176 eflag = 0;
13fdf205047b Hide shapes and groups
Thinker K.F. Li <thinker@branda.to>
parents: 78
diff changeset
177 }
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
178 XFlush(display);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
179 }
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
180
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
181 /*! \brief Handle connection coming data and timeout of timers.
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
182 *
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
183 * \param display is a Display returned by XOpenDisplay().
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
184 * \param rdman is a redraw manager.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
185 * \param tman is a timer manager.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
186 *
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
187 * The display is managed by specified rdman and tman. rdman draws
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
188 * on the display, and tman trigger actions according timers.
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
189 */
83
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
190 void X_MB_handle_connection(X_MB_runtime_t *rt) {
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
191 Display *display = rt->display;
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
192 redraw_man_t *rdman = rt->rdman;
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
193 mb_tman_t *tman = rt->tman;
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
194 int fd;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
195 mb_timeval_t now, tmo;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
196 struct timeval tv;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
197 fd_set rfds;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
198 int nfds;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
199 int r;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
200
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
201 rdman_redraw_all(rdman);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
202 XFlush(display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
203
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
204 fd = XConnectionNumber(display);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
205 nfds = fd + 1;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
206 while(1) {
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
207 FD_ZERO(&rfds);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
208 FD_SET(fd, &rfds);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
209
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
210 get_now(&now);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
211 r = mb_tman_next_timeout(tman, &now, &tmo);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
212
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
213 if(r == 0) {
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
214 tv.tv_sec = MB_TIMEVAL_SEC(&tmo);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
215 tv.tv_usec = MB_TIMEVAL_USEC(&tmo);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
216 r = select(nfds, &rfds, NULL, NULL, &tv);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
217 } else
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
218 r = select(nfds, &rfds, NULL, NULL, NULL);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
219
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
220 if(r == -1) {
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
221 perror("select");
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
222 break;
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
223 }
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
224
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
225 if(r == 0) {
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
226 get_now(&now);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
227 mb_tman_handle_timeout(tman, &now);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
228 rdman_redraw_changed(rdman);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
229 XFlush(display);
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
230 } else if(FD_ISSET(fd, &rfds)){
83
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
231 handle_x_event(rt);
77
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
232 }
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
233 }
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
234 }
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
235
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
236 #define ERR -1
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
237 #define OK 0
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
238
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
239 static int X_init_connection(const char *display_name,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
240 int w, int h,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
241 Display **displayp,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
242 Visual **visualp,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
243 Window *winp) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
244 Display *display;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
245 Window root, win;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
246 Visual *visual;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
247 int screen;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
248 XSetWindowAttributes wattr;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
249 int depth;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
250 int x, y;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
251 int r;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
252
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
253 display = XOpenDisplay(display_name);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
254 if(display == NULL)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
255 return ERR;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
256
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
257 screen = DefaultScreen(display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
258 root = DefaultRootWindow(display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
259 visual = DefaultVisual(display, screen);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
260 depth = DefaultDepth(display, screen);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
261 wattr.override_redirect = False;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
262 x = 10;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
263 y = 10;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
264 win = XCreateWindow(display, root,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
265 x, y,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
266 w, h,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
267 1, depth, InputOutput, visual,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
268 CWOverrideRedirect, &wattr);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
269 r = XMapWindow(display, win);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
270 if(r == -1) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
271 XCloseDisplay(display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
272 return ERR;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
273 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
274
84
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
275 XSelectInput(display, win, PointerMotionMask | ExposureMask |
42698de1f653 Support translate() function for transform attribute of 'g' tag.
Thinker K.F. Li <thinker@branda.to>
parents: 83
diff changeset
276 ButtonPressMask | ButtonReleaseMask);
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
277 XFlush(display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
278
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
279 *displayp = display;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
280 *visualp = visual;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
281 *winp = win;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
282
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
283 return OK;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
284 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
285
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
286 /*! \brief Initialize a MadButterfy runtime for Xlib.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
287 *
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
288 * It setups a runtime environment to run MadButterfly with Xlib.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
289 * Users should specify width and height of the opening window.
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
290 */
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
291 int X_MB_init(const char *display_name,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
292 int w, int h, X_MB_runtime_t *xmb_rt) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
293 memset(xmb_rt, 0, sizeof(X_MB_runtime_t));
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
294
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
295 xmb_rt->w = w;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
296 xmb_rt->h = h;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
297 X_init_connection(display_name, w, h, &xmb_rt->display,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
298 &xmb_rt->visual, &xmb_rt->win);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
299
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
300 xmb_rt->surface =
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
301 cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
302
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
303 xmb_rt->backend_surface =
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
304 cairo_xlib_surface_create(xmb_rt->display,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
305 xmb_rt->win,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
306 xmb_rt->visual,
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
307 w, h);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
308
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
309 xmb_rt->cr = cairo_create(xmb_rt->surface);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
310 xmb_rt->backend_cr = cairo_create(xmb_rt->backend_surface);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
311
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
312 cairo_set_source_surface(xmb_rt->backend_cr, xmb_rt->surface, 0, 0);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
313
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
314 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t));
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
315 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
316
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
317 xmb_rt->tman = mb_tman_new();
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
318
83
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
319 xmb_rt->last = NULL;
ea758bb3bbe2 example
Thinker K.F. Li <thinker@branda.to>
parents: 82
diff changeset
320
78
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
321 return OK;
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
322 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
323
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
324 void X_MB_destroy(X_MB_runtime_t *xmb_rt) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
325 if(xmb_rt->rdman) {
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
326 redraw_man_destroy(xmb_rt->rdman);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
327 free(xmb_rt->rdman);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
328 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
329
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
330 if(xmb_rt->tman)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
331 mb_tman_free(xmb_rt->tman);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
332
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
333 if(xmb_rt->cr)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
334 cairo_destroy(xmb_rt->cr);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
335 if(xmb_rt->backend_cr)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
336 cairo_destroy(xmb_rt->backend_cr);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
337
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
338 if(xmb_rt->surface)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
339 cairo_surface_destroy(xmb_rt->surface);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
340 if(xmb_rt->backend_surface)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
341 cairo_surface_destroy(xmb_rt->backend_surface);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
342
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
343 if(xmb_rt->display)
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
344 XCloseDisplay(xmb_rt->display);
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
345 }
3645e29e4986 Add runtime for Xlib.
Thinker K.F. Li <thinker@branda.to>
parents: 77
diff changeset
346