Changeset 978c9bc5 in mainline


Ignore:
Timestamp:
2020-06-04T16:18:04Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d70e7b7b
Parents:
dbef30f
Message:

Pointer needs to be drawn as part of ds_display_paint

Everything needs to be painted from ds_display_paint. The pointers were
painted in an immediate fashion when they changed. Any window update
would wipe them.

Location:
uspace/srv/hid/display
Files:
3 edited

Legend:

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

    rdbef30f r978c9bc5  
    553553        errno_t rc;
    554554        ds_window_t *wnd;
     555        ds_seat_t *seat;
    555556
    556557        /* Paint background */
     
    569570        }
    570571
     572        seat = ds_display_first_seat(disp);
     573        while (seat != NULL) {
     574                rc = ds_seat_paint_pointer(seat, rect);
     575                if (rc != EOK)
     576                        return rc;
     577
     578                seat = ds_display_next_seat(seat);
     579        }
     580
    571581        return EOK;
    572582}
  • uspace/srv/hid/display/seat.c

    rdbef30f r978c9bc5  
    4545#include "window.h"
    4646
    47 static errno_t ds_seat_clear_pointer(ds_seat_t *);
    48 static errno_t ds_seat_draw_pointer(ds_seat_t *);
     47static void ds_seat_get_pointer_rect(ds_seat_t *, gfx_rect_t *);
     48static errno_t ds_seat_repaint_pointer(ds_seat_t *, gfx_rect_t *);
    4949
    5050/** Create seat.
     
    185185        ds_cursor_t *old_cursor;
    186186        ds_cursor_t *new_cursor;
     187        gfx_rect_t old_rect;
    187188
    188189        old_cursor = ds_seat_get_cursor(seat);
    189190        new_cursor = ds_seat_compute_cursor(seat->wm_cursor, cursor);
    190191
    191         if (new_cursor != old_cursor)
    192                 ds_seat_clear_pointer(seat);
    193 
    194         seat->client_cursor = cursor;
    195 
    196         if (new_cursor != old_cursor)
    197                 ds_seat_draw_pointer(seat);
     192        if (new_cursor != old_cursor) {
     193                ds_seat_get_pointer_rect(seat, &old_rect);
     194                seat->client_cursor = cursor;
     195                ds_seat_repaint_pointer(seat, &old_rect);
     196        } else {
     197                seat->client_cursor = cursor;
     198        }
    198199}
    199200
     
    209210        ds_cursor_t *old_cursor;
    210211        ds_cursor_t *new_cursor;
     212        gfx_rect_t old_rect;
    211213
    212214        old_cursor = ds_seat_get_cursor(seat);
    213215        new_cursor = ds_seat_compute_cursor(cursor, seat->client_cursor);
    214216
    215         if (new_cursor != old_cursor)
    216                 ds_seat_clear_pointer(seat);
    217 
    218         seat->wm_cursor = cursor;
    219 
    220         if (new_cursor != old_cursor)
    221                 ds_seat_draw_pointer(seat);
    222 }
    223 
    224 /** Draw seat pointer
    225  *
    226  * @param seat Seat
     217        if (new_cursor != old_cursor) {
     218                ds_seat_get_pointer_rect(seat, &old_rect);
     219                seat->wm_cursor = cursor;
     220                ds_seat_repaint_pointer(seat, &old_rect);
     221        } else {
     222                seat->wm_cursor = cursor;
     223        }
     224}
     225
     226/** Get rectangle covered by pointer.
     227 *
     228 * @param seat Seat
     229 * @param rect Place to store rectangle
     230 */
     231void ds_seat_get_pointer_rect(ds_seat_t *seat, gfx_rect_t *rect)
     232{
     233        ds_cursor_t *cursor;
     234
     235        cursor = ds_seat_get_cursor(seat);
     236        ds_cursor_get_rect(cursor, &seat->pntpos, rect);
     237}
     238
     239/** Repaint seat pointer
     240 *
     241 * Repaint the pointer after it has moved or changed. This is done by
     242 * repainting the are of the display previously (@a old_rect) and currently
     243 * covered by the pointer.
     244 *
     245 * @param seat Seat
     246 * @param old_rect Rectangle previously covered by pointer
    227247 *
    228248 * @return EOK on success or an error code
    229249 */
    230 static errno_t ds_seat_draw_pointer(ds_seat_t *seat)
    231 {
    232         ds_cursor_t *cursor;
    233 
    234         cursor = ds_seat_get_cursor(seat);
    235         return ds_cursor_paint(cursor, &seat->pntpos);
    236 }
    237 
    238 /** Clear seat pointer
    239  *
    240  * @param seat Seat
    241  *
    242  * @return EOK on success or an error code
    243  */
    244 static errno_t ds_seat_clear_pointer(ds_seat_t *seat)
    245 {
    246         gfx_rect_t rect;
    247         ds_cursor_t *cursor;
    248 
    249         cursor = ds_seat_get_cursor(seat);
    250 
    251         /* Get rectangle covered by cursor */
    252         ds_cursor_get_rect(cursor, &seat->pntpos, &rect);
    253 
    254         /* Repaint it */
    255         return ds_display_paint(seat->display, &rect);
     250static errno_t ds_seat_repaint_pointer(ds_seat_t *seat, gfx_rect_t *old_rect)
     251{
     252        gfx_rect_t new_rect;
     253        gfx_rect_t isect;
     254        gfx_rect_t envelope;
     255        errno_t rc;
     256
     257        ds_seat_get_pointer_rect(seat, &new_rect);
     258
     259        gfx_rect_clip(old_rect, &new_rect, &isect);
     260        if (gfx_rect_is_empty(&isect)) {
     261                /* Rectangles do not intersect. Repaint them separately. */
     262                rc = ds_display_paint(seat->display, &new_rect);
     263                if (rc != EOK)
     264                        return rc;
     265
     266                rc = ds_display_paint(seat->display, old_rect);
     267                if (rc != EOK)
     268                        return rc;
     269        } else {
     270                /*
     271                 * Rectangles intersect. As an optimization, repaint them
     272                 * in a single operation.
     273                 */
     274                gfx_rect_envelope(old_rect, &new_rect, &envelope);
     275
     276                rc = ds_display_paint(seat->display, &envelope);
     277                if (rc != EOK)
     278                        return rc;
     279        }
     280
     281        return EOK;
    256282}
    257283
     
    269295        ds_display_t *disp = seat->display;
    270296        gfx_coord2_t npos;
     297        gfx_rect_t old_rect;
    271298        ds_window_t *wnd;
    272299        pos_event_t pevent;
     
    299326                gfx_coord2_clip(&npos, &disp->rect, &npos);
    300327
    301                 (void) ds_seat_clear_pointer(seat);
     328                ds_seat_get_pointer_rect(seat, &old_rect);
    302329                seat->pntpos = npos;
    303330
     
    312339                        return rc;
    313340
    314                 (void) ds_seat_draw_pointer(seat);
     341                ds_seat_repaint_pointer(seat, &old_rect);
    315342        }
    316343
     
    327354                gfx_coord2_clip(&npos, &disp->rect, &npos);
    328355
    329                 (void) ds_seat_clear_pointer(seat);
     356                ds_seat_get_pointer_rect(seat, &old_rect);
    330357                seat->pntpos = npos;
    331358
     
    340367                        return rc;
    341368
    342                 (void) ds_seat_draw_pointer(seat);
     369                ds_seat_repaint_pointer(seat, &old_rect);
    343370        }
    344371
     
    380407}
    381408
     409/** Paint seat pointer.
     410 *
     411 * @param seat Seat whose pointer to paint
     412 * @param rect Clipping rectangle
     413 */
     414errno_t ds_seat_paint_pointer(ds_seat_t *seat, gfx_rect_t *rect)
     415{
     416        ds_cursor_t *cursor;
     417
     418        cursor = ds_seat_get_cursor(seat);
     419        (void) rect; // XXX ds_cursor_paint should accept a clipping rectangle
     420        return ds_cursor_paint(cursor, &seat->pntpos);
     421}
     422
    382423/** @}
    383424 */
  • uspace/srv/hid/display/seat.h

    rdbef30f r978c9bc5  
    3838
    3939#include <errno.h>
     40#include <gfx/coord.h>
    4041#include <io/kbd_event.h>
    4142#include <io/pos_event.h>
     
    5354extern errno_t ds_seat_post_pos_event(ds_seat_t *, pos_event_t *);
    5455extern void ds_seat_set_wm_cursor(ds_seat_t *, ds_cursor_t *);
     56extern errno_t ds_seat_paint_pointer(ds_seat_t *, gfx_rect_t *);
    5557
    5658#endif
Note: See TracChangeset for help on using the changeset viewer.