Mercurial > MadButterfly
comparison src/X_supp.c @ 192:54fdc2a65242
Remove factory from observer APIs.
- Save factory that used to new a subject as subject's attribute.
- Get factory from subject himself instead of passing as an argument.
- It make API of observer more simple and clean.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 18 Nov 2008 21:42:30 +0800 |
parents | 530bb7728546 |
children | 29e1b2bffe4c |
comparison
equal
deleted
inserted
replaced
191:18f8c3126cdb | 192:54fdc2a65242 |
---|---|
78 | 78 |
79 factory = rdman_get_ob_factory(rdman); | 79 factory = rdman_get_ob_factory(rdman); |
80 kbinfo->kbevents = subject_new(factory, kbinfo, OBJT_KB); | 80 kbinfo->kbevents = subject_new(factory, kbinfo, OBJT_KB); |
81 if(kbinfo->kbevents == NULL) | 81 if(kbinfo->kbevents == NULL) |
82 return ERR; | 82 return ERR; |
83 /*! \todo Make sure ob_factory is still need. */ | |
83 kbinfo->ob_factory = factory; | 84 kbinfo->ob_factory = factory; |
84 | 85 |
85 return OK; | 86 return OK; |
86 } | 87 } |
87 | 88 |
88 static void X_kb_destroy(X_kb_info_t *kbinfo) { | 89 static void X_kb_destroy(X_kb_info_t *kbinfo) { |
89 subject_free(kbinfo->ob_factory, kbinfo->kbevents); | 90 subject_free(kbinfo->kbevents); |
90 XFree(kbinfo->syms); | 91 XFree(kbinfo->syms); |
91 } | 92 } |
92 | 93 |
93 /*! \brief Accept X keyboard events from handle_x_event() and dispatch it. | 94 /*! \brief Accept X keyboard events from handle_x_event() and dispatch it. |
94 */ | 95 */ |
105 event.event.type = EVT_KB_RELEASE; | 106 event.event.type = EVT_KB_RELEASE; |
106 event.event.tgt = event.event.cur_tgt = kbinfo->kbevents; | 107 event.event.tgt = event.event.cur_tgt = kbinfo->kbevents; |
107 event.keycode = code; | 108 event.keycode = code; |
108 event.sym = sym; | 109 event.sym = sym; |
109 | 110 |
110 subject_notify(kbinfo->ob_factory, kbinfo->kbevents, &event.event); | 111 subject_notify(kbinfo->kbevents, &event.event); |
111 } | 112 } |
112 | 113 |
113 /* @} */ | 114 /* @} */ |
114 | 115 |
115 static unsigned int get_button_state(unsigned int state) { | 116 static unsigned int get_button_state(unsigned int state) { |
149 co_aix x, co_aix y, int etype, | 150 co_aix x, co_aix y, int etype, |
150 unsigned int state, | 151 unsigned int state, |
151 unsigned int button) { | 152 unsigned int button) { |
152 mouse_event_t mouse_event; | 153 mouse_event_t mouse_event; |
153 subject_t *subject; | 154 subject_t *subject; |
154 ob_factory_t *factory; | |
155 | 155 |
156 mouse_event.event.type = etype; | 156 mouse_event.event.type = etype; |
157 mouse_event.x = x; | 157 mouse_event.x = x; |
158 mouse_event.y = y; | 158 mouse_event.y = y; |
159 mouse_event.but_state = state; | 159 mouse_event.but_state = state; |
160 mouse_event.button = button; | 160 mouse_event.button = button; |
161 | 161 |
162 subject = sh_get_mouse_event_subject(shape); | 162 subject = sh_get_mouse_event_subject(shape); |
163 factory = rdman_get_ob_factory(rdman); | |
164 | 163 |
165 subject_notify(factory, subject, (event_t *)&mouse_event); | 164 subject_notify(subject, (event_t *)&mouse_event); |
166 } | 165 } |
167 | 166 |
168 /*! \brief Dispatch all X events in the queue. | 167 /*! \brief Dispatch all X events in the queue. |
169 */ | 168 */ |
170 static void handle_x_event(X_MB_runtime_t *rt) { | 169 static void handle_x_event(X_MB_runtime_t *rt) { |