Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/window.c

    r2e0a2e7 r1215db9  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4949#include "window.h"
    5050
    51 static void ds_window_update_cb(void *, gfx_rect_t *);
     51static void ds_window_invalidate_cb(void *, gfx_rect_t *);
     52static void ds_window_update_cb(void *);
    5253static void ds_window_get_preview_rect(ds_window_t *, gfx_rect_t *);
     54
     55static mem_gc_cb_t ds_window_mem_gc_cb = {
     56        .invalidate = ds_window_invalidate_cb,
     57        .update = ds_window_update_cb
     58};
    5359
    5460/** Create window.
     
    6672{
    6773        ds_window_t *wnd = NULL;
     74        ds_seat_t *seat;
    6875        gfx_context_t *dgc;
    6976        gfx_coord2_t dims;
     
    106113        }
    107114
    108         rc = mem_gc_create(&params->rect, &alloc, ds_window_update_cb,
     115        rc = mem_gc_create(&params->rect, &alloc, &ds_window_mem_gc_cb,
    109116            (void *)wnd, &wnd->mgc);
    110117        if (rc != EOK)
     
    115122        wnd->gc = mem_gc_get_ctx(wnd->mgc);
    116123        wnd->cursor = wnd->display->cursor[dcurs_arrow];
     124        wnd->flags = params->flags;
     125
     126        if ((params->flags & wndf_setpos) != 0) {
     127                /* Specific window position */
     128                wnd->dpos = params->pos;
     129        } else {
     130                /* Automatic window placement */
     131                wnd->dpos.x = ((wnd->id - 1) & 1) * 400;
     132                wnd->dpos.y = ((wnd->id - 1) & 2) / 2 * 300;
     133        }
     134
     135        seat = ds_display_first_seat(client->display);
     136
     137        if ((params->flags & wndf_popup) != 0)
     138                ds_seat_set_popup(seat, wnd);
     139        else
     140                ds_seat_set_focus(seat, wnd);
     141
     142        (void) ds_display_paint(wnd->display, NULL);
     143
    117144        *rgc = wnd;
    118145        return EOK;
     
    657684}
    658685
     686/** Get window position.
     687 *
     688 * @param wnd Window
     689 */
     690void ds_window_get_pos(ds_window_t *wnd, gfx_coord2_t *dpos)
     691{
     692        *dpos = wnd->dpos;
     693}
     694
    659695/** Start resizing a window, detected by client.
    660696 *
     
    789825}
    790826
    791 /** Window memory GC update callback.
    792  *
    793  * This is called by the window's memory GC when a rectangle us updated.
    794  */
    795 static void ds_window_update_cb(void *arg, gfx_rect_t *rect)
     827/** Window memory GC invalidate callback.
     828 *
     829 * This is called by the window's memory GC when a rectangle is modified.
     830 */
     831static void ds_window_invalidate_cb(void *arg, gfx_rect_t *rect)
    796832{
    797833        ds_window_t *wnd = (ds_window_t *)arg;
     
    806842}
    807843
     844/** Window memory GC update callback.
     845 *
     846 * This is called by the window's memory GC when it is to be updated.
     847 */
     848static void ds_window_update_cb(void *arg)
     849{
     850        ds_window_t *wnd = (ds_window_t *)arg;
     851
     852        (void) wnd;
     853}
     854
    808855/** @}
    809856 */
Note: See TracChangeset for help on using the changeset viewer.