Changeset fb420e48 in mainline


Ignore:
Timestamp:
2019-12-16T13:47:33Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e9781f
Parents:
c2250702
git-author:
Jiri Svoboda <jiri@…> (2019-12-15 13:47:28)
git-committer:
Jiri Svoboda <jiri@…> (2019-12-16 13:47:33)
Message:

Use window dimensions for picking window to focus

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/display/include/display/wndparams.h

    rc2250702 rfb420e48  
    4040extern void display_wnd_params_init(display_wnd_params_t *);
    4141
    42 
    4342#endif
    4443
  • uspace/lib/gfx/include/gfx/coord.h

    rc2250702 rfb420e48  
    5050extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *);
    5151extern bool gfx_rect_is_empty(gfx_rect_t *);
     52extern bool gfx_pix_inside_rect(gfx_coord2_t *, gfx_rect_t *);
    5253
    5354#endif
  • uspace/lib/gfx/src/coord.c

    rc2250702 rfb420e48  
    189189}
    190190
     191/** Return true if pixel at coordinate @a coord lies within rectangle @a rect. */
     192bool gfx_pix_inside_rect(gfx_coord2_t *coord, gfx_rect_t *rect)
     193{
     194        gfx_rect_t sr;
     195
     196        gfx_rect_points_sort(rect, &sr);
     197
     198        if (coord->x < sr.p0.x || coord->y < sr.p0.y)
     199                return false;
     200
     201        if (coord->x >= sr.p1.x || coord->y >= sr.p1.y)
     202                return false;
     203
     204        return true;
     205}
     206
    191207/** @}
    192208 */
  • uspace/lib/gfx/test/coord.c

    rc2250702 rfb420e48  
    524524}
    525525
     526/** gfx_pix_inside_rect for  */
     527PCUT_TEST(pix_inside_rect)
     528{
     529        gfx_coord2_t coord;
     530        gfx_rect_t rect;
     531
     532        rect.p0.x = 1;
     533        rect.p0.y = 2;
     534        rect.p1.x = 3;
     535        rect.p1.y = 4;
     536
     537        coord.x = 0;
     538        coord.y = 1;
     539        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     540
     541        coord.x = 1;
     542        coord.y = 1;
     543        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     544
     545        coord.x = 0;
     546        coord.y = 2;
     547        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     548
     549        coord.x = 1;
     550        coord.y = 2;
     551        PCUT_ASSERT_TRUE(gfx_pix_inside_rect(&coord, &rect));
     552
     553        coord.x = 2;
     554        coord.y = 3;
     555        PCUT_ASSERT_TRUE(gfx_pix_inside_rect(&coord, &rect));
     556
     557        coord.x = 3;
     558        coord.y = 3;
     559        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     560
     561        coord.x = 2;
     562        coord.y = 4;
     563        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     564
     565        coord.x = 3;
     566        coord.y = 4;
     567        PCUT_ASSERT_FALSE(gfx_pix_inside_rect(&coord, &rect));
     568}
     569
    526570PCUT_EXPORT(coord);
  • uspace/srv/hid/display/display.c

    rc2250702 rfb420e48  
    172172{
    173173        ds_window_t *wnd;
     174        gfx_rect_t drect;
    174175
    175176        wnd = ds_display_first_window(display);
    176177        while (wnd != NULL) {
    177                 // XXX Need to know window dimensions
    178                 if (pos->x >= wnd->dpos.x && pos->y >= wnd->dpos.y &&
    179                     pos->x <= wnd->dpos.x + 100 && pos->y <= wnd->dpos.y + 100) {
     178                /* Window bounding rectangle on display */
     179                gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
     180
     181                if (gfx_pix_inside_rect(pos, &drect))
    180182                        return wnd;
    181                 }
    182183
    183184                wnd = ds_display_next_window(wnd);
Note: See TracChangeset for help on using the changeset viewer.