Changes in uspace/srv/hid/display/display.c [d9d6f29:1215db9] in mainline
- File:
-
- 1 edited
-
uspace/srv/hid/display/display.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/display.c
rd9d6f29 r1215db9 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 45 45 #include "cursimg.h" 46 46 #include "cursor.h" 47 #include "display.h"48 47 #include "seat.h" 49 48 #include "window.h" 50 #include " wmclient.h"49 #include "display.h" 51 50 52 51 static gfx_context_t *ds_display_get_unbuf_gc(ds_display_t *); … … 97 96 fibril_mutex_initialize(&disp->lock); 98 97 list_initialize(&disp->clients); 99 list_initialize(&disp->wmclients);100 98 disp->next_wnd_id = 1; 101 99 list_initialize(&disp->ddevs); … … 116 114 void ds_display_destroy(ds_display_t *disp) 117 115 { 118 int i;119 120 116 assert(list_empty(&disp->clients)); 121 assert(list_empty(&disp->wmclients));122 117 assert(list_empty(&disp->seats)); 123 assert(list_empty(&disp->ddevs)); 124 assert(list_empty(&disp->seats)); 125 assert(list_empty(&disp->windows)); 126 127 /* Destroy cursors */ 128 for (i = 0; i < dcurs_limit; i++) { 129 ds_cursor_destroy(disp->cursor[i]); 130 disp->cursor[i] = NULL; 131 } 132 118 /* XXX destroy cursors */ 133 119 gfx_color_delete(disp->bg_color); 134 120 free(disp); … … 217 203 218 204 return list_get_instance(link, ds_client_t, lclients); 219 }220 221 /** Add WM client to display.222 *223 * @param disp Display224 * @param wmclient WM client225 */226 void ds_display_add_wmclient(ds_display_t *disp, ds_wmclient_t *wmclient)227 {228 assert(wmclient->display == NULL);229 assert(!link_used(&wmclient->lwmclients));230 231 wmclient->display = disp;232 list_append(&wmclient->lwmclients, &disp->wmclients);233 }234 235 /** Remove WM client from display.236 *237 * @param wmclient WM client238 */239 void ds_display_remove_wmclient(ds_wmclient_t *wmclient)240 {241 list_remove(&wmclient->lwmclients);242 wmclient->display = NULL;243 }244 245 /** Get first WM client in display.246 *247 * @param disp Display248 * @return First WM client or @c NULL if there is none249 */250 ds_wmclient_t *ds_display_first_wmclient(ds_display_t *disp)251 {252 link_t *link = list_first(&disp->wmclients);253 254 if (link == NULL)255 return NULL;256 257 return list_get_instance(link, ds_wmclient_t, lwmclients);258 }259 260 /** Get next WM client in display.261 *262 * @param wmclient Current WM client263 * @return Next WM client or @c NULL if there is none264 */265 ds_wmclient_t *ds_display_next_wmclient(ds_wmclient_t *wmclient)266 {267 link_t *link = list_next(&wmclient->lwmclients,268 &wmclient->display->wmclients);269 270 if (link == NULL)271 return NULL;272 273 return list_get_instance(link, ds_wmclient_t, lwmclients);274 205 } 275 206 … … 315 246 gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect); 316 247 317 if (gfx_pix_inside_rect(pos, &drect) && 318 ds_window_is_visible(wnd)) 248 if (gfx_pix_inside_rect(pos, &drect)) 319 249 return wnd; 320 250 … … 325 255 } 326 256 327 /** Add window to window list. 328 * 329 * Topmost windows are enlisted before any other window. Non-topmost 330 * windows are enlisted before any other non-topmost window. 257 /** Add window to display. 331 258 * 332 259 * @param display Display 333 260 * @param wnd Window 334 261 */ 335 void ds_display_enlist_window(ds_display_t *display, ds_window_t *wnd)336 {337 ds_window_t *w;338 339 assert(wnd->display == display);340 assert(!link_used(&wnd->ldwindows));341 342 if ((wnd->flags & wndf_topmost) == 0) {343 /* Find the first non-topmost window */344 w = ds_display_first_window(display);345 while (w != NULL && (w->flags & wndf_topmost) != 0)346 w = ds_display_next_window(w);347 348 if (w != NULL)349 list_insert_before(&wnd->ldwindows, &w->ldwindows);350 else351 list_append(&wnd->ldwindows, &display->windows);352 } else {353 /* Insert at the beginning */354 list_prepend(&wnd->ldwindows, &display->windows);355 }356 357 }358 359 /** Add window to display.360 *361 * @param display Display362 * @param wnd Window363 */364 262 void ds_display_add_window(ds_display_t *display, ds_window_t *wnd) 365 263 { 366 ds_wmclient_t *wmclient;367 368 264 assert(wnd->display == NULL); 369 265 assert(!link_used(&wnd->ldwindows)); 370 266 371 267 wnd->display = display; 372 ds_display_enlist_window(display, wnd); 373 374 /* Notify window managers about the new window */ 375 wmclient = ds_display_first_wmclient(display); 376 while (wmclient != NULL) { 377 ds_wmclient_post_wnd_added_event(wmclient, wnd->id); 378 wmclient = ds_display_next_wmclient(wmclient); 379 } 268 list_prepend(&wnd->ldwindows, &display->windows); 380 269 } 381 270 … … 386 275 void ds_display_remove_window(ds_window_t *wnd) 387 276 { 388 ds_wmclient_t *wmclient;389 ds_display_t *display;390 391 display = wnd->display;392 393 277 list_remove(&wnd->ldwindows); 394 278 wnd->display = NULL; 395 396 /* Notify window managers about the removed window */397 wmclient = ds_display_first_wmclient(display);398 while (wmclient != NULL) {399 ds_wmclient_post_wnd_removed_event(wmclient, wnd->id);400 wmclient = ds_display_next_wmclient(wmclient);401 }402 }403 404 /** Move window to top.405 *406 * @param display Display407 * @param wnd Window408 */409 void ds_display_window_to_top(ds_window_t *wnd)410 {411 assert(wnd->display != NULL);412 assert(link_used(&wnd->ldwindows));413 414 list_remove(&wnd->ldwindows);415 ds_display_enlist_window(wnd->display, wnd);416 279 } 417 280 … … 489 352 ds_seat_t *seat; 490 353 491 / * Determine which seat the event belongs to */492 seat = ds_display_ seat_by_idev(display, event->kbd_id);354 // TODO Determine which seat the event belongs to 355 seat = ds_display_first_seat(display); 493 356 if (seat == NULL) 494 357 return EOK; … … 506 369 ds_seat_t *seat; 507 370 508 / * Determine which seat the event belongs to */509 seat = ds_display_ seat_by_idev(display, event->pos_id);371 // TODO Determine which seat the event belongs to 372 seat = ds_display_first_seat(display); 510 373 if (seat == NULL) 511 374 return EOK; … … 566 429 567 430 return list_get_instance(link, ds_seat_t, lseats); 568 }569 570 /** Get seat which owns the specified input device.571 *572 * @param disp Display573 * @param idev_id Input device ID574 * @return Seat which owns device with ID @a idev_id or @c NULL if not found575 */576 ds_seat_t *ds_display_seat_by_idev(ds_display_t *disp, ds_idev_id_t idev_id)577 {578 // TODO Multi-seat579 (void) idev_id;580 581 return ds_display_first_seat(disp);582 431 } 583 432 … … 644 493 { 645 494 errno_t rc; 646 gfx_rect_t old_disp_rect;647 495 648 496 assert(ddev->display == NULL); 649 497 assert(!link_used(&ddev->lddevs)); 650 651 old_disp_rect = disp->rect;652 498 653 499 ddev->display = disp; … … 661 507 /* Create cloning GC */ 662 508 rc = ds_clonegc_create(ddev->gc, &disp->fbgc); 663 if (rc != EOK) 664 goto error; 509 if (rc != EOK) { 510 // XXX Remove output 511 return ENOMEM; 512 } 665 513 666 514 /* Allocate backbuffer */ 667 515 rc = ds_display_alloc_backbuf(disp); 668 516 if (rc != EOK) { 669 ds_clonegc_delete(disp->fbgc);670 disp->fbgc = NULL;517 // XXX Remove output 518 // XXX Delete clone GC 671 519 goto error; 672 520 } … … 678 526 } 679 527 680 ds_display_update_max_rect(disp);681 682 528 return EOK; 683 529 error: 684 disp->rect = old_disp_rect; 530 disp->rect.p0.x = 0; 531 disp->rect.p0.y = 0; 532 disp->rect.p1.x = 0; 533 disp->rect.p1.y = 0; 685 534 list_remove(&ddev->lddevs); 686 535 return rc; … … 749 598 list_remove(&cursor->ldisplay); 750 599 cursor->display = NULL; 751 }752 753 /** Update display maximize rectangle.754 *755 * Recalculate the maximize rectangle (the rectangle used for maximized756 * windows).757 *758 * @param display Display759 */760 void ds_display_update_max_rect(ds_display_t *display)761 {762 ds_window_t *wnd;763 gfx_rect_t max_rect;764 gfx_rect_t drect;765 766 /* Start with the entire display */767 max_rect = display->rect;768 769 wnd = ds_display_first_window(display);770 while (wnd != NULL) {771 /* Should maximized windows avoid this window? */772 if ((wnd->flags & wndf_avoid) != 0) {773 /* Window bounding rectangle on display */774 gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);775 776 /* Crop maximized rectangle */777 ds_display_crop_max_rect(&drect, &max_rect);778 }779 780 wnd = ds_display_next_window(wnd);781 }782 783 /* Update the maximize rectangle */784 display->max_rect = max_rect;785 }786 787 /** Crop maximize rectangle.788 *789 * Use the avoid rectangle @a arect to crop off maximization rectangle790 * @a mrect. If @a arect covers the top, bottom, left or right part791 * of @a mrect, it will be cropped off. Otherwise there will be792 * no effect.793 *794 * @param arect Avoid rectangle795 * @param mrect Maximize rectangle to be modified796 */797 void ds_display_crop_max_rect(gfx_rect_t *arect, gfx_rect_t *mrect)798 {799 if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y &&800 arect->p1.x == mrect->p1.x) {801 /* Cropp off top part */802 mrect->p0.y = arect->p1.y;803 } else if (arect->p0.x == mrect->p0.x && arect->p1.x == mrect->p1.x &&804 arect->p1.y == mrect->p1.y) {805 /* Cropp off bottom part */806 mrect->p1.y = arect->p0.y;807 } else if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y &&808 arect->p1.y == mrect->p1.y) {809 /* Cropp off left part */810 mrect->p0.x = arect->p1.x;811 } else if (arect->p0.y == mrect->p0.y && arect->p1.x == mrect->p1.x &&812 arect->p1.y == mrect->p1.y) {813 /* Cropp off right part */814 mrect->p1.x = arect->p0.x;815 }816 600 } 817 601
Note:
See TracChangeset
for help on using the changeset viewer.
