Changeset 9901f267 in mainline
- Timestamp:
- 2020-05-22T10:38:52Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef20a91
- Parents:
- 9242ad9
- git-author:
- Jiri Svoboda <jiri@…> (2020-05-21 17:38:41)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-05-22 10:38:52)
- Location:
- uspace
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/display/wndresize.h
r9242ad9 r9901f267 36 36 #define _LIBDISPLAY_DISPLAY_WNDRESIZE_H_ 37 37 38 #include <stdbool.h> 39 #include "../types/display/cursor.h" 38 40 #include "../types/display/wndresize.h" 41 42 extern display_stock_cursor_t display_cursor_from_wrsz(display_wnd_rsztype_t); 43 extern bool display_wndrsz_valid(display_wnd_rsztype_t); 39 44 40 45 #endif -
uspace/lib/display/meson.build
r9242ad9 r9901f267 31 31 'src/display.c', 32 32 'src/disp_srv.c', 33 'src/wndresize.c', 33 34 ) 34 35 … … 36 37 'test/display.c', 37 38 'test/main.c', 39 'test/wndresize.c', 38 40 ) -
uspace/lib/display/test/main.c
r9242ad9 r9901f267 1 1 /* 2 * Copyright (c) 20 19Jiri Svoboda2 * Copyright (c) 2020 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 32 32 33 33 PCUT_IMPORT(display); 34 PCUT_IMPORT(wndresize); 34 35 35 36 PCUT_MAIN(); -
uspace/srv/hid/display/dsops.c
r9242ad9 r9901f267 169 169 ds_window_t *wnd; 170 170 171 if (!display_wndrsz_valid(rsztype)) 172 return EINVAL; 173 171 174 ds_display_lock(client->display); 172 175 -
uspace/srv/hid/display/seat.c
r9242ad9 r9901f267 45 45 #include "window.h" 46 46 47 static errno_t ds_seat_clear_pointer(ds_seat_t *); 48 static errno_t ds_seat_draw_pointer(ds_seat_t *); 49 47 50 /** Create seat. 48 51 * … … 63 66 seat->pntpos.y = 0; 64 67 65 seat->cursor = display->cursor[dcurs_arrow]; 68 seat->client_cursor = display->cursor[dcurs_arrow]; 69 seat->wm_cursor = NULL; 66 70 67 71 *rseat = seat; … … 145 149 } 146 150 151 /** Get current cursor used by seat. 152 * 153 * @param wmcurs WM curor 154 * @param ccurs Client cursor 155 * @return 156 */ 157 static ds_cursor_t *ds_seat_compute_cursor(ds_cursor_t *wmcurs, ds_cursor_t *ccurs) 158 { 159 if (wmcurs != NULL) 160 return wmcurs; 161 162 return ccurs; 163 } 164 165 /** Get current cursor used by seat. 166 * 167 * @param seat Seat 168 * @return Current cursor 169 */ 170 static ds_cursor_t *ds_seat_get_cursor(ds_seat_t *seat) 171 { 172 return ds_seat_compute_cursor(seat->wm_cursor, seat->client_cursor); 173 } 174 175 /** Set client cursor. 176 * 177 * Set cursor selected by client. This may update the actual cursor 178 * if WM is not overriding the cursor. 179 * 180 * @param seat Seat 181 * @param cursor Client cursor 182 */ 183 static void ds_seat_set_client_cursor(ds_seat_t *seat, ds_cursor_t *cursor) 184 { 185 ds_cursor_t *old_cursor; 186 ds_cursor_t *new_cursor; 187 188 old_cursor = ds_seat_get_cursor(seat); 189 new_cursor = ds_seat_compute_cursor(seat->wm_cursor, cursor); 190 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); 198 } 199 200 /** Set WM cursor. 201 * 202 * Set cursor override for window management. 203 * 204 * @param seat Seat 205 * @param cursor WM cursor override or @c NULL not to override the cursor 206 */ 207 void ds_seat_set_wm_cursor(ds_seat_t *seat, ds_cursor_t *cursor) 208 { 209 ds_cursor_t *old_cursor; 210 ds_cursor_t *new_cursor; 211 212 old_cursor = ds_seat_get_cursor(seat); 213 new_cursor = ds_seat_compute_cursor(cursor, seat->client_cursor); 214 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 147 224 /** Draw seat pointer 148 225 * … … 153 230 static errno_t ds_seat_draw_pointer(ds_seat_t *seat) 154 231 { 155 return ds_cursor_paint(seat->cursor, &seat->pntpos); 232 ds_cursor_t *cursor; 233 234 cursor = ds_seat_get_cursor(seat); 235 return ds_cursor_paint(cursor, &seat->pntpos); 156 236 } 157 237 … … 165 245 { 166 246 gfx_rect_t rect; 247 ds_cursor_t *cursor; 248 249 cursor = ds_seat_get_cursor(seat); 167 250 168 251 /* Get rectangle covered by cursor */ 169 ds_cursor_get_rect( seat->cursor, &seat->pntpos, &rect);252 ds_cursor_get_rect(cursor, &seat->pntpos, &rect); 170 253 171 254 /* Repaint it */ … … 182 265 * @return EOK on success or an error code 183 266 */ 184 #include <stdio.h>185 267 errno_t ds_seat_post_ptd_event(ds_seat_t *seat, ptd_event_t *event) 186 268 { … … 279 361 if (wnd != NULL) { 280 362 /* Moving over a window */ 281 seat->cursor = wnd->cursor;363 ds_seat_set_client_cursor(seat, wnd->cursor); 282 364 283 365 rc = ds_window_post_pos_event(wnd, event); … … 286 368 } else { 287 369 /* Not over a window */ 288 seat->cursor = seat->display->cursor[dcurs_arrow];370 ds_seat_set_client_cursor(seat, seat->display->cursor[dcurs_arrow]); 289 371 } 290 372 -
uspace/srv/hid/display/seat.h
r9242ad9 r9901f267 52 52 extern errno_t ds_seat_post_ptd_event(ds_seat_t *, ptd_event_t *); 53 53 extern errno_t ds_seat_post_pos_event(ds_seat_t *, pos_event_t *); 54 extern void ds_seat_set_wm_cursor(ds_seat_t *, ds_cursor_t *); 54 55 55 56 #endif -
uspace/srv/hid/display/test/seat.c
r9242ad9 r9901f267 353 353 } 354 354 355 /** Set WM cursor */ 356 PCUT_TEST(set_wm_cursor) 357 { 358 ds_display_t *disp; 359 ds_client_t *client; 360 ds_seat_t *seat; 361 bool called_cb = false; 362 errno_t rc; 363 364 rc = ds_display_create(NULL, &disp); 365 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 366 367 rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client); 368 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 369 370 rc = ds_seat_create(disp, &seat); 371 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 372 373 ds_seat_set_wm_cursor(seat, disp->cursor[dcurs_size_ud]); 374 ds_seat_set_wm_cursor(seat, NULL); 375 376 ds_seat_destroy(seat); 377 ds_client_destroy(client); 378 ds_display_destroy(disp); 379 } 380 355 381 PCUT_EXPORT(seat); -
uspace/srv/hid/display/test/window.c
r9242ad9 r9901f267 36 36 #include "../client.h" 37 37 #include "../display.h" 38 #include "../seat.h" 38 39 #include "../window.h" 39 40 … … 55 56 ds_display_t *disp; 56 57 ds_client_t *client; 58 ds_seat_t *seat; 57 59 ds_window_t *wnd; 58 60 display_wnd_params_t params; … … 65 67 66 68 rc = ds_client_create(disp, NULL, NULL, &client); 69 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 70 71 rc = ds_seat_create(disp, &seat); 67 72 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 68 73 … … 89 94 90 95 ds_window_destroy(wnd); 96 ds_seat_destroy(seat); 91 97 ds_client_destroy(client); 92 98 ds_display_destroy(disp); … … 288 294 ds_display_t *disp; 289 295 ds_client_t *client; 296 ds_seat_t *seat; 290 297 ds_window_t *wnd; 291 298 display_wnd_params_t params; … … 300 307 301 308 rc = ds_client_create(disp, NULL, NULL, &client); 309 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 310 311 rc = ds_seat_create(disp, &seat); 302 312 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 303 313 … … 321 331 322 332 ds_window_destroy(wnd); 333 ds_seat_destroy(seat); 323 334 ds_client_destroy(client); 324 335 ds_display_destroy(disp); … … 639 650 } 640 651 641 642 652 static errno_t dummy_set_color(void *arg, gfx_color_t *color) 643 653 { -
uspace/srv/hid/display/types/display/seat.h
r9242ad9 r9901f267 48 48 /** Window this seat is focused on */ 49 49 struct ds_window *focus; 50 /** Current seat cursor */ 51 struct ds_cursor *cursor; 50 /** Cursor selected by client */ 51 struct ds_cursor *client_cursor; 52 /** Cursor override for window management or @c NULL */ 53 struct ds_cursor *wm_cursor; 52 54 /** Pointer position */ 53 55 gfx_coord2_t pntpos; -
uspace/srv/hid/display/window.c
r9242ad9 r9901f267 45 45 #include "client.h" 46 46 #include "display.h" 47 #include "seat.h" 47 48 #include "window.h" 48 49 … … 515 516 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos) 516 517 { 518 ds_seat_t *seat; 519 display_stock_cursor_t ctype; 520 517 521 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)", 518 522 (int) pos->x, (int) pos->y); … … 525 529 wnd->rsztype = rsztype; 526 530 wnd->preview_rect = wnd->rect; 531 532 // XXX Need client to tell us which seat started the resize! 533 seat = ds_display_first_seat(wnd->display); 534 ctype = display_cursor_from_wrsz(rsztype); 535 ds_seat_set_wm_cursor(seat, wnd->display->cursor[ctype]); 527 536 } 528 537 … … 536 545 gfx_coord2_t dresize; 537 546 gfx_rect_t nrect; 547 ds_seat_t *seat; 538 548 539 549 log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)", … … 552 562 wnd->state = dsw_idle; 553 563 ds_client_post_resize_event(wnd->client, wnd, &nrect); 564 565 // XXX Need to know which seat started the resize! 566 seat = ds_display_first_seat(wnd->display); 567 ds_seat_set_wm_cursor(seat, NULL); 554 568 } 555 569
Note:
See TracChangeset
for help on using the changeset viewer.