Subversion Repositories HelenOS-historic

Rev

Rev 1498 | Rev 1501 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1498 Rev 1500
Line 74... Line 74...
74
    unsigned int rows, cols;
74
    unsigned int rows, cols;
75
    /* Style for text printing */
75
    /* Style for text printing */
76
    int bgcolor, fgcolor;
76
    int bgcolor, fgcolor;
77
    /* Auto-cursor position */
77
    /* Auto-cursor position */
78
    int cursor_active, cur_col, cur_row;
78
    int cursor_active, cur_col, cur_row;
-
 
79
    int cursor_shown;
79
} viewport_t;
80
} viewport_t;
80
 
81
 
81
#define MAX_VIEWPORTS 128
82
#define MAX_VIEWPORTS 128
82
static viewport_t viewports[128];
83
static viewport_t viewports[128];
83
 
84
 
Line 393... Line 394...
393
    viewport_create(0,0,xres,yres);
394
    viewport_create(0,0,xres,yres);
394
 
395
 
395
    clear_port(0);
396
    clear_port(0);
396
}
397
}
397
 
398
 
-
 
399
static void cursor_hide(int vp)
-
 
400
{
-
 
401
    viewport_t *vport = &viewports[vp];
-
 
402
 
-
 
403
    if (vport->cursor_active && vport->cursor_shown) {
-
 
404
        invert_char(vp, vport->cur_row, vport->cur_col);
-
 
405
        vport->cursor_shown = 0;
-
 
406
    }
-
 
407
}
-
 
408
 
-
 
409
static void cursor_print(int vp)
-
 
410
{
-
 
411
    viewport_t *vport = &viewports[vp];
-
 
412
 
-
 
413
    /* Do not check for cursor_shown */
-
 
414
    if (vport->cursor_active) {
-
 
415
        invert_char(vp, vport->cur_row, vport->cur_col);
-
 
416
        vport->cursor_shown = 1;
-
 
417
    }
-
 
418
}
-
 
419
 
-
 
420
static void cursor_blink(int vp)
-
 
421
{
-
 
422
    viewport_t *vport = &viewports[vp];
-
 
423
 
-
 
424
    if (vport->cursor_shown)
-
 
425
        cursor_hide(vp);
-
 
426
    else
-
 
427
        cursor_print(vp);
-
 
428
}
-
 
429
 
398
/** Draw character at given position relative to viewport
430
/** Draw character at given position relative to viewport
399
 *
431
 *
400
 * @param vp Viewport identification
432
 * @param vp Viewport identification
401
 * @param c Character to print
433
 * @param c Character to print
402
 * @param row Screen position relative to viewport
434
 * @param row Screen position relative to viewport
Line 404... Line 436...
404
 */
436
 */
405
static void draw_char(int vp, char c, unsigned int row, unsigned int col)
437
static void draw_char(int vp, char c, unsigned int row, unsigned int col)
406
{
438
{
407
    viewport_t *vport = &viewports[vp];
439
    viewport_t *vport = &viewports[vp];
408
 
440
 
-
 
441
    /* Optimize - do not hide cursor if we are going to overwrite it */
-
 
442
    if (vport->cursor_active && vport->cursor_shown &&
409
    if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row))
443
        (vport->cur_col != col || vport->cur_row != row))
410
        invert_char(vp, vport->cur_row, vport->cur_col);
444
        invert_char(vp, vport->cur_row, vport->cur_col);
411
   
445
   
412
    draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES);
446
    draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES);
413
 
447
 
414
    vport->cur_col = col;
448
    vport->cur_col = col;
Line 419... Line 453...
419
        vport->cur_col = 0;
453
        vport->cur_col = 0;
420
        vport->cur_row++;
454
        vport->cur_row++;
421
        if (vport->cur_row >= vport->rows)
455
        if (vport->cur_row >= vport->rows)
422
            vport->cur_row--;
456
            vport->cur_row--;
423
    }
457
    }
424
    if (vport->cursor_active)
458
    cursor_print(vp);
425
        invert_char(vp, vport->cur_row, vport->cur_col);
-
 
426
}
459
}
427
 
460
 
428
/** Function for handling connections to FB
461
/** Function for handling connections to FB
429
 *
462
 *
430
 */
463
 */
Line 446... Line 479...
446
    }
479
    }
447
    client_connected = 1;
480
    client_connected = 1;
448
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
481
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
449
 
482
 
450
    while (1) {
483
    while (1) {
451
        callid = async_get_call(&call);
484
        callid = async_get_call_timeout(&call,250000);
-
 
485
        if (!callid) {
-
 
486
            cursor_blink(vp);
-
 
487
            continue;
-
 
488
        }
452
        switch (IPC_GET_METHOD(call)) {
489
        switch (IPC_GET_METHOD(call)) {
453
        case IPC_M_PHONE_HUNGUP:
490
        case IPC_M_PHONE_HUNGUP:
454
            client_connected = 0;
491
            client_connected = 0;
455
            /* cleanup other viewports */
492
            /* cleanup other viewports */
456
            for (i=1; i < MAX_VIEWPORTS; i++)
493
            for (i=1; i < MAX_VIEWPORTS; i++)
Line 469... Line 506...
469
 
506
 
470
            draw_char(vp, c, row, col);
507
            draw_char(vp, c, row, col);
471
            continue; /* msg already answered */
508
            continue; /* msg already answered */
472
        case FB_CLEAR:
509
        case FB_CLEAR:
473
            clear_port(vp);
510
            clear_port(vp);
474
            if (vport->cursor_active)
511
            cursor_print(vp);
475
                invert_char(vp, vport->cur_row, vport->cur_col);
-
 
476
            retval = 0;
512
            retval = 0;
477
            break;
513
            break;
478
        case FB_CURSOR_GOTO:
514
        case FB_CURSOR_GOTO:
479
            row = IPC_GET_ARG1(call);
515
            row = IPC_GET_ARG1(call);
480
            col = IPC_GET_ARG2(call);
516
            col = IPC_GET_ARG2(call);
481
            if (row >= vport->rows || col >= vport->cols) {
517
            if (row >= vport->rows || col >= vport->cols) {
482
                retval = EINVAL;
518
                retval = EINVAL;
483
                break;
519
                break;
484
            }
520
            }
485
            retval = 0;
521
            retval = 0;
486
            if (viewports[vp].cursor_active) {
-
 
487
                invert_char(vp, vport->cur_row, vport->cur_col);
-
 
488
                invert_char(vp, row, col);
522
            cursor_hide(vp);
489
            }
-
 
490
            vport->cur_col = col;
523
            vport->cur_col = col;
491
            vport->cur_row = row;
524
            vport->cur_row = row;
-
 
525
            cursor_print(vp);
492
            break;
526
            break;
493
        case FB_CURSOR_VISIBILITY:
527
        case FB_CURSOR_VISIBILITY:
-
 
528
            cursor_hide(vp);
494
            i = IPC_GET_ARG1(call);
529
            vport->cursor_active = IPC_GET_ARG1(call);
-
 
530
            cursor_print(vp);
495
            retval = 0;
531
            retval = 0;
496
            if ((i && vport->cursor_active) || (!i && !vport->cursor_active))
-
 
497
                break;
-
 
498
 
-
 
499
            vport->cursor_active = i;
-
 
500
            invert_char(vp, vport->cur_row, vport->cur_col);
-
 
501
            break;
532
            break;
502
        case FB_GET_CSIZE:
533
        case FB_GET_CSIZE:
503
            ipc_answer_fast(callid, 0, vport->rows, vport->cols);
534
            ipc_answer_fast(callid, 0, vport->rows, vport->cols);
504
            continue;
535
            continue;
505
        case FB_SCROLL:
536
        case FB_SCROLL:
506
            i = IPC_GET_ARG1(call);
537
            i = IPC_GET_ARG1(call);
507
            if (i > vport->rows || i < (- (int)vport->rows)) {
538
            if (i > vport->rows || i < (- (int)vport->rows)) {
508
                retval = EINVAL;
539
                retval = EINVAL;
509
                break;
540
                break;
510
            }
541
            }
511
            if (vport->cursor_active)
542
            cursor_hide(vp);
512
                invert_char(vp, vport->cur_row, vport->cur_col);
-
 
513
            scroll_port(vp, i);
543
            scroll_port(vp, i);
514
            if (vport->cursor_active)
544
            cursor_print(vp);
515
                invert_char(vp, vport->cur_row, vport->cur_col);
-
 
516
            retval = 0;
545
            retval = 0;
517
            break;
546
            break;
518
        case FB_VIEWPORT_SWITCH:
547
        case FB_VIEWPORT_SWITCH:
519
            i = IPC_GET_ARG1(call);
548
            i = IPC_GET_ARG1(call);
520
            if (i < 0 || i >= MAX_VIEWPORTS) {
549
            if (i < 0 || i >= MAX_VIEWPORTS) {
Line 523... Line 552...
523
            }
552
            }
524
            if (! viewports[i].initialized ) {
553
            if (! viewports[i].initialized ) {
525
                retval = EADDRNOTAVAIL;
554
                retval = EADDRNOTAVAIL;
526
                break;
555
                break;
527
            }
556
            }
-
 
557
            cursor_hide(vp);
528
            vp = i;
558
            vp = i;
529
            vport = &viewports[vp];
559
            vport = &viewports[vp];
-
 
560
            cursor_print(vp);
530
            retval = 0;
561
            retval = 0;
531
            break;
562
            break;
532
        case FB_VIEWPORT_CREATE:
563
        case FB_VIEWPORT_CREATE:
533
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
564
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
534
                         IPC_GET_ARG1(call) & 0xffff,
565
                         IPC_GET_ARG1(call) & 0xffff,