Changeset 1bebc906 in mainline


Ignore:
Timestamp:
2021-06-10T12:51:21Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Parents:
4b72e81
git-author:
Jiri Svoboda <jiri@…> (2021-06-09 18:51:04)
git-committer:
Jiri Svoboda <jiri@…> (2021-06-10 12:51:21)
Message:

Allow setting initial window position (instead of moving the window)

To reduce display artifacts. We can create the menu popup windows
in the correct place from the start. The same goes for regular
windows with specific placement.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/include/types/display/wndparams.h

    r4b72e81 r1bebc906  
    4141typedef enum {
    4242        /** Popup window (capture events, no focus) */
    43         wndf_popup = 0x1
     43        wndf_popup = 0x1,
     44        /** Set specific initial window position */
     45        wndf_setpos = 0x2
    4446} display_wnd_flags_t;
    4547
     
    5658        /** Minimum size (when being resized) */
    5759        gfx_coord2_t min_size;
     60        /** Initial position (if flag wndf_setpos is set) */
     61        gfx_coord2_t pos;
    5862        /** Flags */
    5963        display_wnd_flags_t flags;
  • uspace/lib/ui/src/window.c

    r4b72e81 r1bebc906  
    109109}
    110110
    111 static errno_t ui_window_place(ui_window_t *window, display_t *display,
    112     display_info_t *info, ui_wnd_params_t *params)
    113 {
    114         gfx_coord2_t pos;
    115         errno_t rc;
    116 
     111/** Compute where window should be placed on the screen.
     112 *
     113 * This only applies to windows that do not use default placement.
     114 *
     115 * @param window Window
     116 * @param display Display
     117 * @param info Display info
     118 * @param params Window parameters
     119 * @param pos Place to store position of top-left corner
     120 */
     121static void ui_window_place(ui_window_t *window, display_t *display,
     122    display_info_t *info, ui_wnd_params_t *params, gfx_coord2_t *pos)
     123{
    117124        assert(params->placement != ui_wnd_place_default);
    118125
    119         pos.x = 0;
    120         pos.y = 0;
     126        pos->x = 0;
     127        pos->y = 0;
     128
    121129        switch (params->placement) {
    122130        case ui_wnd_place_default:
     
    124132        case ui_wnd_place_top_left:
    125133        case ui_wnd_place_full_screen:
    126                 pos.x = info->rect.p0.x - params->rect.p0.x;
    127                 pos.y = info->rect.p0.y - params->rect.p0.y;
     134                pos->x = info->rect.p0.x - params->rect.p0.x;
     135                pos->y = info->rect.p0.y - params->rect.p0.y;
    128136                break;
    129137        case ui_wnd_place_top_right:
    130                 pos.x = info->rect.p1.x - params->rect.p1.x;
    131                 pos.y = info->rect.p0.y - params->rect.p0.y;
     138                pos->x = info->rect.p1.x - params->rect.p1.x;
     139                pos->y = info->rect.p0.y - params->rect.p0.y;
    132140                break;
    133141        case ui_wnd_place_bottom_left:
    134                 pos.x = info->rect.p0.x - params->rect.p0.x;
    135                 pos.y = info->rect.p1.y - params->rect.p1.y;
     142                pos->x = info->rect.p0.x - params->rect.p0.x;
     143                pos->y = info->rect.p1.y - params->rect.p1.y;
    136144                break;
    137145        case ui_wnd_place_bottom_right:
    138                 pos.x = info->rect.p1.x - params->rect.p1.x;
    139                 pos.y = info->rect.p1.y - params->rect.p1.y;
     146                pos->x = info->rect.p1.x - params->rect.p1.x;
     147                pos->y = info->rect.p1.y - params->rect.p1.y;
    140148                break;
    141149        case ui_wnd_place_popup:
    142150                /* Place popup window below parent rectangle */
    143                 pos.x = params->prect.p0.x;
    144                 pos.y = params->prect.p1.y;
     151                pos->x = params->prect.p0.x;
     152                pos->y = params->prect.p1.y;
    145153                break;
    146154        }
    147 
    148         rc = display_window_move(window->dwindow, &pos);
    149         if (rc != EOK)
    150                 goto error;
    151 
    152         return EOK;
    153 error:
    154         return rc;
    155155}
    156156
     
    205205                }
    206206
     207                if (params->placement != ui_wnd_place_default) {
     208                        /* Set initial display window position */
     209                        ui_window_place(window, ui->display, &info,
     210                            params, &dparams.pos);
     211
     212                        dparams.flags |= wndf_setpos;
     213                }
     214
    207215                rc = display_window_create(ui->display, &dparams, &dwnd_cb,
    208216                    (void *) window, &window->dwindow);
    209217                if (rc != EOK)
    210218                        goto error;
    211 
    212                 if (params->placement != ui_wnd_place_default) {
    213                         rc = ui_window_place(window, ui->display, &info,
    214                             params);
    215                         if (rc != EOK)
    216                                 goto error;
    217                 }
    218219
    219220                rc = display_window_get_gc(window->dwindow, &gc);
  • uspace/srv/hid/display/window.c

    r4b72e81 r1bebc906  
    119119        wnd->flags = params->flags;
    120120
    121         wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
    122         wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
     121        if ((params->flags & wndf_setpos) != 0) {
     122                /* Specific window position */
     123                wnd->dpos = params->pos;
     124        } else {
     125                /* Automatic window placement */
     126                wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
     127                wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
     128        }
    123129
    124130        seat = ds_display_first_seat(client->display);
Note: See TracChangeset for help on using the changeset viewer.