Changeset ce3efa0 in mainline
- 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
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/input.c
rf6ab787 rce3efa0 83 83 { 84 84 async_exch_t *exch = async_exchange_begin(input->sess); 85 86 85 int rc = async_req_0_0(exch, INPUT_YIELD); 87 86 async_exchange_end(exch); 88 87 89 88 return rc; 90 89 } -
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; -
uspace/srv/hid/console/console.c
rf6ab787 rce3efa0 377 377 } 378 378 } 379 379 380 380 return size; 381 381 } … … 388 388 while (off < size) 389 389 cons_write_char(cons, str_decode(data, &off, size)); 390 390 391 return size; 391 392 } … … 498 499 event->type = CEV_KEY; 499 500 event->ev.key = *kevent; 501 500 502 free(kevent); 501 503 return EOK; … … 526 528 con_conn(iid, icall, &cons->srvs); 527 529 } 528 529 530 530 531 static int input_connect(const char *svc) … … 583 584 static bool console_srv_init(char *input_svc, char *output_svc) 584 585 { 585 int rc;586 587 586 /* Connect to input service */ 588 rc = input_connect(input_svc);587 int rc = input_connect(input_svc); 589 588 if (rc != EOK) 590 589 return false; -
uspace/srv/hid/input/input.c
rf6ab787 rce3efa0 103 103 104 104 switch (key) { 105 case KC_LCTRL: mod_mask = KM_LCTRL; break; 106 case KC_RCTRL: mod_mask = KM_RCTRL; break; 107 case KC_LSHIFT: mod_mask = KM_LSHIFT; break; 108 case KC_RSHIFT: mod_mask = KM_RSHIFT; break; 109 case KC_LALT: mod_mask = KM_LALT; break; 110 case KC_RALT: mod_mask = KM_RALT; break; 111 default: mod_mask = 0; break; 105 case KC_LCTRL: 106 mod_mask = KM_LCTRL; 107 break; 108 case KC_RCTRL: 109 mod_mask = KM_RCTRL; 110 break; 111 case KC_LSHIFT: 112 mod_mask = KM_LSHIFT; 113 break; 114 case KC_RSHIFT: 115 mod_mask = KM_RSHIFT; 116 break; 117 case KC_LALT: 118 mod_mask = KM_LALT; 119 break; 120 case KC_RALT: 121 mod_mask = KM_RALT; 122 break; 123 default: 124 mod_mask = 0; 112 125 } 113 126 … … 120 133 121 134 switch (key) { 122 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 123 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 124 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 125 default: mod_mask = 0; break; 135 case KC_CAPS_LOCK: 136 mod_mask = KM_CAPS_LOCK; 137 break; 138 case KC_NUM_LOCK: 139 mod_mask = KM_NUM_LOCK; 140 break; 141 case KC_SCROLL_LOCK: 142 mod_mask = KM_SCROLL_LOCK; 143 break; 144 default: 145 mod_mask = 0; 126 146 } 127 147 … … 143 163 } 144 164 145 if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) && 146 key == KC_F1) { 165 // TODO: More elegant layout switching 166 167 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 168 (key == KC_F1)) { 147 169 layout_destroy(kdev->active_layout); 148 170 kdev->active_layout = layout_create(layout[0]); … … 150 172 } 151 173 152 if ( type == KEY_PRESS&& (kdev->mods & KM_LCTRL) &&153 key == KC_F2) {174 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 175 (key == KC_F2)) { 154 176 layout_destroy(kdev->active_layout); 155 177 kdev->active_layout = layout_create(layout[1]); … … 157 179 } 158 180 159 if ( type == KEY_PRESS&& (kdev->mods & KM_LCTRL) &&160 key == KC_F3) {181 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 182 (key == KC_F3)) { 161 183 layout_destroy(kdev->active_layout); 162 184 kdev->active_layout = layout_create(layout[2]); … … 164 186 } 165 187 166 if ( type == KEY_PRESS&& (kdev->mods & KM_LCTRL) &&167 key == KC_F4) {188 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 189 (key == KC_F4)) { 168 190 layout_destroy(kdev->active_layout); 169 191 kdev->active_layout = layout_create(layout[3]); … … 620 642 static int input_start_dev_discovery(void) 621 643 { 622 int rc; 623 624 rc = loc_register_cat_change_cb(cat_change_cb); 644 int rc = loc_register_cat_change_cb(cat_change_cb); 625 645 if (rc != EOK) { 626 646 printf("%s: Failed registering callback for device discovery. " … … 628 648 return rc; 629 649 } 630 650 631 651 return dev_check_new(); 632 652 } … … 668 688 /* Register driver */ 669 689 async_set_client_connection(client_connection); 690 670 691 int rc = loc_server_register(NAME); 671 692 if (rc != EOK) { -
uspace/srv/hid/input/port/niagara.c
rf6ab787 rce3efa0 127 127 /** 128 128 * Called regularly by the polling thread. Reads codes of all the 129 * pressed keys from the buffer. 129 * pressed keys from the buffer. 130 130 */ 131 131 static void niagara_key_pressed(void) -
uspace/srv/hid/input/port/ski.c
rf6ab787 rce3efa0 109 109 if (c == 0) 110 110 break; 111 111 112 kbd_push_data(kbd_dev, c); 112 113 } -
uspace/srv/hid/output/output.c
rf6ab787 rce3efa0 432 432 srv_set_rgb_color(callid, &call); 433 433 break; 434 435 434 case OUTPUT_UPDATE: 436 435 srv_update(callid, &call); -
uspace/srv/hid/remcons/remcons.c
rf6ab787 rce3efa0 225 225 { 226 226 telnet_user_t *user = arg; 227 int rc; 228 227 229 228 char term[LOC_NAME_MAXLEN]; 230 229 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name); 231 230 232 231 task_id_t task; 233 rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL);232 int rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL); 234 233 if (rc != EOK) { 235 234 telnet_user_error(user, "Spawning `%s -w %s %s' failed: %s.",
Note:
See TracChangeset
for help on using the changeset viewer.