- Timestamp:
- 2006-06-01T15:27:38Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3993b3d
- Parents:
- a2ae4f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fb/fb.c
ra2ae4f4 r88c3151 78 78 int bgcolor, fgcolor; 79 79 /* Auto-cursor position */ 80 int cursor_active, cur_ x, cur_y;80 int cursor_active, cur_col, cur_row; 81 81 } viewport_t; 82 82 … … 197 197 } 198 198 } 199 200 /** Optimized scroll for windows that cover whole lines */201 //static void scroll_optim(int vp, int rows)202 //{203 /* TODO */204 //}205 199 206 200 /** Scroll port up/down … … 323 317 return ELIMIT; 324 318 325 viewports[i].initialized = 1; 319 if (width ==0 || height == 0 || 320 x+width > screen.xres || y+height > screen.yres) 321 return EINVAL; 322 if (width < FONT_SCANLINES || height < COL_WIDTH) 323 return EINVAL; 324 326 325 viewports[i].x = x; 327 326 viewports[i].y = y; … … 335 334 viewports[i].fgcolor = DEFAULT_FGCOLOR; 336 335 336 viewports[i].initialized = 1; 337 337 338 return i; 338 339 } … … 415 416 } 416 417 418 static void draw_char(int vp, char c, unsigned int col, unsigned int row) 419 { 420 viewport_t *vport = &viewports[vp]; 421 422 if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row)) 423 invert_char(vp, vport->cur_col,vport->cur_row); 424 425 draw_glyph(vp, c, col, row); 426 427 if (vport->cursor_active) { 428 vport->cur_col++; 429 if (vport->cur_col>= vport->cols) { 430 vport->cur_col = 0; 431 vport->cur_row++; 432 if (vport->cur_row >= vport->rows) 433 vport->cur_row--; 434 } 435 invert_char(vp, vport->cur_col,vport->cur_row); 436 } 437 } 438 417 439 void client_connection(ipc_callid_t iid, ipc_call_t *icall) 418 440 { … … 423 445 unsigned int row,col; 424 446 char c; 447 425 448 int vp = 0; 449 viewport_t *vport = &viewports[0]; 426 450 427 451 if (client_connected) { … … 429 453 return; 430 454 } 455 client_connected = 1; 431 456 ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ 432 457 … … 438 463 /* cleanup other viewports */ 439 464 for (i=1; i < MAX_VIEWPORTS; i++) 440 v iewports[i].initialized = 0;465 vport->initialized = 0; 441 466 ipc_answer_fast(callid,0,0,0); 442 467 return; /* Exit thread */ … … 445 470 row = IPC_GET_ARG2(call); 446 471 col = IPC_GET_ARG3(call); 447 if (row >= v iewports[vp].rows || col >= viewports[vp].cols) {472 if (row >= vport->rows || col >= vport->cols) { 448 473 retval = EINVAL; 449 474 break; 450 475 } 451 476 ipc_answer_fast(callid,0,0,0); 452 draw_glyph(vp,c, row, col); 477 478 draw_char(vp, c, row, col); 453 479 continue; /* msg already answered */ 454 480 case FB_CLEAR: 455 481 clear_port(vp); 482 if (vport->cursor_active) 483 invert_char(vp, vport->cur_col,vport->cur_row); 456 484 retval = 0; 457 485 break; 458 /* case FB_CURSOR_GOTO: */ 459 /* retval = 0; */ 460 /* break; */ 461 /* case FB_CURSOR_VISIBILITY: */ 462 /* retval = 0; */ 463 /* break; */ 486 case FB_CURSOR_GOTO: 487 row = IPC_GET_ARG1(call); 488 col = IPC_GET_ARG2(call); 489 if (row >= vport->rows || col >= vport->cols) { 490 retval = EINVAL; 491 break; 492 } 493 retval = 0; 494 if (viewports[vp].cursor_active) { 495 invert_char(vp, vport->cur_col,vport->cur_row); 496 invert_char(vp, col, row); 497 } 498 vport->cur_col = col; 499 vport->cur_row = row; 500 break; 501 case FB_CURSOR_VISIBILITY: 502 i = IPC_GET_ARG1(call); 503 retval = 0; 504 if ((i && vport->cursor_active) || (!i && !vport->cursor_active)) 505 break; 506 507 vport->cursor_active = i; 508 invert_char(vp, vport->cur_col,vport->cur_row); 509 break; 464 510 case FB_GET_CSIZE: 465 ipc_answer_fast(callid, 0, viewports[vp].rows, viewports[vp].cols); 511 ipc_answer_fast(callid, 0, vport->rows, vport->cols); 512 continue; 513 case FB_SCROLL: 514 i = IPC_GET_ARG1(call); 515 if (i > vport->rows || i < (- (int)vport->rows)) { 516 retval = EINVAL; 517 break; 518 } 519 if (vport->cursor_active) 520 invert_char(vp, vport->cur_col,vport->cur_row); 521 scroll_port(vp, i); 522 if (vport->cursor_active) 523 invert_char(vp, vport->cur_col,vport->cur_row); 524 retval = 0; 525 break; 526 case FB_VIEWPORT_SWITCH: 527 i = IPC_GET_ARG1(call); 528 if (i < 0 || i >= MAX_VIEWPORTS) { 529 retval = EINVAL; 530 break; 531 } 532 if (! viewports[i].initialized ) { 533 retval = EADDRNOTAVAIL; 534 break; 535 } 536 vp = i; 537 vport = &viewports[vp]; 538 retval = 0; 539 break; 540 case FB_VIEWPORT_CREATE: 541 retval = viewport_create(IPC_GET_ARG1(call) >> 16, 542 IPC_GET_ARG1(call) & 0xffff, 543 IPC_GET_ARG2(call) >> 16, 544 IPC_GET_ARG2(call) & 0xffff); 545 break; 546 case FB_VIEWPORT_DELETE: 547 i = IPC_GET_ARG1(call); 548 if (i < 0 || i >= MAX_VIEWPORTS) { 549 retval = EINVAL; 550 break; 551 } 552 if (! viewports[i].initialized ) { 553 retval = EADDRNOTAVAIL; 554 break; 555 } 556 viewports[i].initialized = 0; 557 retval = 0; 558 break; 559 case FB_SET_STYLE: 560 vport->fgcolor = IPC_GET_ARG1(call); 561 vport->bgcolor = IPC_GET_ARG2(call); 562 retval = 0; 563 break; 564 case FB_GET_RESOLUTION: 565 ipc_answer_fast(callid, 0, screen.xres,screen.yres); 466 566 continue; 467 567 default: 468 568 retval = ENOENT; 469 569 } 470 retval = ENOENT;471 570 ipc_answer_fast(callid,retval,0,0); 472 571 }
Note:
See TracChangeset
for help on using the changeset viewer.