Changeset ea15a89a in mainline for uspace/lib/gui/terminal.c
- Timestamp:
- 2013-04-29T14:26:22Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 533e2d7, 94dfb92
- Parents:
- b2fa2d86 (diff), 9e7898e (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
rb2fa2d86 rea15a89a 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 = { … … 420 420 if (pos < size) { 421 421 link_t *link = prodcons_consume(&term->input_pc); 422 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); 423 423 424 424 /* Accept key presses of printable chars only. */ 425 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) { 426 427 wchar_t tmp[2] = { 427 event-> c,428 event->ev.key.c, 428 429 0 429 430 }; … … 579 580 } 580 581 581 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) 582 583 { 583 584 terminal_t *term = srv_to_terminal(srv); 584 585 link_t *link = prodcons_consume(&term->input_pc); 585 kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link);586 587 *event = * kevent;588 free( kevent);586 cons_event_t *ev = list_get_instance(link, cons_event_t, link); 587 588 *event = *ev; 589 free(ev); 589 590 return EOK; 590 591 } … … 634 635 } 635 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 */ 636 652 static void terminal_handle_keyboard_event(widget_t *widget, 637 653 kbd_event_t kbd_event) 638 654 { 639 655 terminal_t *term = (terminal_t *) widget; 640 641 /* Got key press/release event */ 642 kbd_event_t *event = 643 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 644 if (event == NULL) 645 return; 646 647 link_initialize(&event->link); 648 event->type = kbd_event.type; 649 event->key = kbd_event.key; 650 event->mods = kbd_event.mods; 651 event->c = kbd_event.c; 652 653 prodcons_produce(&term->input_pc, &event->link); 654 } 655 656 static void terminal_handle_position_event(widget_t *widget, pos_event_t event) 657 { 658 /* 659 * Mouse events are ignored so far. 660 * There is no consumer for it. 661 */ 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 } 662 681 } 663 682
Note:
See TracChangeset
for help on using the changeset viewer.