Changeset 0e6e77f in mainline for uspace/lib/display/src/display.c


Ignore:
Timestamp:
2020-02-28T15:44:55Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a8eed5f
Parents:
2a515dcd
git-author:
Jiri Svoboda <jiri@…> (2020-02-26 18:26:13)
git-committer:
Jiri Svoboda <jiri@…> (2020-02-28 15:44:55)
Message:

Window resize by client request

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/src/display.c

    r2a515dcd r0e6e77f  
    3838#include <mem.h>
    3939#include <stdlib.h>
     40#include "../private/params.h"
    4041
    4142static errno_t display_callback_create(display_t *);
     
    237238
    238239        *rgc = ipc_gc_get_ctx(gc);
     240        return EOK;
     241}
     242
     243/** Resize display window.
     244 *
     245 * It seems resizing windows should be easy with bounding rectangles.
     246 * You have an old bounding rectangle and a new bounding rectangle (@a nrect).
     247 * Change .p0 and top-left corner moves. Change .p1 and bottom-right corner
     248 * moves. Piece of cake!
     249 *
     250 * There's always a catch, though. By series of resizes and moves .p0 could
     251 * drift outside of the range of @c gfx_coord_t. Now what? @a offs to the
     252 * rescue! @a offs moves the @em boundaries of the window with respect
     253 * to the display, while keeping the @em contents of the window in the
     254 * same place (with respect to the display). In other words, @a offs shifts
     255 * the window's internal coordinate system.
     256 *
     257 * A few examples follow:
     258 *
     259 * Enlarge window by moving bottom-right corner 1 right, 1 down:
     260 *
     261 *   bound = (0, 0, 10, 10)
     262 *   offs  = (0, 0)
     263 *   nrect = (0, 0, 11, 11)
     264 *
     265 * Enlarge window by moving top-left corner, 1 up, 1 left, allowing the
     266 * window-relative coordinate of the top-left corner to drift (undesirable)
     267 *
     268 *   bound = (0, 0, 10, 10)
     269 *   offs  = (0, 0)
     270 *   nrect = (-1, -1, 10, 10) <- this is the new bounding rectangle
     271 *
     272 * Enlarge window by moving top-left corner 1 up, 1 left, keeping top-left
     273 * corner locked to (0,0) window-relative coordinates (desirable):
     274 *
     275 *   bound = (0, 0, 10, 10)
     276 *   off   = (-1,-1)        <- top-left corner goes 1 up, 1 left
     277 *   nrect = (0, 0, 11, 11) <- window still starts at 0,0 window-relative
     278 *
     279 * @param window Window
     280 * @param nrect New bounding rectangle
     281 * @param offs
     282 * @return EOK on success or an error code. In both cases @a window must
     283 *         not be accessed anymore
     284 */
     285errno_t display_window_resize(display_window_t *window, gfx_coord2_t *offs,
     286    gfx_rect_t *nrect)
     287{
     288        async_exch_t *exch;
     289        aid_t req;
     290        ipc_call_t answer;
     291        display_wnd_move_t wmove;
     292        errno_t rc;
     293
     294        wmove.offs = *offs;
     295        wmove.nrect = *nrect;
     296
     297        exch = async_exchange_begin(window->display->sess);
     298        req = async_send_1(exch, DISPLAY_WINDOW_RESIZE, window->id, &answer);
     299        rc = async_data_write_start(exch, &wmove, sizeof (display_wnd_move_t));
     300        async_exchange_end(exch);
     301        if (rc != EOK) {
     302                async_forget(req);
     303                return rc;
     304        }
     305
     306        async_wait_for(req, &rc);
     307        if (rc != EOK)
     308                return rc;
     309
    239310        return EOK;
    240311}
Note: See TracChangeset for help on using the changeset viewer.