Changeset 06176e1 in mainline for uspace/srv


Ignore:
Timestamp:
2022-12-20T12:31:44Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e7b0ad
Parents:
d46ac73
git-author:
Jiri Svoboda <jiri@…> (2022-12-19 18:31:30)
git-committer:
Jiri Svoboda <jiri@…> (2022-12-20 12:31:44)
Message:

Minimizing windows

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

Legend:

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

    rd46ac73 r06176e1  
    304304                gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect);
    305305
    306                 if (gfx_pix_inside_rect(pos, &drect))
     306                if (gfx_pix_inside_rect(pos, &drect) &&
     307                    ds_window_is_visible(wnd))
    307308                        return wnd;
    308309
  • uspace/srv/hid/display/dsops.c

    rd46ac73 r06176e1  
    5454static errno_t disp_window_resize(void *, sysarg_t, gfx_coord2_t *,
    5555    gfx_rect_t *);
     56static errno_t disp_window_minimize(void *, sysarg_t);
    5657static errno_t disp_window_maximize(void *, sysarg_t);
    5758static errno_t disp_window_unmaximize(void *, sysarg_t);
     
    7071        .window_resize_req = disp_window_resize_req,
    7172        .window_resize = disp_window_resize,
     73        .window_minimize = disp_window_minimize,
    7274        .window_maximize = disp_window_maximize,
    7375        .window_unmaximize = disp_window_unmaximize,
     
    247249}
    248250
     251static errno_t disp_window_minimize(void *arg, sysarg_t wnd_id)
     252{
     253        ds_client_t *client = (ds_client_t *) arg;
     254        ds_window_t *wnd;
     255        errno_t rc;
     256
     257        ds_display_lock(client->display);
     258
     259        wnd = ds_client_find_window(client, wnd_id);
     260        if (wnd == NULL) {
     261                ds_display_unlock(client->display);
     262                return ENOENT;
     263        }
     264
     265        log_msg(LOG_DEFAULT, LVL_DEBUG, "disp_window_maximize()");
     266        rc = ds_window_minimize(wnd);
     267        ds_display_unlock(client->display);
     268        return rc;
     269}
     270
    249271static errno_t disp_window_maximize(void *arg, sysarg_t wnd_id)
    250272{
  • uspace/srv/hid/display/seat.c

    rd46ac73 r06176e1  
    9090void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd)
    9191{
     92        errno_t rc;
     93
    9294        if (wnd == seat->focus) {
    9395                /* Focus is not changing */
    9496                return;
     97        }
     98
     99        if (wnd != NULL) {
     100                rc = ds_window_unminimize(wnd);
     101                if (rc != EOK)
     102                        return;
    95103        }
    96104
  • uspace/srv/hid/display/test/window.c

    rd46ac73 r06176e1  
    261261}
    262262
     263/** Test ds_window_minimize(). */
     264PCUT_TEST(window_minimize)
     265{
     266        ds_display_t *disp;
     267        ds_client_t *client;
     268        ds_seat_t *seat;
     269        ds_window_t *wnd;
     270        display_wnd_params_t params;
     271        errno_t rc;
     272
     273        rc = ds_display_create(NULL, df_none, &disp);
     274        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     275
     276        rc = ds_client_create(disp, NULL, NULL, &client);
     277        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     278
     279        rc = ds_seat_create(disp, &seat);
     280        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     281
     282        display_wnd_params_init(&params);
     283        params.rect.p0.x = params.rect.p0.y = 0;
     284        params.rect.p1.x = params.rect.p1.y = 10;
     285
     286        rc = ds_window_create(client, &params, &wnd);
     287        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     288
     289        rc = ds_window_minimize(wnd);
     290        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     291
     292        PCUT_ASSERT_INT_EQUALS(wndf_minimized, wnd->flags & wndf_minimized);
     293
     294        ds_window_destroy(wnd);
     295        ds_seat_destroy(seat);
     296        ds_client_destroy(client);
     297        ds_display_destroy(disp);
     298}
     299
     300/** Test ds_window_unminimize(). */
     301PCUT_TEST(window_unminimize)
     302{
     303        ds_display_t *disp;
     304        ds_client_t *client;
     305        ds_seat_t *seat;
     306        ds_window_t *wnd;
     307        display_wnd_params_t params;
     308        errno_t rc;
     309
     310        rc = ds_display_create(NULL, df_none, &disp);
     311        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     312
     313        rc = ds_client_create(disp, NULL, NULL, &client);
     314        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     315
     316        rc = ds_seat_create(disp, &seat);
     317        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     318
     319        display_wnd_params_init(&params);
     320        params.flags |= wndf_minimized;
     321        params.rect.p0.x = params.rect.p0.y = 0;
     322        params.rect.p1.x = params.rect.p1.y = 10;
     323
     324        rc = ds_window_create(client, &params, &wnd);
     325        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     326
     327        rc = ds_window_unminimize(wnd);
     328        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     329
     330        PCUT_ASSERT_INT_EQUALS(0, wnd->flags & wndf_minimized);
     331
     332        ds_window_destroy(wnd);
     333        ds_seat_destroy(seat);
     334        ds_client_destroy(client);
     335        ds_display_destroy(disp);
     336}
     337
    263338/** Test ds_window_maximize(). */
    264339PCUT_TEST(window_maximize)
     
    373448        gc = ds_window_get_ctx(wnd);
    374449        PCUT_ASSERT_NOT_NULL(gc);
     450
     451        ds_window_destroy(wnd);
     452        ds_seat_destroy(seat);
     453        ds_client_destroy(client);
     454        ds_display_destroy(disp);
     455}
     456
     457/** Test ds_window_is_visible() */
     458PCUT_TEST(is_visible)
     459{
     460        ds_display_t *disp;
     461        ds_client_t *client;
     462        ds_seat_t *seat;
     463        ds_window_t *wnd;
     464        display_wnd_params_t params;
     465        errno_t rc;
     466
     467        rc = ds_display_create(NULL, df_none, &disp);
     468        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     469
     470        rc = ds_client_create(disp, NULL, NULL, &client);
     471        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     472
     473        rc = ds_seat_create(disp, &seat);
     474        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     475
     476        display_wnd_params_init(&params);
     477        params.rect.p0.x = params.rect.p0.y = 0;
     478        params.rect.p1.x = params.rect.p1.y = 10;
     479
     480        rc = ds_window_create(client, &params, &wnd);
     481        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     482
     483        PCUT_ASSERT_TRUE(ds_window_is_visible(wnd));
     484
     485        wnd->flags |= wndf_minimized;
     486
     487        PCUT_ASSERT_FALSE(ds_window_is_visible(wnd));
    375488
    376489        ds_window_destroy(wnd);
  • uspace/srv/hid/display/window.c

    rd46ac73 r06176e1  
    220220}
    221221
     222/** Determine if window is visible.
     223 *
     224 * @param wnd Window
     225 * @return @c true iff window is visible
     226 */
     227bool ds_window_is_visible(ds_window_t *wnd)
     228{
     229        return (wnd->flags & wndf_minimized) == 0;
     230}
     231
    222232/** Paint a window using its backing bitmap.
    223233 *
     
    233243
    234244        log_msg(LOG_DEFAULT, LVL_DEBUG2, "ds_window_paint");
     245
     246        /* Skip painting the window if not visible */
     247        if (!ds_window_is_visible(wnd))
     248                return EOK;
    235249
    236250        if (rect != NULL) {
     
    808822}
    809823
     824/** Minimize window.
     825 *
     826 * @param wnd Window
     827 * @return EOK on success or an error code
     828 */
     829errno_t ds_window_minimize(ds_window_t *wnd)
     830{
     831        /* If already minimized, do nothing and return success. */
     832        if ((wnd->flags & wndf_minimized) != 0)
     833                return EOK;
     834
     835        wnd->flags |= wndf_minimized;
     836        (void) ds_display_paint(wnd->display, NULL);
     837        return EOK;
     838}
     839
     840/** Unminimize window.
     841 *
     842 * @param wnd Window
     843 * @return EOK on success or an error code
     844 */
     845errno_t ds_window_unminimize(ds_window_t *wnd)
     846{
     847        /* If not minimized, do nothing and return success. */
     848        if ((wnd->flags & wndf_minimized) == 0)
     849                return EOK;
     850
     851        wnd->flags &= ~wndf_minimized;
     852        (void) ds_display_paint(wnd->display, NULL);
     853        return EOK;
     854}
     855
    810856/** Maximize window.
    811857 *
  • uspace/srv/hid/display/window.h

    rd46ac73 r06176e1  
    4141#include <errno.h>
    4242#include <io/pos_event.h>
     43#include <stdbool.h>
    4344#include <types/gfx/context.h>
    4445#include <types/gfx/coord.h>
     
    5556extern void ds_window_bring_to_top(ds_window_t *);
    5657extern gfx_context_t *ds_window_get_ctx(ds_window_t *);
     58extern bool ds_window_is_visible(ds_window_t *);
    5759extern errno_t ds_window_paint(ds_window_t *, gfx_rect_t *);
    5860errno_t ds_window_paint_preview(ds_window_t *, gfx_rect_t *);
     
    6870    gfx_coord2_t *);
    6971extern errno_t ds_window_resize(ds_window_t *, gfx_coord2_t *, gfx_rect_t *);
     72extern errno_t ds_window_minimize(ds_window_t *);
     73extern errno_t ds_window_unminimize(ds_window_t *);
    7074extern errno_t ds_window_maximize(ds_window_t *);
    7175extern errno_t ds_window_unmaximize(ds_window_t *);
  • uspace/srv/hid/display/wmops.c

    rd46ac73 r06176e1  
    4141#include "display.h"
    4242#include "seat.h"
     43#include "window.h"
    4344#include "wmclient.h"
    4445
Note: See TracChangeset for help on using the changeset viewer.