Changeset 9242ad9 in mainline
- Timestamp:
- 2020-05-20T17:35:07Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9901f267
- Parents:
- 5480d5e
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/types/display/cursor.h
r5480d5e r9242ad9 52 52 enum { 53 53 /** Number of stock cursor types */ 54 dcurs_limit = dcurs_size_urdl 54 dcurs_limit = dcurs_size_urdl + 1 55 55 }; 56 56 -
uspace/lib/gui/window.c
r5480d5e r9242ad9 99 99 }; 100 100 101 static void set_cursor(window_t *window, display_stock_cursor_t cursor) 102 { 103 if (cursor != window->cursor) { 104 (void) display_window_set_cursor(window->dwindow, cursor); 105 window->cursor = cursor; 106 } 107 } 108 101 109 static void paint_internal(widget_t *widget) 102 110 { … … 294 302 bool close = (header) && 295 303 (event.hpos >= width - border_thickness - close_thickness); 304 305 if ((top && left) || (bottom && right)) 306 (void) set_cursor(widget->window, dcurs_size_uldr); 307 else if ((top && right) || (bottom && left)) 308 (void) set_cursor(widget->window, dcurs_size_urdl); 309 else if (top || bottom) 310 (void) set_cursor(widget->window, dcurs_size_ud); 311 else if (left || right) 312 (void) set_cursor(widget->window, dcurs_size_lr); 313 else 314 (void) set_cursor(widget->window, dcurs_arrow); 296 315 297 316 pos.x = event.hpos; … … 654 673 win->grab = NULL; 655 674 win->focus = NULL; 675 win->cursor = dcurs_arrow; 656 676 657 677 /* Allocate resources for new surface. */ -
uspace/lib/gui/window.h
r5480d5e r9242ad9 63 63 surface_t *surface; /**< Window surface shared with display server. */ 64 64 gfx_bitmap_t *bitmap; /**< Window bitmap */ 65 display_stock_cursor_t cursor; /**< Selected cursor */ 65 66 }; 66 67 -
uspace/srv/hid/display/cursimg.c
r5480d5e r9242ad9 61 61 }; 62 62 63 static uint8_t size_ud_img[] = { 64 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0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, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 136 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 137 }; 138 63 139 ds_cursimg_t ds_cursimg[dcurs_limit] = { 64 140 { 65 141 .rect = { 0, 0, 13, 21 }, 66 142 .image = arrow_img 143 }, 144 { 145 .rect = { -6, -10, 7, 11 }, 146 .image = size_ud_img 147 }, 148 { 149 .rect = { -10, -6, 11, 7 }, 150 .image = size_lr_img 151 }, 152 { 153 .rect = { -7, -7, 8, 8 }, 154 .image = size_uldr_img 155 }, 156 { 157 .rect = { -7, -7, 8, 8 }, 158 .image = size_urdl_img 67 159 } 68 160 }; -
uspace/srv/hid/display/dsops.c
r5480d5e r9242ad9 52 52 static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *, 53 53 gfx_rect_t *); 54 static errno_t disp_window_set_cursor(void *, sysarg_t, display_stock_cursor_t); 54 55 static errno_t disp_get_event(void *, sysarg_t *, display_wnd_ev_t *); 55 56 static errno_t disp_get_info(void *, display_info_t *); … … 62 63 .window_resize_req = disp_window_resize_req, 63 64 .window_resize = disp_window_resize, 65 .window_set_cursor = disp_window_set_cursor, 64 66 .get_event = disp_get_event, 65 67 .get_info = disp_get_info … … 202 204 } 203 205 206 static errno_t disp_window_set_cursor(void *arg, sysarg_t wnd_id, 207 display_stock_cursor_t cursor) 208 { 209 ds_client_t *client = (ds_client_t *) arg; 210 ds_window_t *wnd; 211 errno_t rc; 212 213 ds_display_lock(client->display); 214 215 wnd = ds_client_find_window(client, wnd_id); 216 if (wnd == NULL) { 217 ds_display_unlock(client->display); 218 return ENOENT; 219 } 220 221 log_msg(LOG_DEFAULT, LVL_NOTE, "disp_window_set_cursor()"); 222 rc = ds_window_set_cursor(wnd, cursor); 223 ds_display_unlock(client->display); 224 return rc; 225 } 226 204 227 static errno_t disp_get_event(void *arg, sysarg_t *wnd_id, 205 228 display_wnd_ev_t *event) -
uspace/srv/hid/display/seat.c
r5480d5e r9242ad9 278 278 wnd = ds_display_window_by_pos(seat->display, &seat->pntpos); 279 279 if (wnd != NULL) { 280 /* Moving over a window */ 281 seat->cursor = wnd->cursor; 282 280 283 rc = ds_window_post_pos_event(wnd, event); 281 284 if (rc != EOK) 282 285 return rc; 286 } else { 287 /* Not over a window */ 288 seat->cursor = seat->display->cursor[dcurs_arrow]; 283 289 } 284 290 -
uspace/srv/hid/display/test/window.c
r5480d5e r9242ad9 590 590 } 591 591 592 /** Test ds_window_set_cursor() */ 593 PCUT_TEST(window_set_cursor) 594 { 595 gfx_context_t *gc; 596 ds_display_t *disp; 597 ds_client_t *client; 598 ds_window_t *wnd; 599 display_wnd_params_t params; 600 errno_t rc; 601 602 rc = gfx_context_new(&dummy_ops, NULL, &gc); 603 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 604 605 rc = ds_display_create(gc, &disp); 606 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 607 608 rc = ds_client_create(disp, NULL, NULL, &client); 609 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 610 611 display_wnd_params_init(¶ms); 612 params.rect.p0.x = params.rect.p0.y = 0; 613 params.rect.p1.x = params.rect.p1.y = 1; 614 615 rc = ds_window_create(client, ¶ms, &wnd); 616 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 617 618 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor); 619 620 rc = ds_window_set_cursor(wnd, -1); 621 PCUT_ASSERT_ERRNO_VAL(EINVAL, rc); 622 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor); 623 624 rc = ds_window_set_cursor(wnd, dcurs_limit); 625 PCUT_ASSERT_ERRNO_VAL(EINVAL, rc); 626 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor); 627 628 rc = ds_window_set_cursor(wnd, dcurs_limit + 1); 629 PCUT_ASSERT_ERRNO_VAL(EINVAL, rc); 630 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor); 631 632 rc = ds_window_set_cursor(wnd, dcurs_size_lr); 633 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 634 PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_size_lr], wnd->cursor); 635 636 ds_window_destroy(wnd); 637 ds_client_destroy(client); 638 ds_display_destroy(disp); 639 } 640 641 592 642 static errno_t dummy_set_color(void *arg, gfx_color_t *color) 593 643 { -
uspace/srv/hid/display/types/display/window.h
r5480d5e r9242ad9 86 86 /** Current drawing color */ 87 87 pixel_t color; 88 /** Cursor set by client */ 89 struct ds_cursor *cursor; 88 90 89 91 /** State */ -
uspace/srv/hid/display/window.c
r5480d5e r9242ad9 309 309 wnd->min_size = params->min_size; 310 310 wnd->gc = gc; 311 wnd->cursor = wnd->display->cursor[dcurs_arrow]; 311 312 *rgc = wnd; 312 313 return EOK; … … 822 823 } 823 824 825 /** Set window cursor. 826 * 827 * @param wnd Window 828 * @return EOK on success, EINVAL if @a cursor is invalid 829 */ 830 errno_t ds_window_set_cursor(ds_window_t *wnd, display_stock_cursor_t cursor) 831 { 832 if (cursor >= dcurs_arrow && 833 cursor < (display_stock_cursor_t) dcurs_limit) { 834 wnd->cursor = wnd->display->cursor[cursor]; 835 return EOK; 836 } else { 837 return EINVAL; 838 } 839 } 840 824 841 /** @} 825 842 */ -
uspace/srv/hid/display/window.h
r5480d5e r9242ad9 44 44 #include <types/gfx/coord.h> 45 45 #include <types/gfx/ops/context.h> 46 #include "types/display/cursor.h" 46 47 #include "types/display/display.h" 47 48 #include "types/display/window.h" … … 66 67 extern void ds_window_calc_resize(ds_window_t *, gfx_coord2_t *, 67 68 gfx_rect_t *); 69 extern errno_t ds_window_set_cursor(ds_window_t *, display_stock_cursor_t); 68 70 69 71 #endif
Note:
See TracChangeset
for help on using the changeset viewer.