Changes in uspace/srv/hid/compositor/compositor.c [cf02eaf:fbb2d0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
rcf02eaf rfbb2d0d 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; … … 335 337 } 336 338 337 list_foreach(viewport_list, link) { 338 viewport_t *vp = list_get_instance(link, viewport_t, link); 339 list_foreach(viewport_list, link, viewport_t, vp) { 339 340 sysarg_t w_vp, h_vp; 340 341 surface_get_resolution(vp->surface, &w_vp, &h_vp); … … 354 355 fibril_mutex_lock(&pointer_list_mtx); 355 356 356 list_foreach(pointer_list, link) { 357 pointer_t *ptr = list_get_instance(link, pointer_t, link); 357 list_foreach(pointer_list, link, pointer_t, ptr) { 358 358 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x; 359 359 ptr->pos.y = ptr->pos.y > viewport_bound_rect.y ? ptr->pos.y : viewport_bound_rect.y; … … 374 374 fibril_mutex_lock(&pointer_list_mtx); 375 375 376 list_foreach(viewport_list, link) { 377 376 list_foreach(viewport_list, link, viewport_t, vp) { 378 377 /* Determine what part of the viewport must be updated. */ 379 viewport_t *vp = list_get_instance(link, viewport_t, link);380 378 sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp; 381 379 surface_get_resolution(vp->surface, &w_dmg_vp, &h_dmg_vp); … … 446 444 } 447 445 448 list_foreach(pointer_list, link) { 449 450 pointer_t *ptr = list_get_instance(link, pointer_t, link); 446 list_foreach(pointer_list, link, pointer_t, ptr) { 451 447 if (ptr->ghost.surface) { 452 448 … … 522 518 } 523 519 524 list_foreach(pointer_list, link ) {520 list_foreach(pointer_list, link, pointer_t, ptr) { 525 521 526 522 /* Determine what part of the pointer intersects with the 527 523 * updated area of the current viewport. */ 528 pointer_t *ptr = list_get_instance(link, pointer_t, link);529 524 sysarg_t x_dmg_ptr, y_dmg_ptr, w_dmg_ptr, h_dmg_ptr; 530 525 surface_t *sf_ptr = ptr->cursor.states[ptr->state]; … … 569 564 570 565 /* Notify visualizers about updated regions. */ 571 list_foreach(viewport_list, link) { 572 viewport_t *vp = list_get_instance(link, viewport_t, link); 566 list_foreach(viewport_list, link, viewport_t, vp) { 573 567 sysarg_t x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp; 574 568 surface_get_damaged_region(vp->surface, &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp); … … 631 625 632 626 fibril_mutex_lock(&pointer_list_mtx); 633 list_foreach(pointer_list, link) { 634 pointer_t *pointer = list_get_instance(link, pointer_t, link); 627 list_foreach(pointer_list, link, pointer_t, pointer) { 635 628 if (pointer->id == pos_id) { 636 629 pointer->grab_flags = pointer->pressed ? grab_flags : GF_EMPTY; … … 710 703 { 711 704 fibril_mutex_lock(&window_list_mtx); 712 window_t *window = NULL; 713 list_foreach(window_list, link) { 714 window = list_get_instance(link, window_t, link); 705 706 list_foreach(window_list, link, window_t, window) { 715 707 if (window == target) { 716 708 prodcons_produce(&window->queue, &event->link); 717 }718 }719 if (!window) {720 free(event);721 } 709 fibril_mutex_unlock(&window_list_mtx); 710 return; 711 } 712 } 713 722 714 fibril_mutex_unlock(&window_list_mtx); 715 free(event); 723 716 } 724 717 … … 863 856 window_t *win = NULL; 864 857 fibril_mutex_lock(&window_list_mtx); 865 list_foreach(window_list, link) { 866 window_t *cur = list_get_instance(link, window_t, link); 858 list_foreach(window_list, link, window_t, cur) { 867 859 if (cur->in_dsid == service_id || cur->out_dsid == service_id) { 868 860 win = cur; … … 1007 999 /* Close all clients and their windows. */ 1008 1000 fibril_mutex_lock(&window_list_mtx); 1009 list_foreach(window_list, link) { 1010 window_t *win = list_get_instance(link, window_t, link); 1001 list_foreach(window_list, link, window_t, win) { 1011 1002 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 1012 1003 if (event) { … … 1034 1025 viewport_t *vp = NULL; 1035 1026 fibril_mutex_lock(&viewport_list_mtx); 1036 list_foreach(viewport_list, link) { 1037 viewport_t *cur = list_get_instance(link, viewport_t, link); 1027 list_foreach(viewport_list, link, viewport_t, cur) { 1038 1028 if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) { 1039 1029 vp = cur; … … 1571 1561 1572 1562 /* Determine the window which the mouse click belongs to. */ 1573 list_foreach(window_list, link ) {1574 win = list_get_instance(link, window_t, link);1563 list_foreach(window_list, link, window_t, cw) { 1564 win = cw; 1575 1565 if (win->surface) { 1576 1566 surface_get_resolution(win->surface, &width, &height); … … 2126 2116 } 2127 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 2160 /* TODO damage only newly added viewports */ 2161 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2162 return EOK; 2163 } 2164 2165 static void category_change_cb(void) 2166 { 2167 fibril_mutex_lock(&discovery_mtx); 2168 discover_viewports(); 2169 fibril_mutex_unlock(&discovery_mtx); 2170 } 2171 2128 2172 static int compositor_srv_init(char *input_svc, char *name) 2129 2173 { … … 2132 2176 2133 2177 /* Color of the viewport background. Must be opaque. */ 2134 bg_color = PIXEL(255, 75, 70, 75);2178 bg_color = PIXEL(255, 69, 51, 103); 2135 2179 2136 2180 /* Register compositor server. */ … … 2177 2221 } 2178 2222 2179 /* Create viewports and connect them to visualizers. */ 2180 category_id_t cat_id; 2181 rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2223 rc = loc_register_cat_change_cb(category_change_cb); 2182 2224 if (rc != EOK) { 2183 printf("%s: Failed to get visualizer category.\n", NAME);2225 printf("%s: Failed to register category change callback\n", NAME); 2184 2226 input_disconnect(); 2185 return -1; 2186 } 2187 2188 service_id_t *svcs; 2189 size_t svcs_cnt = 0; 2190 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 2191 if (rc != EOK || svcs_cnt == 0) { 2192 printf("%s: Failed to get visualizer category services.\n", NAME); 2227 return rc; 2228 } 2229 2230 rc = discover_viewports(); 2231 if (rc != EOK) { 2193 2232 input_disconnect(); 2194 return -1; 2195 } 2196 2197 for (size_t i = 0; i < svcs_cnt; ++i) { 2198 char *svc_name; 2199 rc = loc_service_get_name(svcs[i], &svc_name); 2200 if (rc == EOK) { 2201 viewport_t *vp = viewport_create(svc_name); 2202 if (vp != NULL) { 2203 list_append(&vp->link, &viewport_list); 2204 } 2205 } 2233 return rc; 2206 2234 } 2207 2235 … … 2215 2243 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2216 2244 2245 2217 2246 return EOK; 2218 2247 }
Note:
See TracChangeset
for help on using the changeset viewer.