Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2012fe0 in mainline


Ignore:
Timestamp:
2020-01-21T15:04:53Z (8 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
28db46b
Parents:
c79545e
git-author:
Jiri Svoboda <jiri@…> (2020-01-20 19:04:50)
git-committer:
Jiri Svoboda <jiri@…> (2020-01-21 15:04:53)
Message:

Repaint display when finished moving a window

Location:
uspace/srv/hid/display
Files:
5 edited

Legend:

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

    rc79545e r2012fe0  
    236236}
    237237
     238/** Get last window in display.
     239 *
     240 * @param display Display
     241 * @return Last window or @c NULL if there is none
     242 */
     243ds_window_t *ds_display_last_window(ds_display_t *display)
     244{
     245        link_t *link = list_last(&display->windows);
     246
     247        if (link == NULL)
     248                return NULL;
     249
     250        return list_get_instance(link, ds_window_t, ldwindows);
     251}
     252
    238253/** Get next window in client.
    239254 *
     
    244259{
    245260        link_t *link = list_next(&wnd->ldwindows, &wnd->display->windows);
     261
     262        if (link == NULL)
     263                return NULL;
     264
     265        return list_get_instance(link, ds_window_t, ldwindows);
     266}
     267
     268/** Get previous window in client.
     269 *
     270 * @param wnd Current window
     271 * @return Previous window or @c NULL if there is none
     272 */
     273ds_window_t *ds_display_prev_window(ds_window_t *wnd)
     274{
     275        link_t *link = list_prev(&wnd->ldwindows, &wnd->display->windows);
    246276
    247277        if (link == NULL)
     
    441471}
    442472
     473/** Paint display.
     474 *
     475 * @param display Display
     476 * @param rect Bounding rectangle or @c NULL to repaint entire display
     477 */
     478errno_t ds_display_paint(ds_display_t *disp, gfx_rect_t *rect)
     479{
     480        errno_t rc;
     481        ds_window_t *wnd;
     482
     483        /* Paint background */
     484        rc = ds_display_paint_bg(disp, rect);
     485        if (rc != EOK)
     486                return rc;
     487
     488        /* Paint windows bottom to top */
     489        wnd = ds_display_last_window(disp);
     490        while (wnd != NULL) {
     491                rc = ds_window_paint(wnd, rect);
     492                if (rc != EOK)
     493                        return rc;
     494
     495                wnd = ds_display_prev_window(wnd);
     496        }
     497
     498        return EOK;
     499}
     500
    443501/** @}
    444502 */
  • uspace/srv/hid/display/display.h

    rc79545e r2012fe0  
    5858extern void ds_display_remove_window(ds_window_t *);
    5959extern ds_window_t *ds_display_first_window(ds_display_t *);
     60extern ds_window_t *ds_display_last_window(ds_display_t *);
    6061extern ds_window_t *ds_display_next_window(ds_window_t *);
     62extern ds_window_t *ds_display_prev_window(ds_window_t *);
    6163extern errno_t ds_display_post_kbd_event(ds_display_t *, kbd_event_t *);
    6264extern errno_t ds_display_post_ptd_event(ds_display_t *, ptd_event_t *);
     
    7173extern gfx_context_t *ds_display_get_gc(ds_display_t *);
    7274extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *);
     75extern errno_t ds_display_paint(ds_display_t *, gfx_rect_t *);
    7376
    7477#endif
  • uspace/srv/hid/display/test/display.c

    rc79545e r2012fe0  
    128128        PCUT_ASSERT_NULL(wnd);
    129129
     130        wnd = ds_display_last_window(disp);
     131        PCUT_ASSERT_EQUALS(w1, wnd);
     132
     133        wnd = ds_display_prev_window(wnd);
     134        PCUT_ASSERT_EQUALS(w0, wnd);
     135
     136        wnd = ds_display_prev_window(wnd);
     137        PCUT_ASSERT_NULL(wnd);
     138
    130139        wnd = ds_display_find_window(disp, w0->id);
    131140        PCUT_ASSERT_EQUALS(w0, wnd);
  • uspace/srv/hid/display/window.c

    rc79545e r2012fe0  
    348348}
    349349
    350 /** Repaint a window using its backing bitmap.
    351  *
    352  * @param wnd Window to repaint
    353  * @return EOK on success or an error code
    354  */
    355 static errno_t ds_window_repaint(ds_window_t *wnd)
    356 {
    357         log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_repaint");
    358         return gfx_bitmap_render(wnd->bitmap, NULL, &wnd->dpos);
     350/** Paint a window using its backing bitmap.
     351 *
     352 * @param wnd Window to paint
     353 * @param rect Display rectangle to paint to
     354 * @return EOK on success or an error code
     355 */
     356errno_t ds_window_paint(ds_window_t *wnd, gfx_rect_t *rect)
     357{
     358        gfx_rect_t srect;
     359        gfx_rect_t *brect;
     360        gfx_rect_t crect;
     361
     362        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_paint");
     363
     364        if (rect != NULL) {
     365                gfx_rect_rtranslate(&wnd->dpos, rect, &srect);
     366
     367                /* Determine if we have anything to do */
     368                gfx_rect_clip(&srect, rect, &crect);
     369                if (gfx_rect_is_empty(&crect))
     370                        return EOK;
     371
     372                brect = &srect;
     373        } else {
     374                brect = NULL;
     375        }
     376
     377        return gfx_bitmap_render(wnd->bitmap, brect, &wnd->dpos);
    359378}
    360379
     
    399418        wnd->state = dsw_idle;
    400419
    401         (void) ds_window_repaint(wnd);
     420        (void) ds_display_paint(wnd->display, NULL);
    402421}
    403422
  • uspace/srv/hid/display/window.h

    rc79545e r2012fe0  
    4040#include <io/pos_event.h>
    4141#include <types/gfx/context.h>
     42#include <types/gfx/coord.h>
    4243#include <types/gfx/ops/context.h>
    4344#include "types/display/display.h"
     
    5152extern void ds_window_destroy(ds_window_t *);
    5253extern gfx_context_t *ds_window_get_ctx(ds_window_t *);
     54extern errno_t ds_window_paint(ds_window_t *, gfx_rect_t *);
    5355extern errno_t ds_window_post_pos_event(ds_window_t *, pos_event_t *);
    5456
Note: See TracChangeset for help on using the changeset viewer.