Changeset 29a5a99 in mainline for uspace/srv/hid/display/display.c


Ignore:
Timestamp:
2022-12-04T10:42:48Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
14b4577
Parents:
795c6f7
Message:

Maximized windows should avoid task bar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/display.c

    r795c6f7 r29a5a99  
    665665        }
    666666
     667        ds_display_update_max_rect(disp);
     668
    667669        return EOK;
    668670error:
     
    739741}
    740742
     743/** Update display maximize rectangle.
     744 *
     745 * Recalculate the maximize rectangle (the rectangle used for maximized
     746 * windows).
     747 *
     748 * @param display Display
     749 */
     750void ds_display_update_max_rect(ds_display_t *display)
     751{
     752        ds_window_t *wnd;
     753        gfx_rect_t max_rect;
     754        gfx_rect_t drect;
     755
     756        /* Start with the entire display */
     757        max_rect = display->rect;
     758
     759        wnd = ds_display_first_window(display);
     760        while (wnd != NULL) {
     761                /* Should maximized windows avoid this window? */
     762                if ((wnd->flags & wndf_avoid) != 0) {
     763                        /* Window bounding rectangle on display */
     764                        gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
     765
     766                        /* Crop maximized rectangle */
     767                        ds_display_crop_max_rect(&drect, &max_rect);
     768                }
     769
     770                wnd = ds_display_next_window(wnd);
     771        }
     772
     773        /* Update the maximize rectangle */
     774        display->max_rect = max_rect;
     775}
     776
     777/** Crop maximize rectangle.
     778 *
     779 * Use the avoid rectangle @a arect to crop off maximization rectangle
     780 * @a mrect. If @a arect covers the top, bottom, left or right part
     781 * of @a mrect, it will be cropped off. Otherwise there will be
     782 * no effect.
     783 *
     784 * @param arect Avoid rectangle
     785 * @param mrect Maximize rectangle to be modified
     786 */
     787void ds_display_crop_max_rect(gfx_rect_t *arect, gfx_rect_t *mrect)
     788{
     789        if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y &&
     790            arect->p1.x == mrect->p1.x) {
     791                /* Cropp off top part */
     792                mrect->p0.y = arect->p1.y;
     793        } else if (arect->p0.x == mrect->p0.x && arect->p1.x == mrect->p1.x &&
     794            arect->p1.y == mrect->p1.y) {
     795                /* Cropp off bottom part */
     796                mrect->p1.y = arect->p0.y;
     797        } else if (arect->p0.x == mrect->p0.x && arect->p0.y == mrect->p0.y &&
     798            arect->p1.y == mrect->p1.y) {
     799                /* Cropp off left part */
     800                mrect->p0.x = arect->p1.x;
     801        } else if (arect->p0.y == mrect->p0.y && arect->p1.x == mrect->p1.x &&
     802            arect->p1.y == mrect->p1.y) {
     803                /* Cropp off right part */
     804                mrect->p1.x = arect->p0.x;
     805        }
     806}
     807
    741808/** Get unbuffered GC.
    742809 *
Note: See TracChangeset for help on using the changeset viewer.