1 #include <atk/atk.h>
2
3 static void _check_position (AtkObject *obj);
4
_check_position(AtkObject * obj)5 static void _check_position (AtkObject *obj)
6 {
7 AtkObject *parent, *ret_object;
8
9 gint x, y, width, height;
10 gint x1, y1, width1, height1;
11
12 x = y = width = height = 0;
13 x1 = y1 = width1 = height1 = 0;
14
15 if (!ATK_IS_COMPONENT (obj))
16 return;
17
18 atk_component_get_extents (ATK_COMPONENT(obj), &x, &y, &width, &height, ATK_XY_SCREEN);
19 atk_component_get_position (ATK_COMPONENT(obj), &x1, &y1, ATK_XY_SCREEN );
20 atk_component_get_size (ATK_COMPONENT(obj), &width1, &height1);
21 if ((x1 != x) || (y1 != y))
22 {
23 g_print ("atk_component_get_extents and atk_get_position give different"
24 " values: %d,%d %d,%d\n", x, y, x1, y1);
25 }
26 if ((width1 != width) || (height1 != height))
27 {
28 g_print ("atk_component_get_extents and atk_get_size give different"
29 " values: %d,%d %d,%d\n", width, height, width1, height1);
30 }
31
32 atk_component_get_position (ATK_COMPONENT(obj), &x1, &y1, ATK_XY_SCREEN);
33 g_print ("Object Type: %s\n", g_type_name (G_OBJECT_TYPE (obj)));
34 g_print ("Object at %d, %d on screen\n", x1, y1);
35 g_print ("Object at %d, %d, size: %d, %d\n", x, y, width, height);
36
37 parent = atk_object_get_parent (obj);
38
39 if (ATK_IS_COMPONENT (parent))
40 {
41 gint px, py, pwidth, pheight;
42
43 atk_component_get_extents (ATK_COMPONENT(parent),
44 &px, &py, &pwidth, &pheight, ATK_XY_SCREEN);
45 g_print ("Parent Type: %s\n", g_type_name (G_OBJECT_TYPE (parent)));
46 g_print ("Parent at %d, %d, size: %d, %d\n", px, py, pwidth, pheight);
47 ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
48 x, y, ATK_XY_SCREEN);
49
50 if (!ret_object)
51 {
52 g_print ("1:atk_component_ref_accessible_at_point returns NULL\n");
53 }
54 else if (ret_object != obj)
55 {
56 g_print ("1:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
57 x, y);
58 atk_component_get_extents (ATK_COMPONENT(ret_object),
59 &px, &py, &pwidth, &pheight, ATK_XY_SCREEN);
60 g_print ("ret_object at %d, %d, size: %d, %d\n", px, py, pwidth, pheight);
61 }
62 if (ret_object)
63 g_object_unref (G_OBJECT (ret_object));
64 ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
65 x+width-1, y+height-1, ATK_XY_SCREEN);
66 if (!ret_object)
67 {
68 g_print ("2:atk_component_ref_accessible_at_point returns NULL\n");
69 }
70 else if (ret_object != obj)
71 {
72 g_print ("2:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
73 x+width-1, y+height-1);
74 }
75 if (ret_object)
76 g_object_unref (G_OBJECT (ret_object));
77 ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
78 x-1, y-1, ATK_XY_SCREEN);
79 if ((ret_object) && (ret_object == obj))
80 {
81 g_print ("3:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
82 x-1, y-1);
83 }
84 if (ret_object)
85 g_object_unref (G_OBJECT (ret_object));
86 ret_object = atk_component_ref_accessible_at_point (ATK_COMPONENT (parent),
87 x+width, y+height, ATK_XY_SCREEN);
88 if ((ret_object) && (ret_object == obj))
89 {
90 g_print ("4:atk_component_ref_accessible_at_point returns wrong value for %d %d\n",
91 x+width, y+height);
92 }
93 if (ret_object)
94 g_object_unref (G_OBJECT (ret_object));
95 }
96 if (!atk_component_contains (ATK_COMPONENT(obj), x, y, ATK_XY_SCREEN))
97 g_print ("Component does not contain position, %d %d\n", x, y);
98 if (atk_component_contains (ATK_COMPONENT(obj), x-1, y-1, ATK_XY_SCREEN))
99 g_print ("Component does contain position, %d %d\n", x-1, y-1);
100 if (!atk_component_contains (ATK_COMPONENT(obj), x+width-1, y+height-1, ATK_XY_SCREEN))
101 g_print ("Component does not contain position, %d %d\n",
102 x+width-1, y+height-1);
103 if (atk_component_contains (ATK_COMPONENT(obj), x+width, y+height, ATK_XY_SCREEN))
104 g_print ("Component does contain position, %d %d\n", x+width, y+height);
105 }
106
107 static void
_create_event_watcher(void)108 _create_event_watcher (void)
109 {
110 atk_add_focus_tracker (_check_position);
111 }
112
113 int
gtk_module_init(gint argc,char * argv[])114 gtk_module_init(gint argc, char* argv[])
115 {
116 g_print("testcomponent Module loaded\n");
117
118 _create_event_watcher();
119
120 return 0;
121 }
122