diff -aburB cvs/of/gnopernicus/srcore/default.xml.in gnopernicus/srcore/default.xml.in
--- cvs/of/gnopernicus/srcore/default.xml.in	2004-08-05 11:02:47.000000000 +0300
+++ gnopernicus/srcore/default.xml.in	2004-08-03 19:30:41.000000000 +0300
@@ -134,12 +134,6 @@
           <attribute type="string">name</attribute>
         </event>
       </role>
-      <role name="label">
-        <event name="generic">
-          <attribute type="string">role</attribute>
-          <attribute type="string">name</attribute>
-        </event>
-      </role>
       <role name="link">
         <event name="generic">
           <attribute type="string">role</attribute>
@@ -630,11 +624,8 @@
           <_literal voice="system">titleize window</_literal>
           <attribute type="string" voice="name">name</attribute>
         </event>
-      </role>
-      <role name="label">
-        <event name="generic">
+        <event name="object:context-switched">
           <attribute type="string" voice="name">name</attribute>
-          <attribute type="string" voice="role">role</attribute>
         </event>
       </role>
       <role name="link">
diff -aburB cvs/of/gnopernicus/srcore/verbose.xml.in gnopernicus/srcore/verbose.xml.in
--- cvs/of/gnopernicus/srcore/verbose.xml.in	2004-08-05 11:02:47.000000000 +0300
+++ gnopernicus/srcore/verbose.xml.in	2004-08-03 19:29:36.000000000 +0300
@@ -134,12 +134,6 @@
           <attribute type="string">name</attribute>
         </event>
       </role>
-      <role name="label">
-        <event name="generic">
-          <attribute type="string">role</attribute>
-          <attribute type="string">name</attribute>
-        </event>
-      </role>
       <role name="link">
         <event name="generic">
           <attribute type="string">role</attribute>
@@ -635,12 +629,8 @@
           <_literal voice="system">titleize window</_literal>
           <attribute type="string" voice="name">name</attribute>
         </event>
-      </role>
-      <role name="label">
-        <event name="generic">
+        <event name="object:context-switched">
           <attribute type="string" voice="name">name</attribute>
-          <attribute type="string" voice="description">description</attribute>
-	  <attribute type="string" voice="role">role</attribute>
         </event>
       </role>
       <role name="link">
diff -aburB cvs/of/gnopernicus/srlow/libsrlow/SRLow.c gnopernicus/srlow/libsrlow/SRLow.c
--- cvs/of/gnopernicus/srlow/libsrlow/SRLow.c	2004-08-05 11:02:48.000000000 +0300
+++ gnopernicus/srlow/libsrlow/SRLow.c	2004-08-05 10:36:28.000000000 +0300
@@ -74,6 +74,7 @@
 #define SRL_EVENT_NAME_CHILDREN_REMOVED         "object:children-changed:remove"
 #define SRL_EVENT_NAME_TAB_ADDED                "object:tab-added"
 #define SRL_EVENT_NAME_TAB_REMOVED              "object:tab-removed"
+#define SRL_EVENT_NAME_CONTEXT_SWITCHED         "object:context-switched"
 
 #define SRL_TOOLKIT_MOZILLA			"mozilla"
 #define SRL_APP_METACITY			"metacity"
@@ -116,8 +117,7 @@
     SRL_EVENT_CHILDREN_REMOVED,
     SRL_EVENT_TAB_ADDED,
     SRL_EVENT_TAB_REMOVED,
-    
-
+    SRL_EVENT_CONTEXT_SWITCHED,
     SRL_EVENT_WINDOW_RENAME
 }SRLEventType;
 
@@ -195,6 +195,7 @@
 static Accessible		*srl_last_focus		= NULL;
 static Accessible		*srl_watched_acc	= NULL;
 static Accessible 		*srl_last_table 	= NULL;
+static Accessible 		*srl_last_context 	= NULL;
 /*FIXME:next varaible should be in SRObject.c file */
 Accessible 			*srl_last_edit		= NULL;
 
@@ -510,6 +511,7 @@
 
     if (event->acc)
 	Accessible_unref (event->acc);
+    if (event->acc_ev)
     AccessibleEvent_unref (event->acc_ev);
     g_free (event);
 }
@@ -711,6 +713,8 @@
 	return SRL_EVENT_NAME_FOCUS;
     if (srle_has_type (event, SRL_EVENT_FOCUS2))
 	return SRL_EVENT_NAME_FOCUS;
+    if (srle_has_type (event, SRL_EVENT_CONTEXT_SWITCHED))
+	return SRL_EVENT_NAME_CONTEXT_SWITCHED;
 
     srl_assert_not_reached ();
     return SRL_EVENT_NAME_UNKNOWN;
@@ -734,6 +738,7 @@
 	    event->type == SRL_EVENT_WINDOW_DEACTIVATE ||
 	    event->type == SRL_EVENT_WINDOW_RENAME ||
 	    event->type == SRL_EVENT_TAB_ADDED ||
+	    event->type == SRL_EVENT_CONTEXT_SWITCHED ||
 	    event->type == SRL_EVENT_TAB_REMOVED;
 }
 static gboolean
@@ -995,7 +1000,7 @@
 		sro_set_difference (obj, diff);
 	    SPI_freeString (diff);
 	}
-	if (srl_is_window_event (event))
+	if (srl_is_window_event (event) && event->type != SRL_EVENT_CONTEXT_SWITCHED)
 	{
 	    gchar *name = AccessibleWindowEvent_getTitleString (event->acc_ev);
 	    if (name)
@@ -1682,6 +1687,148 @@
 }
 
 static gboolean
+srl_is_label_for (Accessible *label, Accessible *acc)
+{
+    AccessibleRelation **relation;
+    gint i;
+    gboolean rv = FALSE;
+
+    srl_assert (acc && label);
+
+    relation = Accessible_getRelationSet (acc);
+    if (!relation)
+	return FALSE;
+    for (i = 0; !rv && relation[i]; ++i)
+    {
+	if (AccessibleRelation_getRelationType (relation[i]) == SPI_RELATION_LABELED_BY)
+	{
+	    gint j, cnt;
+	    cnt = AccessibleRelation_getNTargets (relation[i]);
+	    for (j = 0; !rv && j < cnt; j++)
+	    {
+		Accessible *label_;
+		label_ = AccessibleRelation_getTarget (relation[i], j);
+		if (label_ == label)
+		    rv = TRUE;
+		if (label_)
+		    Accessible_unref (label_);
+	    }
+	}
+    }
+    for (i = 0; relation[i]; ++i)
+	AccessibleRelation_unref (relation[i]);
+    g_free (relation);
+
+    return rv;
+}
+
+
+#define SRL_MAX_LEVELS_UP 5
+static Accessible*
+srl_get_context (Accessible *acc)
+{
+    Accessible *context;
+    gint i;
+
+    sru_assert (acc);
+
+    context = NULL;
+    Accessible_ref (acc);
+    for (i = 0; i < SRL_MAX_LEVELS_UP; i++)
+    {
+	Accessible *parent = Accessible_getParent (acc);
+	if (parent)
+	{
+	    AccessibleRole role;
+	    Accessible_unref (acc);
+	    acc = parent;
+	    role = Accessible_getRole (acc);
+	    if (role == SPI_ROLE_EMBEDDED)
+	    {
+		context = acc;
+		Accessible_ref (context);
+	    }
+	    if (srl_acc_has_state (acc, SPI_STATE_VERTICAL) && 
+		    (role == SPI_ROLE_FILLER || role == SPI_ROLE_PANEL))
+	    {
+		gint cnt;
+		cnt = Accessible_getChildCount (acc);
+		if (cnt == 2)
+		{
+		    Accessible *label, *container;
+		    label = Accessible_getChildAtIndex (acc, 0);
+		    container = Accessible_getChildAtIndex (acc, 1);
+		    if (label && container)
+		    {
+			if (Accessible_getRole (label) == SPI_ROLE_LABEL &&
+			    Accessible_getRole (container) == SPI_ROLE_FILLER)
+			{
+			    gchar *name = Accessible_getName (label);
+			    if (name && name[0])
+				if (!srl_is_label_for (label, acc))
+				{
+				    context = label;
+				    Accessible_ref (label);
+				}
+			    SPI_freeString (name);
+			}
+		    }
+		    if (label)
+		        Accessible_unref (label);
+		    if (container)
+		        Accessible_unref (container);
+		}
+	    }
+	}
+	else
+	    break;
+	if (context)
+	    break;
+    }
+    if (acc)
+	Accessible_unref (acc);
+    return context;
+}
+
+static gboolean
+srl_check_context_changed (SRLEvent *event)
+{
+    Accessible *context;
+
+    srl_assert (event);
+
+    context = srl_get_context (event->acc_ev->source);
+    if (context)
+    {
+	if (context != srl_last_context)
+	{
+	    SRLEvent *ev;
+	    if (srl_last_context)
+		Accessible_unref (srl_last_context);
+	    srl_last_context = context;
+	    ev = srle_new ();
+	    ev->acc = srl_last_context;
+	    Accessible_ref (srl_last_context);
+	    ev->type = SRL_EVENT_CONTEXT_SWITCHED;
+	    srl_notify_clients_obj (ev, SR_EVENT_WINDOW);
+	    srle_free (ev);
+	}
+	else
+	{
+	    Accessible_unref (context);
+	}
+    }
+    else
+    {
+	if (srl_last_context)
+	    Accessible_unref (srl_last_context);
+	srl_last_context = NULL;    
+    }
+    return TRUE;
+}
+
+
+static gboolean
 srl_process_event (SRLEvent *event)
 {
     gboolean process = FALSE;
@@ -1693,6 +1840,9 @@
     srle_change_type (event);
     process = srl_event_is_reported (event);
 
+    if (srle_has_type (event, SRL_EVENT_FOCUS))
+	srl_check_context_changed (event);
+
     if (srle_has_type (event, SRL_EVENT_FOCUS) ||
 	srle_has_type (event, SRL_EVENT_FOCUS2))
 	    srl_set_last_focus ((Accessible*)srle_get_acc (event));
@@ -1776,6 +1926,7 @@
     srl_idle_installed	= FALSE;
     srl_watched_acc	= NULL;
     srl_last_table	= NULL;
+    srl_last_context 	= NULL;
     
     srl_log_init ();
     srl_timing_init ();
@@ -1838,6 +1989,8 @@
 	Accessible_unref (srl_watched_acc);
     if (srl_last_table)
 	Accessible_unref (srl_last_table);
+    if (srl_last_context)
+	Accessible_unref (srl_last_context);
     srl_log_terminate ();
     srl_timing_terminate ();
     srl_set_uninitialized ();
