Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/terminal.c

    r5d94b16c ra116f7f2  
    7777static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
    7878static void term_set_cursor_visibility(con_srv_t *, bool);
    79 static int term_get_event(con_srv_t *, kbd_event_t *);
     79static int term_get_event(con_srv_t *, cons_event_t *);
    8080
    8181static con_ops_t con_ops = {
     
    104104static void getterm(const char *svc, const char *app)
    105105{
    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);
    116108}
    117109
     
    194186        //        for full UTF-32 coverage.
    195187       
    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);
    201189       
    202190        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;
    207199                }
    208200        }
     201        surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES);
    209202}
    210203
     
    261254       
    262255        bool front_visibility =
    263             chargrid_get_cursor_visibility(term->frontbuf);
     256            chargrid_get_cursor_visibility(term->frontbuf) &&
     257            term->widget.window->is_focused;
    264258        bool back_visibility =
    265259            chargrid_get_cursor_visibility(term->backbuf);
     
    419413                if (pos < size) {
    420414                        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);
    422416                       
    423417                        /* 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) {
    425420                                wchar_t tmp[2] = {
    426                                         event->c,
     421                                        event->ev.key.c,
    427422                                        0
    428423                                };
     
    578573}
    579574
    580 static int term_get_event(con_srv_t *srv, kbd_event_t *event)
     575static int term_get_event(con_srv_t *srv, cons_event_t *event)
    581576{
    582577        terminal_t *term = srv_to_terminal(srv);
    583578        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);
    588583        return EOK;
    589584}
     
    633628}
    634629
     630static 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 */
    635645static void terminal_handle_keyboard_event(widget_t *widget,
    636646    kbd_event_t kbd_event)
    637647{
    638648        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
     657static 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        }
    661674}
    662675
     
    665678        terminal_t *term = NULL;
    666679       
    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) {
    670681                if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) {
    671682                        term = cur;
Note: See TracChangeset for help on using the changeset viewer.