idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
branchRCL_3
changeset 17 b8fae6b8a148
parent 12 9674c1a575e9
child 18 d05a55b217df
--- a/idlehomescreen/widgetmanager/src/wmmaincontainer.cpp	Mon Mar 15 12:39:47 2010 +0200
+++ b/idlehomescreen/widgetmanager/src/wmmaincontainer.cpp	Wed Mar 31 21:17:19 2010 +0300
@@ -724,7 +724,9 @@
     {
     if ( !iClosingDown  )
         {
-		
+        TBool eatEvent( EFalse );
+        TPointerEvent event( aPointerEvent );
+
 		if (aPointerEvent.iType == TPointerEvent::EButton1Down)
 			{
 	        // Check if user clicked a child control
@@ -748,9 +750,37 @@
 	            // repaint
 	            DrawDeferred();
 	            }
+	        
+	        // stylus popup should not be opened when uninstalling. 
+	        // ou1cimx1#302973
+	        if ( control == iWidgetsList && iWidgetsList->IsFocused() )
+	             {
+	             TInt itemIndex = iWidgetsList->CurrentListBoxItemIndex();
+	             TBool itemPointed = iWidgetsList->View()->XYPosToItemIndex(
+	                                     aPointerEvent.iPosition,
+	                                     itemIndex );
+	             if ( itemIndex >= 0 && itemPointed )
+	                 {
+	                 CWmWidgetData& data = iWidgetsList->WidgetData( itemIndex );                
+	                 if ( &data && data.IsUninstalling() )
+	                     {
+                         event.iType = TPointerEvent::EButton1Up;
+	                     eatEvent = ETrue;
+	                     }
+	                 }
+	             }
+	        
 			}
-        
-        CCoeControl::HandlePointerEventL( aPointerEvent );
+		
+		// set downkey event to base class
+		CCoeControl::HandlePointerEventL( aPointerEvent );
+		
+		// send key up event if selected widget is being uninstalled.
+		// stylus popup shouldn't be displayed for this item.
+		if ( eatEvent )
+		    {
+            CCoeControl::HandlePointerEventL( event );
+		    }
         }
     }
 
@@ -950,7 +980,8 @@
     if ( WidgetSelected() && data && !data->IsUninstalling() )
         {
         if ( data->WidgetType() == CWmWidgetData::ECps &&
-                data->PublisherUid() != KNullUid )
+            data->PublisherUid() != KNullUid && 
+            data->WrtType() != CWmWidgetData::EUnIdentified )
             {
             retVal = ETrue;
             }
@@ -1025,37 +1056,20 @@
 void CWmMainContainer::AddWidgetToHomeScreenL()
     {
     CWmWidgetData* data = iWidgetsList->WidgetData();
-    if ( !iClosingDown && data && !data->IsUninstalling() )
+    if ( !iClosingDown )
         {
         if ( iFindbox && iFindPaneIsVisible )
             {
             DeactivateFindPaneL();
             }
-
-        // set add to homescreen to be executed later
-        iWmPlugin.SetPostponedCommandL(
-            CWmPlugin::EAddToHomescreen,
-            data->HsContentInfo() );
-
-        // check if we can add any widgets to hs. 
-        TBool hsContentFull = ETrue;
-        for ( TInt i=0; i<iWidgetsList->WidgetDataCount(); i++ )
+        
+        if ( data && !data->IsUninstalling() )
             {
-            CHsContentInfo& info = iWidgetsList->WidgetData(i).HsContentInfo();
-            if ( info.CanBeAdded() ) 
-                {
-                hsContentFull = EFalse;
-                break;
-                }
-            }
-        
-        // deactivate wm if there's not enough space to add widget to hs.
-        if ( !data->HsContentInfo().CanBeAdded() && !hsContentFull )
-            {
-            iWmPlugin.ExecuteCommandL();
-            }
-        else
-            {
+            // set add to homescreen to be executed later
+            iWmPlugin.SetPostponedCommandL(
+                        CWmPlugin::EAddToHomescreen,
+                        data->HsContentInfo() );
+
             iWmPlugin.CloseView();
             }
         }
@@ -1089,11 +1103,14 @@
 // CWmMainContainer::ActivateFindPaneL
 // ---------------------------------------------------------------------------
 //
-void CWmMainContainer::ActivateFindPaneL( TBool aActivateAdabtive )
+void CWmMainContainer::ActivateFindPaneL( TBool aActivateAdaptive )
     {
     if ( iFindbox && !iFindPaneIsVisible &&
             iWidgetsList->Model()->NumberOfItems() > KMinWidgets )
         {
+        // reset focus
+        ResetFocus();
+        
         // set column filter flag
         TBitFlags32 bitFlag;
         bitFlag.ClearAll(); // clear all columns
@@ -1122,7 +1139,7 @@
         // layout listbox and findbox
         LayoutControls();        
         
-        if ( aActivateAdabtive )
+        if ( aActivateAdaptive )
             {
             iFindbox->ShowAdaptiveSearchGrid();
             }
@@ -1162,11 +1179,12 @@
             m->Filter()->ResetFilteringL();
             m->RemoveFilter();
             }
+        
+        ResetFocus();
 
-        iFindbox->MakeVisible( EFalse );
-        iFindbox->SetFocus( EFalse );
-        iFindPaneIsVisible = EFalse;
-        iWidgetsList->SetFindPaneIsVisible( EFalse );
+        iFindbox->MakeVisible( EFalse );        
+        iFindPaneIsVisible = EFalse;        
+        iWidgetsList->SetFindPaneIsVisible( EFalse );       
         
         LayoutControls();
 
@@ -1407,22 +1425,36 @@
 //
 void CWmMainContainer::ProcessForegroundEvent( TBool aForeground )
     {
-    if ( aForeground )
+    if ( iFindbox && iFindPaneIsVisible && 
+        iFindbox->IsFocused() )
+        {
+        // keep focus & do nothing 
+        }
+    else if ( aForeground )
         {
         // set init state when wm comes to foreground.
 		// remove focus from all controls when activating view.
-        CCoeControl* control = NULL;
-        CCoeControlArray::TCursor cursor = Components().Begin();
-        while( ( control = cursor.Control<CCoeControl>() ) != NULL )
+        ResetFocus( EDrawNow );
+        }
+    }
+
+// ----------------------------------------------------
+// CWmMainContainer::ResetFocus
+// ----------------------------------------------------
+//
+void CWmMainContainer::ResetFocus( TDrawNow aDrawNow )
+    {
+    CCoeControl* control = NULL;
+    CCoeControlArray::TCursor cursor = Components().Begin();
+    while( ( control = cursor.Control<CCoeControl>() ) != NULL )
+        {
+        if( control->IsVisible() && control->IsFocused() )
             {
-            if( control->IsVisible() && control->IsFocused() )
-                {
-                control->SetFocus( EFalse, EDrawNow );
-                }
-            cursor.Next();
+            control->SetFocus( EFalse, aDrawNow );
             }
-        UpdateFocusMode();
+        cursor.Next();
         }
+    UpdateFocusMode();
     }
 
 // ----------------------------------------------------