From bbab5a148da5ebd9d61a4f140a88f9ad6b051c65 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 25 Jun 2013 22:50:22 +0100 Subject: [PATCH] [ui] log display improvement * Shift main dialog left in case of overlap * Fix loss of application focus when displaying the log * Display Windows version in the log * Also switch to LZMA for UPX compression * Closes #148 --- Makefile.am | 3 ++- Makefile.in | 3 ++- _pre-commit.sh | 2 +- src/rufus.c | 22 +++++++++++++++++++++- src/rufus.h | 9 +++++---- src/rufus.rc | 10 +++++----- src/stdfn.c | 30 +++++++++++++++++++++++------- 7 files changed, 59 insertions(+), 20 deletions(-) diff --git a/Makefile.am b/Makefile.am index 137f5042..e6abecc4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,9 +2,10 @@ SUBDIRS = src TARGET = rufus # This step produces the UPX compressed and signed releases that are made available for public download +# NB: UPX v3.09 or later is needed for LZMA compression (http://upx.sourceforge.net/) release: all @mv src/$(TARGET)$(EXEEXT) . @$(STRIP) $(TARGET)$(EXEEXT) - @upx $(TARGET)$(EXEEXT) + @upx --lzma $(TARGET)$(EXEEXT) @mv $(TARGET)$(EXEEXT) $(TARGET)_v$(VERSION)$(EXEEXT) @cmd.exe /k _sign.cmd $(TARGET)_v$(VERSION)$(EXEEXT) diff --git a/Makefile.in b/Makefile.in index 131d5fcb..52f15289 100644 --- a/Makefile.in +++ b/Makefile.in @@ -443,10 +443,11 @@ uninstall-am: # This step produces the UPX compressed and signed releases that are made available for public download +# NB: UPX v3.09 or later is needed for LZMA compression (http://upx.sourceforge.net/) release: all @mv src/$(TARGET)$(EXEEXT) . @$(STRIP) $(TARGET)$(EXEEXT) - @upx $(TARGET)$(EXEEXT) + @upx --lzma $(TARGET)$(EXEEXT) @mv $(TARGET)$(EXEEXT) $(TARGET)_v$(VERSION)$(EXEEXT) @cmd.exe /k _sign.cmd $(TARGET)_v$(VERSION)$(EXEEXT) diff --git a/_pre-commit.sh b/_pre-commit.sh index a1824f6e..b3518498 100644 --- a/_pre-commit.sh +++ b/_pre-commit.sh @@ -19,7 +19,7 @@ TAGVER=`echo $VER` # of a .amend file in the current directory will do if [ -f ./.amend ]; then TAGVER=`expr $TAGVER - 1` - git tag -d "#$TAGVER" + git tag -d "b$TAGVER" rm ./.amend; fi echo "setting nano to $TAGVER" diff --git a/src/rufus.c b/src/rufus.c index 2e54b5d4..91b0b76d 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -1274,6 +1274,8 @@ void InitDialog(HWND hDlg) HDC hDC; int i, i16, s16; char tmp[128], *token; + BOOL is_x64 = FALSE; + BOOL (__stdcall *pIsWow64Process)(HANDLE, PBOOL) = NULL; #ifdef RUFUS_TEST ShowWindow(GetDlgItem(hDlg, IDC_TEST), SW_SHOW); @@ -1319,6 +1321,18 @@ void InitDialog(HWND hDlg) rufus_version[i] = (uint16_t)atoi(token); uprintf(APPLICATION_NAME " version %d.%d.%d.%d\n", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]); + // Detect if we're running a 32 or 64 bit system + if (sizeof(uintptr_t) < 8) { + pIsWow64Process = (BOOL (__stdcall *)(HANDLE, PBOOL)) + GetProcAddress(GetModuleHandleA("KERNEL32"), "IsWow64Process"); + if (pIsWow64Process != NULL) { + (*pIsWow64Process)(GetCurrentProcess(), &is_x64); + } + } else { + is_x64 = TRUE; + } + uprintf("Windows version: %s %d-bit\n", PrintWindowsVersion(nWindowsVersion), is_x64?64:32); + // Prefer FreeDOS to MS-DOS selection_default = DT_FREEDOS; // Create the status line and initialize the taskbar icon for progress overlay @@ -1548,16 +1562,22 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA Point.x = min(DialogRect.right + GetSystemMetrics(SM_CXSIZEFRAME)+(int)(2.0f * fScale), DesktopRect.right - nWidth); Point.y = max(DialogRect.top, DesktopRect.top - nHeight); MoveWindow(hLogDlg, Point.x, Point.y, nWidth, nHeight, FALSE); + // The log may have been recentered to fit the screen, in which case, try to shift our main dialog left + nWidth = DialogRect.right - DialogRect.left; + nHeight = DialogRect.bottom - DialogRect.top; + MoveWindow(hDlg, max((DialogRect.left<0)?DialogRect.left:0, + Point.x - nWidth - GetSystemMetrics(SM_CXSIZEFRAME) - (int)(2.0f * fScale)), Point.y, nWidth, nHeight, TRUE); first_log_display = FALSE; } // Display the log Window log_displayed = !log_displayed; - ShowWindow(hLogDlg, log_displayed?SW_SHOW:SW_HIDE); if (IsShown(hISOProgressDlg)) SetFocus(hISOProgressDlg); // Set focus on the start button SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0); SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDC_START), TRUE); + // Must come last for the log window to get focus + ShowWindow(hLogDlg, log_displayed?SW_SHOW:SW_HIDE); break; #ifdef RUFUS_TEST case IDC_TEST: diff --git a/src/rufus.h b/src/rufus.h index 2ebc08ea..fe0ba328 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -242,14 +242,14 @@ typedef enum TASKBAR_PROGRESS_FLAGS /* Windows versions */ enum WindowsVersion { - WINDOWS_UNDEFINED, + WINDOWS_UNDEFINED = 0, WINDOWS_UNSUPPORTED, WINDOWS_XP, - WINDOWS_2003, + WINDOWS_2003, // Also XP x64 WINDOWS_VISTA, WINDOWS_7, - WINDOWS_8, - WINDOWS_9 + WINDOWS_8_OR_LATER, + WINDOWS_MAX }; /* @@ -277,6 +277,7 @@ extern int dialog_showing; * Shared prototypes */ extern enum WindowsVersion DetectWindowsVersion(void); +extern const char* PrintWindowsVersion(enum WindowsVersion version); extern const char *WindowsErrorString(void); extern void DumpBufferHex(void *buf, size_t size); extern void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...); diff --git a/src/rufus.rc b/src/rufus.rc index 453b18e6..485ea4f4 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.3.4.259" +CAPTION "Rufus v1.3.4.260" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -278,8 +278,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,4,259 - PRODUCTVERSION 1,3,4,259 + FILEVERSION 1,3,4,260 + PRODUCTVERSION 1,3,4,260 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -296,13 +296,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.3.4.259" + VALUE "FileVersion", "1.3.4.260" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.3.4.259" + VALUE "ProductVersion", "1.3.4.260" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index f5a80924..7b1f21a6 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -27,6 +27,17 @@ #include "msapi_utf8.h" #include "rufus.h" +// Must be in the same order as enum WindowsVersion +static const char* WindowsVersionName[WINDOWS_MAX] = { + "Undefined", + "Windows 2000 or earlier (unsupported)", + "Windows XP", + "Windows 2003 (or XP x64)", + "Windows Vista", + "Windows 7", + "Windows 8 or later", +}; + enum WindowsVersion nWindowsVersion = WINDOWS_UNDEFINED; /* @@ -48,18 +59,23 @@ enum WindowsVersion DetectWindowsVersion(void) if ((OSVersion.dwMajorVersion == 5) && (OSVersion.dwMinorVersion == 1)) return WINDOWS_XP; if ((OSVersion.dwMajorVersion == 5) && (OSVersion.dwMinorVersion == 2)) - return WINDOWS_2003; + return WINDOWS_2003; if ((OSVersion.dwMajorVersion == 6) && (OSVersion.dwMinorVersion == 0)) - return WINDOWS_VISTA; + return WINDOWS_VISTA; if ((OSVersion.dwMajorVersion == 6) && (OSVersion.dwMinorVersion == 1)) - return WINDOWS_7; - if ((OSVersion.dwMajorVersion == 6) && (OSVersion.dwMinorVersion == 2)) - return WINDOWS_8; - if ((OSVersion.dwMajorVersion > 6) || ((OSVersion.dwMajorVersion == 6) && (OSVersion.dwMinorVersion >= 3))) - return WINDOWS_9; + return WINDOWS_7; + if ((OSVersion.dwMajorVersion > 6) || ((OSVersion.dwMajorVersion == 6) && (OSVersion.dwMinorVersion >= 2))) + return WINDOWS_8_OR_LATER; return WINDOWS_UNSUPPORTED; } +const char* PrintWindowsVersion(enum WindowsVersion version) +{ + if ((version < 0) || (version >= WINDOWS_MAX)) + version = WINDOWS_UNDEFINED; + return WindowsVersionName[version]; +} + /* * String array manipulation */