Changeset 4d8002d in mainline


Ignore:
Timestamp:
2020-05-15T16:18:51Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4912dd59
Parents:
6feccae
Message:

Bitmapped mouse cursor

Location:
uspace
Files:
8 added
7 edited

Legend:

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

    r6feccae r4d8002d  
    4040#include <stdlib.h>
    4141#include "client.h"
     42#include "cursimg.h"
     43#include "cursor.h"
    4244#include "seat.h"
    4345#include "window.h"
     
    5355{
    5456        ds_display_t *disp;
     57        ds_cursor_t *cursor;
     58        int i;
    5559        errno_t rc;
    5660
     
    6367                free(disp);
    6468                return ENOMEM;
     69        }
     70
     71        list_initialize(&disp->cursors);
     72
     73        for (i = 0; i < dcurs_limit; i++) {
     74                rc = ds_cursor_create(disp, &ds_cursimg[i].rect,
     75                    ds_cursimg[i].image, &cursor);
     76                if (rc != EOK)
     77                        goto error;
     78
     79                disp->cursor[i] = cursor;
    6580        }
    6681
     
    7388        *rdisp = disp;
    7489        return EOK;
     90error:
     91        ds_display_destroy(disp);
     92        return rc;
    7593}
    7694
     
    83101        assert(list_empty(&disp->clients));
    84102        assert(list_empty(&disp->seats));
     103        /* XXX destroy cursors */
    85104        gfx_color_delete(disp->bg_color);
    86105        free(disp);
     
    462481}
    463482
     483/** Add cursor to display.
     484 *
     485 * @param display Display
     486 * @param cursor Cursor
     487 */
     488void ds_display_add_cursor(ds_display_t *display, ds_cursor_t *cursor)
     489{
     490        assert(cursor->display == NULL);
     491        assert(!link_used(&cursor->ldisplay));
     492
     493        cursor->display = display;
     494        list_prepend(&cursor->ldisplay, &display->cursors);
     495}
     496
     497/** Remove cursor from display.
     498 *
     499 * @param cursor Cursor
     500 */
     501void ds_display_remove_cursor(ds_cursor_t *cursor)
     502{
     503        list_remove(&cursor->ldisplay);
     504        cursor->display = NULL;
     505}
     506
    464507// XXX
    465508gfx_context_t *ds_display_get_gc(ds_display_t *display)
  • uspace/srv/hid/display/display.h

    r6feccae r4d8002d  
    4343#include <io/kbd_event.h>
    4444#include "types/display/client.h"
     45#include "types/display/cursor.h"
    4546#include "types/display/ddev.h"
    4647#include "types/display/display.h"
     
    7576extern ds_ddev_t *ds_display_first_ddev(ds_display_t *);
    7677extern ds_ddev_t *ds_display_next_ddev(ds_ddev_t *);
     78extern void ds_display_add_cursor(ds_display_t *, ds_cursor_t *);
     79extern void ds_display_remove_cursor(ds_cursor_t *);
    7780extern gfx_context_t *ds_display_get_gc(ds_display_t *);
    7881extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *);
  • uspace/srv/hid/display/meson.build

    r6feccae r4d8002d  
    3131src = files(
    3232        'client.c',
     33        'cursor.c',
     34        'cursimg.c',
    3335        'ddev.c',
    3436        'display.c',
     
    4345test_src = files(
    4446        'client.c',
     47        'cursimg.c',
     48        'cursor.c',
    4549        'display.c',
    4650        'seat.c',
    4751        'window.c',
    4852        'test/client.c',
     53        'test/cursor.c',
    4954        'test/display.c',
    5055        'test/main.c',
  • uspace/srv/hid/display/seat.c

    r6feccae r4d8002d  
    4040#include <stdlib.h>
    4141#include "client.h"
     42#include "cursor.h"
    4243#include "display.h"
    4344#include "seat.h"
     
    6162        seat->pntpos.x = 0;
    6263        seat->pntpos.y = 0;
     64
     65        seat->cursor = display->cursor[dcurs_arrow];
    6366
    6467        *rseat = seat;
     
    142145}
    143146
    144 /** Draw cross at seat pointer position.
    145  *
    146  * @param seat Seat
    147  * @param len Cross length
    148  * @param w Cross extra width
    149  * @param color Color
    150  *
    151  * @return EOK on success or an error code
    152  */
    153 static errno_t ds_seat_draw_cross(ds_seat_t *seat, gfx_coord_t len,
    154     gfx_coord_t w, gfx_color_t *color)
    155 {
    156         gfx_context_t *gc;
    157         gfx_rect_t rect, r0;
    158         errno_t rc;
    159 
    160         gc = ds_display_get_gc(seat->display);
    161         if (gc == NULL)
    162                 return EOK;
    163 
    164         rc = gfx_set_color(gc, color);
    165         if (rc != EOK)
    166                 goto error;
    167 
    168         r0.p0.x = -len;
    169         r0.p0.y = -w;
    170         r0.p1.x = +len + 1;
    171         r0.p1.y = +w + 1;
    172         gfx_rect_translate(&seat->pntpos, &r0, &rect);
    173 
    174         rc = gfx_fill_rect(gc, &rect);
    175         if (rc != EOK)
    176                 goto error;
    177 
    178         r0.p0.x = -w;
    179         r0.p0.y = -len;
    180         r0.p1.x = +w + 1;
    181         r0.p1.y = +len + 1;
    182         gfx_rect_translate(&seat->pntpos, &r0, &rect);
    183 
    184         rc = gfx_fill_rect(gc, &rect);
    185         if (rc != EOK)
    186                 goto error;
    187 
    188         return EOK;
    189 error:
    190         return rc;
    191 }
    192 
    193147/** Draw seat pointer
    194148 *
     
    199153static errno_t ds_seat_draw_pointer(ds_seat_t *seat)
    200154{
    201         errno_t rc;
    202         gfx_color_t *black = NULL;
    203         gfx_color_t *white;
    204 
    205         rc = gfx_color_new_rgb_i16(0, 0, 0, &black);
    206         if (rc != EOK)
    207                 goto error;
    208 
    209         rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &white);
    210         if (rc != EOK)
    211                 goto error;
    212 
    213         rc = ds_seat_draw_cross(seat, 8, 1, black);
    214         if (rc != EOK)
    215                 goto error;
    216 
    217         rc = ds_seat_draw_cross(seat, 8, 0, white);
    218         if (rc != EOK)
    219                 goto error;
    220 
    221         gfx_color_delete(black);
    222         gfx_color_delete(white);
    223 
    224         return EOK;
    225 error:
    226         if (black != NULL)
    227                 gfx_color_delete(black);
    228         if (white != NULL)
    229                 gfx_color_delete(white);
    230         return rc;
     155        return ds_cursor_paint(seat->cursor, &seat->pntpos);
    231156}
    232157
     
    241166        gfx_rect_t rect;
    242167
    243         rect.p0.x = seat->pntpos.x - 8;
    244         rect.p0.y = seat->pntpos.y - 8;
    245         rect.p1.x = seat->pntpos.x + 8 + 1;
    246         rect.p1.y = seat->pntpos.y + 8 + 1;
    247 
     168        /* Get rectangle covered by cursor */
     169        ds_cursor_get_rect(seat->cursor, &seat->pntpos, &rect);
     170
     171        /* Repaint it */
    248172        return ds_display_paint(seat->display, &rect);
    249173}
  • uspace/srv/hid/display/types/display/display.h

    r6feccae r4d8002d  
    4242#include <gfx/coord.h>
    4343#include <io/input.h>
     44#include <types/display/cursor.h>
     45#include "cursor.h"
    4446#include "window.h"
    4547
     
    7476        gfx_color_t *bg_color;
    7577
     78        /** Stock cursors */
     79        ds_cursor_t *cursor[dcurs_limit];
     80
     81        /** List of all cursors */
     82        list_t cursors;
     83
    7684        /** Bounding rectangle */
    7785        gfx_rect_t rect;
  • uspace/srv/hid/display/types/display/seat.h

    r6feccae r4d8002d  
    4848        /** Window this seat is focused on */
    4949        struct ds_window *focus;
     50        /** Current seat cursor */
     51        struct ds_cursor *cursor;
    5052        /** Pointer position */
    5153        gfx_coord2_t pntpos;
  • uspace/srv/hid/display/window.c

    r6feccae r4d8002d  
    3131 */
    3232/**
    33  * @file GFX window backend
    34  *
    35  * This implements a graphics context over display server window.
     33 * @file Display server window
    3634 */
    3735
Note: See TracChangeset for help on using the changeset viewer.