Changes in uspace/lib/gui/terminal.c [5d94b16c:a116f7f2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gui/terminal.c
r5d94b16c ra116f7f2 77 77 static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t); 78 78 static void term_set_cursor_visibility(con_srv_t *, bool); 79 static int term_get_event(con_srv_t *, kbd_event_t *);79 static int term_get_event(con_srv_t *, cons_event_t *); 80 80 81 81 static con_ops_t con_ops = { … … 104 104 static void getterm(const char *svc, const char *app) 105 105 { 106 char term[LOC_NAME_MAXLEN]; 107 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc); 108 109 /* Wait for the terminal service to be ready */ 110 service_id_t service_id; 111 int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING); 112 if (rc != EOK) 113 return; 114 115 task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term, app, NULL); 106 task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc, 107 LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL); 116 108 } 117 109 … … 194 186 // for full UTF-32 coverage. 195 187 196 uint16_t glyph = fb_font_glyph(field->ch); 197 198 // FIXME: This font drawing routine is shamelessly 199 // suboptimal. It should be optimized for 200 // aligned memory transfers, etc. 188 uint16_t glyph = fb_font_glyph(field->ch, NULL); 201 189 202 190 for (unsigned int y = 0; y < FONT_SCANLINES; y++) { 203 for (unsigned int x = 0; x < FONT_WIDTH; x++) { 204 pixel_t pixel = 205 (fb_font[glyph][y] & (1 << (7 - x))) ? fgcolor : bgcolor; 206 surface_put_pixel(surface, bx + x, by + y, pixel); 191 pixel_t *dst = pixelmap_pixel_at( 192 surface_pixmap_access(surface), bx, by + y); 193 pixel_t *dst_max = pixelmap_pixel_at( 194 surface_pixmap_access(surface), bx + FONT_WIDTH - 1, by + y); 195 if (!dst || !dst_max) continue; 196 int count = FONT_WIDTH; 197 while (count-- != 0) { 198 *dst++ = (fb_font[glyph][y] & (1 << count)) ? fgcolor : bgcolor; 207 199 } 208 200 } 201 surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES); 209 202 } 210 203 … … 261 254 262 255 bool front_visibility = 263 chargrid_get_cursor_visibility(term->frontbuf); 256 chargrid_get_cursor_visibility(term->frontbuf) && 257 term->widget.window->is_focused; 264 258 bool back_visibility = 265 259 chargrid_get_cursor_visibility(term->backbuf); … … 419 413 if (pos < size) { 420 414 link_t *link = prodcons_consume(&term->input_pc); 421 kbd_event_t *event = list_get_instance(link, kbd_event_t, link);415 cons_event_t *event = list_get_instance(link, cons_event_t, link); 422 416 423 417 /* Accept key presses of printable chars only. */ 424 if ((event->type == KEY_PRESS) && (event->c != 0)) { 418 if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS && 419 event->ev.key.c != 0) { 425 420 wchar_t tmp[2] = { 426 event-> c,421 event->ev.key.c, 427 422 0 428 423 }; … … 578 573 } 579 574 580 static int term_get_event(con_srv_t *srv, kbd_event_t *event)575 static int term_get_event(con_srv_t *srv, cons_event_t *event) 581 576 { 582 577 terminal_t *term = srv_to_terminal(srv); 583 578 link_t *link = prodcons_consume(&term->input_pc); 584 kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);585 586 *event = * kevent;587 free( kevent);579 cons_event_t *ev = list_get_instance(link, cons_event_t, link); 580 581 *event = *ev; 582 free(ev); 588 583 return EOK; 589 584 } … … 633 628 } 634 629 630 static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev) 631 { 632 /* Got key press/release event */ 633 cons_event_t *event = 634 (cons_event_t *) malloc(sizeof(cons_event_t)); 635 if (event == NULL) 636 return; 637 638 *event = *ev; 639 link_initialize(&event->link); 640 641 prodcons_produce(&term->input_pc, &event->link); 642 } 643 644 /* Got key press/release event */ 635 645 static void terminal_handle_keyboard_event(widget_t *widget, 636 646 kbd_event_t kbd_event) 637 647 { 638 648 terminal_t *term = (terminal_t *) widget; 639 640 /* Got key press/release event */ 641 kbd_event_t *event = 642 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 643 if (event == NULL) 644 return; 645 646 link_initialize(&event->link); 647 event->type = kbd_event.type; 648 event->key = kbd_event.key; 649 event->mods = kbd_event.mods; 650 event->c = kbd_event.c; 651 652 prodcons_produce(&term->input_pc, &event->link); 653 } 654 655 static void terminal_handle_position_event(widget_t *widget, pos_event_t event) 656 { 657 /* 658 * Mouse events are ignored so far. 659 * There is no consumer for it. 660 */ 649 cons_event_t event; 650 651 event.type = CEV_KEY; 652 event.ev.key = kbd_event; 653 654 terminal_queue_cons_event(term, &event); 655 } 656 657 static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event) 658 { 659 cons_event_t event; 660 terminal_t *term = (terminal_t *) widget; 661 sysarg_t sx = term->widget.hpos; 662 sysarg_t sy = term->widget.vpos; 663 664 if (pos_event.type == POS_PRESS) { 665 event.type = CEV_POS; 666 event.ev.pos.type = pos_event.type; 667 event.ev.pos.pos_id = pos_event.pos_id; 668 event.ev.pos.btn_num = pos_event.btn_num; 669 670 event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH; 671 event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES; 672 terminal_queue_cons_event(term, &event); 673 } 661 674 } 662 675 … … 665 678 terminal_t *term = NULL; 666 679 667 list_foreach(terms, link) { 668 terminal_t *cur = list_get_instance(link, terminal_t, link); 669 680 list_foreach(terms, link, terminal_t, cur) { 670 681 if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) { 671 682 term = cur;
Note:
See TracChangeset
for help on using the changeset viewer.