Adding a stub runner application to avoid loading two large processes. wince only. npodb

This commit is contained in:
dougt%meer.net 2005-10-18 18:09:29 +00:00
Родитель a5f144f900
Коммит cf6472af79
4 изменённых файлов: 108 добавлений и 64 удалений

Просмотреть файл

@ -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!

Просмотреть файл

@ -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

60
minimo/base/wince/Makefile.in Executable file
Просмотреть файл

@ -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 <dougt@meer.net>.
# 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

42
minimo/base/wince/runner.cpp Executable file
Просмотреть файл

@ -0,0 +1,42 @@
#include <windows.h>
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;
}