Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3c3657c in mainline


Ignore:
Timestamp:
2021-09-04T08:04:36Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
7896f23
Parents:
81d3612
Message:

Correctly position windows in fullscreen mode (only works with CSR)

This involves translating the rendering operations as well as
hardware cursor operations and position events. This currently
only works with client-side rendering (using memory GC for translation),
but not with server-side rendering (need a new special GC to translate
the operations).

Location:
uspace/lib/ui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/private/window.h

    r81d3612 r3c3657c  
    7474        /** Window rectangle */
    7575        gfx_rect_t rect;
     76        /** Display position (if fullscreen mode) */
     77        gfx_coord2_t dpos;
    7678        /** Application area bitmap */
    7779        gfx_bitmap_t *app_bmp;
  • uspace/lib/ui/src/ui.c

    r81d3612 r3c3657c  
    236236        ui_window_t *awnd;
    237237        ui_evclaim_t claim;
     238        pos_event_t pos;
    238239
    239240        awnd = ui_window_get_active(ui);
     
    246247                break;
    247248        case CEV_POS:
    248                 claim = ui_wdecor_pos_event(awnd->wdecor, &event->ev.pos);
     249                pos = event->ev.pos;
     250#ifdef CONFIG_UI_CS_RENDER
     251                /*
     252                 * TODO Enable translation for server-side rendering
     253                 * once we can translate rendering operations in this
     254                 * case.
     255                 */
     256                pos.hpos -= awnd->dpos.x;
     257                pos.vpos -= awnd->dpos.y;
     258#endif
     259
     260                claim = ui_wdecor_pos_event(awnd->wdecor, &pos);
    249261                /* Note: If event is claimed, awnd might not be valid anymore */
    250262                if (claim == ui_unclaimed)
    251                         ui_window_send_pos(awnd, &event->ev.pos);
     263                        ui_window_send_pos(awnd, &pos);
     264
    252265                break;
    253266        }
  • uspace/lib/ui/src/window.c

    r81d3612 r3c3657c  
    132132/** Compute where window should be placed on the screen.
    133133 *
    134  * This only applies to windows that do not use default placement.
    135  *
    136  * @param window Window
    137  * @param display Display
    138  * @param info Display info
     134 * This only applies to windows that do not use default placement or
     135 * if we are running in full-screen mode.
     136 *
     137 * @param window Window
     138 * @param drect Display rectangle
    139139 * @param params Window parameters
    140140 * @param pos Place to store position of top-left corner
    141141 */
    142 static void ui_window_place(ui_window_t *window, display_t *display,
    143     display_info_t *info, ui_wnd_params_t *params, gfx_coord2_t *pos)
    144 {
    145         assert(params->placement != ui_wnd_place_default);
     142static void ui_window_place(ui_window_t *window, gfx_rect_t *drect,
     143    ui_wnd_params_t *params, gfx_coord2_t *pos)
     144{
     145        gfx_coord2_t dims;
     146
     147        assert(params->placement != ui_wnd_place_default ||
     148            ui_is_fullscreen(window->ui));
    146149
    147150        pos->x = 0;
     
    150153        switch (params->placement) {
    151154        case ui_wnd_place_default:
    152                 assert(false);
     155                assert(ui_is_fullscreen(window->ui));
     156                /* Center window */
     157                gfx_rect_dims(&params->rect, &dims);
     158                pos->x = (drect->p0.x + drect->p1.x) / 2 - dims.x / 2;
     159                pos->y = (drect->p0.y + drect->p1.y) / 2 - dims.y / 2;
     160                break;
    153161        case ui_wnd_place_top_left:
    154162        case ui_wnd_place_full_screen:
    155                 pos->x = info->rect.p0.x - params->rect.p0.x;
    156                 pos->y = info->rect.p0.y - params->rect.p0.y;
     163                pos->x = drect->p0.x - params->rect.p0.x;
     164                pos->y = drect->p0.y - params->rect.p0.y;
    157165                break;
    158166        case ui_wnd_place_top_right:
    159                 pos->x = info->rect.p1.x - params->rect.p1.x;
    160                 pos->y = info->rect.p0.y - params->rect.p0.y;
     167                pos->x = drect->p1.x - params->rect.p1.x;
     168                pos->y = drect->p0.y - params->rect.p0.y;
    161169                break;
    162170        case ui_wnd_place_bottom_left:
    163                 pos->x = info->rect.p0.x - params->rect.p0.x;
    164                 pos->y = info->rect.p1.y - params->rect.p1.y;
     171                pos->x = drect->p0.x - params->rect.p0.x;
     172                pos->y = drect->p1.y - params->rect.p1.y;
    165173                break;
    166174        case ui_wnd_place_bottom_right:
    167                 pos->x = info->rect.p1.x - params->rect.p1.x;
    168                 pos->y = info->rect.p1.y - params->rect.p1.y;
     175                pos->x = drect->p1.x - params->rect.p1.x;
     176                pos->y = drect->p1.y - params->rect.p1.y;
    169177                break;
    170178        case ui_wnd_place_popup:
     
    204212                return ENOMEM;
    205213
     214        window->ui = ui;
     215
    206216        display_wnd_params_init(&dparams);
    207217        dparams.rect = params->rect;
     
    228238                if (params->placement != ui_wnd_place_default) {
    229239                        /* Set initial display window position */
    230                         ui_window_place(window, ui->display, &info,
    231                             params, &dparams.pos);
     240                        ui_window_place(window, &info.rect, params,
     241                            &dparams.pos);
    232242
    233243                        dparams.flags |= wndf_setpos;
     
    293303        window->gc = gc;
    294304#endif
     305        if (ui->display == NULL)
     306                ui_window_place(window, &ui->rect, params, &window->dpos);
    295307
    296308        rc = ui_resource_create(window->gc, ui_is_textmode(ui), &res);
     
    308320        ui_resource_set_expose_cb(res, ui_window_expose_cb, (void *) window);
    309321
    310         window->ui = ui;
    311322        window->rect = dparams.rect;
    312 
    313323        window->res = res;
    314324        window->wdecor = wdecor;
     
    594604                        return rc;
    595605        } else {
    596                 pos->x = 0;
    597                 pos->y = 0;
     606                *pos = window->dpos;
    598607        }
    599608
     
    10141023        ui_window_t *window = (ui_window_t *) arg;
    10151024
    1016         if (!gfx_rect_is_empty(&window->dirty_rect))
    1017                 (void) gfx_bitmap_render(window->bmp, &window->dirty_rect, NULL);
     1025        if (!gfx_rect_is_empty(&window->dirty_rect)) {
     1026                (void) gfx_bitmap_render(window->bmp, &window->dirty_rect,
     1027                    &window->dpos);
     1028        }
    10181029
    10191030        window->dirty_rect.p0.x = 0;
     
    10311042{
    10321043        ui_window_t *window = (ui_window_t *) arg;
    1033 
    1034         return gfx_cursor_get_pos(window->realgc, pos);
     1044        gfx_coord2_t cpos;
     1045        errno_t rc;
     1046
     1047        rc = gfx_cursor_get_pos(window->realgc, &cpos);
     1048        if (rc != EOK)
     1049                return rc;
     1050
     1051        pos->x = cpos.x - window->dpos.x;
     1052        pos->y = cpos.y - window->dpos.y;
     1053        return EOK;
    10351054}
    10361055
     
    10431062{
    10441063        ui_window_t *window = (ui_window_t *) arg;
    1045 
    1046         return gfx_cursor_set_pos(window->realgc, pos);
     1064        gfx_coord2_t cpos;
     1065
     1066        cpos.x = pos->x + window->dpos.x;
     1067        cpos.y = pos->y + window->dpos.y;
     1068
     1069        return gfx_cursor_set_pos(window->realgc, &cpos);
    10471070}
    10481071
Note: See TracChangeset for help on using the changeset viewer.