Changeset 46a47c0 in mainline for uspace/lib/ui/test


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/ui/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/test/control.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444static ui_evclaim_t test_ctl_kbd_event(void *, kbd_event_t *);
    4545static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    46 static void test_ctl_unfocus(void *);
     46static void test_ctl_unfocus(void *, unsigned);
    4747
    4848static ui_control_ops_t test_ctl_ops = {
     
    7979        /** @c true iff unfocus was called */
    8080        bool unfocus;
     81        /** Number of remaining foci that was sent */
     82        unsigned unfocus_nfocus;
    8183} test_resp_t;
    8284
     
    223225        resp.unfocus = false;
    224226
    225         ui_control_unfocus(control);
     227        ui_control_unfocus(control, 42);
    226228        PCUT_ASSERT_TRUE(resp.unfocus);
     229        PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
    227230
    228231        ui_control_delete(control);
     
    264267}
    265268
    266 static void test_ctl_unfocus(void *arg)
     269static void test_ctl_unfocus(void *arg, unsigned nfocus)
    267270{
    268271        test_resp_t *resp = (test_resp_t *) arg;
    269272
    270273        resp->unfocus = true;
     274        resp->unfocus_nfocus = nfocus;
    271275}
    272276
  • uspace/lib/ui/test/fixed.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4141static errno_t test_ctl_paint(void *);
    4242static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    43 static void test_ctl_unfocus(void *);
     43static void test_ctl_unfocus(void *, unsigned);
    4444
    4545static ui_control_ops_t test_ctl_ops = {
     
    6666        /** @c true iff unfocus was called */
    6767        bool unfocus;
     68        /** Number of remaining foci */
     69        unsigned unfocus_nfocus;
    6870} test_resp_t;
    6971
     
    253255        resp.unfocus = false;
    254256
    255         ui_fixed_unfocus(fixed);
     257        ui_fixed_unfocus(fixed, 42);
    256258        PCUT_ASSERT_TRUE(resp.unfocus);
     259        PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
    257260
    258261        ui_fixed_destroy(fixed);
     
    284287}
    285288
    286 static void test_ctl_unfocus(void *arg)
     289static void test_ctl_unfocus(void *arg, unsigned nfocus)
    287290{
    288291        test_resp_t *resp = (test_resp_t *) arg;
    289292
    290293        resp->unfocus = true;
     294        resp->unfocus_nfocus = nfocus;
    291295}
    292296
  • uspace/lib/ui/test/popup.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6464static errno_t test_ctl_paint(void *);
    6565static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    66 static void test_ctl_unfocus(void *);
     66static void test_ctl_unfocus(void *, unsigned);
    6767
    6868static ui_control_ops_t test_ctl_ops = {
     
    9191        pos_event_t pos_event;
    9292        bool unfocus;
     93        unsigned unfocus_nfocus;
    9394} test_ctl_resp_t;
    9495
     
    341342}
    342343
    343 static void test_ctl_unfocus(void *arg)
     344static void test_ctl_unfocus(void *arg, unsigned nfocus)
    344345{
    345346        test_ctl_resp_t *resp = (test_ctl_resp_t *) arg;
    346347
    347348        resp->unfocus = true;
     349        resp->unfocus_nfocus = nfocus;
    348350}
    349351
  • uspace/lib/ui/test/window.c

    rb3eeae5 r46a47c0  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4949static void test_window_unmaximize(ui_window_t *, void *);
    5050static void test_window_close(ui_window_t *, void *);
    51 static void test_window_focus(ui_window_t *, void *);
     51static void test_window_focus(ui_window_t *, void *, unsigned);
    5252static void test_window_kbd(ui_window_t *, void *, kbd_event_t *);
    5353static errno_t test_window_paint(ui_window_t *, void *);
    5454static void test_window_pos(ui_window_t *, void *, pos_event_t *);
    55 static void test_window_unfocus(ui_window_t *, void *);
     55static void test_window_unfocus(ui_window_t *, void *, unsigned);
    5656
    5757static ui_window_cb_t test_window_cb = {
     
    7272static errno_t test_ctl_paint(void *);
    7373static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    74 static void test_ctl_unfocus(void *);
     74static void test_ctl_unfocus(void *, unsigned);
    7575
    7676static ui_control_ops_t test_ctl_ops = {
     
    8787        bool close;
    8888        bool focus;
     89        unsigned focus_nfocus;
    8990        bool kbd;
    9091        kbd_event_t kbd_event;
     
    9394        pos_event_t pos_event;
    9495        bool unfocus;
     96        unsigned unfocus_nfocus;
    9597} test_cb_resp_t;
    9698
     
    102104        pos_event_t pos_event;
    103105        bool unfocus;
     106        unsigned unfocus_nfocus;
    104107} test_ctl_resp_t;
    105108
     
    530533        resp.unfocus = false;
    531534
    532         ui_window_def_unfocus(window);
     535        ui_window_def_unfocus(window, 42);
    533536        PCUT_ASSERT_TRUE(resp.unfocus);
     537        PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
    534538
    535539        /* Need to remove first because we didn't implement the destructor */
     
    704708
    705709        /* Focus callback with no callbacks set */
    706         ui_window_send_focus(window);
     710        ui_window_send_focus(window, 42);
    707711
    708712        /* Focus callback with focus callback not implemented */
    709713        ui_window_set_cb(window, &dummy_window_cb, NULL);
    710         ui_window_send_focus(window);
     714        ui_window_send_focus(window, 42);
    711715
    712716        /* Focus callback with real callback set */
    713717        resp.focus = false;
    714718        ui_window_set_cb(window, &test_window_cb, &resp);
    715         ui_window_send_focus(window);
     719        ui_window_send_focus(window, 42);
    716720        PCUT_ASSERT_TRUE(resp.focus);
     721        PCUT_ASSERT_INT_EQUALS(42, resp.focus_nfocus);
    717722
    718723        ui_window_destroy(window);
     
    872877
    873878        /* Unfocus callback with no callbacks set */
    874         ui_window_send_unfocus(window);
     879        ui_window_send_unfocus(window, 42);
    875880
    876881        /* Unfocus callback with unfocus callback not implemented */
    877882        ui_window_set_cb(window, &dummy_window_cb, NULL);
    878         ui_window_send_unfocus(window);
     883        ui_window_send_unfocus(window, 42);
    879884
    880885        /* Unfocus callback with real callback set */
    881886        resp.close = false;
    882887        ui_window_set_cb(window, &test_window_cb, &resp);
    883         ui_window_send_unfocus(window);
     888        ui_window_send_unfocus(window, 42);
    884889        PCUT_ASSERT_TRUE(resp.unfocus);
     890        PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
    885891
    886892        ui_window_destroy(window);
     
    916922}
    917923
    918 static void test_window_focus(ui_window_t *window, void *arg)
     924static void test_window_focus(ui_window_t *window, void *arg, unsigned nfocus)
    919925{
    920926        test_cb_resp_t *resp = (test_cb_resp_t *) arg;
    921927
    922928        resp->focus = true;
     929        resp->focus_nfocus = nfocus;
    923930}
    924931
     
    949956}
    950957
    951 static void test_window_unfocus(ui_window_t *window, void *arg)
     958static void test_window_unfocus(ui_window_t *window, void *arg, unsigned nfocus)
    952959{
    953960        test_cb_resp_t *resp = (test_cb_resp_t *) arg;
    954961
    955962        resp->unfocus = true;
     963        resp->unfocus_nfocus = nfocus;
    956964}
    957965
     
    974982}
    975983
    976 static void test_ctl_unfocus(void *arg)
     984static void test_ctl_unfocus(void *arg, unsigned nfocus)
    977985{
    978986        test_ctl_resp_t *resp = (test_ctl_resp_t *) arg;
    979987
    980988        resp->unfocus = true;
     989        resp->unfocus_nfocus = nfocus;
    981990}
    982991
Note: See TracChangeset for help on using the changeset viewer.