Changeset 46a47c0 in mainline for uspace/srv


Ignore:
Timestamp:
2023-01-16T20:34:01Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b0ae23f
Parents:
b3eeae5
Message:

Make sure window is only show as inactive when it loses last focus

This currently affects the title bar and also the cursor in Terminal.

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

Legend:

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

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    257257 * @param client Client
    258258 * @param ewindow Window that the message is targetted to
    259  *
    260  * @return EOK on success or an error code
    261  */
    262 errno_t ds_client_post_focus_event(ds_client_t *client, ds_window_t *ewindow)
     259 * @param event Focus event data
     260 *
     261 * @return EOK on success or an error code
     262 */
     263errno_t ds_client_post_focus_event(ds_client_t *client, ds_window_t *ewindow,
     264    display_wnd_focus_ev_t *event)
    263265{
    264266        ds_window_ev_t *wevent;
     
    270272        wevent->window = ewindow;
    271273        wevent->event.etype = wev_focus;
     274        wevent->event.ev.focus = *event;
    272275        list_append(&wevent->levents, &client->events);
    273276
     
    373376 * @param client Client
    374377 * @param ewindow Window that the message is targetted to
    375  *
    376  * @return EOK on success or an error code
    377  */
    378 errno_t ds_client_post_unfocus_event(ds_client_t *client, ds_window_t *ewindow)
     378 * @param event Unfocus event data
     379 *
     380 * @return EOK on success or an error code
     381 */
     382errno_t ds_client_post_unfocus_event(ds_client_t *client, ds_window_t *ewindow,
     383    display_wnd_unfocus_ev_t *event)
    379384{
    380385        ds_window_ev_t *wevent;
     
    386391        wevent->window = ewindow;
    387392        wevent->event.etype = wev_unfocus;
     393        wevent->event.ev.unfocus = *event;
    388394        list_append(&wevent->levents, &client->events);
    389395
  • uspace/srv/hid/display/client.h

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5555extern void ds_client_purge_window_events(ds_client_t *, ds_window_t *);
    5656extern errno_t ds_client_post_close_event(ds_client_t *, ds_window_t *);
    57 extern errno_t ds_client_post_focus_event(ds_client_t *, ds_window_t *);
     57extern errno_t ds_client_post_focus_event(ds_client_t *, ds_window_t *,
     58    display_wnd_focus_ev_t *);
    5859extern errno_t ds_client_post_kbd_event(ds_client_t *, ds_window_t *,
    5960    kbd_event_t *);
     
    6263extern errno_t ds_client_post_resize_event(ds_client_t *, ds_window_t *,
    6364    gfx_rect_t *);
    64 extern errno_t ds_client_post_unfocus_event(ds_client_t *, ds_window_t *);
     65extern errno_t ds_client_post_unfocus_event(ds_client_t *, ds_window_t *,
     66    display_wnd_unfocus_ev_t *);
    6567
    6668#endif
  • uspace/srv/hid/display/test/client.c

    rb3eeae5 r46a47c0  
    240240        display_wnd_params_t params;
    241241        ds_window_t *rwindow;
     242        display_wnd_focus_ev_t efocus;
    242243        display_wnd_ev_t revent;
    243244        bool called_cb = NULL;
     
    271272        PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
    272273
    273         rc = ds_client_post_focus_event(client, wnd);
     274        efocus.nfocus = 42;
     275
     276        rc = ds_client_post_focus_event(client, wnd, &efocus);
    274277        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    275278        PCUT_ASSERT_TRUE(called_cb);
     
    279282        PCUT_ASSERT_EQUALS(wnd, rwindow);
    280283        PCUT_ASSERT_EQUALS(wev_focus, revent.etype);
     284        PCUT_ASSERT_INT_EQUALS(efocus.nfocus, revent.ev.focus.nfocus);
    281285
    282286        rc = ds_client_get_event(client, &rwindow, &revent);
     
    504508        display_wnd_params_t params;
    505509        ds_window_t *rwindow;
     510        display_wnd_unfocus_ev_t eunfocus;
    506511        display_wnd_ev_t revent;
    507512        bool called_cb = NULL;
     
    535540        PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
    536541
    537         rc = ds_client_post_unfocus_event(client, wnd);
     542        eunfocus.nfocus = 42;
     543
     544        rc = ds_client_post_unfocus_event(client, wnd, &eunfocus);
    538545        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    539546        PCUT_ASSERT_TRUE(called_cb);
     
    543550        PCUT_ASSERT_EQUALS(wnd, rwindow);
    544551        PCUT_ASSERT_EQUALS(wev_unfocus, revent.etype);
     552        PCUT_ASSERT_INT_EQUALS(eunfocus.nfocus, revent.ev.unfocus.nfocus);
    545553
    546554        rc = ds_client_get_event(client, &rwindow, &revent);
  • uspace/srv/hid/display/window.c

    rb3eeae5 r46a47c0  
    680680errno_t ds_window_post_focus_event(ds_window_t *wnd)
    681681{
     682        display_wnd_focus_ev_t efocus;
    682683        errno_t rc;
    683684        ds_wmclient_t *wmclient;
     
    685686        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_focus_event");
    686687
    687         rc = ds_client_post_focus_event(wnd->client, wnd);
     688        /* Increase focus counter */
     689        ++wnd->nfocus;
     690        efocus.nfocus = wnd->nfocus;
     691
     692        rc = ds_client_post_focus_event(wnd->client, wnd, &efocus);
    688693        if (rc != EOK)
    689694                return rc;
    690 
    691         /* Increase focus counter */
    692         ++wnd->nfocus;
    693695
    694696        /* Notify window managers about window information change */
     
    709711errno_t ds_window_post_unfocus_event(ds_window_t *wnd)
    710712{
     713        display_wnd_unfocus_ev_t eunfocus;
    711714        errno_t rc;
    712715        ds_wmclient_t *wmclient;
     
    714717        log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_post_unfocus_event");
    715718
    716         rc = ds_client_post_unfocus_event(wnd->client, wnd);
     719        /* Decrease focus counter */
     720        --wnd->nfocus;
     721        eunfocus.nfocus = wnd->nfocus;
     722
     723        rc = ds_client_post_unfocus_event(wnd->client, wnd, &eunfocus);
    717724        if (rc != EOK)
    718725                return rc;
    719 
    720         /* Decrease focus counter */
    721         --wnd->nfocus;
    722726
    723727        /* Notify window managers about window information change */
Note: See TracChangeset for help on using the changeset viewer.