Changeset a4e4e29 in mainline


Ignore:
Timestamp:
2026-02-17T11:57:13Z (3 days ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
2c12135
Parents:
00d26202
git-author:
Jiri Svoboda <jiri@…> (2026-02-17 18:56:50)
git-committer:
Jiri Svoboda <jiri@…> (2026-02-17 11:57:13)
Message:

GFXDemo react to console resize in console mode.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/gfxdemo/gfxdemo.c

    r00d26202 ra4e4e29  
    7979static console_ctrl_t *con = NULL;
    8080static bool textmode;
     81static console_gc_t *cgc = NULL;
     82static unsigned scr_width, scr_height;
    8183static ui_t *ui;
    8284
     
    99101        usec_t usec;
    100102        cons_event_t cevent;
     103        sysarg_t cols, rows;
    101104
    102105        if (ui != NULL)
     
    113116                                                demo_kbd_event(&cevent.ev.key);
    114117                                                fibril_mutex_lock(&quit_lock);
     118                                        } else if (cevent.type == CEV_RESIZE) {
     119                                                rc = console_get_size(con,
     120                                                    &cols, &rows);
     121                                                if (rc == EOK) {
     122                                                        scr_width = cols;
     123                                                        scr_height = rows;
     124                                                }
     125                                                rc = console_gc_resize(cgc);
     126                                                if (rc != EOK)
     127                                                        exit(1);
    115128                                        }
    116129                                }
     
    10241037 *
    10251038 * @param gc Graphic context
    1026  * @param w Width
    1027  * @param h Height
    1028  */
    1029 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
    1030 {
    1031         errno_t rc;
    1032 
    1033         (void) demo_font_init(gc, w, h);
     1039 */
     1040static errno_t demo_loop(gfx_context_t *gc)
     1041{
     1042        errno_t rc;
     1043
     1044        (void) demo_font_init(gc, scr_width, scr_height);
    10341045
    10351046        while (!quit) {
    1036                 rc = demo_rects(gc, w, h);
    1037                 if (rc != EOK)
    1038                         goto error;
    1039 
    1040                 rc = demo_bitmap(gc, w, h);
    1041                 if (rc != EOK)
    1042                         goto error;
    1043 
    1044                 rc = demo_bitmap2(gc, w, h);
    1045                 if (rc != EOK)
    1046                         goto error;
    1047 
    1048                 rc = demo_bitmap_kc(gc, w, h);
    1049                 if (rc != EOK)
    1050                         goto error;
    1051 
    1052                 rc = demo_text(gc, w, h);
    1053                 if (rc != EOK)
    1054                         goto error;
    1055 
    1056                 rc = demo_text_abbr(gc, w, h);
    1057                 if (rc != EOK)
    1058                         goto error;
    1059 
    1060                 rc = demo_clip(gc, w, h);
     1047                rc = demo_rects(gc, scr_width, scr_height);
     1048                if (rc != EOK)
     1049                        goto error;
     1050
     1051                rc = demo_bitmap(gc, scr_width, scr_height);
     1052                if (rc != EOK)
     1053                        goto error;
     1054
     1055                rc = demo_bitmap2(gc, scr_width, scr_height);
     1056                if (rc != EOK)
     1057                        goto error;
     1058
     1059                rc = demo_bitmap_kc(gc, scr_width, scr_height);
     1060                if (rc != EOK)
     1061                        goto error;
     1062
     1063                rc = demo_text(gc, scr_width, scr_height);
     1064                if (rc != EOK)
     1065                        goto error;
     1066
     1067                rc = demo_text_abbr(gc, scr_width, scr_height);
     1068                if (rc != EOK)
     1069                        goto error;
     1070
     1071                rc = demo_clip(gc, scr_width, scr_height);
    10611072                if (rc != EOK)
    10621073                        goto error;
     
    10731084static errno_t demo_console(void)
    10741085{
    1075         console_gc_t *cgc = NULL;
    10761086        gfx_context_t *gc;
    10771087        sysarg_t cols, rows;
     
    10951105        textmode = true;
    10961106
    1097         rc = demo_loop(gc, cols, rows);
     1107        scr_width = cols;
     1108        scr_height = rows;
     1109
     1110        rc = demo_loop(gc);
    10981111        if (rc != EOK)
    10991112                return rc;
     
    11121125
    11131126        ui_lock(args->ui);
    1114         rc = demo_loop(args->gc, args->dims.x, args->dims.y);
     1127        scr_width = args->dims.x;
     1128        scr_height = args->dims.y;
     1129        rc = demo_loop(args->gc);
    11151130        ui_unlock(args->ui);
    11161131        ui_quit(args->ui);
     
    12591274        textmode = false;
    12601275
    1261         rc = demo_loop(gc, 400, 300);
     1276        scr_width = 400;
     1277        scr_height = 300;
     1278        rc = demo_loop(gc);
    12621279        if (rc != EOK)
    12631280                return rc;
  • uspace/lib/congfx/include/congfx/console.h

    r00d26202 ra4e4e29  
    4949extern errno_t console_gc_suspend(console_gc_t *);
    5050extern errno_t console_gc_resume(console_gc_t *);
     51extern errno_t console_gc_resize(console_gc_t *);
    5152extern gfx_context_t *console_gc_get_ctx(console_gc_t *);
    5253
  • uspace/lib/congfx/src/console.c

    r00d26202 ra4e4e29  
    314314}
    315315
     316/** Update console GC size after console resize.
     317 *
     318 * @param con Console object
     319 *
     320 * @return EOK on success or an error code
     321 */
     322errno_t console_gc_resize(console_gc_t *cgc)
     323{
     324        sysarg_t rows;
     325        sysarg_t cols;
     326        charfield_t *buf = NULL;
     327        errno_t rc;
     328
     329        console_unmap(cgc->con, cgc->buf);
     330        cgc->buf = NULL;
     331
     332        rc = console_get_size(cgc->con, &cols, &rows);
     333        if (rc != EOK)
     334                goto error;
     335
     336        rc = console_map(cgc->con, cols, rows, &buf);
     337        if (rc != EOK)
     338                goto error;
     339
     340        cgc->rect.p0.x = 0;
     341        cgc->rect.p0.y = 0;
     342        cgc->rect.p1.x = cols;
     343        cgc->rect.p1.y = rows;
     344        cgc->clip_rect = cgc->rect;
     345        cgc->buf = buf;
     346        return EOK;
     347error:
     348        return rc;
     349}
     350
     351
    316352/** Get generic graphic context from console GC.
    317353 *
Note: See TracChangeset for help on using the changeset viewer.