Changeset 0680854 in mainline for uspace/lib/gui/window.c


Ignore:
Timestamp:
2020-03-20T15:42:27Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b7e394
Parents:
aeb3037
git-author:
Jiri Svoboda <jiri@…> (2020-03-19 19:42:21)
git-committer:
Jiri Svoboda <jiri@…> (2020-03-20 15:42:27)
Message:

Moving window by client request, emulate window placement flags

File:
1 edited

Legend:

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

    raeb3037 r0680854  
    375375        gfx_bitmap_t *new_bitmap = NULL;
    376376        gfx_coord2_t offs;
     377        gfx_coord2_t dpos;
     378        display_info_t dinfo;
     379        gfx_rect_t drect;
    377380        gfx_rect_t nrect;
    378381        errno_t rc;
     
    460463
    461464                surface_destroy(new_surface);
    462         } else {
    463                 if (old_bitmap != NULL)
    464                         gfx_bitmap_destroy(old_bitmap);
    465                 /* Deallocate old surface. */
    466                 if (old_surface)
    467                         surface_destroy(old_surface);
    468 
    469                 (void) gfx_bitmap_render(win->bitmap, NULL, NULL);
    470         }
     465                return;
     466        }
     467
     468        if (old_bitmap != NULL)
     469                gfx_bitmap_destroy(old_bitmap);
     470        /* Deallocate old surface. */
     471        if (old_surface)
     472                surface_destroy(old_surface);
     473
     474        if (placement_flags != WINDOW_PLACEMENT_ANY) {
     475                dpos.x = 0;
     476                dpos.y = 0;
     477
     478                rc = display_get_info(win->display, &dinfo);
     479                if (rc != EOK) {
     480                        (void) gfx_bitmap_render(win->bitmap, NULL, NULL);
     481                        return;
     482                }
     483
     484                drect = dinfo.rect;
     485
     486                if (placement_flags & WINDOW_PLACEMENT_LEFT)
     487                        dpos.x = drect.p0.x;
     488                else if (placement_flags & WINDOW_PLACEMENT_CENTER_X)
     489                        dpos.x = (drect.p0.x + drect.p0.y - width) / 2;
     490                else
     491                        dpos.x = drect.p1.x - width;
     492
     493                if (placement_flags & WINDOW_PLACEMENT_TOP)
     494                        dpos.y = drect.p0.y;
     495                else if (placement_flags & WINDOW_PLACEMENT_CENTER_Y)
     496                        dpos.y = (drect.p0.y + drect.p1.y - height) / 2;
     497                else
     498                        dpos.y = drect.p1.y - height;
     499
     500                (void) display_window_move(win->dwindow, &dpos);
     501        }
     502
     503        (void) gfx_bitmap_render(win->bitmap, NULL, NULL);
    471504}
    472505
Note: See TracChangeset for help on using the changeset viewer.