Changeset 25eec4e in mainline for uspace/lib/gui/terminal.c
- Timestamp:
- 2013-04-19T18:38:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d717a4
- Parents:
- a1e2df13 (diff), 289cb7dd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gui/terminal.c
ra1e2df13 r25eec4e 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 = { … … 196 196 uint16_t glyph = fb_font_glyph(field->ch); 197 197 198 // FIXME: This font drawing routine is shamelessly199 // suboptimal. It should be optimized for200 // aligned memory transfers, etc.201 202 198 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); 199 pixel_t *dst = pixelmap_pixel_at( 200 surface_pixmap_access(surface), bx, by + y); 201 pixel_t *dst_max = pixelmap_pixel_at( 202 surface_pixmap_access(surface), bx + FONT_WIDTH - 1, by + y); 203 if (!dst || !dst_max) continue; 204 int count = FONT_WIDTH; 205 while (count-- != 0) { 206 *dst++ = (fb_font[glyph][y] & (1 << count)) ? fgcolor : bgcolor; 207 207 } 208 208 } 209 surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES); 209 210 } 210 211 … … 419 420 if (pos < size) { 420 421 link_t *link = prodcons_consume(&term->input_pc); 421 kbd_event_t *event = list_get_instance(link, kbd_event_t, link);422 cons_event_t *event = list_get_instance(link, cons_event_t, link); 422 423 423 424 /* Accept key presses of printable chars only. */ 424 if ((event->type == KEY_PRESS) && (event->c != 0)) { 425 if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS && 426 event->ev.key.c != 0) { 425 427 wchar_t tmp[2] = { 426 event-> c,428 event->ev.key.c, 427 429 0 428 430 }; … … 578 580 } 579 581 580 static int term_get_event(con_srv_t *srv, kbd_event_t *event)582 static int term_get_event(con_srv_t *srv, cons_event_t *event) 581 583 { 582 584 terminal_t *term = srv_to_terminal(srv); 583 585 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);586 cons_event_t *ev = list_get_instance(link, cons_event_t, link); 587 588 *event = *ev; 589 free(ev); 588 590 return EOK; 589 591 } … … 633 635 } 634 636 637 static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev) 638 { 639 /* Got key press/release event */ 640 cons_event_t *event = 641 (cons_event_t *) malloc(sizeof(cons_event_t)); 642 if (event == NULL) 643 return; 644 645 *event = *ev; 646 link_initialize(&event->link); 647 648 prodcons_produce(&term->input_pc, &event->link); 649 } 650 651 /* Got key press/release event */ 635 652 static void terminal_handle_keyboard_event(widget_t *widget, 636 653 kbd_event_t kbd_event) 637 654 { 638 655 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 */ 656 cons_event_t event; 657 658 event.type = CEV_KEY; 659 event.ev.key = kbd_event; 660 661 terminal_queue_cons_event(term, &event); 662 } 663 664 static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event) 665 { 666 cons_event_t event; 667 terminal_t *term = (terminal_t *) widget; 668 sysarg_t sx = term->widget.hpos; 669 sysarg_t sy = term->widget.vpos; 670 671 if (pos_event.type == POS_PRESS) { 672 event.type = CEV_POS; 673 event.ev.pos.type = pos_event.type; 674 event.ev.pos.pos_id = pos_event.pos_id; 675 event.ev.pos.btn_num = pos_event.btn_num; 676 677 event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH; 678 event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES; 679 terminal_queue_cons_event(term, &event); 680 } 661 681 } 662 682
Note:
See TracChangeset
for help on using the changeset viewer.