- Allow execution of CEF using the current application's message loop.
tests/cefclient:
- Support running of the cefclient application using a single message loop via the TEST_SINGLE_THREADED_MESSAGE_LOOP define.

Issue #1, Suggested implementation by: vridosh

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@13 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2009-01-29 18:53:17 +00:00
parent 9d3cd36b4b
commit 15f6c270fa
4 changed files with 150 additions and 63 deletions

View File

@@ -15,6 +15,10 @@
#define BUTTON_WIDTH 72
#define URLBAR_HEIGHT 24
// Define this value to run CEF with messages processed using the current
// application's message loop.
//#define TEST_SINGLE_THREADED_MESSAGE_LOOP
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
@@ -31,11 +35,17 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// Initialize the CEF
CefInitialize();
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
// Initialize the CEF with messages processed using the current application's
// message loop.
CefInitialize(false);
#else
// Initialize the CEF with messages processed using a separate UI thread.
CefInitialize(true);
#endif
// Structure providing information about the client plugin.
CefPluginInfo plugin_info;
@@ -56,31 +66,36 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// Register the internal client plugin
CefRegisterPlugin(plugin_info);
MSG msg;
HACCEL hAccelTable;
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
// Perform application initialization
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT));
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CEFCLIENT));
// Main message loop
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// Main message loop
while (GetMessage(&msg, NULL, 0, 0))
{
#ifdef TEST_SINGLE_THREADED_MESSAGE_LOOP
// Allow the CEF to do its message loop processing.
CefDoMessageLoopWork();
#endif
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// Shut down the CEF
CefShutdown();