Changeset ce3efa0 in mainline for uspace/srv/hid/compositor/compositor.c
- Timestamp:
- 2014-08-12T16:49:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 593e023
- Parents:
- f6ab787
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
rf6ab787 rce3efa0 230 230 static void window_destroy(window_t *win) 231 231 { 232 if ( win && atomic_get(&win->ref_cnt) == 0) {232 if ((win) && (atomic_get(&win->ref_cnt) == 0)) { 233 233 while (!list_empty(&win->queue.list)) { 234 234 window_event_t *event = (window_event_t *) list_first(&win->queue.list); … … 236 236 free(event); 237 237 } 238 239 if (win->surface) {238 239 if (win->surface) 240 240 surface_destroy(win->surface); 241 }241 242 242 free(win); 243 243 } … … 251 251 transform_invert(&win_trans); 252 252 transform_apply_affine(&win_trans, &x, &y); 253 254 /* Since client coordinate origin is (0, 0), it is necessary to check 253 254 /* 255 * Since client coordinate origin is (0, 0), it is necessary to check 255 256 * coordinates to avoid underflow. Moreover, it is convenient to also 256 257 * check against provided upper limits to determine whether the converted 257 * coordinates are within the client window. */ 258 if (x < 0 || y < 0) { 258 * coordinates are within the client window. 259 */ 260 if ((x < 0) || (y < 0)) 259 261 return false; 260 } else { 261 (*x_out) = (sysarg_t) (x + 0.5); 262 (*y_out) = (sysarg_t) (y + 0.5); 263 264 if ((*x_out) >= x_lim || (*y_out) >= y_lim) { 265 return false; 266 } else { 267 return true; 268 } 269 } 262 263 (*x_out) = (sysarg_t) (x + 0.5); 264 (*y_out) = (sysarg_t) (y + 0.5); 265 266 if (((*x_out) >= x_lim) || ((*y_out) >= y_lim)) 267 return false; 268 269 return true; 270 270 } 271 271 … … 277 277 transform_apply_affine(&win_trans, &x, &y); 278 278 279 /* It is assumed that compositor coordinate origin is chosen in such way, 280 * that underflow/overflow here would be unlikely. */ 279 /* 280 * It is assumed that compositor coordinate origin is chosen in such way, 281 * that underflow/overflow here would be unlikely. 282 */ 281 283 (*x_out) = (sysarg_t) (x + 0.5); 282 284 (*y_out) = (sysarg_t) (y + 0.5); … … 436 438 transform_translate(&transform, -pos.x, -pos.y); 437 439 438 source_set_transform(&source, transform); 440 source_set_transform(&source, transform); 439 441 source_set_texture(&source, win->surface, false); 440 442 source_set_alpha(&source, PIXEL(win->opacity, 0, 0, 0)); … … 572 574 vp->sess, x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 0, 0); 573 575 } 574 576 575 577 fibril_mutex_unlock(&viewport_list_mtx); 576 578 } … … 588 590 return; 589 591 } 592 590 593 int rc = async_data_read_finalize(callid, event, len); 591 594 if (rc != EOK) { … … 594 597 return; 595 598 } 599 596 600 async_answer_0(iid, EOK); 597 598 601 free(event); 599 602 } … … 606 609 double height = IPC_GET_ARG4(*icall); 607 610 608 if ( width == 0 || height == 0) {611 if ((width == 0) || (height == 0)) { 609 612 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 610 613 } else { … … 855 858 856 859 comp_damage(x, y, width, height); 857 858 860 async_answer_0(iid, EOK); 859 861 } … … 861 863 static void comp_window_close_request(window_t *win, ipc_callid_t iid, ipc_call_t *icall) 862 864 { 863 865 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 864 866 if (event == NULL) { 865 867 async_answer_0(iid, ENOMEM); … … 1001 1003 break; 1002 1004 case WINDOW_CLOSE: 1003 /* Postpone the closing until the phone is hung up to cover 1004 * the case when the client is killed abruptly. */ 1005 /* 1006 * Postpone the closing until the phone is hung up to cover 1007 * the case when the client is killed abruptly. 1008 */ 1005 1009 async_answer_0(callid, EOK); 1006 1010 break; … … 1017 1021 static void comp_mode_change(viewport_t *vp, ipc_callid_t iid, ipc_call_t *icall) 1018 1022 { 1019 int rc;1020 1023 sysarg_t mode_idx = IPC_GET_ARG2(*icall); 1021 1024 fibril_mutex_lock(&viewport_list_mtx); … … 1023 1026 /* Retrieve the mode that shall be set. */ 1024 1027 vslmode_t new_mode; 1025 rc = visualizer_get_mode(vp->sess, &new_mode, mode_idx);1028 int rc = visualizer_get_mode(vp->sess, &new_mode, mode_idx); 1026 1029 if (rc != EOK) { 1027 1030 fibril_mutex_unlock(&viewport_list_mtx); … … 1041 1044 /* Try to set the mode and share out the surface. */ 1042 1045 rc = visualizer_set_mode(vp->sess, 1043 1046 new_mode.index, new_mode.version, surface_direct_access(new_surface)); 1044 1047 if (rc != EOK) { 1045 1048 surface_destroy(new_surface); … … 1075 1078 /* Release viewport resources. */ 1076 1079 fibril_mutex_lock(&viewport_list_mtx); 1080 1077 1081 list_remove(&vp->link); 1078 1082 viewport_destroy(vp); 1079 1083 1080 1084 /* Terminate compositor if there are no more viewports. */ 1081 1085 if (list_empty(&viewport_list)) { … … 1120 1124 fibril_mutex_unlock(&viewport_list_mtx); 1121 1125 1122 if (!vp) {1126 if (!vp) 1123 1127 return; 1124 }1125 1128 1126 1129 /* Ignore parameters, the connection is already opened. */ … … 1223 1226 /* Try to set the mode and share out the surface. */ 1224 1227 rc = visualizer_set_mode(vp->sess, 1225 1228 vp->mode.index, vp->mode.version, surface_direct_access(vp->surface)); 1226 1229 if (rc != EOK) { 1227 1230 printf("%s: Unable to set mode (%s)\n", NAME, str_error(rc)); … … 1233 1236 if (claimed) 1234 1237 visualizer_yield(vp->sess); 1238 1235 1239 if (vp->sess != NULL) 1236 1240 async_hangup(vp->sess); 1241 1237 1242 free(vp); 1238 1243 free(vsl_name); … … 2196 2201 /* Register compositor server. */ 2197 2202 async_set_client_connection(client_connection); 2203 2198 2204 int rc = loc_server_register(NAME); 2199 2205 if (rc != EOK) { … … 2229 2235 return -1; 2230 2236 } 2231 2237 2232 2238 /* Establish input bidirectional connection. */ 2233 2239 rc = input_connect(input_svc); … … 2236 2242 return rc; 2237 2243 } 2238 2244 2239 2245 rc = loc_register_cat_change_cb(category_change_cb); 2240 2246 if (rc != EOK) { … … 2243 2249 return rc; 2244 2250 } 2245 2251 2246 2252 rc = discover_viewports(); 2247 2253 if (rc != EOK) { … … 2255 2261 return -1; 2256 2262 } 2257 2263 2258 2264 comp_restrict_pointers(); 2259 2265 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2260 2261 2266 2262 2267 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.