Mercurial > MadButterfly
comparison src/X_supp.c @ 224:29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
- backend does not interpret mouse events (over/out/move), now.
- redraw manager, now, interpret mouse events to make it backend independent.
- The task (interpret mouse events) should be moved to somewhere in futhure.
- backend only sent MotionNotify as EVT_MOUSE_MOVE_RAW.
- EVT_MOUSE_MOVE_RAW is interpreted by backend independent code.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 15 Dec 2008 10:13:03 +0800 |
parents | 54fdc2a65242 |
children | ab8284c8dcee |
comparison
equal
deleted
inserted
replaced
223:8be36a0d4239 | 224:29e1b2bffe4c |
---|---|
10 #include "mb_X_supp.h" | 10 #include "mb_X_supp.h" |
11 | 11 |
12 #define ERR -1 | 12 #define ERR -1 |
13 #define OK 0 | 13 #define OK 0 |
14 | 14 |
15 #define ONLY_MOUSE_MOVE_RAW 1 | |
16 | |
15 /*! \ingroup xkb | 17 /*! \ingroup xkb |
16 * @{ | 18 * @{ |
17 */ | 19 */ |
18 struct _X_kb_info { | 20 struct _X_kb_info { |
19 int keycode_min, keycode_max; | 21 int keycode_min, keycode_max; |
35 mb_tman_t *tman; | 37 mb_tman_t *tman; |
36 int w, h; | 38 int w, h; |
37 | 39 |
38 X_kb_info_t kbinfo; | 40 X_kb_info_t kbinfo; |
39 | 41 |
42 #ifndef ONLY_MOUSE_MOVE_RAW | |
40 /* States */ | 43 /* States */ |
41 shape_t *last; | 44 shape_t *last; |
45 #endif | |
42 }; | 46 }; |
43 | 47 |
44 /*! \defgroup xkb X Keyboard Handling | 48 /*! \defgroup xkb X Keyboard Handling |
45 * | 49 * |
46 * Accept keyboard events from X server and delivery it to | 50 * Accept keyboard events from X server and delivery it to |
143 * | 147 * |
144 * Observers of parent shapes may be called if the subject is not | 148 * Observers of parent shapes may be called if the subject is not |
145 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event | 149 * with SUBF_STOP_PROPAGATE flag. The subject of mouse event |
146 * for a shape is returned by sh_get_mouse_event_subject(). | 150 * for a shape is returned by sh_get_mouse_event_subject(). |
147 */ | 151 */ |
148 static void notify_shapes(redraw_man_t *rdman, | 152 static void notify_coord_or_shape(redraw_man_t *rdman, |
149 shape_t *shape, | 153 mb_obj_t *obj, |
150 co_aix x, co_aix y, int etype, | 154 co_aix x, co_aix y, int etype, |
151 unsigned int state, | 155 unsigned int state, |
152 unsigned int button) { | 156 unsigned int button) { |
153 mouse_event_t mouse_event; | 157 mouse_event_t mouse_event; |
154 subject_t *subject; | 158 subject_t *subject; |
155 | 159 |
156 mouse_event.event.type = etype; | 160 mouse_event.event.type = etype; |
157 mouse_event.x = x; | 161 mouse_event.x = x; |
158 mouse_event.y = y; | 162 mouse_event.y = y; |
159 mouse_event.but_state = state; | 163 mouse_event.but_state = state; |
160 mouse_event.button = button; | 164 mouse_event.button = button; |
161 | 165 |
162 subject = sh_get_mouse_event_subject(shape); | 166 if(IS_MBO_SHAPES(obj)) |
167 subject = sh_get_mouse_event_subject((shape_t *)obj); | |
168 else | |
169 subject = coord_get_mouse_event((coord_t *)obj); | |
163 | 170 |
164 subject_notify(subject, (event_t *)&mouse_event); | 171 subject_notify(subject, (event_t *)&mouse_event); |
165 } | 172 } |
166 | 173 |
167 /*! \brief Dispatch all X events in the queue. | 174 /*! \brief Dispatch all X events in the queue. |
178 | 185 |
179 int eflag = 0; | 186 int eflag = 0; |
180 int ex1=0, ey1=0, ex2=0, ey2=0; | 187 int ex1=0, ey1=0, ex2=0, ey2=0; |
181 | 188 |
182 shape_t *shape; | 189 shape_t *shape; |
190 coord_t *root; | |
183 | 191 |
184 unsigned int state, button; | 192 unsigned int state, button; |
185 int in_stroke; | 193 int in_stroke; |
186 int r; | 194 int r; |
187 | 195 |
199 button = get_button(bevt->button); | 207 button = get_button(bevt->button); |
200 | 208 |
201 shape = find_shape_at_pos(rdman, x, y, | 209 shape = find_shape_at_pos(rdman, x, y, |
202 &in_stroke); | 210 &in_stroke); |
203 if(shape) | 211 if(shape) |
204 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_PRESS, | 212 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
205 state, button); | 213 x, y, EVT_MOUSE_BUT_PRESS, |
214 state, button); | |
206 break; | 215 break; |
207 | 216 |
208 case ButtonRelease: | 217 case ButtonRelease: |
209 bevt = (XButtonEvent *)&evt; | 218 bevt = (XButtonEvent *)&evt; |
210 x = bevt->x; | 219 x = bevt->x; |
213 button = get_button(bevt->button); | 222 button = get_button(bevt->button); |
214 | 223 |
215 shape = find_shape_at_pos(rdman, x, y, | 224 shape = find_shape_at_pos(rdman, x, y, |
216 &in_stroke); | 225 &in_stroke); |
217 if(shape) | 226 if(shape) |
218 notify_shapes(rdman, shape, x, y, EVT_MOUSE_BUT_RELEASE, | 227 notify_coord_or_shape(rdman, (mb_obj_t *)shape, |
228 x, y, EVT_MOUSE_BUT_RELEASE, | |
219 state, button); | 229 state, button); |
220 break; | 230 break; |
221 | 231 |
222 case MotionNotify: | 232 case MotionNotify: |
223 mevt = (XMotionEvent *)&evt; | 233 mevt = (XMotionEvent *)&evt; |
225 y = mevt->y; | 235 y = mevt->y; |
226 state = get_button_state(mevt->state); | 236 state = get_button_state(mevt->state); |
227 | 237 |
228 shape = find_shape_at_pos(rdman, x, y, | 238 shape = find_shape_at_pos(rdman, x, y, |
229 &in_stroke); | 239 &in_stroke); |
240 #ifdef ONLY_MOUSE_MOVE_RAW | |
241 if(shape != NULL) { | |
242 notify_coord_or_shape(rdman, (mb_obj_t *)shape, | |
243 x, y, EVT_MOUSE_MOVE_RAW, state, 0); | |
244 } else { | |
245 root = rdman_get_root(rdman); | |
246 notify_coord_or_shape(rdman, (mb_obj_t *)root, | |
247 x, y, EVT_MOUSE_MOVE_RAW, state, 0); | |
248 } | |
249 #else | |
230 if(shape != NULL) { | 250 if(shape != NULL) { |
231 if(rt->last != shape) { | 251 if(rt->last != shape) { |
232 if(rt->last) | 252 if(rt->last) |
233 notify_shapes(rdman, rt->last, x, y, | 253 notify_coord_or_shape(rdman, rt->last, x, y, |
234 EVT_MOUSE_OUT, state, 0); | 254 EVT_MOUSE_OUT, state, 0); |
235 notify_shapes(rdman, shape, x, y, | 255 notify_coord_or_shape(rdman, shape, x, y, |
236 EVT_MOUSE_OVER, state, 0); | 256 EVT_MOUSE_OVER, state, 0); |
237 rt->last = shape; | 257 rt->last = shape; |
238 } else | 258 } else |
239 notify_shapes(rdman, shape, x, y, | 259 notify_coord_or_shape(rdman, shape, x, y, |
240 EVT_MOUSE_MOVE, state, 0); | 260 EVT_MOUSE_MOVE, state, 0); |
241 } else { | 261 } else { |
242 if(rt->last) { | 262 if(rt->last) { |
243 notify_shapes(rdman, rt->last, x, y, | 263 notify_coord_or_shape(rdman, rt->last, x, y, |
244 EVT_MOUSE_OUT, state, 0); | 264 EVT_MOUSE_OUT, state, 0); |
245 rt->last = NULL; | 265 rt->last = NULL; |
246 } | 266 } |
247 } | 267 } |
268 #endif | |
248 break; | 269 break; |
249 | 270 |
250 case KeyPress: | 271 case KeyPress: |
251 case KeyRelease: | 272 case KeyRelease: |
252 xkey = &evt.xkey; | 273 xkey = &evt.xkey; |
422 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); | 443 xmb_rt->rdman = (redraw_man_t *)malloc(sizeof(redraw_man_t)); |
423 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); | 444 redraw_man_init(xmb_rt->rdman, xmb_rt->cr, xmb_rt->backend_cr); |
424 | 445 |
425 xmb_rt->tman = mb_tman_new(); | 446 xmb_rt->tman = mb_tman_new(); |
426 | 447 |
448 #ifndef ONLY_MOUSE_MOVE_RAW | |
427 xmb_rt->last = NULL; | 449 xmb_rt->last = NULL; |
450 #endif | |
428 | 451 |
429 X_kb_init(&xmb_rt->kbinfo, xmb_rt->display, xmb_rt->rdman); | 452 X_kb_init(&xmb_rt->kbinfo, xmb_rt->display, xmb_rt->rdman); |
430 | 453 |
431 return OK; | 454 return OK; |
432 } | 455 } |