Changeset 8a9a41e in mainline for uspace/lib/ui/src/ui.c


Ignore:
Timestamp:
2021-10-24T08:28:43Z (2 years ago)
Author:
GitHub <noreply@…>
Children:
f628215
Parents:
2ce943a (diff), cd981f2a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
git-committer:
GitHub <noreply@…> (2021-10-24 08:28:43)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/ui.c

    r2ce943a r8a9a41e  
    3939#include <errno.h>
    4040#include <fibril.h>
     41#include <gfx/color.h>
     42#include <gfx/render.h>
    4143#include <io/console.h>
    4244#include <stdbool.h>
     
    5355 *
    5456 * Output specification has the form <proto>@<service> where proto is
    55  * eiher 'disp' for display service or 'cons' for console. Service
    56  * is a location ID service name (e.g. hid/display).
     57 * eiher 'disp' for display service, 'cons' for console, 'null'
     58 * for dummy output. Service is a location ID service name (e.g. hid/display).
    5759 *
    5860 * @param ospec Output specification
     
    8082                } else if (str_lcmp(ospec, "cons@", str_length("cons@")) == 0) {
    8183                        *ws = ui_ws_console;
     84                } else if (str_lcmp(ospec, "null@", str_length("null@")) == 0) {
     85                        *ws = ui_ws_null;
    8286                } else {
    8387                        *ws = ui_ws_unknown;
     
    97101 *
    98102 * @param ospec Output specification or @c UI_DISPLAY_DEFAULT to use
    99  *              the default output
     103 *              the default display service, UI_CONSOLE_DEFAULT to use
     104 *              the default console service, UI_DISPLAY_NULL to use
     105 *              dummy output.
    100106 * @param rui Place to store pointer to new UI
    101107 * @return EOK on success or an error code
     
    109115        ui_winsys_t ws;
    110116        const char *osvc;
     117        sysarg_t cols;
     118        sysarg_t rows;
    111119        ui_t *ui;
    112120
     
    128136                        return EIO;
    129137
     138                rc = console_get_size(console, &cols, &rows);
     139                if (rc != EOK) {
     140                        console_done(console);
     141                        return rc;
     142                }
     143
     144                console_cursor_visibility(console, false);
     145
    130146                /* ws == ui_ws_console */
    131147                rc = ui_create_cons(console, &ui);
     
    143159
    144160                ui->cgc = cgc;
     161                ui->rect.p0.x = 0;
     162                ui->rect.p0.y = 0;
     163                ui->rect.p1.x = cols;
     164                ui->rect.p1.y = rows;
     165
     166                (void) ui_paint(ui);
     167        } else if (ws == ui_ws_null) {
     168                rc = ui_create_disp(NULL, &ui);
     169                if (rc != EOK)
     170                        return rc;
    145171        } else {
    146172                return EINVAL;
     
    203229                if (ui->cgc != NULL)
    204230                        console_gc_delete(ui->cgc);
    205                 if (ui->console != NULL)
     231                if (ui->console != NULL) {
     232                        console_cursor_visibility(ui->console, true);
    206233                        console_done(ui->console);
     234                }
    207235                if (ui->display != NULL)
    208236                        display_close(ui->display);
     
    216244        ui_window_t *awnd;
    217245        ui_evclaim_t claim;
     246        pos_event_t pos;
    218247
    219248        awnd = ui_window_get_active(ui);
     
    226255                break;
    227256        case CEV_POS:
    228                 claim = ui_wdecor_pos_event(awnd->wdecor, &event->ev.pos);
     257                pos = event->ev.pos;
     258                /* Translate event to window-relative coordinates */
     259                pos.hpos -= awnd->dpos.x;
     260                pos.vpos -= awnd->dpos.y;
     261
     262                claim = ui_wdecor_pos_event(awnd->wdecor, &pos);
    229263                /* Note: If event is claimed, awnd might not be valid anymore */
    230264                if (claim == ui_unclaimed)
    231                         ui_window_send_pos(awnd, &event->ev.pos);
     265                        ui_window_send_pos(awnd, &pos);
     266
    232267                break;
    233268        }
     
    280315{
    281316        errno_t rc;
     317        gfx_context_t *gc;
    282318        ui_window_t *awnd;
     319        gfx_color_t *color = NULL;
     320
     321        /* In case of null output */
     322        if (ui->cgc == NULL)
     323                return EOK;
     324
     325        gc = console_gc_get_ctx(ui->cgc);
     326
     327        rc = gfx_color_new_ega(0x11, &color);
     328        if (rc != EOK)
     329                return rc;
     330
     331        rc = gfx_set_color(gc, color);
     332        if (rc != EOK) {
     333                gfx_color_delete(color);
     334                return rc;
     335        }
     336
     337        rc = gfx_fill_rect(gc, &ui->rect);
     338        if (rc != EOK) {
     339                gfx_color_delete(color);
     340                return rc;
     341        }
     342
     343        gfx_color_delete(color);
    283344
    284345        /* XXX Should repaint all windows */
Note: See TracChangeset for help on using the changeset viewer.