Changeset 56dcf53 in mainline for uspace/lib/gui/window.c


Ignore:
Timestamp:
2020-06-22T17:30:07Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dbf5d7c
Parents:
c8e1f93
Message:

Avoid display artifacts when creating windows

Now the window only becomes noticeable when it's in the right place
and has the right size (it has 1x1 pixels before that). Still,
it first appears black. Ideally we'd only make if visible after
the client has painted the contents.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/window.c

    rc8e1f93 r56dcf53  
    6868static sysarg_t close_thickness = 20;
    6969static sysarg_t corner_size = 24;
     70static sysarg_t window_initial_size = 1;
    7071
    7172static pixel_t color_highlight = PIXEL(255, 255, 255, 255);
     
    428429        }
    429430
     431        /* Place window, if appropriate */
     432        if (placement_flags != WINDOW_PLACEMENT_ANY) {
     433                dpos.x = 0;
     434                dpos.y = 0;
     435
     436                rc = display_get_info(win->display, &dinfo);
     437                if (rc != EOK) {
     438                        fibril_mutex_unlock(&win->guard);
     439                        return;
     440                }
     441
     442                drect = dinfo.rect;
     443
     444                if (placement_flags & WINDOW_PLACEMENT_LEFT)
     445                        dpos.x = drect.p0.x;
     446                else if (placement_flags & WINDOW_PLACEMENT_CENTER_X)
     447                        dpos.x = (drect.p0.x + drect.p1.x - width) / 2;
     448                else
     449                        dpos.x = drect.p1.x - width;
     450
     451                if (placement_flags & WINDOW_PLACEMENT_TOP)
     452                        dpos.y = drect.p0.y;
     453                else if (placement_flags & WINDOW_PLACEMENT_CENTER_Y)
     454                        dpos.y = (drect.p0.y + drect.p1.y - height) / 2;
     455                else
     456                        dpos.y = drect.p1.y - height;
     457
     458                (void) display_window_move(win->dwindow, &dpos);
     459        }
     460
    430461        /* Resize the display window. */
    431462        offs.x = offset_x;
     
    437468
    438469        rc = display_window_resize(win->dwindow, &offs, &nrect);
    439         if (rc != EOK)
    440                 return;
     470        if (rc != EOK) {
     471                fibril_mutex_unlock(&win->guard);
     472                return;
     473        }
    441474
    442475        gfx_bitmap_params_init(&params);
     
    493526        surface_reset_damaged_region(win->surface);
    494527        fibril_mutex_unlock(&win->guard);
    495 
    496         if (placement_flags != WINDOW_PLACEMENT_ANY) {
    497                 dpos.x = 0;
    498                 dpos.y = 0;
    499 
    500                 rc = display_get_info(win->display, &dinfo);
    501                 if (rc != EOK) {
    502                         (void) gfx_bitmap_render(win->bitmap, NULL, NULL);
    503                         return;
    504                 }
    505 
    506                 drect = dinfo.rect;
    507 
    508                 if (placement_flags & WINDOW_PLACEMENT_LEFT)
    509                         dpos.x = drect.p0.x;
    510                 else if (placement_flags & WINDOW_PLACEMENT_CENTER_X)
    511                         dpos.x = (drect.p0.x + drect.p1.x - width) / 2;
    512                 else
    513                         dpos.x = drect.p1.x - width;
    514 
    515                 if (placement_flags & WINDOW_PLACEMENT_TOP)
    516                         dpos.y = drect.p0.y;
    517                 else if (placement_flags & WINDOW_PLACEMENT_CENTER_Y)
    518                         dpos.y = (drect.p0.y + drect.p1.y - height) / 2;
    519                 else
    520                         dpos.y = drect.p1.y - height;
    521 
    522                 (void) display_window_move(win->dwindow, &dpos);
    523         }
    524528
    525529        (void) gfx_bitmap_render(win->bitmap, NULL, NULL);
     
    688692
    689693        /* Allocate resources for new surface. */
    690         win->surface = surface_create(100, 100, NULL, SURFACE_FLAG_SHARED);
     694        win->surface = surface_create( window_initial_size,
     695            window_initial_size, NULL, SURFACE_FLAG_SHARED);
    691696        if (win->surface == NULL) {
    692697                free(win);
     
    705710        wparams.rect.p0.x = 0;
    706711        wparams.rect.p0.y = 0;
    707         wparams.rect.p1.x = 100;
    708         wparams.rect.p1.y = 100;
     712        wparams.rect.p1.x = window_initial_size;
     713        wparams.rect.p1.y = window_initial_size;
    709714        wparams.min_size.x = 2 * border_thickness + header_min_width;
    710715        wparams.min_size.y = 2 * border_thickness + header_height;
Note: See TracChangeset for help on using the changeset viewer.