Changeset af967ef9 in mainline


Ignore:
Timestamp:
2023-10-10T17:37:09Z (7 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9ae472
Parents:
bd2fab5
Message:

GFX Demo should quit more prompty

File:
1 edited

Legend:

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

    rbd2fab5 raf967ef9  
    6969
    7070static bool quit = false;
     71static FIBRIL_MUTEX_INITIALIZE(quit_lock);
     72static FIBRIL_CONDVAR_INITIALIZE(quit_cv);
    7173static gfx_typeface_t *tface;
    7274static gfx_font_t *font;
     
    8385        // XXX Need a proper way to determine text mode
    8486        return w <= 80;
     87}
     88
     89/** Sleep until timeout or quit request.
     90 *
     91 * @param msec Number of microseconds to sleep for
     92 */
     93static void demo_msleep(unsigned msec)
     94{
     95        fibril_mutex_lock(&quit_lock);
     96
     97        if (!quit) {
     98                (void) fibril_condvar_wait_timeout(&quit_cv, &quit_lock,
     99                    (usec_t)msec * 1000);
     100        }
     101
     102        fibril_mutex_unlock(&quit_lock);
    85103}
    86104
     
    316334                gfx_color_delete(color);
    317335
    318                 fibril_usleep(500 * 1000);
    319 
     336                demo_msleep(500);
    320337                if (quit)
    321338                        break;
     
    478495                        if (rc != EOK)
    479496                                goto error;
    480                         fibril_usleep(250 * 1000);
    481 
     497
     498                        demo_msleep(250);
    482499                        if (quit)
    483500                                goto out;
     
    539556                }
    540557
    541                 fibril_usleep(500 * 1000);
    542 
     558                demo_msleep(500);
    543559                if (quit)
    544560                        break;
     
    600616                }
    601617
    602                 fibril_usleep(500 * 1000);
    603 
     618                demo_msleep(500);
    604619                if (quit)
    605620                        break;
     
    791806
    792807        for (i = 0; i < 10; i++) {
    793                 fibril_usleep(500 * 1000);
     808                demo_msleep(500);
    794809                if (quit)
    795810                        break;
     
    872887
    873888        for (i = 0; i < 10; i++) {
    874                 fibril_usleep(500 * 1000);
     889                demo_msleep(500);
    875890                if (quit)
    876891                        break;
     
    969984                }
    970985
    971                 fibril_usleep(500 * 1000);
    972 
     986                demo_msleep(500);
    973987                if (quit)
    974988                        break;
     
    11781192}
    11791193
     1194static void demo_quit(void)
     1195{
     1196        fibril_mutex_lock(&quit_lock);
     1197        quit = true;
     1198        fibril_mutex_unlock(&quit_lock);
     1199        fibril_condvar_broadcast(&quit_cv);
     1200}
     1201
    11801202static void wnd_close_event(void *arg)
    11811203{
    1182         quit = true;
     1204        demo_quit();
    11831205}
    11841206
     
    11861208{
    11871209        if (event->type == KEY_PRESS)
    1188                 quit = true;
     1210                demo_quit();
    11891211}
    11901212
    11911213static void uiwnd_close_event(ui_window_t *window, void *arg)
    11921214{
    1193         quit = true;
     1215        demo_quit();
    11941216}
    11951217
     
    11971219{
    11981220        if (event->type == KEY_PRESS)
    1199                 quit = true;
     1221                demo_quit();
    12001222}
    12011223
Note: See TracChangeset for help on using the changeset viewer.