Changeset d08ba7fc in mainline
- Timestamp:
- 2013-09-10T18:06:30Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fdfa2e1
- Parents:
- 39b13f8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r39b13f8 rd08ba7fc 143 143 static LIST_INITIALIZE(viewport_list); 144 144 145 static FIBRIL_MUTEX_INITIALIZE(discovery_mtx); 146 145 147 /** Input server proxy */ 146 148 static input_t *input; … … 2114 2116 } 2115 2117 2118 static int discover_viewports(void) 2119 { 2120 /* Create viewports and connect them to visualizers. */ 2121 category_id_t cat_id; 2122 int rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2123 if (rc != EOK) { 2124 printf("%s: Failed to get visualizer category.\n", NAME); 2125 return -1; 2126 } 2127 2128 service_id_t *svcs; 2129 size_t svcs_cnt = 0; 2130 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 2131 if (rc != EOK || svcs_cnt == 0) { 2132 printf("%s: Failed to get visualizer category services.\n", NAME); 2133 return -1; 2134 } 2135 2136 fibril_mutex_lock(&viewport_list_mtx); 2137 for (size_t i = 0; i < svcs_cnt; ++i) { 2138 bool exists = false; 2139 list_foreach(viewport_list, link, viewport_t, vp) { 2140 if (vp->dsid == svcs[i]) { 2141 exists = true; 2142 break; 2143 } 2144 } 2145 2146 if (exists) 2147 continue; 2148 2149 char *svc_name; 2150 rc = loc_service_get_name(svcs[i], &svc_name); 2151 if (rc == EOK) { 2152 viewport_t *vp = viewport_create(svc_name); 2153 if (vp != NULL) { 2154 list_append(&vp->link, &viewport_list); 2155 } 2156 } 2157 } 2158 fibril_mutex_unlock(&viewport_list_mtx); 2159 return EOK; 2160 } 2161 2162 static void category_change_cb(void) 2163 { 2164 fibril_mutex_lock(&discovery_mtx); 2165 discover_viewports(); 2166 fibril_mutex_unlock(&discovery_mtx); 2167 } 2168 2116 2169 static int compositor_srv_init(char *input_svc, char *name) 2117 2170 { … … 2165 2218 } 2166 2219 2167 /* Create viewports and connect them to visualizers. */ 2168 category_id_t cat_id; 2169 rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2220 rc = loc_register_cat_change_cb(category_change_cb); 2170 2221 if (rc != EOK) { 2171 printf("%s: Failed to get visualizer category.\n", NAME);2222 printf("%s: Failed to register category change callback\n", NAME); 2172 2223 input_disconnect(); 2173 return -1; 2174 } 2175 2176 service_id_t *svcs; 2177 size_t svcs_cnt = 0; 2178 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 2179 if (rc != EOK || svcs_cnt == 0) { 2180 printf("%s: Failed to get visualizer category services.\n", NAME); 2224 return rc; 2225 } 2226 2227 rc = discover_viewports(); 2228 if (rc != EOK) { 2181 2229 input_disconnect(); 2182 return -1; 2183 } 2184 2185 for (size_t i = 0; i < svcs_cnt; ++i) { 2186 char *svc_name; 2187 rc = loc_service_get_name(svcs[i], &svc_name); 2188 if (rc == EOK) { 2189 viewport_t *vp = viewport_create(svc_name); 2190 if (vp != NULL) { 2191 list_append(&vp->link, &viewport_list); 2192 } 2193 } 2230 return rc; 2194 2231 } 2195 2232 … … 2203 2240 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2204 2241 2242 2205 2243 return EOK; 2206 2244 }
Note:
See TracChangeset
for help on using the changeset viewer.