Changeset 46a47c0 in mainline for uspace/lib/ui/test/window.c


Ignore:
Timestamp:
2023-01-16T20:34:01Z (2 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.