Tk Source Code

Check-in [6a72df82]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Accessibility names/descriptions now read by Orca
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | tka11y
Files: files | file ages | folders
SHA3-256: 6a72df82f121a131e0a3b62498a8abc0fd81c894b640978f5bfd4ed791864597
User & Date: kevin_walzer 2025-08-15 21:44:49.671
Context
2025-08-15
21:44
Accessibility names/descriptions now read by Orca Leaf check-in: 6a72df82 user: kevin_walzer tags: tka11y
19:13
Additional cleanup check-in: a6258251 user: kevin_walzer tags: tka11y
Changes
Unified Diff Ignore Whitespace Patch
Changes to unix/tkUnixAccessibility.c.
895
896
897
898
899
900
901
902
903


904
905


906
907


908
909


910
911
912
913
914
915
916
917
918
919
920
921
922


923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946


947
948


949
950


951
952


953
954
955
956
957
958
959
960
961
962
963
964
965
 */

static gchar *GetAtkNameForWidget(Tk_Window win)
{
    if (!win) return NULL;
    
    gchar *name = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "name"};


    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {


	Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
	if (AccessibleAttributes) {


	    Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
	    if (hPtr2) {


		const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
		if (result) {
		    name = sanitize_utf8(result);
		}
	    }
	}
    }
    return name;
}

static const gchar *tk_get_name(AtkObject *obj)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;


    return acc->cached_name;
}

static void tk_set_name(AtkObject *obj, const gchar *name)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;

    if (!acc) return; 

    if (obj == tk_root_accessible) {
	/* Free old cached name.  */
	g_free(acc->cached_name);
	acc->cached_name = sanitize_utf8(name); 
    }
    atk_object_set_name(obj, name);
}

static gchar *GetAtkDescriptionForWidget(Tk_Window win)
{
    if (!win) return NULL;

    gchar *description = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "description"};


    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {


	Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
	if (AccessibleAttributes) {


	    Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
	    if (hPtr2) {


		const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
		if (result) {
		    description = sanitize_utf8(result);
		}
	    }
	}
    }
    return description;
}

static const gchar *tk_get_description(AtkObject *obj)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;







<

>
>


>
>
|
|
>
>
|
|
>
>
|
|
|
|
|
|







>
>




















|

<

>
>


>
>
|
|
>
>
|
|
>
>
|
|
|
|
|
|







895
896
897
898
899
900
901

902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953

954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
 */

static gchar *GetAtkNameForWidget(Tk_Window win)
{
    if (!win) return NULL;
    
    gchar *name = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "name"};
    
    /* Find the window's hash entry. */
    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {
        /* Get the attributes table, passing hPtr as result. */
        data.result = (gpointer)hPtr;
        Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
        if (AccessibleAttributes) {
            /* Find the name key, passing the table as result. */
            data.result = (gpointer)AccessibleAttributes;
            Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
            if (hPtr2) {
                /* Get the string value, passing hPtr2 as result. */
                data.result = (gpointer)hPtr2;
                const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
                if (result) {
                    name = sanitize_utf8(result);
                }
            }
        }
    }
    return name;
}

static const gchar *tk_get_name(AtkObject *obj)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;
    gchar *name = GetAtkNameForWidget(acc->tkwin);
    acc->cached_name = name;
    return acc->cached_name;
}

static void tk_set_name(AtkObject *obj, const gchar *name)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;

    if (!acc) return; 

    if (obj == tk_root_accessible) {
	/* Free old cached name.  */
	g_free(acc->cached_name);
	acc->cached_name = sanitize_utf8(name); 
    }
    atk_object_set_name(obj, name);
}

static gchar *GetAtkDescriptionForWidget(Tk_Window win)
{
    if (!win) return NULL;
    
    gchar *description = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "description"};
    
    /* Find the window's hash entry. */
    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {
        /* Get the attributes table, passing hPtr as result. */
        data.result = (gpointer)hPtr;
        Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
        if (AccessibleAttributes) {
            /* Find the name key, passing the table as result. */
            data.result = (gpointer)AccessibleAttributes;
            Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
            if (hPtr2) {
                /* Get the string value, passing hPtr2 as result. */
                data.result = (gpointer)hPtr2;
                const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
                if (result) {
                    description = sanitize_utf8(result);
                }
            }
        }
    }
    return description;
}

static const gchar *tk_get_description(AtkObject *obj)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;
973
974
975
976
977
978
979
980
981


982
983


984
985


986
987


988
989
990
991
992
993
994
995
996
997
998
999
1000
 */

static gchar *GetAtkValueForWidget(Tk_Window win)
{
    if (!win) return NULL;
    
    gchar *value = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "value"};


    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {


	Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
	if (AccessibleAttributes) {


	    Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
	    if (hPtr2) {


		const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
		if (result) {
		    value = sanitize_utf8(result);
		}
	    }
	}
    }
    return value;
}

 
static void tk_get_current_value(AtkValue *obj, GValue *value)
{







<

>
>


>
>
|
|
>
>
|
|
>
>
|
|
|
|
|
|







989
990
991
992
993
994
995

996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
 */

static gchar *GetAtkValueForWidget(Tk_Window win)
{
    if (!win) return NULL;
    
    gchar *value = NULL;

    MainThreadData data = {win, NULL, NULL, NULL, "value"};
    
    /* Find the window's hash entry. */
    Tcl_HashEntry *hPtr = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_main, &data);
    if (hPtr) {
        /* Get the attributes table, passing hPtr as result. */
        data.result = (gpointer)hPtr;
        Tcl_HashTable *AccessibleAttributes = (Tcl_HashTable *)RunOnMainThread(get_hash_value_main, &data);
        if (AccessibleAttributes) {
            /* Find the name key, passing the table as result. */
            data.result = (gpointer)AccessibleAttributes;
            Tcl_HashEntry *hPtr2 = (Tcl_HashEntry *)RunOnMainThread(find_hash_entry_by_key_main, &data);
            if (hPtr2) {
                /* Get the string value, passing hPtr2 as result. */
                data.result = (gpointer)hPtr2;
                const char *result = (const char *)RunOnMainThread(get_hash_string_value_main, &data);
                if (result) {
                    value = sanitize_utf8(result);
                }
            }
        }
    }
    return value;
}

 
static void tk_get_current_value(AtkValue *obj, GValue *value)
{
1430
1431
1432
1433
1434
1435
1436

1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449

1450
1451
1452
1453
1454
1455
1456
    if (role == ATK_ROLE_UNKNOWN &&
        ((gboolean)(uintptr_t)RunOnMainThread(is_toplevel_main, &data) ||
         tkwin == (Tk_Window)RunOnMainThread(get_main_window_main, &(MainThreadData){NULL, interp, NULL, NULL, NULL}))) {
        role = ATK_ROLE_WINDOW;
    }
    atk_object_set_role(obj, role);


    /* Set ATK name and description. */
    if (acc->cached_description && *acc->cached_description) {
        atk_object_set_name(obj, acc->cached_description);
    } else if (acc->cached_name && *acc->cached_name) {
        atk_object_set_name(obj, acc->cached_name);
    } else {
        atk_object_set_name(obj, path);
    }
    if (acc->cached_description && *acc->cached_description) {
        atk_object_set_description(obj, acc->cached_description);
    } else {
        atk_object_set_description(obj, path);
    }


    /* Set initial states. */
    AtkStateSet *state_set = atk_object_ref_state_set(obj);
    if (state_set != NULL) {
        atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
        atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
        atk_state_set_add_state(state_set, ATK_STATE_ENABLED);







>













>







1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
    if (role == ATK_ROLE_UNKNOWN &&
        ((gboolean)(uintptr_t)RunOnMainThread(is_toplevel_main, &data) ||
         tkwin == (Tk_Window)RunOnMainThread(get_main_window_main, &(MainThreadData){NULL, interp, NULL, NULL, NULL}))) {
        role = ATK_ROLE_WINDOW;
    }
    atk_object_set_role(obj, role);

#if 0
    /* Set ATK name and description. */
    if (acc->cached_description && *acc->cached_description) {
        atk_object_set_name(obj, acc->cached_description);
    } else if (acc->cached_name && *acc->cached_name) {
        atk_object_set_name(obj, acc->cached_name);
    } else {
        atk_object_set_name(obj, path);
    }
    if (acc->cached_description && *acc->cached_description) {
        atk_object_set_description(obj, acc->cached_description);
    } else {
        atk_object_set_description(obj, path);
    }
    #endif

    /* Set initial states. */
    AtkStateSet *state_set = atk_object_ref_state_set(obj);
    if (state_set != NULL) {
        atk_state_set_add_state(state_set, ATK_STATE_VISIBLE);
        atk_state_set_add_state(state_set, ATK_STATE_SHOWING);
        atk_state_set_add_state(state_set, ATK_STATE_ENABLED);
1646
1647
1648
1649
1650
1651
1652

1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
}

static void UpdateNameCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "name"};
    acc->cached_name = (gchar*)RunOnMainThread(get_atk_name_for_widget_main, &data);

}

static void UpdateDescriptionCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "description"};
    acc->cached_value = (gchar*)RunOnMainThread(get_atk_description_for_widget_main, &data);
}

static void UpdateValueCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "value"};
    acc->cached_value = (gchar*)RunOnMainThread(get_atk_value_for_widget_main, &data);







>






|







1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
}

static void UpdateNameCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "name"};
    acc->cached_name = (gchar*)RunOnMainThread(get_atk_name_for_widget_main, &data);
    g_warning("name is %s\n", acc->cached_name);
}

static void UpdateDescriptionCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "description"};
    acc->cached_description = (gchar*)RunOnMainThread(get_atk_description_for_widget_main, &data);
}

static void UpdateValueCache(TkAtkAccessible *acc)
{
    if (!acc || !acc->tkwin) return;
    MainThreadData data = {acc->tkwin, acc->interp, NULL, NULL, "value"};
    acc->cached_value = (gchar*)RunOnMainThread(get_atk_value_for_widget_main, &data);