Pārlūkot izejas kodu

Remote file list was not focused on startup

Source commit: 9636ececfd1b215d030405726bf191e46b7c3fd2
Martin Prikryl 10 gadi atpakaļ
vecāks
revīzija
859f21a710

+ 7 - 2
source/forms/CustomScpExplorer.cpp

@@ -7437,7 +7437,7 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
         RemoteDirView->Enabled = true;
         if (FRemoteDirViewWasFocused)
         {
-          RemoteDirView->SetFocus();
+          ActiveControl = RemoteDirView;
         }
       }
       RemoteDriveView->Enabled = true;
@@ -7452,7 +7452,7 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
         // (not anymore due to Showing test above)
         // but the false is overriden in the constructor later.
         // An even later in TScpCommanderForm::DoShow()
-        FRemoteDirViewWasFocused = RemoteDirView->Focused();
+        FRemoteDirViewWasFocused = (ActiveControl == RemoteDirView);
         EnableControl(RemoteDirView, false);
       }
       EnableControl(RemoteDriveView, false);
@@ -7850,6 +7850,11 @@ void __fastcall TCustomScpExplorerForm::CMShowingChanged(TMessage & Message)
     // This happens before application ever goes idle, so the toolbars would
     // stay enabled (initial state) until the Login dialog is dismissed.
     UpdateActions();
+    // Need to process WM_ACTIVATEAPP before showing the Login dialog,
+    // otherwise the dialog does not receive focus.
+    // With Commander interface the ProcessMessages is called already
+    // by TDriveView, but with Explorer interface, we need to call it explicily
+    Application->ProcessMessages();
     // do not reload sessions, they have been loaded just now (optimization)
     NeedSession(false);
   }

+ 12 - 3
source/forms/ScpCommander.cpp

@@ -340,6 +340,18 @@ bool __fastcall TScpCommanderForm::CopyParamDialog(TTransferDirection Direction,
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::DoShow()
 {
+  // Make sure the RemoteDirView is disabled (if not connected yet)
+  // before the focusing below,
+  // otherwise we disable the view while setting it focused
+  // (UpdateControls gets calling within the SetFocus),
+  // leading to VCL focus inconsistency wih Windows,
+  // and the view [anothing actually] not getting focused after the session
+  // is finally connected
+  UpdateControls();
+
+  // If we do not call SetFocus on any control before DoShow,
+  // no control will get focused on Login dialog
+  // (HACK seems like a bug in VCL)
   if (WinConfiguration->ScpCommander.CurrentPanel == osLocal)
   {
     LocalDirView->SetFocus();
@@ -355,13 +367,10 @@ void __fastcall TScpCommanderForm::DoShow()
     {
       LocalDirView->SetFocus();
     }
-    assert(FRemoteDirViewWasFocused);
     FRemoteDirViewWasFocused = true;
   }
 
   TCustomScpExplorerForm::DoShow();
-
-  UpdateControls();
 }
 //---------------------------------------------------------------------------
 Boolean __fastcall TScpCommanderForm::AllowedAction(TAction * Action, TActionAllowed Allowed)

+ 3 - 1
source/forms/ScpExplorer.cpp

@@ -158,11 +158,13 @@ bool __fastcall TScpExplorerForm::CopyParamDialog(TTransferDirection Direction,
 //---------------------------------------------------------------------------
 void __fastcall TScpExplorerForm::DoShow()
 {
+  // See comment in TScpCommanderForm::DoShow()
+  UpdateControls();
+
   if (RemoteDirView->Enabled)
   {
     RemoteDirView->SetFocus();
   }
-  assert(FRemoteDirViewWasFocused);
   FRemoteDirViewWasFocused = true;
 
   TCustomScpExplorerForm::DoShow();