Changes in uspace/srv/hid/compositor/compositor.c [f9f45e7:feeac0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
rf9f45e7 rfeeac0d 143 143 static LIST_INITIALIZE(viewport_list); 144 144 145 static FIBRIL_MUTEX_INITIALIZE(discovery_mtx);146 147 145 /** Input server proxy */ 148 146 static input_t *input; … … 2116 2114 } 2117 2115 2118 static int discover_viewports(void) 2119 { 2116 static int compositor_srv_init(char *input_svc, char *name) 2117 { 2118 /* Coordinates of the central pixel. */ 2119 coord_origin = UINT32_MAX / 4; 2120 2121 /* Color of the viewport background. Must be opaque. */ 2122 bg_color = PIXEL(255, 75, 70, 75); 2123 2124 /* Register compositor server. */ 2125 async_set_client_connection(client_connection); 2126 int rc = loc_server_register(NAME); 2127 if (rc != EOK) { 2128 printf("%s: Unable to register server (%s)\n", NAME, str_error(rc)); 2129 return -1; 2130 } 2131 2132 /* Register interrupt handler to switch back from kconsole. */ 2133 async_set_interrupt_received(interrupt_received); 2134 rc = event_subscribe(EVENT_KCONSOLE, 0); 2135 if (rc != EOK) { 2136 printf("%s: Failed to register kconsole notifications (%s)\n", 2137 NAME, str_error(rc)); 2138 } 2139 2140 server_name = name; 2141 2142 char svc[LOC_NAME_MAXLEN + 1]; 2143 snprintf(svc, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, server_name); 2144 2145 service_id_t service_id; 2146 rc = loc_service_register(svc, &service_id); 2147 if (rc != EOK) { 2148 printf("%s: Unable to register service %s\n", NAME, svc); 2149 return rc; 2150 } 2151 2152 /* Prepare window registrator (entrypoint for clients). */ 2153 char winreg[LOC_NAME_MAXLEN + 1]; 2154 snprintf(winreg, LOC_NAME_MAXLEN, "%s%s/winreg", NAMESPACE, server_name); 2155 if (loc_service_register(winreg, &winreg_id) != EOK) { 2156 printf("%s: Unable to register service %s\n", NAME, winreg); 2157 return -1; 2158 } 2159 2160 /* Establish input bidirectional connection. */ 2161 rc = input_connect(input_svc); 2162 if (rc != EOK) { 2163 printf("%s: Failed to connect to input service.\n", NAME); 2164 return rc; 2165 } 2166 2120 2167 /* Create viewports and connect them to visualizers. */ 2121 2168 category_id_t cat_id; 2122 intrc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);2169 rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 2123 2170 if (rc != EOK) { 2124 2171 printf("%s: Failed to get visualizer category.\n", NAME); 2172 input_disconnect(); 2125 2173 return -1; 2126 2174 } … … 2131 2179 if (rc != EOK || svcs_cnt == 0) { 2132 2180 printf("%s: Failed to get visualizer category services.\n", NAME); 2181 input_disconnect(); 2133 2182 return -1; 2134 2183 } 2135 2136 fibril_mutex_lock(&viewport_list_mtx); 2184 2137 2185 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 2186 char *svc_name; 2150 2187 rc = loc_service_get_name(svcs[i], &svc_name); … … 2156 2193 } 2157 2194 } 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 2172 static int compositor_srv_init(char *input_svc, char *name)2173 {2174 /* Coordinates of the central pixel. */2175 coord_origin = UINT32_MAX / 4;2176 2177 /* Color of the viewport background. Must be opaque. */2178 bg_color = PIXEL(255, 75, 70, 75);2179 2180 /* Register compositor server. */2181 async_set_client_connection(client_connection);2182 int rc = loc_server_register(NAME);2183 if (rc != EOK) {2184 printf("%s: Unable to register server (%s)\n", NAME, str_error(rc));2185 return -1;2186 }2187 2188 /* Register interrupt handler to switch back from kconsole. */2189 async_set_interrupt_received(interrupt_received);2190 rc = event_subscribe(EVENT_KCONSOLE, 0);2191 if (rc != EOK) {2192 printf("%s: Failed to register kconsole notifications (%s)\n",2193 NAME, str_error(rc));2194 }2195 2196 server_name = name;2197 2198 char svc[LOC_NAME_MAXLEN + 1];2199 snprintf(svc, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, server_name);2200 2201 service_id_t service_id;2202 rc = loc_service_register(svc, &service_id);2203 if (rc != EOK) {2204 printf("%s: Unable to register service %s\n", NAME, svc);2205 return rc;2206 }2207 2208 /* Prepare window registrator (entrypoint for clients). */2209 char winreg[LOC_NAME_MAXLEN + 1];2210 snprintf(winreg, LOC_NAME_MAXLEN, "%s%s/winreg", NAMESPACE, server_name);2211 if (loc_service_register(winreg, &winreg_id) != EOK) {2212 printf("%s: Unable to register service %s\n", NAME, winreg);2213 return -1;2214 }2215 2216 /* Establish input bidirectional connection. */2217 rc = input_connect(input_svc);2218 if (rc != EOK) {2219 printf("%s: Failed to connect to input service.\n", NAME);2220 return rc;2221 }2222 2223 rc = loc_register_cat_change_cb(category_change_cb);2224 if (rc != EOK) {2225 printf("%s: Failed to register category change callback\n", NAME);2226 input_disconnect();2227 return rc;2228 }2229 2230 rc = discover_viewports();2231 if (rc != EOK) {2232 input_disconnect();2233 return rc;2234 }2235 2195 2236 2196 if (list_empty(&viewport_list)) { … … 2243 2203 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2244 2204 2245 2246 2205 return EOK; 2247 2206 }
Note:
See TracChangeset
for help on using the changeset viewer.