Changeset 978c9bc5 in mainline
- Timestamp:
- 2020-06-04T16:18:04Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d70e7b7b
- Parents:
- dbef30f
- Location:
- uspace/srv/hid/display
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
rdbef30f r978c9bc5 553 553 errno_t rc; 554 554 ds_window_t *wnd; 555 ds_seat_t *seat; 555 556 556 557 /* Paint background */ … … 569 570 } 570 571 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 571 581 return EOK; 572 582 } -
uspace/srv/hid/display/seat.c
rdbef30f r978c9bc5 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 *);47 static void ds_seat_get_pointer_rect(ds_seat_t *, gfx_rect_t *); 48 static errno_t ds_seat_repaint_pointer(ds_seat_t *, gfx_rect_t *); 49 49 50 50 /** Create seat. … … 185 185 ds_cursor_t *old_cursor; 186 186 ds_cursor_t *new_cursor; 187 gfx_rect_t old_rect; 187 188 188 189 old_cursor = ds_seat_get_cursor(seat); 189 190 new_cursor = ds_seat_compute_cursor(seat->wm_cursor, cursor); 190 191 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 } 198 199 } 199 200 … … 209 210 ds_cursor_t *old_cursor; 210 211 ds_cursor_t *new_cursor; 212 gfx_rect_t old_rect; 211 213 212 214 old_cursor = ds_seat_get_cursor(seat); 213 215 new_cursor = ds_seat_compute_cursor(cursor, seat->client_cursor); 214 216 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 */ 231 void 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 227 247 * 228 248 * @return EOK on success or an error code 229 249 */ 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); 250 static 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; 256 282 } 257 283 … … 269 295 ds_display_t *disp = seat->display; 270 296 gfx_coord2_t npos; 297 gfx_rect_t old_rect; 271 298 ds_window_t *wnd; 272 299 pos_event_t pevent; … … 299 326 gfx_coord2_clip(&npos, &disp->rect, &npos); 300 327 301 (void) ds_seat_clear_pointer(seat);328 ds_seat_get_pointer_rect(seat, &old_rect); 302 329 seat->pntpos = npos; 303 330 … … 312 339 return rc; 313 340 314 (void) ds_seat_draw_pointer(seat);341 ds_seat_repaint_pointer(seat, &old_rect); 315 342 } 316 343 … … 327 354 gfx_coord2_clip(&npos, &disp->rect, &npos); 328 355 329 (void) ds_seat_clear_pointer(seat);356 ds_seat_get_pointer_rect(seat, &old_rect); 330 357 seat->pntpos = npos; 331 358 … … 340 367 return rc; 341 368 342 (void) ds_seat_draw_pointer(seat);369 ds_seat_repaint_pointer(seat, &old_rect); 343 370 } 344 371 … … 380 407 } 381 408 409 /** Paint seat pointer. 410 * 411 * @param seat Seat whose pointer to paint 412 * @param rect Clipping rectangle 413 */ 414 errno_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 382 423 /** @} 383 424 */ -
uspace/srv/hid/display/seat.h
rdbef30f r978c9bc5 38 38 39 39 #include <errno.h> 40 #include <gfx/coord.h> 40 41 #include <io/kbd_event.h> 41 42 #include <io/pos_event.h> … … 53 54 extern errno_t ds_seat_post_pos_event(ds_seat_t *, pos_event_t *); 54 55 extern void ds_seat_set_wm_cursor(ds_seat_t *, ds_cursor_t *); 56 extern errno_t ds_seat_paint_pointer(ds_seat_t *, gfx_rect_t *); 55 57 56 58 #endif
Note:
See TracChangeset
for help on using the changeset viewer.