Changeset 9b502dd in mainline


Ignore:
Timestamp:
2020-03-15T18:16:58Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b3825aa
Parents:
03c8081
Message:

Maintain minimum window size in display server

Location:
uspace
Files:
5 edited

Legend:

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

    r03c8081 r9b502dd  
    4848        /** Bounding rectangle */
    4949        gfx_rect_t rect;
     50        /** Minimum size (when being resized) */
     51        gfx_coord2_t min_size;
    5052} display_wnd_params_t;
    5153
  • uspace/lib/display/test/display.c

    r03c8081 r9b502dd  
    9797        bool window_create_called;
    9898        gfx_rect_t create_rect;
     99        gfx_coord2_t create_min_size;
    99100        bool window_destroy_called;
    100101        sysarg_t destroy_wnd_id;
     
    183184        params.rect.p0.x = 100;
    184185        params.rect.p0.y = 100;
     186        params.min_size.x = 11;
     187        params.min_size.y = 12;
    185188
    186189        rc = display_window_create(disp, &params, &test_display_wnd_cb,
     
    191194        PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
    192195        PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
     196        PCUT_ASSERT_EQUALS(params.min_size.x, resp.create_min_size.x);
     197        PCUT_ASSERT_EQUALS(params.min_size.y, resp.create_min_size.y);
    193198        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
    194199        PCUT_ASSERT_NULL(wnd);
     
    12381243        resp->window_create_called = true;
    12391244        resp->create_rect = params->rect;
     1245        resp->create_min_size = params->min_size;
    12401246        if (resp->rc == EOK)
    12411247                *rwnd_id = resp->wnd_id;
  • uspace/lib/gui/window.c

    r03c8081 r9b502dd  
    645645        wparams.rect.p1.x = 100;
    646646        wparams.rect.p1.y = 100;
     647        wparams.min_size.x = 2 * border_thickness + header_min_width;
     648        wparams.min_size.y = 2 * border_thickness + header_height;
    647649
    648650        rc = display_window_create(win->display, &wparams, &window_cb,
  • uspace/srv/hid/display/types/display/window.h

    r03c8081 r9b502dd  
    7070        /** Display position */
    7171        gfx_coord2_t dpos;
     72        /** Minimum size */
     73        gfx_coord2_t min_size;
    7274        /** Window ID */
    7375        ds_wnd_id_t id;
  • uspace/srv/hid/display/window.c

    r03c8081 r9b502dd  
    4343#include <io/log.h>
    4444#include <io/pixelmap.h>
     45#include <macros.h>
    4546#include <stdlib.h>
    4647#include "client.h"
     
    302303
    303304        wnd->rect = params->rect;
     305        wnd->min_size = params->min_size;
    304306        wnd->gc = gc;
    305307        *rgc = wnd;
     
    750752    gfx_rect_t *nrect)
    751753{
    752         *nrect = wnd->rect;
    753 
    754         if ((wnd->rsztype & display_wr_top) != 0)
    755                 nrect->p0.y += dresize->y;
    756         if ((wnd->rsztype & display_wr_left) != 0)
    757                 nrect->p0.x += dresize->x;
    758         if ((wnd->rsztype & display_wr_bottom) != 0)
    759                 nrect->p1.y += dresize->y;
    760         if ((wnd->rsztype & display_wr_right) != 0)
    761                 nrect->p1.x += dresize->x;
     754        if ((wnd->rsztype & display_wr_top) != 0) {
     755                nrect->p0.y = min(wnd->rect.p0.y + dresize->y,
     756                    wnd->rect.p1.y - wnd->min_size.y);
     757        } else {
     758                nrect->p0.y = wnd->rect.p0.y;
     759        }
     760
     761        if ((wnd->rsztype & display_wr_left) != 0) {
     762                nrect->p0.x = min(wnd->rect.p0.x + dresize->x,
     763                    wnd->rect.p1.x - wnd->min_size.x);
     764        } else {
     765                nrect->p0.x = wnd->rect.p0.x;
     766        }
     767
     768        if ((wnd->rsztype & display_wr_bottom) != 0) {
     769                nrect->p1.y = max(wnd->rect.p1.y + dresize->y,
     770                    wnd->rect.p0.y + wnd->min_size.y);
     771        } else {
     772                nrect->p1.y = wnd->rect.p1.y;
     773        }
     774
     775        if ((wnd->rsztype & display_wr_right) != 0) {
     776                nrect->p1.x = max(wnd->rect.p1.x + dresize->x,
     777                    wnd->rect.p0.x + wnd->min_size.x);
     778        } else {
     779                nrect->p1.x = wnd->rect.p1.x;
     780        }
    762781}
    763782
Note: See TracChangeset for help on using the changeset viewer.