Mercurial > MadButterfly
comparison src/X_supp.c @ 84:42698de1f653
Support translate() function for transform attribute of 'g' tag.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 22 Aug 2008 12:52:48 +0800 |
parents | ea758bb3bbe2 |
children | 5df7403b6fbc |
comparison
equal
deleted
inserted
replaced
83:ea758bb3bbe2 | 84:42698de1f653 |
---|---|
41 * Observers of parent shapes may be called if the subject is not | 41 * Observers of parent shapes may be called if the subject is not |
42 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event | 42 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event |
43 * for a shape is returned by sh_get_mouse_event_subject(). | 43 * for a shape is returned by sh_get_mouse_event_subject(). |
44 */ | 44 */ |
45 static void notify_shapes(redraw_man_t *rdman, | 45 static void notify_shapes(redraw_man_t *rdman, |
46 shape_t *shape, | |
46 co_aix x, co_aix y, int etype, | 47 co_aix x, co_aix y, int etype, |
47 unsigned int state, | 48 unsigned int state, |
48 unsigned int button) { | 49 unsigned int button) { |
49 mouse_event_t mouse_event; | 50 mouse_event_t mouse_event; |
50 shape_t *shape; | |
51 subject_t *subject; | 51 subject_t *subject; |
52 ob_factory_t *factory; | 52 ob_factory_t *factory; |
53 int in_stroke; | |
54 | 53 |
55 mouse_event.event.type = etype; | 54 mouse_event.event.type = etype; |
56 mouse_event.x = x; | 55 mouse_event.x = x; |
57 mouse_event.y = y; | 56 mouse_event.y = y; |
58 mouse_event.but_state = state; | 57 mouse_event.but_state = state; |
59 mouse_event.button = button; | 58 mouse_event.button = button; |
60 | 59 |
61 shape = find_shape_at_pos(rdman, x, y, | |
62 &in_stroke); | |
63 if(shape == NULL) | |
64 return; | |
65 subject = sh_get_mouse_event_subject(shape); | 60 subject = sh_get_mouse_event_subject(shape); |
66 factory = rdman_get_ob_factory(rdman); | 61 factory = rdman_get_ob_factory(rdman); |
67 | 62 |
68 subject_notify(factory, subject, (event_t *)&mouse_event); | 63 subject_notify(factory, subject, (event_t *)&mouse_event); |
69 } | 64 } |
80 co_aix x, y, w, h; | 75 co_aix x, y, w, h; |
81 | 76 |
82 int eflag = 0; | 77 int eflag = 0; |
83 int ex1=0, ey1=0, ex2=0, ey2=0; | 78 int ex1=0, ey1=0, ex2=0, ey2=0; |
84 | 79 |
80 shape_t *shape; | |
81 | |
85 unsigned int state, button; | 82 unsigned int state, button; |
83 int in_stroke; | |
86 int r; | 84 int r; |
87 | 85 |
88 while(XEventsQueued(display, QueuedAfterReading) > 0) { | 86 while(XEventsQueued(display, QueuedAfterReading) > 0) { |
89 r = XNextEvent(display, &evt); | 87 r = XNextEvent(display, &evt); |
90 if(r == -1) | 88 if(r == -1) |
96 x = bevt->x; | 94 x = bevt->x; |
97 y = bevt->y; | 95 y = bevt->y; |
98 state = get_button_state(bevt->state); | 96 state = get_button_state(bevt->state); |
99 button = get_button(bevt->button); | 97 button = get_button(bevt->button); |
100 | 98 |
101 notify_shapes(rdman, x, y, EVT_MOUSE_BUT_PRESS, | 99 shape = find_shape_at_pos(rdman, x, y, |
102 state, button); | 100 &in_stroke); |
101 if(shape) | |
102 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_PRESS, | |
103 state, button); | |
103 break; | 104 break; |
104 | 105 |
105 case ButtonRelease: | 106 case ButtonRelease: |
106 bevt = (XButtonEvent *)&evt; | 107 bevt = (XButtonEvent *)&evt; |
107 x = bevt->x; | 108 x = bevt->x; |
108 y = bevt->y; | 109 y = bevt->y; |
109 state = get_button_state(bevt->state); | 110 state = get_button_state(bevt->state); |
110 button = get_button(bevt->button); | 111 button = get_button(bevt->button); |
111 | 112 |
112 notify_shapes(rdman, x, y, EVT_MOUSE_BUT_RELEASE, | 113 shape = find_shape_at_pos(rdman, x, y, |
113 state, button); | 114 &in_stroke); |
115 if(shape) | |
116 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_RELEASE, | |
117 state, button); | |
114 break; | 118 break; |
115 | 119 |
116 case MotionNotify: | 120 case MotionNotify: |
117 mevt = (XMotionEvent *)&evt; | 121 mevt = (XMotionEvent *)&evt; |
118 x = mevt->x; | 122 x = mevt->x; |
119 y = mevt->y; | 123 y = mevt->y; |
120 state = get_button_state(mevt->state); | 124 state = get_button_state(mevt->state); |
121 | 125 |
122 notify_shapes(rdman, x, y, EVT_MOUSE_MOVE, state, 0); | 126 shape = find_shape_at_pos(rdman, x, y, |
127 &in_stroke); | |
128 if(shape != NULL) { | |
129 if(rt->last != shape) { | |
130 if(rt->last) | |
131 notify_shapes(rdman, rt->last, x, y, | |
132 EVT_MOUSE_OUT, state, 0); | |
133 notify_shapes(rdman, shape, x, y, | |
134 EVT_MOUSE_OVER, state, 0); | |
135 rt->last = shape; | |
136 } else | |
137 notify_shapes(rdman, shape, x, y, | |
138 EVT_MOUSE_MOVE, state, 0); | |
139 } else { | |
140 if(rt->last) { | |
141 notify_shapes(rdman, rt->last, x, y, | |
142 EVT_MOUSE_OUT, state, 0); | |
143 rt->last = NULL; | |
144 } | |
145 } | |
123 break; | 146 break; |
124 | 147 |
125 case Expose: | 148 case Expose: |
126 eevt = &evt.xexpose; | 149 eevt = &evt.xexpose; |
127 x = eevt->x; | 150 x = eevt->x; |
247 if(r == -1) { | 270 if(r == -1) { |
248 XCloseDisplay(display); | 271 XCloseDisplay(display); |
249 return ERR; | 272 return ERR; |
250 } | 273 } |
251 | 274 |
252 XSelectInput(display, win, PointerMotionMask | ExposureMask); | 275 XSelectInput(display, win, PointerMotionMask | ExposureMask | |
276 ButtonPressMask | ButtonReleaseMask); | |
253 XFlush(display); | 277 XFlush(display); |
254 | 278 |
255 *displayp = display; | 279 *displayp = display; |
256 *visualp = visual; | 280 *visualp = visual; |
257 *winp = win; | 281 *winp = win; |