Changeset 46a47c0 in mainline for uspace/lib/display


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/lib/display
Files:
4 edited

Legend:

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

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6060        void (*close_event)(void *);
    6161        /** Focus event */
    62         void (*focus_event)(void *);
     62        void (*focus_event)(void *, unsigned);
    6363        /** Keyboard event */
    6464        void (*kbd_event)(void *, kbd_event_t *);
     
    6868        void (*resize_event)(void *, gfx_rect_t *);
    6969        /** Unfocus event */
    70         void (*unfocus_event)(void *);
     70        void (*unfocus_event)(void *, unsigned);
    7171} display_wnd_cb_t;
    7272
  • uspace/lib/display/include/types/display/event.h

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5656} display_wnd_ev_type_t;
    5757
     58/** Display window focus event */
     59typedef struct {
     60        /** New number of foci */
     61        unsigned nfocus;
     62} display_wnd_focus_ev_t;
     63
    5864/** Display window resize event */
    5965typedef struct {
    6066        gfx_rect_t rect;
    6167} display_wnd_resize_ev_t;
     68
     69/** Display window unfocus event */
     70typedef struct {
     71        /** Number of remaining foci */
     72        unsigned nfocus;
     73} display_wnd_unfocus_ev_t;
    6274
    6375/** Display window event */
     
    6678        display_wnd_ev_type_t etype;
    6779        union {
     80                /** Focus event data */
     81                display_wnd_focus_ev_t focus;
    6882                /** Keyboard event data */
    6983                kbd_event_t kbd;
     
    7286                /** Resize event data */
    7387                display_wnd_resize_ev_t resize;
     88                /** Unfocus event data */
     89                display_wnd_unfocus_ev_t unfocus;
    7490        } ev;
    7591} display_wnd_ev_t;
  • uspace/lib/display/src/display.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    716716                case wev_focus:
    717717                        if (window->cb != NULL && window->cb->focus_event != NULL) {
    718                                 window->cb->focus_event(window->cb_arg);
     718                                window->cb->focus_event(window->cb_arg,
     719                                    event.ev.focus.nfocus);
    719720                        }
    720721                        break;
     
    739740                case wev_unfocus:
    740741                        if (window->cb != NULL && window->cb->unfocus_event != NULL) {
    741                                 window->cb->unfocus_event(window->cb_arg);
     742                                window->cb->unfocus_event(window->cb_arg,
     743                                    event.ev.unfocus.nfocus);
    742744                        }
    743745                        break;
  • uspace/lib/display/test/display.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5151
    5252static void test_close_event(void *);
    53 static void test_focus_event(void *);
     53static void test_focus_event(void *, unsigned);
    5454static void test_kbd_event(void *, kbd_event_t *);
    5555static void test_pos_event(void *, pos_event_t *);
    56 static void test_unfocus_event(void *);
     56static void test_unfocus_event(void *, unsigned);
    5757
    5858static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *);
     
    166166        bool set_color_called;
    167167        bool close_event_called;
     168
    168169        bool focus_event_called;
    169170        bool kbd_event_called;
     
    16771678        resp.event_cnt = 1;
    16781679        resp.event.etype = wev_focus;
     1680        resp.event.ev.focus.nfocus = 42;
    16791681        resp.wnd_id = wnd->id;
    16801682        resp.focus_event_called = false;
     
    16931695        PCUT_ASSERT_INT_EQUALS(resp.event.etype,
    16941696            resp.revent.etype);
     1697        PCUT_ASSERT_INT_EQUALS(resp.event.ev.focus.nfocus,
     1698            resp.revent.ev.focus.nfocus);
    16951699
    16961700        rc = display_window_destroy(wnd);
     
    18961900        resp.event_cnt = 1;
    18971901        resp.event.etype = wev_unfocus;
     1902        resp.event.ev.unfocus.nfocus = 42;
    18981903        resp.wnd_id = wnd->id;
    18991904        resp.unfocus_event_called = false;
     
    19121917        PCUT_ASSERT_INT_EQUALS(resp.event.etype,
    19131918            resp.revent.etype);
     1919        PCUT_ASSERT_INT_EQUALS(resp.event.ev.focus.nfocus,
     1920            resp.revent.ev.focus.nfocus);
    19141921
    19151922        rc = display_window_destroy(wnd);
     
    20572064}
    20582065
    2059 static void test_focus_event(void *arg)
     2066static void test_focus_event(void *arg, unsigned nfocus)
    20602067{
    20612068        test_response_t *resp = (test_response_t *) arg;
    20622069
    20632070        resp->revent.etype = wev_focus;
     2071        resp->revent.ev.focus.nfocus = nfocus;
    20642072
    20652073        fibril_mutex_lock(&resp->event_lock);
     
    20952103}
    20962104
    2097 static void test_unfocus_event(void *arg)
     2105static void test_unfocus_event(void *arg, unsigned nfocus)
    20982106{
    20992107        test_response_t *resp = (test_response_t *) arg;
    21002108
    21012109        resp->revent.etype = wev_unfocus;
     2110        resp->revent.ev.unfocus.nfocus = nfocus;
    21022111
    21032112        fibril_mutex_lock(&resp->event_lock);
Note: See TracChangeset for help on using the changeset viewer.