From cf6472af799df66a6e63baee265b884d0e53af86 Mon Sep 17 00:00:00 2001 From: "dougt%meer.net" Date: Tue, 18 Oct 2005 18:09:29 +0000 Subject: [PATCH] Adding a stub runner application to avoid loading two large processes. wince only. npodb --- minimo/base/Makefile.in | 7 +++- minimo/base/Minimo.cpp | 63 ----------------------------------- minimo/base/wince/Makefile.in | 60 +++++++++++++++++++++++++++++++++ minimo/base/wince/runner.cpp | 42 +++++++++++++++++++++++ 4 files changed, 108 insertions(+), 64 deletions(-) create mode 100755 minimo/base/wince/Makefile.in create mode 100755 minimo/base/wince/runner.cpp diff --git a/minimo/base/Makefile.in b/minimo/base/Makefile.in index 3b61e5815fc..6d1449b5608 100755 --- a/minimo/base/Makefile.in +++ b/minimo/base/Makefile.in @@ -44,6 +44,11 @@ include $(DEPTH)/config/autoconf.mk MOZILLA_INTERNAL_API = 1 + +ifdef WINCE +DIRS = wince +endif + PROGRAM = minimo$(BIN_SUFFIX) MODULE = minimo @@ -79,7 +84,7 @@ CPPSRCS = Minimo.cpp \ WindowCreator.cpp \ SplashScreen.cpp \ nsConsoleWriter.cpp \ - $(NULL) \ + $(NULL) # this should move into the toolkit! diff --git a/minimo/base/Minimo.cpp b/minimo/base/Minimo.cpp index d4209bf2cad..227f852ab83 100755 --- a/minimo/base/Minimo.cpp +++ b/minimo/base/Minimo.cpp @@ -470,66 +470,6 @@ void OverrideComponents() } } -#ifdef WINCE -typedef struct FindAppStruct -{ - HWND hwnd; -} FindAppStruct; - -BOOL CALLBACK FindApplicationWindowProc(HWND hwnd, LPARAM lParam) -{ - FindAppStruct* findApp = (FindAppStruct*) lParam; - - unsigned short windowName[MAX_PATH]; - GetWindowTextW(hwnd, windowName, MAX_PATH); - - if (wcsstr(windowName, L"Minimo")) - { - findApp->hwnd = hwnd; - return FALSE; - } - return TRUE; -} - -#define USE_MUTEX - -PRBool DoesProcessAlreadyExist() -{ -#ifdef USE_MUTEX - - const HANDLE hMutex = CreateMutexW(0, 0, L"_MINIMO_EXE_MUTEX_"); - - if(hMutex) - { - if(ERROR_ALREADY_EXISTS == GetLastError()) - { - FindAppStruct findApp; - findApp.hwnd = NULL; - - EnumWindows(FindApplicationWindowProc, (LPARAM)&findApp); - - if (findApp.hwnd) - { - SetForegroundWindow(findApp.hwnd); - return TRUE; - } - - MessageBox(0, "Minimo is running, but can't be switched to.", "Unexpected Error", 0); - return TRUE; - } - return FALSE; - } - MessageBox(0, "Can not start Minimo", "Unexpected Error", 0); - return TRUE; -#else - return FALSE; -#endif -} -#else -PRBool DoesProcessAlreadyExist() {return PR_FALSE;} -#endif - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Complete hack below. We to ensure that the layout of all @@ -587,9 +527,6 @@ int main(int argc, char *argv[]) gtk_init(&argc, &argv); #endif - if (DoesProcessAlreadyExist()) - return 0; - CreateSplashScreen(); #ifdef HACKY_PRE_LOAD_LIBRARY diff --git a/minimo/base/wince/Makefile.in b/minimo/base/wince/Makefile.in new file mode 100755 index 00000000000..51e19d8cff0 --- /dev/null +++ b/minimo/base/wince/Makefile.in @@ -0,0 +1,60 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Minimo. +# +# The Initial Developer of the Original Code is +# Doug Turner . +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +PROGRAM = minimo_runner.exe + +MODULE = minimo + +CPPSRCS = runner.cpp \ + $(NULL) + +RCINCLUDE = AppIcon.rc + +include $(topsrcdir)/config/config.mk + +LOCAL_INCLUDES += -I$(srcdir)/. +OS_LIBS += $(call EXPAND_LIBNAME, aygshell cellcore uuid ole32 oleaut32) + +include $(topsrcdir)/config/rules.mk + diff --git a/minimo/base/wince/runner.cpp b/minimo/base/wince/runner.cpp new file mode 100755 index 00000000000..ff33be9d445 --- /dev/null +++ b/minimo/base/wince/runner.cpp @@ -0,0 +1,42 @@ +#include + + + + +int main(int argc, char *argv[]) +{ + HWND h = FindWindowW(NULL, L"Minimo"); + if (h) + { + ShowWindow(h, SW_SHOWNORMAL); + SetForegroundWindow(h); + return 0; + } + + char *cp; + char exe[MAX_PATH]; + GetModuleFileName(GetModuleHandle(NULL), exe, sizeof(exe)); + cp = strrchr(exe,'\\'); + if (cp != NULL) + { + cp++; // pass the \ char. + *cp = 0; + } + + strcat(exe, "minimo.exe"); + + PROCESS_INFORMATION pi; + + BOOL b = CreateProcess(exe, + NULL, + NULL, + NULL, + NULL, + 0, + NULL, + NULL, + NULL, + &pi); + return 0; +} +