Changeset 4d8002d in mainline
- Timestamp:
- 2020-05-15T16:18:51Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4912dd59
- Parents:
- 6feccae
- Location:
- uspace
- Files:
-
- 8 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
r6feccae r4d8002d 40 40 #include <stdlib.h> 41 41 #include "client.h" 42 #include "cursimg.h" 43 #include "cursor.h" 42 44 #include "seat.h" 43 45 #include "window.h" … … 53 55 { 54 56 ds_display_t *disp; 57 ds_cursor_t *cursor; 58 int i; 55 59 errno_t rc; 56 60 … … 63 67 free(disp); 64 68 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; 65 80 } 66 81 … … 73 88 *rdisp = disp; 74 89 return EOK; 90 error: 91 ds_display_destroy(disp); 92 return rc; 75 93 } 76 94 … … 83 101 assert(list_empty(&disp->clients)); 84 102 assert(list_empty(&disp->seats)); 103 /* XXX destroy cursors */ 85 104 gfx_color_delete(disp->bg_color); 86 105 free(disp); … … 462 481 } 463 482 483 /** Add cursor to display. 484 * 485 * @param display Display 486 * @param cursor Cursor 487 */ 488 void 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 */ 501 void ds_display_remove_cursor(ds_cursor_t *cursor) 502 { 503 list_remove(&cursor->ldisplay); 504 cursor->display = NULL; 505 } 506 464 507 // XXX 465 508 gfx_context_t *ds_display_get_gc(ds_display_t *display) -
uspace/srv/hid/display/display.h
r6feccae r4d8002d 43 43 #include <io/kbd_event.h> 44 44 #include "types/display/client.h" 45 #include "types/display/cursor.h" 45 46 #include "types/display/ddev.h" 46 47 #include "types/display/display.h" … … 75 76 extern ds_ddev_t *ds_display_first_ddev(ds_display_t *); 76 77 extern ds_ddev_t *ds_display_next_ddev(ds_ddev_t *); 78 extern void ds_display_add_cursor(ds_display_t *, ds_cursor_t *); 79 extern void ds_display_remove_cursor(ds_cursor_t *); 77 80 extern gfx_context_t *ds_display_get_gc(ds_display_t *); 78 81 extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *); -
uspace/srv/hid/display/meson.build
r6feccae r4d8002d 31 31 src = files( 32 32 'client.c', 33 'cursor.c', 34 'cursimg.c', 33 35 'ddev.c', 34 36 'display.c', … … 43 45 test_src = files( 44 46 'client.c', 47 'cursimg.c', 48 'cursor.c', 45 49 'display.c', 46 50 'seat.c', 47 51 'window.c', 48 52 'test/client.c', 53 'test/cursor.c', 49 54 'test/display.c', 50 55 'test/main.c', -
uspace/srv/hid/display/seat.c
r6feccae r4d8002d 40 40 #include <stdlib.h> 41 41 #include "client.h" 42 #include "cursor.h" 42 43 #include "display.h" 43 44 #include "seat.h" … … 61 62 seat->pntpos.x = 0; 62 63 seat->pntpos.y = 0; 64 65 seat->cursor = display->cursor[dcurs_arrow]; 63 66 64 67 *rseat = seat; … … 142 145 } 143 146 144 /** Draw cross at seat pointer position.145 *146 * @param seat Seat147 * @param len Cross length148 * @param w Cross extra width149 * @param color Color150 *151 * @return EOK on success or an error code152 */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 193 147 /** Draw seat pointer 194 148 * … … 199 153 static errno_t ds_seat_draw_pointer(ds_seat_t *seat) 200 154 { 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); 231 156 } 232 157 … … 241 166 gfx_rect_t rect; 242 167 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 */ 248 172 return ds_display_paint(seat->display, &rect); 249 173 } -
uspace/srv/hid/display/types/display/display.h
r6feccae r4d8002d 42 42 #include <gfx/coord.h> 43 43 #include <io/input.h> 44 #include <types/display/cursor.h> 45 #include "cursor.h" 44 46 #include "window.h" 45 47 … … 74 76 gfx_color_t *bg_color; 75 77 78 /** Stock cursors */ 79 ds_cursor_t *cursor[dcurs_limit]; 80 81 /** List of all cursors */ 82 list_t cursors; 83 76 84 /** Bounding rectangle */ 77 85 gfx_rect_t rect; -
uspace/srv/hid/display/types/display/seat.h
r6feccae r4d8002d 48 48 /** Window this seat is focused on */ 49 49 struct ds_window *focus; 50 /** Current seat cursor */ 51 struct ds_cursor *cursor; 50 52 /** Pointer position */ 51 53 gfx_coord2_t pntpos; -
uspace/srv/hid/display/window.c
r6feccae r4d8002d 31 31 */ 32 32 /** 33 * @file GFX window backend 34 * 35 * This implements a graphics context over display server window. 33 * @file Display server window 36 34 */ 37 35
Note:
See TracChangeset
for help on using the changeset viewer.