This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Setup.exe dialog boxes losing focus after download of ini/packages


This patch removes the calls to SetForegroundWindow
in geturl.cc and install.cc - these, IMO, make setup.exe
dialogs to not properly gain focus after a the 
get_url_* or do_install dialogs are created. Actually
there is no need to call SetForegroundWindow at all
on these progress dialogs - they dont have to compete
with anyone in the current app since only one dialog is
active at any moment.

Another way to fix the problem would be to add a 
SetForegroundWindow in the WM_INITDIALOG handler
of each dialog of setup.exe.

There are other 's too but since this is a very simple
program I dont think its worth discussing.

The patch also makes setup skip the creation
of the "download setup.ini progress dialog"
when install from current directory is selected.
diff -up ../../../cygwin-snapshot-20011018-1/winsup/cinstall/geturl.cc ./geturl.cc
--- ../../../cygwin-snapshot-20011018-1/winsup/cinstall/geturl.cc	Sun Aug 26 03:41:54 2001
+++ ./geturl.cc	Fri Oct 26 10:18:10 2001
@@ -36,7 +36,6 @@ static char *cvsid = "\n%%% $Id: geturl.
 #include "diskfull.h"
 #include "mount.h"
 
-static int is_showing = 0;
 static HWND gw_dialog = 0;
 static HWND gw_url = 0;
 static HWND gw_rate = 0;
@@ -48,6 +47,7 @@ static HWND gw_pprogress_text = 0;
 static HWND gw_iprogress_text = 0;
 static HANDLE init_event;
 static int max_bytes = 0;
+static int is_local_install = 0;
 
 int total_download_bytes = 0;
 int total_download_bytes_sofar = 0;
@@ -80,7 +80,7 @@ dialog_proc (HWND h, UINT message, WPARA
       gw_pprogress_text = GetDlgItem (h, IDC_DLS_PPROGRESS_TEXT);
       gw_iprogress_text = GetDlgItem (h, IDC_DLS_IPROGRESS_TEXT);
       SetEvent (init_event);
-      return FALSE;
+      return TRUE;
     case WM_COMMAND:
       return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
     }
@@ -107,6 +107,8 @@ static DWORD start_tics;
 static void
 init_dialog (char *url, int length)
 {
+  if (is_local_install)
+    return;
   if (gw_dialog == 0)
     {
       DWORD tid;
@@ -118,7 +120,6 @@ init_dialog (char *url, int length)
       SendMessage (gw_progress, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
       SendMessage (gw_pprogress, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
       SendMessage (gw_iprogress, PBM_SETRANGE, 0, MAKELPARAM (0, 100));
-      is_showing = 0;
     }
   char *sl=url, *cp;
   for (cp=url; *cp; cp++)
@@ -146,11 +147,6 @@ init_dialog (char *url, int length)
     }
   ShowWindow (gw_iprogress, (total_download_bytes > 0) ? SW_SHOW : SW_HIDE);
   ShowWindow (gw_dialog, SW_SHOWNORMAL);
-  if (!is_showing)
-    {
-      SetForegroundWindow (gw_dialog);
-      is_showing = 1;
-    }
   start_tics = GetTickCount ();
 }
 
@@ -161,6 +157,8 @@ progress (int bytes)
   static char buf[100];
   int kbps;
   static int last_tics = 0;
+  if (is_local_install)
+    return;
   DWORD tics = GetTickCount ();
   if (tics == start_tics) // to prevent division by zero
     return;
@@ -201,6 +199,7 @@ char *
 get_url_to_string (char *_url)
 {
   log (LOG_BABBLE, "get_url_to_string %s", _url);
+  is_local_install = (source == IDC_SOURCE_CWD);
   init_dialog (_url, 0);
   NetIO *n = NetIO::open (_url);
   if (!n || !n->ok ())
@@ -309,6 +308,6 @@ get_url_to_file (char *_url, char *_file
 void
 dismiss_url_status_dialog ()
 {
-  ShowWindow (gw_dialog, SW_HIDE);
-  is_showing = 0;
+  if (!is_local_install)
+    ShowWindow (gw_dialog, SW_HIDE);
 }
diff -up ../../../cygwin-snapshot-20011018-1/winsup/cinstall/install.cc ./install.cc
--- ../../../cygwin-snapshot-20011018-1/winsup/cinstall/install.cc	Sun Aug 26 03:41:54 2001
+++ ./install.cc	Fri Oct 26 10:18:49 2001
@@ -89,7 +89,7 @@ dialog_proc (HWND h, UINT message, WPARA
       ins_iprogress = GetDlgItem (h, IDC_INS_IPROGRESS);
       ins_diskfull = GetDlgItem (h, IDC_INS_DISKFULL);
       SetEvent (init_event);
-      return FALSE;
+      return TRUE;
     case WM_COMMAND:
       return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
     }
@@ -137,7 +137,6 @@ init_dialog ()
   SendMessage (ins_iprogress, PBM_SETPOS, (WPARAM) 0, 0);
   SendMessage (ins_diskfull, PBM_SETPOS, (WPARAM) 0, 0);
   ShowWindow (ins_dialog, SW_SHOWNORMAL);
-  SetForegroundWindow (ins_dialog);
 }
 
 static void
Common subdirectories: ../../../cygwin-snapshot-20011018-1/winsup/cinstall/temp and ./temp
Common subdirectories: ../../../cygwin-snapshot-20011018-1/winsup/cinstall/zlib and ./zlib

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]