Tk Source Code

Check-in [cb8f83f4]
Login

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

Overview
Comment:Remove compiler warnings
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tka11y
Files: files | file ages | folders
SHA3-256: cb8f83f4d5136a5daff6f8462589e819bc9ae2fb0134392e39bd3c98cf620117
User & Date: kevin_walzer 2025-07-27 01:32:00.701
Context
2025-07-27
01:43
Minor adjustments check-in: b7bf7220 user: kevin_walzer tags: tka11y
01:32
Remove compiler warnings check-in: cb8f83f4 user: kevin_walzer tags: tka11y
01:11
Remove unneeded notifications check-in: 2cb94468 user: kevin_walzer tags: tka11y
Changes
Unified Diff Ignore Whitespace Patch
Changes to unix/tkUnixAccessibility.c.
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
static AtkObject *tk_root_accessible = NULL;
static GList *toplevel_accessible_objects = NULL; /* This list will hold refs to toplevels. */
static GHashTable *tk_to_atk_map = NULL; /* Maps Tk_Window to AtkObject. */

/* Atk/Tk glue functions. */
static void tk_get_extents(AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type);
static gint tk_get_n_children(AtkObject *obj);
static AtkObject *tk_ref_child(AtkObject *obj, guint i);
static AtkRole GetAtkRoleForWidget(Tk_Window win);
static AtkRole tk_get_role(AtkObject *obj);
static const gchar *tk_get_name(AtkObject *obj);
static void tk_set_name(AtkObject *obj, const gchar *name);
static const gchar *tk_get_description(AtkObject *obj);
static void tk_get_current_value(AtkValue *obj, GValue *value);
static AtkStateSet *tk_ref_state_set(AtkObject *obj);







|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
static AtkObject *tk_root_accessible = NULL;
static GList *toplevel_accessible_objects = NULL; /* This list will hold refs to toplevels. */
static GHashTable *tk_to_atk_map = NULL; /* Maps Tk_Window to AtkObject. */

/* Atk/Tk glue functions. */
static void tk_get_extents(AtkComponent *component, gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type);
static gint tk_get_n_children(AtkObject *obj);
static AtkObject *tk_ref_child(AtkObject *obj, gint i);
static AtkRole GetAtkRoleForWidget(Tk_Window win);
static AtkRole tk_get_role(AtkObject *obj);
static const gchar *tk_get_name(AtkObject *obj);
static void tk_set_name(AtkObject *obj, const gchar *name);
static const gchar *tk_get_description(AtkObject *obj);
static void tk_get_current_value(AtkValue *obj, GValue *value);
static AtkStateSet *tk_ref_state_set(AtkObject *obj);
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
			G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, tk_atk_action_interface_init)
			G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE, tk_atk_value_interface_init))

/*
 * Map Atk component interface to Tk.
 */
 
static void tk_get_extents(AtkComponent *component, gint *x, gint *y,gint *width, gint *height, AtkCoordType coord_type)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)component;

    if (!acc || !acc->tkwin) {
	*x = *y = *width = *height = 0;
	return;
    }







|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
			G_IMPLEMENT_INTERFACE(ATK_TYPE_ACTION, tk_atk_action_interface_init)
			G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE, tk_atk_value_interface_init))

/*
 * Map Atk component interface to Tk.
 */
 
    static void tk_get_extents(AtkComponent *component, gint *x, gint *y,gint *width, gint *height, AtkCoordType coord_type)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)component;

    if (!acc || !acc->tkwin) {
	*x = *y = *width = *height = 0;
	return;
    }
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218

219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
            count++;
        }
    }
    return count;
}


static AtkObject *tk_ref_child(AtkObject *obj, guint i)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;

    if (!acc) return NULL;

    if (obj == tk_root_accessible) {
        if (i >= g_list_length(toplevel_accessible_objects)) {

            return NULL;
        }
	/* Get accessible object from toplevel list. */
        AtkObject *child = g_list_nth_data(toplevel_accessible_objects, i);
        if (child) {
            g_object_ref(child); /* Increment ref count as per ATK interface contract. */
        }
        return child;
    }

    if (!acc->tkwin) {
        return NULL;
    }

    /* Return i-th direct child with accessible object. */
    int index = 0;
    TkWindow *winPtr = (TkWindow *)acc->tkwin;
    TkWindow *childPtr;
    for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) {
        AtkObject *child_obj = GetAtkObjectForTkWindow((Tk_Window)childPtr);
        if (child_obj) {
            if (index == i) {
                g_object_ref(child_obj); /* Increment ref count as per ATK interface contract. */
                return child_obj;
            }
            index++;
        }
    }
    return NULL;
}

/*
 * Functions to map accessible role to Atk.
 */

static AtkRole GetAtkRoleForWidget(Tk_Window win)
{
    if (!win) return ATK_ROLE_UNKNOWN;

    AtkObject *obj = GetAtkObjectForTkWindow(win);

    Tcl_HashEntry *hPtr, *hPtr2;
    Tcl_HashTable *AccessibleAttributes;
    AtkRole role = ATK_ROLE_UNKNOWN;

    /* Check if we have accessibility attributes. */
    hPtr = Tcl_FindHashEntry(TkAccessibilityObject, (char *)win);
    if (hPtr) {







|






|
>















|





|

















<
<







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258


259
260
261
262
263
264
265
            count++;
        }
    }
    return count;
}


static AtkObject *tk_ref_child(AtkObject *obj, gint i)
{
    TkAtkAccessible *acc = (TkAtkAccessible *)obj;

    if (!acc) return NULL;

    if (obj == tk_root_accessible) {
        if (i >= (gint)g_list_length(toplevel_accessible_objects))
 {
            return NULL;
        }
	/* Get accessible object from toplevel list. */
        AtkObject *child = g_list_nth_data(toplevel_accessible_objects, i);
        if (child) {
            g_object_ref(child); /* Increment ref count as per ATK interface contract. */
        }
        return child;
    }

    if (!acc->tkwin) {
        return NULL;
    }

    /* Return i-th direct child with accessible object. */
    guint index = 0;
    TkWindow *winPtr = (TkWindow *)acc->tkwin;
    TkWindow *childPtr;
    for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) {
        AtkObject *child_obj = GetAtkObjectForTkWindow((Tk_Window)childPtr);
        if (child_obj) {
	    if (i >= 0 && (guint)i == index) {
                g_object_ref(child_obj); /* Increment ref count as per ATK interface contract. */
                return child_obj;
            }
            index++;
        }
    }
    return NULL;
}

/*
 * Functions to map accessible role to Atk.
 */

static AtkRole GetAtkRoleForWidget(Tk_Window win)
{
    if (!win) return ATK_ROLE_UNKNOWN;



    Tcl_HashEntry *hPtr, *hPtr2;
    Tcl_HashTable *AccessibleAttributes;
    AtkRole role = ATK_ROLE_UNKNOWN;

    /* Check if we have accessibility attributes. */
    hPtr = Tcl_FindHashEntry(TkAccessibilityObject, (char *)win);
    if (hPtr) {
593
594
595
596
597
598
599
600

601
602
603
604
605
606
607
	 * Remove from toplevel list if it was a toplevel.
	 */
        if (Tk_IsTopLevel(self->tkwin)) {
            toplevel_accessible_objects = g_list_remove(toplevel_accessible_objects, self);
	    /* 
	     * No need to unref here, as the object is being finalized,
	     * and the list only held a pointer, not an owning ref.
	     * If the list *did* own a ref, it would be unreffed when removed from list.

	     */
        }
        /* Unregister from the Tk_Window to AtkObject map. */
        UnregisterAtkObjectForTkWindow(self->tkwin);
    }

    /* Free path and cached name. */







|
>







592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
	 * Remove from toplevel list if it was a toplevel.
	 */
        if (Tk_IsTopLevel(self->tkwin)) {
            toplevel_accessible_objects = g_list_remove(toplevel_accessible_objects, self);
	    /* 
	     * No need to unref here, as the object is being finalized,
	     * and the list only held a pointer, not an owning ref.
	     * If the list *did* own a ref, it would be unreffed when
	     * removed from list.
	     */
        }
        /* Unregister from the Tk_Window to AtkObject map. */
        UnregisterAtkObjectForTkWindow(self->tkwin);
    }

    /* Free path and cached name. */
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
            TkAtkAccessible_RegisterEventHandlers(child, (TkAtkAccessible *)child_obj);
        }

        /* Ensure proper parent relationship. */
        AtkObject *current_parent = atk_object_get_parent(child_obj);
        if (current_parent != parent_obj) {
	    /* 
         * If the child was previously parented to something else or unparented,
         * emit a remove signal from the old parent first if known.
	     * For simplicity, we'll just set the parent and emit 'add' for the new parent.
	     */
            atk_object_set_parent(child_obj, parent_obj);
            g_signal_emit_by_name(parent_obj, "children-changed::add", index, child_obj);
        }

        /* Set the name for the child object. */







|
|







692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
            TkAtkAccessible_RegisterEventHandlers(child, (TkAtkAccessible *)child_obj);
        }

        /* Ensure proper parent relationship. */
        AtkObject *current_parent = atk_object_get_parent(child_obj);
        if (current_parent != parent_obj) {
	    /* 
	     * If the child was previously parented to something else or unparented,
	     * emit a remove signal from the old parent first if known.
	     * For simplicity, we'll just set the parent and emit 'add' for the new parent.
	     */
            atk_object_set_parent(child_obj, parent_obj);
            g_signal_emit_by_name(parent_obj, "children-changed::add", index, child_obj);
        }

        /* Set the name for the child object. */
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
{
    if (!tk_root_accessible) {
        TkAtkAccessible *acc = g_object_new(TK_ATK_TYPE_ACCESSIBLE, NULL);
        tk_root_accessible = ATK_OBJECT(acc);
        atk_object_initialize(tk_root_accessible, NULL);

        /* Set proper application name. */
		atk_object_set_role(tk_root_accessible, ATK_ROLE_APPLICATION);

        /* Set an initial name for the root, can be updated later. */
        tk_set_name(tk_root_accessible, "Tk Application");
    }

    return tk_root_accessible;
}







|







733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
{
    if (!tk_root_accessible) {
        TkAtkAccessible *acc = g_object_new(TK_ATK_TYPE_ACCESSIBLE, NULL);
        tk_root_accessible = ATK_OBJECT(acc);
        atk_object_initialize(tk_root_accessible, NULL);

        /* Set proper application name. */
	atk_object_set_role(tk_root_accessible, ATK_ROLE_APPLICATION);

        /* Set an initial name for the root, can be updated later. */
        tk_set_name(tk_root_accessible, "Tk Application");
    }

    return tk_root_accessible;
}
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
}

static void GtkEventLoop(ClientData clientData) 
{
    GMainContext *context = (GMainContext *)clientData;
    if (!context) return;

/* Process GLib events immediately. */
    int iterations = 0;
    while (g_main_context_pending(context) && iterations < 25) {
        if (!g_main_context_iteration(context, FALSE)) break;
        iterations++;
    }

     /* Reschedule the event loop. */
    Tcl_CreateTimerHandler(50, GtkEventLoop, clientData);
}


/*
 * Functions to map Tk window to its corresponding Atk object.
 */







|

|




|







826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
}

static void GtkEventLoop(ClientData clientData) 
{
    GMainContext *context = (GMainContext *)clientData;
    if (!context) return;

    /* Process GLib events immediately. */
    int iterations = 0;
    while (g_main_context_pending(context) && iterations < 100) {
        if (!g_main_context_iteration(context, FALSE)) break;
        iterations++;
    }

    /* Reschedule the event loop. */
    Tcl_CreateTimerHandler(50, GtkEventLoop, clientData);
}


/*
 * Functions to map Tk window to its corresponding Atk object.
 */
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
 *	Accessibility module is now activated.
 *
 *----------------------------------------------------------------------
 */
#ifdef USE_ATK
int TkAtkAccessibility_Init(Tcl_Interp *interp)
{
    /* Set environment variables for proper AT-SPI operation. */
    g_setenv("GTK_MODULES", "gail:atk-bridge", FALSE);
    g_setenv("NO_AT_BRIDGE", "0", FALSE);

    /* Initialize Glib type system first. */
    g_type_init();

    /* Create and configure root object. */
    tk_root_accessible = tk_util_get_root();
    if (tk_root_accessible) {
	const gchar *name = tk_get_name(tk_root_accessible);
	if (name) {
	    tk_set_name(tk_root_accessible, name); /* Set the name and notify. */
	    g_free((gpointer)name); /* Free the string returned by tk_get_name. */







<
<
<
<
<
<
<







1197
1198
1199
1200
1201
1202
1203







1204
1205
1206
1207
1208
1209
1210
 *	Accessibility module is now activated.
 *
 *----------------------------------------------------------------------
 */
#ifdef USE_ATK
int TkAtkAccessibility_Init(Tcl_Interp *interp)
{







    /* Create and configure root object. */
    tk_root_accessible = tk_util_get_root();
    if (tk_root_accessible) {
	const gchar *name = tk_get_name(tk_root_accessible);
	if (name) {
	    tk_set_name(tk_root_accessible, name); /* Set the name and notify. */
	    g_free((gpointer)name); /* Free the string returned by tk_get_name. */