diff 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
line wrap: on
line diff
--- a/src/X_supp.c	Tue Nov 18 13:55:09 2008 +0800
+++ b/src/X_supp.c	Tue Nov 18 21:42:30 2008 +0800
@@ -80,13 +80,14 @@
     kbinfo->kbevents = subject_new(factory, kbinfo, OBJT_KB);
     if(kbinfo->kbevents == NULL)
 	return ERR;
+    /*! \todo Make sure ob_factory is still need. */
     kbinfo->ob_factory = factory;
 
     return OK;
 }
 
 static void X_kb_destroy(X_kb_info_t *kbinfo) {
-    subject_free(kbinfo->ob_factory, kbinfo->kbevents);
+    subject_free(kbinfo->kbevents);
     XFree(kbinfo->syms);
 }
 
@@ -107,7 +108,7 @@
     event.keycode = code;
     event.sym = sym;
 
-    subject_notify(kbinfo->ob_factory, kbinfo->kbevents, &event.event);
+    subject_notify(kbinfo->kbevents, &event.event);
 }
 
 /* @} */
@@ -151,7 +152,6 @@
 			  unsigned int button) {
     mouse_event_t mouse_event;
     subject_t *subject;
-    ob_factory_t *factory;
 
     mouse_event.event.type = etype;
     mouse_event.x = x;
@@ -160,9 +160,8 @@
     mouse_event.button = button;
     
     subject = sh_get_mouse_event_subject(shape);
-    factory = rdman_get_ob_factory(rdman);
     
-    subject_notify(factory, subject, (event_t *)&mouse_event);
+    subject_notify(subject, (event_t *)&mouse_event);
 }
 
 /*! \brief Dispatch all X events in the queue.