Changeset b3c185b6 in mainline for uspace/app/gfxdemo/gfxdemo.c


Ignore:
Timestamp:
2019-11-04T14:05:35Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be15256
Parents:
22faaf2
git-author:
Jiri Svoboda <jiri@…> (2019-10-03 18:05:09)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-04 14:05:35)
Message:

Window event delivery mechanism

File:
1 edited

Legend:

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

    r22faaf2 rb3c185b6  
    4444#include <io/console.h>
    4545#include <io/pixelmap.h>
     46#include <stdbool.h>
    4647#include <stdlib.h>
    4748#include <str.h>
    4849#include <window.h>
     50
     51static void wnd_kbd_event(void *, kbd_event_t *);
     52
     53static display_wnd_cb_t wnd_cb = {
     54        .kbd_event = wnd_kbd_event
     55};
     56
     57static bool quit = false;
    4958
    5059/** Clear screen.
     
    126135
    127136                fibril_usleep(500 * 1000);
     137
     138                if (quit)
     139                        break;
    128140        }
    129141
     
    245257                                goto error;
    246258                        fibril_usleep(250 * 1000);
     259
     260                        if (quit)
     261                                break;
    247262                }
    248263        }
     
    298313
    299314                fibril_usleep(500 * 1000);
     315
     316                if (quit)
     317                        break;
    300318        }
    301319
     
    318336        errno_t rc;
    319337
    320         while (true) {
     338        while (!quit) {
    321339                rc = demo_rects(gc, w, h);
    322340                if (rc != EOK)
     
    331349                        return rc;
    332350        }
     351
     352        return EOK;
    333353}
    334354
     
    444464        }
    445465
    446         rc = display_window_create(display, &window);
     466        rc = display_window_create(display, &wnd_cb, NULL, &window);
    447467        if (rc != EOK) {
    448468                printf("Error creating window.\n");
     
    464484
    465485        return EOK;
     486}
     487
     488static void wnd_kbd_event(void *arg, kbd_event_t *event)
     489{
     490        printf("Keyboard event type=%d key=%d\n", event->type, event->key);
     491        quit = true;
    466492}
    467493
Note: See TracChangeset for help on using the changeset viewer.