cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [37/50] [abbrv] git commit: General update:
Date Wed, 17 Oct 2012 23:27:01 GMT
General update:

- Updated project file to Visual Studio 2012 format
- Fixed accelerometer code so it accepts 8 bytes samples
- Enabled low latency Media Foundation pipelines on Windows 8
- Used thread naming trick so threads are named in VS debugger
- Updated Cordova JS codebase
- Centered notification dialogs
- Added back key handling
- Added preliminarly compass support


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/commit/26faf172
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/tree/26faf172
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/diff/26faf172

Branch: refs/heads/master
Commit: 26faf1721ffafcbcfe4b59c986c91f743fcf700f
Parents: 7807de0
Author: Patrick Porlan <patrick.porlan@intel.com>
Authored: Wed Sep 26 16:58:32 2012 +0200
Committer: Patrick Porlan <patrick.porlan@intel.com>
Committed: Wed Sep 26 16:58:32 2012 +0200

----------------------------------------------------------------------
 Cordova/Cordova.vcxproj         |   19 ++-
 Cordova/Cordova.vcxproj.filters |    7 +-
 Cordova/Cordova.vcxproj.user    |    4 +
 Cordova/accel.c                 |   40 +++---
 Cordova/accel.h                 |    3 +-
 Cordova/capture.c               |   60 ++++---
 Cordova/common.c                |   31 ++++
 Cordova/common.h                |   11 ++-
 Cordova/compass.c               |  277 ++++++++++++++++++++++++++++++++++
 Cordova/compass.h               |   23 +++
 Cordova/device.c                |    2 +-
 Cordova/mp4patch.c              |    9 +-
 Cordova/notification.c          |   19 +++-
 Cordova/platform.c              |   17 ++-
 Cordova/platform.h              |    2 +
 Cordova/shell.c                 |   89 +++++++++--
 Cordova/www/cordova.win7.js     |    4 +-
 Cordova/www/events.html         |    9 +-
 18 files changed, 543 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/Cordova.vcxproj
----------------------------------------------------------------------
diff --git a/Cordova/Cordova.vcxproj b/Cordova/Cordova.vcxproj
index 6c79c0d..a430887 100644
--- a/Cordova/Cordova.vcxproj
+++ b/Cordova/Cordova.vcxproj
@@ -20,12 +20,14 @@
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>Unicode</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>Unicode</CharacterSet>
+    <PlatformToolset>v110</PlatformToolset>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
@@ -39,13 +41,13 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(DXSDK_DIR)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include</IncludePath>
-    <LibraryPath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
+    <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include</IncludePath>
+    <LibraryPath>$(WindowsSdkDir)lib\win8\um\x86;$(ProgramFiles)\Microsoft SDKs\Internet
Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(DXSDK_DIR)include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include</IncludePath>
-    <LibraryPath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
+    <IncludePath>$(ProgramFiles)\Microsoft SDKs\Internet Explorer\v9\include;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include\um;$(WindowsSdkDir)include\shared;$(FrameworkSDKDir)\include</IncludePath>
+    <LibraryPath>$(WindowsSdkDir)lib\win8\um\x86;$(ProgramFiles)\Microsoft SDKs\Internet
Explorer\v9\lib;$(DXSDK_DIR)lib\x86;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
@@ -90,6 +92,7 @@
     <ClCompile Include="accel.c" />
     <ClCompile Include="capture.c" />
     <ClCompile Include="common.c" />
+    <ClCompile Include="compass.c" />
     <ClCompile Include="device.c" />
     <ClCompile Include="file.c" />
     <ClCompile Include="filetransfer.c" />
@@ -107,6 +110,7 @@
     <ClInclude Include="accel.h" />
     <ClInclude Include="capture.h" />
     <ClInclude Include="common.h" />
+    <ClInclude Include="compass.h" />
     <ClInclude Include="device.h" />
     <ClInclude Include="file.h" />
     <ClInclude Include="filetransfer.h" />
@@ -133,13 +137,16 @@
     <None Include="www\accel_game.html" />
     <None Include="www\accel_game.js" />
     <None Include="www\capture.html" />
+    <None Include="www\compass.html" />
     <None Include="www\cordova.win7.js" />
     <None Include="www\device.html" />
-    <None Include="www\events.html" />
+    <None Include="www\events.html">
+      <SubType>Designer</SubType>
+    </None>
     <None Include="www\file.html" />
     <None Include="www\index.html" />
     <None Include="www\network.html" />
-    <None Include="www\notification.html" />
+    <None Include="www\notify.html" />
     <None Include="www\storage.html" />
   </ItemGroup>
   <ItemGroup>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/Cordova.vcxproj.filters
----------------------------------------------------------------------
diff --git a/Cordova/Cordova.vcxproj.filters b/Cordova/Cordova.vcxproj.filters
index 9a634a6..fa63de7 100644
--- a/Cordova/Cordova.vcxproj.filters
+++ b/Cordova/Cordova.vcxproj.filters
@@ -16,6 +16,7 @@
     <ClCompile Include="common.c" />
     <ClCompile Include="filetransfer.c" />
     <ClCompile Include="mp4patch.c" />
+    <ClCompile Include="compass.c" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="accel.h" />
@@ -33,6 +34,7 @@
     <ClInclude Include="file.h" />
     <ClInclude Include="filetransfer.h" />
     <ClInclude Include="mp4patch.h" />
+    <ClInclude Include="compass.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="resource.rc" />
@@ -78,6 +80,9 @@
     <None Include="www\events.html">
       <Filter>html</Filter>
     </None>
+    <None Include="www\notify.html">
+      <Filter>html</Filter>
+    </None>
     <None Include="lib\js\plugin\win7\jsHandler.js">
       <Filter>javascript</Filter>
     </None>
@@ -93,7 +98,7 @@
     <None Include="www\file.html">
       <Filter>html</Filter>
     </None>
-    <None Include="www\notification.html">
+    <None Include="www\compass.html">
       <Filter>html</Filter>
     </None>
   </ItemGroup>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/Cordova.vcxproj.user
----------------------------------------------------------------------
diff --git a/Cordova/Cordova.vcxproj.user b/Cordova/Cordova.vcxproj.user
index ace9a86..93358af 100644
--- a/Cordova/Cordova.vcxproj.user
+++ b/Cordova/Cordova.vcxproj.user
@@ -1,3 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+    <LocalDebuggerDebuggerType>Script</LocalDebuggerDebuggerType>
+  </PropertyGroup>
 </Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/accel.c
----------------------------------------------------------------------
diff --git a/Cordova/accel.c b/Cordova/accel.c
index 2a0749c..bbfc2ec 100644
--- a/Cordova/accel.c
+++ b/Cordova/accel.c
@@ -23,6 +23,7 @@
 #include <propvarutil.h>
 #include <portabledevicetypes.h>
 #include <wchar.h>
+#include "common.h"
 
 #pragma comment(lib, "sensorsapi.lib")
 #pragma comment(lib, "portabledeviceguids.lib")
@@ -44,7 +45,7 @@ BOOL stop_flag;			// Flag raised to indicate that the acquisition thread
should
 
 BSTR new_sample_callback;
 
-void propagate_sample (void)
+void propagate_accel_sample (void)
 {
 	if (new_sample_callback)
 	{
@@ -64,6 +65,8 @@ unsigned int __stdcall accel_thread_proc(void* param)
 	HRESULT hr;
 	ULONG ulCount = 0;
 
+	set_thread_name(-1, "Accelerometer Sampling");
+
 	CoInitialize(0);
 
 	// Retrieve sensor manager object
@@ -79,7 +82,7 @@ unsigned int __stdcall accel_thread_proc(void* param)
 		// Sensor API not available...
 		return -2;
 
-	// Get the list of available orientation sensors
+	// Get the list of available accelerometers
 	hr = sensor_manager_if->lpVtbl->GetSensorsByCategory(sensor_manager_if, &SENSOR_CATEGORY_MOTION,
&sensor_collection_if);
   		
 	sensor_manager_if->lpVtbl->RequestPermissions(sensor_manager_if, GetForegroundWindow(),
sensor_collection_if, TRUE);
@@ -93,14 +96,14 @@ unsigned int __stdcall accel_thread_proc(void* param)
 		{
 			if (acceleration_sensor_count == 0)
 			{
-				// No orientation sensor
+				// No accelerometer
 			}
 		}
 	}
 
 	if (SUCCEEDED(hr))
 	{
-		// Get the first available orientation sensor
+		// Get the first available accelerometer
 		hr = sensor_collection_if->lpVtbl->GetAt(sensor_collection_if, 0, &accelerometer_if);
 	}
 
@@ -150,18 +153,24 @@ unsigned int __stdcall accel_thread_proc(void* param)
 			data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_X_G,
&v);
 			if (v.vt == VT_R4)
 				last_x = v.fltVal;
+			if (v.vt == VT_R8)
+				last_x = v.dblVal;
 			PropVariantClear(&v);
 
 			PropVariantInit(&v);
 			data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_Y_G,
&v);
 			if (v.vt == VT_R4)
 				last_y = v.fltVal;
+			if (v.vt == VT_R8)
+				last_y = v.dblVal;
 			PropVariantClear(&v);
 
 			PropVariantInit(&v);
 			data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_ACCELERATION_Z_G,
&v);
 			if (v.vt == VT_R4)
 				last_z = v.fltVal;
+			if (v.vt == VT_R8)
+				last_z = v.dblVal;
 			PropVariantClear(&v);
 	
 			//data_report_if->lpVtbl->GetTimestamp(data_report_if, &timestamp);
@@ -171,7 +180,7 @@ unsigned int __stdcall accel_thread_proc(void* param)
 		}
 
 		if (last_x != prev_x || last_y != prev_y || last_z != prev_z)
-			SendMessage(hWnd, WM_USER, 0, 0);	// Request the main thread to invoke a JS call for us
; will call propagate_sample in response
+			SendMessage(hWnd, WM_USER_ACCEL, 0, 0);	// Request the main thread to invoke a JS call
for us ; will call propagate_accel_sample in response
 
 		Sleep(10);
 	}
@@ -179,15 +188,15 @@ unsigned int __stdcall accel_thread_proc(void* param)
 	return 0;
 }
 
-int start_acquisition (void)
+int start_accel_acquisition (void)
 {
+	if (accel_thread)
+		return -1;
+
 	// Return 0 x/y/z and 0 timestamp until samples start coming in
 	last_x = 0;
 	last_y = 0;
 	last_z = 0;
-
-	if (accel_thread)
-		return -1;
 	
 	stop_flag = FALSE;
 	
@@ -196,7 +205,7 @@ int start_acquisition (void)
 	return 0;
 }
 
-int stop_acquisition (void)
+int stop_accel_acquisition (void)
 {
 	if (accel_thread == 0)
 		return -1;
@@ -217,11 +226,6 @@ int stop_acquisition (void)
 	return 0;
 }
 
-int setup_sensors (void)
-{
-	return 0;
-}
-
 
 HRESULT accel_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
 {
@@ -229,14 +233,14 @@ HRESULT accel_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT
*result)
 	{
 		new_sample_callback = SysAllocString(callback_id);
 		last_x = last_y = last_z = 0;	
-		propagate_sample();
-		start_acquisition();
+		propagate_accel_sample();
+		start_accel_acquisition();
 		return S_OK;
 	}
 
 	if (!wcscmp(action, L"stop"))
 	{
-		stop_acquisition();
+		stop_accel_acquisition();
 		cordova_success_callback(callback_id, FALSE, NULL_MESSAGE);
 		return S_OK;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/accel.h
----------------------------------------------------------------------
diff --git a/Cordova/accel.h b/Cordova/accel.h
index 5949ab5..807cf49 100644
--- a/Cordova/accel.h
+++ b/Cordova/accel.h
@@ -17,7 +17,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-int setup_sensors(void);
-void propagate_sample(void);
+void propagate_accel_sample(void);
 
 DECLARE_CORDOVA_MODULE(Accelerometer)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/capture.c
----------------------------------------------------------------------
diff --git a/Cordova/capture.c b/Cordova/capture.c
index c28a053..c182366 100644
--- a/Cordova/capture.c
+++ b/Cordova/capture.c
@@ -36,6 +36,9 @@
 #include "common.h"
 #include "mp4patch.h"
 
+// Workaround for a declaration in the Windows 8 SDK that's mistakenly missing for non C++
files
+STDAPI MFCreateCollection(_Out_ IMFCollection **ppIMFCollection);
+
 #pragma comment(lib, "mfuuid.lib")      // Media Foundation UUIDs
 #pragma comment(lib, "mfplat.lib")	// MF attributes
 #pragma comment(lib, "mf.lib")	// MF topology, session, device enumeration and video renderer
@@ -65,7 +68,6 @@ IMFMediaType* mic_config_if;	// Audio capture device output configuration
 
 IMFMediaSource*	video_source_if;	// These need to be shutdown before being released, so keep
keep pointers around
 IMFMediaSource*	audio_source_if;
-IMFMediaSource* av_source_if;
 IMFMediaSink* media_sink_if;
 IMFTransform* video_compr_transform_if;
 IMFTransform* audio_compr_transform_if;
@@ -93,8 +95,7 @@ wchar_t temp_directory_url[MAX_FILE_NAME_LEN + 8];	//	file://C:/Temp syntax
 wchar_t last_recorded_file_name_full[MAX_FILE_NAME_LEN+1];	// Full path
 wchar_t last_recorded_file_name[MAX_FILE_NAME_LEN+1];		// Name only
 
-LONGLONG start_time;	// Markers used to compute the duration of the last recording
-LONGLONG stop_time;
+LONGLONG start_time;	// Marker used to compute the duration of the last recording
 
 // Note: the MPEG 4 sink is limited to 4 GB
 
@@ -411,7 +412,10 @@ HRESULT add_frame_grabber_node (IMFTopology* topology_if, IMFMediaType*
input_ty
 	hr = grabber_config_if->lpVtbl->SetGUID(grabber_config_if, &MF_MT_MAJOR_TYPE,
&MFMediaType_Video);     
 
 	// If the cam is sending JPEG frames use that for the frame grabber node, otherwise request
RGB 24 bpp representation
-	mjpeg_mode = IsEqualGUID(&input_format, &MFVideoFormat_MJPG);
+	mjpeg_mode = 0; // IsEqualGUID(&input_format, &MFVideoFormat_MJPG); disabled for
now ; some webcams send JFIF frames,
+					// others AVI1 MJPEG frames (JPEG minus DHT segment) ; the missing Huffman table contents
is fixed,
+					// so it can be added programatically, but for single-frame capture we don't really
need to optimize,
+					// and using MJPEG rather than YUV or RGB modes may make the preview more costly
 		
 	if (mjpeg_mode)
 		hr = grabber_config_if->lpVtbl->SetGUID(grabber_config_if, &MF_MT_SUBTYPE, &MFVideoFormat_MJPG);
@@ -539,7 +543,7 @@ HRESULT configure_mft(IMFTransform* mft_if)
     if (attributes_if)
     {
         hr = attributes_if->lpVtbl->SetUINT32(attributes_if, &MF_TRANSFORM_ASYNC_UNLOCK,
TRUE);
-     //   hr = attributes_if->lpVtbl->SetUINT32(attributes_if, &MF_LOW_LATENCY,
TRUE);
+        hr = attributes_if->lpVtbl->SetUINT32(attributes_if, &MF_LOW_LATENCY, TRUE);
 	
 		RELEASE(attributes_if);
     }
@@ -830,7 +834,7 @@ HRESULT add_tee_node(IMFTopology* topology_if, IMFTopologyNode** tee_node_ifp)
 }
 
 
-HRESULT create_av_source (void)
+HRESULT create_av_source (IMFMediaSource** av_source_ifp)
 {
     // We may get video from a cam and audio from a separate mic - Handle them as two streams
coming out of a single media source
 	HRESULT hr;
@@ -844,7 +848,7 @@ HRESULT create_av_source (void)
 	if (audio_source_if)
 		hr = collection_if->lpVtbl->AddElement(collection_if, (IUnknown*) audio_source_if);
 	
-	hr = MFCreateAggregateSource(collection_if, &av_source_if);
+	hr = MFCreateAggregateSource(collection_if, av_source_ifp);
 
 	RELEASE(collection_if);
 
@@ -1016,13 +1020,14 @@ void prepare_video_framing (IMFTopology* topology_if)
 	IMFPresentationDescriptor* av_pres_descr_if = 0;
 	IMFTopologyNode*	video_capture_node_if = 0;
 	IMFTopologyNode*	video_preview_node_if = 0;
+	IMFMediaSource*	av_source_if = 0;
 
 	// Select video input device
 	hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
 
 	// Create combined AV source - a media session can only be associated to a single source
 	// Not required since we're not dealing with audio here though, but let's share code with
the video case
-	hr = create_av_source();
+	hr = create_av_source(&av_source_if);
 
 	if (av_source_if)
 	{
@@ -1059,7 +1064,6 @@ void prepare_video_capture (IMFTopology* topology_if, wchar_t* file_name)
 	
 	HRESULT hr;
 	IMFPresentationDescriptor* av_pres_descr_if = 0;
-
 	IMFTopologyNode*	video_capture_node_if = 0;
 	IMFTopologyNode*	audio_capture_node_if = 0;
 	IMFTopologyNode*	video_preview_node_if = 0;
@@ -1067,16 +1071,16 @@ void prepare_video_capture (IMFTopology* topology_if, wchar_t* file_name)
 	IMFTopologyNode*	color_transform_node_if = 0;
 	IMFTopologyNode*	video_compression_node_if = 0;
 	IMFTopologyNode*	audio_compression_node_if = 0;
-
 	IMFTopologyNode*	video_output_node_if = 0;
 	IMFTopologyNode*	audio_output_node_if = 0;
+	IMFMediaSource*	av_source_if = 0;
 
 	// Select video and audio input devices
 	hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
 	hr = select_audio_capture_device(&audio_source_if);
 
 	// Create combined AV source - a media session can only be associated to a single source
-	hr = create_av_source();
+	hr = create_av_source(&av_source_if);
 
 	if (av_source_if)
 	{
@@ -1161,18 +1165,19 @@ void prepare_video_capture (IMFTopology* topology_if, wchar_t* file_name)
 void prepare_photo_capture (IMFTopology* topology_if)
 {
 	HRESULT hr;
-	IMFPresentationDescriptor* av_pres_descr_if = 0;
+	IMFPresentationDescriptor*	av_pres_descr_if = 0;
 	IMFTopologyNode*	video_capture_node_if = 0;
 	IMFTopologyNode*	video_preview_node_if = 0;
 	IMFTopologyNode*	tee_node_if = 0;
 	IMFTopologyNode*	frame_grabber_if = 0;
+	IMFMediaSource*		av_source_if = 0;
 
 	// Select video input device
 	hr = select_video_capture_device(&video_source_if, preferred_video_capture_dev);
 
 	// Create combined AV source - a media session can only be associated to a single source
 	// Not required since we're not dealing with audio here though, but let's share code with
the video case
-	hr = create_av_source();
+	hr = create_av_source(&av_source_if);
 
 	if (av_source_if)
 	{
@@ -1270,6 +1275,8 @@ unsigned int __stdcall session_control_proc(void* param)
 	BOOL done = FALSE;
 	IMFTopology* topology_if = (IMFTopology*) param;
 
+	set_thread_name(-1, "Media Session Control");
+
 	CoInitialize(0);
 	
 	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
@@ -1319,6 +1326,10 @@ unsigned int __stdcall session_control_proc(void* param)
 								PropVariantClear(&var);
 								break;
 
+							case MF_TOPOSTATUS_STARTED_SOURCE:
+								start_time = MFGetSystemTime();
+								break;
+
 							case MF_TOPOSTATUS_ENDED:
 								break;
 						}
@@ -1326,16 +1337,14 @@ unsigned int __stdcall session_control_proc(void* param)
 					break;
 
             case MESessionStarted:
-				start_time = MFGetSystemTime();
 				break;
 
-            case MESessionEnded:
+			case MESessionEnded:
                 // In the case of capture, another thread will call Stop
 				hr = media_session_if->lpVtbl->Stop(media_session_if);
                 break;
 
             case MESessionStopped:
-				stop_time = MFGetSystemTime();
 				// The MPEG 4 media sink is finalizable, and the session should invoke the finalization
routines at this point
 				hr = media_session_if->lpVtbl->Close(media_session_if);
 				break;
@@ -1375,12 +1384,6 @@ the_end:
 		RELEASE_Z(video_source_if);
 	}
 
-	if (av_source_if)
-	{
-		av_source_if->lpVtbl->Shutdown(av_source_if);
-		RELEASE_Z(av_source_if);
-	}
-
 	if (color_transform_if)
 	{	
 		MFShutdownObject((IUnknown*) color_transform_if);
@@ -1476,12 +1479,15 @@ void start_audio_playback (void)
 	start_session(AUDIO_PLAYBACK_TOPO);
 }
 
-void end_active_session (void)
+LONGLONG end_active_session (void)
 {
 	HRESULT hr;
-	
+	LONGLONG session_duration = 0;
+
 	if (media_session_if)
 	{
+		session_duration = MFGetSystemTime() - start_time;
+
 		hr = media_session_if->lpVtbl->Stop(media_session_if);
 	
 		// Wait until the session control thread exits
@@ -1491,13 +1497,15 @@ void end_active_session (void)
 	MFShutdown();
 
 	session_control_thread = 0;
+
+	return session_duration;
 }
 
 void stop_video_capture (void)
 {
-	end_active_session();
+	LONGLONG duration = end_active_session();
 
-	fix_mp4_duration(last_recorded_file_name_full, stop_time - start_time);
+	fix_mp4_duration(last_recorded_file_name_full, duration);
 }
 
 void stop_video_framing (void)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/common.c
----------------------------------------------------------------------
diff --git a/Cordova/common.c b/Cordova/common.c
index a8df1ee..5c7721f 100644
--- a/Cordova/common.c
+++ b/Cordova/common.c
@@ -87,3 +87,34 @@ void text_buf_free(TextBuf buf)
 		free(buf->wbuf);
 	free(buf);
 }
+
+// Thread naming utility - see http://msdn.microsoft.com/en-us/library/xcb2z8hs%28VS.90%29.aspx
+
+const DWORD MS_VC_EXCEPTION=0x406D1388;
+
+#pragma pack(push,8)
+typedef struct tagTHREADNAME_INFO
+{
+   DWORD dwType; // Must be 0x1000.
+   LPCSTR szName; // Pointer to name (in user addr space).
+   DWORD dwThreadID; // Thread ID (-1=caller thread).
+   DWORD dwFlags; // Reserved for future use, must be zero.
+} THREADNAME_INFO;
+#pragma pack(pop)
+
+void set_thread_name (DWORD thread_id, char* thread_name)
+{
+   THREADNAME_INFO info;
+   info.dwType = 0x1000;
+   info.szName = thread_name;
+   info.dwThreadID = thread_id;
+   info.dwFlags = 0;
+
+   __try
+   {
+      RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info
);
+   }
+   __except(EXCEPTION_EXECUTE_HANDLER)
+   {
+   }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/common.h
----------------------------------------------------------------------
diff --git a/Cordova/common.h b/Cordova/common.h
index 77d66df..2e13cd7 100644
--- a/Cordova/common.h
+++ b/Cordova/common.h
@@ -19,6 +19,12 @@
 
 #define CORDOVA_REG_KEY	L"Software\\Intel\\Cordova"
 
+typedef enum {
+	WM_EXEC_JS_SCRIPT = WM_USER,
+	WM_USER_ACCEL,
+	WM_USER_COMPASS
+};
+
 #define ASSERT(x) if (!(x)) __debugbreak()
 
 struct _TextBuf;
@@ -33,4 +39,7 @@ wchar_t *text_buf_get(const TextBuf buf);
 size_t text_buf_get_len(const TextBuf buf);
 
 void text_buf_reset(TextBuf buf);
-void text_buf_free(TextBuf buf);
\ No newline at end of file
+void text_buf_free(TextBuf buf);
+
+void set_thread_name (DWORD thread_id, char* thread_name);
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/compass.c
----------------------------------------------------------------------
diff --git a/Cordova/compass.c b/Cordova/compass.c
new file mode 100644
index 0000000..c321771
--- /dev/null
+++ b/Cordova/compass.c
@@ -0,0 +1,277 @@
+// Copyright 2012 Intel Corporation
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <windows.h>
+#include <sensors.h>
+#include <sensorsapi.h>
+#include <propvarutil.h>
+#include <portabledevicetypes.h>
+#include <wchar.h>
+#include "common.h"
+
+#pragma comment(lib, "sensorsapi.lib")
+#pragma comment(lib, "portabledeviceguids.lib")
+
+#include "shell.h"
+extern HWND hWnd;	// Main window, used as a way to request routine calls from the main thread
+
+ISensorManager*		sensor_manager_if;
+ISensorCollection*	sensor_collection_if;
+ISensor*			compass_if;
+
+int orientation_sensor_count;
+
+double last_x, last_y, last_z;
+double prev_x, prev_y, prev_z;
+
+double last_h;
+double prev_h;
+
+
+// See http://dev.w3.org/geo/api/spec-source-orientation.html
+
+// Definitions missing from Windows 7 SDK...
+#define INITGUID
+#include <propkeydef.h>
+DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_HEADING_COMPENSATED_MAGNETIC_NORTH_DEGREES,
   0X1637D8A2, 0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 11);
+DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS,     0X1637D8A2,
0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 19);
+DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS,     0X1637D8A2,
0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 20);
+DEFINE_PROPERTYKEY(SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS,     0X1637D8A2,
0X4248, 0X4275, 0X86, 0X5D, 0X55, 0X8D, 0XE8, 0X4A, 0XED, 0XFD, 21);
+
+
+HANDLE compass_thread;	// Data acquisition thread handle
+BOOL stop_flag;			// Flag raised to indicate that the acquisition thread should exit
+
+BSTR new_sample_callback;
+
+void propagate_compass_sample (void)
+{
+	if (new_sample_callback)
+	{
+		wchar_t buf[100];
+		swprintf(buf, sizeof(buf)/sizeof(buf[0]), L"{magneticHeading:%f}", last_h);
+
+		cordova_success_callback(new_sample_callback, TRUE, buf);
+	}
+}
+
+unsigned int __stdcall compass_thread_proc(void* param)
+{
+	ISensorDataReport* data_report_if;
+	PROPVARIANT v;
+//	SYSTEMTIME timestamp;
+	static int counter;
+	HRESULT hr;
+	ULONG ulCount = 0;
+
+	set_thread_name(-1, "Compass Sampling");
+
+	CoInitialize(0);
+
+	// Retrieve sensor manager object
+	hr = CoCreateInstance(&CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &IID_ISensorManager,
(void**) &sensor_manager_if);
+
+	if (hr == HRESULT_FROM_WIN32(ERROR_ACCESS_DISABLED_BY_POLICY))
+	{
+		// The user hasn't granted access to sensors
+		return -1;
+	}
+
+	if (!SUCCEEDED(hr))
+		// Sensor API not available...
+		return -2;
+
+	// Get the list of available orientation sensors
+	hr = sensor_manager_if->lpVtbl->GetSensorsByCategory(sensor_manager_if, &SENSOR_CATEGORY_ORIENTATION,
&sensor_collection_if);
+  		
+	sensor_manager_if->lpVtbl->RequestPermissions(sensor_manager_if, GetForegroundWindow(),
sensor_collection_if, TRUE);
+
+	if (SUCCEEDED(hr))
+	{
+		// Check sensor count
+		hr = sensor_collection_if->lpVtbl->GetCount(sensor_collection_if, &orientation_sensor_count);
+
+		if (SUCCEEDED(hr))
+		{
+			if (orientation_sensor_count == 0)
+			{
+				// No orientation sensor
+			}
+			else
+			{
+				// Get the first available orientation sensor
+				hr = sensor_collection_if->lpVtbl->GetAt(sensor_collection_if, 0, &compass_if);
+
+			}
+		}
+	}
+
+
+
+	if (SUCCEEDED(hr))
+	{
+		IPortableDeviceValues* params_in = NULL;
+		IPortableDeviceValues* params_out = NULL;
+
+		// Need a properties object...
+		hr = CoCreateInstance(&CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, &IID_IPortableDeviceValues,
(void**) &params_in);
+
+		if (SUCCEEDED(hr))
+		{
+			// Request 20 ms update interval
+			hr = params_in->lpVtbl->SetUnsignedIntegerValue(params_in, &SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL,
20);
+		}
+
+		if (SUCCEEDED(hr))
+		{
+			// Set property
+			hr = compass_if->lpVtbl->SetProperties(compass_if, params_in, &params_out);
+		}
+
+		if (params_in)
+			params_in->lpVtbl->Release(params_in);
+
+		if (params_out)
+			params_out->lpVtbl->Release(params_out);
+	}	
+	
+	while (!stop_flag)
+	{
+		prev_x = last_x;
+		prev_y = last_y;
+		prev_z = last_z;
+		
+		if (!compass_if || !SUCCEEDED(compass_if->lpVtbl->GetData(compass_if, &data_report_if)))
+		{
+			last_x = .002 * (rand()%1000) -1;
+			last_y = .002 * (rand()%1000) -1;
+			last_z = .002 * (rand()%1000) -1;
+		}
+		else
+		{
+			PropVariantInit(&v);
+			hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_HEADING_COMPENSATED_MAGNETIC_NORTH_DEGREES,
&v);
+			if (v.vt == VT_R4)
+				last_h = v.fltVal;
+			if (v.vt == VT_R8)
+				last_h = v.dblVal;
+			PropVariantClear(&v);
+
+			PropVariantInit(&v);
+			hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_X_MILLIGAUSS,
&v);
+			if (v.vt == VT_R4)
+				last_x = v.fltVal;
+			if (v.vt == VT_R8)
+				last_x = v.dblVal;
+			PropVariantClear(&v);
+
+			PropVariantInit(&v);
+			hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Y_MILLIGAUSS,
&v);
+			if (v.vt == VT_R4)
+				last_y = v.fltVal;
+			if (v.vt == VT_R8)
+				last_y = v.dblVal;
+			PropVariantClear(&v);
+
+			PropVariantInit(&v);
+			hr = data_report_if->lpVtbl->GetSensorValue(data_report_if, &SENSOR_DATA_TYPE_MAGNETIC_FIELD_STRENGTH_Z_MILLIGAUSS,
&v);
+			if (v.vt == VT_R4)
+				last_z = v.fltVal;
+			if (v.vt == VT_R8)
+				last_z = v.dblVal;
+			PropVariantClear(&v);
+	
+			//data_report_if->lpVtbl->GetTimestamp(data_report_if, &timestamp);
+			//*ts = 0;
+
+			data_report_if->lpVtbl->Release(data_report_if);
+		}
+
+		if (last_x != prev_x || last_y != prev_y || last_z != prev_z)
+			SendMessage(hWnd, WM_USER_COMPASS, 0, 0);	// Request the main thread to invoke a JS call
for us ; will call propagate_compass_sample in response
+
+		Sleep(10);
+	}
+
+	return 0;
+}
+
+static int start_compass_acquisition (void)
+{
+	if (compass_thread)
+		return -1;
+
+	// Return 0 x/y/z and 0 timestamp until samples start coming in
+	last_x = 0;
+	last_y = 0;
+	last_z = 0;
+
+	stop_flag = FALSE;
+	
+	// Reading sensor values seem to block the calling thread ; do this in a dedicated thread
+	compass_thread = CreateThread(0, 0, compass_thread_proc, 0, 0, 0);
+	return 0;
+}
+
+int stop_compass_acquisition (void)
+{
+	if (compass_thread == 0)
+		return -1;
+
+	stop_flag = TRUE;
+		
+	// Wait until the acquisition thread exits
+	WaitForSingleObject(compass_thread, INFINITE);
+		
+	compass_thread = 0;
+
+	if (new_sample_callback)
+	{
+		SysFreeString(new_sample_callback);
+		new_sample_callback = 0;
+	}
+
+	return 0;
+}
+
+
+HRESULT compass_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
+{
+	if (!wcscmp(action, L"getHeading"))
+	{
+		new_sample_callback = SysAllocString(callback_id);
+		last_x = last_y = last_z = 0;	
+		propagate_compass_sample();
+		start_compass_acquisition();
+		return S_OK;
+	}
+
+	return DISP_E_MEMBERNOTFOUND;
+}
+
+DEFINE_CORDOVA_MODULE(Compass, L"Compass", compass_exec, NULL, NULL)
+
+	/*
+	
+    magneticHeading: The heading in degrees from 0 - 359.99 at a single moment in time. (Number)
+    trueHeading: The heading relative to the geographic North Pole in degrees 0 - 359.99
at a single moment in time. A negative value indicates that the true heading could not be
determined. (Number)
+    headingAccuracy: The deviation in degrees between the reported heading and the true heading.
(Number)
+    timestamp: The time at which this heading was determined. (milliseconds)
+
+	*/

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/compass.h
----------------------------------------------------------------------
diff --git a/Cordova/compass.h b/Cordova/compass.h
new file mode 100644
index 0000000..8958ea7
--- /dev/null
+++ b/Cordova/compass.h
@@ -0,0 +1,23 @@
+// Copyright 2012 Intel Corporation
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+void propagate_compass_sample(void);
+
+DECLARE_CORDOVA_MODULE(Compass)
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/device.c
----------------------------------------------------------------------
diff --git a/Cordova/device.c b/Cordova/device.c
index 5479462..618f743 100644
--- a/Cordova/device.c
+++ b/Cordova/device.c
@@ -33,7 +33,7 @@
 #include "common.h"
 
 #define CORDOVA_MACHINE_ID		L"MachineID"
-#define CORDOVA_VERSION			L"2.0.0"
+#define CORDOVA_VERSION			L"2.1.0"
 #define CORDOVA_VERSION_LEN		5
 
 // A valid UUID string should look like this: f7b38bf1-2ece-4e2a-94a6-e791863f0109

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/mp4patch.c
----------------------------------------------------------------------
diff --git a/Cordova/mp4patch.c b/Cordova/mp4patch.c
index 7415686..b377cc0 100644
--- a/Cordova/mp4patch.c
+++ b/Cordova/mp4patch.c
@@ -151,10 +151,13 @@ void fix_mp4_duration (wchar_t* file_name, LONGLONG duration)
 
 			time_scale = READ_BE4(mvhd_addr + 4 + 4 + 1 + 3 + 4 + 4);
 			
-			time_ratio = (DWORD) (10000000L / time_scale);	// Duration is passed as a number of 100
ns units - there are 10 million ticks per sec
-			fixed_duration = (DWORD) (duration/time_ratio);
+			if (time_scale)
+			{
+					time_ratio = (DWORD) (10000000L / time_scale);	// Duration is passed as a number of
100 ns units - there are 10 million ticks per sec
+					fixed_duration = (DWORD) (duration/time_ratio);
 
-			WRITE_BE4(mvhd_addr + 4 + 4 + 1 + 3 + 4 + 4 + 4, fixed_duration);
+					WRITE_BE4(mvhd_addr + 4 + 4 + 1 + 3 + 4 + 4 + 4, fixed_duration);
+			}
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/notification.c
----------------------------------------------------------------------
diff --git a/Cordova/notification.c b/Cordova/notification.c
index f5fe738..a185b11 100644
--- a/Cordova/notification.c
+++ b/Cordova/notification.c
@@ -36,10 +36,27 @@ extern HWND	hWnd;
 LRESULT CALLBACK NotificationDialogProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
 	int btn_id;
-	
+	HWND hParent;
+	RECT parent_rect;
+	RECT dialog_rect;
+	RECT rc;
+
 	switch (uMsg)
 	{
 		case WM_INITDIALOG:
+
+			// Center the dialog within parent window
+			hParent = GetParent(hDlg);
+
+			GetWindowRect(hParent, &parent_rect);
+			GetWindowRect(hDlg, &dialog_rect);
+			rc = parent_rect;
+
+			OffsetRect(&dialog_rect, -dialog_rect.left, -dialog_rect.top);
+			OffsetRect(&rc, -rc.left, -rc.top);
+			OffsetRect(&rc, -dialog_rect.right, -dialog_rect.bottom);
+
+			SetWindowPos(hDlg, HWND_TOP, parent_rect.left + rc.right*1/2, parent_rect.top + rc.bottom*1/2,
0, 0, SWP_NOSIZE);
 			return TRUE;
 
 		case WM_COMMAND:

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/platform.c
----------------------------------------------------------------------
diff --git a/Cordova/platform.c b/Cordova/platform.c
index 3a08603..3b4f14a 100644
--- a/Cordova/platform.c
+++ b/Cordova/platform.c
@@ -22,19 +22,26 @@
 
 #include "platform.h"
 
-static BOOL override = FALSE;
+static BOOL event_on = TRUE;
 
-BOOL override_back_button(void)
+BOOL is_back_button_event_enabled(void)
 {
-	return override;
+	return event_on;
 }
 
 static HRESULT platform_exec(BSTR callback_id, BSTR action, BSTR args, VARIANT *result)
 {
 	if (!wcscmp(action, L"backButtonEventOn"))
-			override = TRUE;
+	{
+		event_on = TRUE;
+		return S_OK;
+	}
+
 	if (!wcscmp(action, L"backButtonEventOff"))
-		override = FALSE;
+	{
+		event_on = FALSE;
+		return S_OK;
+	}
 
 	return DISP_E_MEMBERNOTFOUND;
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/platform.h
----------------------------------------------------------------------
diff --git a/Cordova/platform.h b/Cordova/platform.h
index f947e1d..398a58d 100644
--- a/Cordova/platform.h
+++ b/Cordova/platform.h
@@ -19,4 +19,6 @@
 
 #include "shell.h"
 
+BOOL is_back_button_event_enabled (void);
+
 DECLARE_CORDOVA_MODULE(Platform)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/shell.c
----------------------------------------------------------------------
diff --git a/Cordova/shell.c b/Cordova/shell.c
index 822f76f..6235476 100644
--- a/Cordova/shell.c
+++ b/Cordova/shell.c
@@ -29,6 +29,9 @@
 
 #include <ipifcons.h>	// Network types
 
+#include <commctrl.h>					// Let's initialize the common controls library
+#pragma comment(lib, "comctl32.lib")	// so they can be used with the process
+
 #include "shell.h"
 #include "common.h"
 #include "device.h"
@@ -40,16 +43,10 @@
 #include "platform.h"
 #include "file.h"
 #include "filetransfer.h"
-
-#include <commctrl.h>					// Let's initialize the common controls library
-#pragma comment(lib, "comctl32.lib")	// so they can be used with the process
+#include "compass.h"
 
 //-------------------------------------------------------------------------------------------------
 
-typedef enum {
-	WM_EXEC_JS_SCRIPT = (WM_USER + 1)
-} UserMessages;
-
 #define NOT_IMPLEMENTED __debugbreak(); OutputDebugStringA(__FUNCTION__); return 0;
 
 IWebBrowser2*			browser_web_if;			// IWebBrowser2 interface to the browser control
@@ -114,6 +111,9 @@ int current_state;	// Rough operating state : not ready / ready / temporarily
pa
 
 int skip_title_update = 1;	// Title update skip counter, used to avoid initial "index.html"
 
+// Browser window subclassing
+static WNDPROC initial_browser_wnd_proc;
+LRESULT CALLBACK BrowserWndProcWrapper(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 //-------------------------------------------------------------------------------------------------
 
@@ -154,6 +154,7 @@ static void register_cordova_modules()
 	register_cordova_module(CORDOVA_MODULE(Platform));
 	register_cordova_module(CORDOVA_MODULE(File));
 	register_cordova_module(CORDOVA_MODULE(FileTransfer));
+	register_cordova_module(CORDOVA_MODULE(Compass));
 }
 
 static void close_cordova_modules()
@@ -168,6 +169,7 @@ static void close_cordova_modules()
 	close_cordova_module(CORDOVA_MODULE(Platform));
 	close_cordova_module(CORDOVA_MODULE(File));
 	close_cordova_module(CORDOVA_MODULE(FileTransfer));
+	close_cordova_module(CORDOVA_MODULE(Compass));
 }
 
 static CordovaModule *find_cordova_module(BSTR module_id)
@@ -801,8 +803,38 @@ void invoke_js_routine (wchar_t* wcs)
 
 //-------------------------------------------------------------------------------------------------
 
+BOOL CALLBACK enum_proc(HWND window, LPARAM reply)
+{
+	static wchar_t wanted[] = L"Internet Explorer_Server";
+	char buf[sizeof(wanted)];
+
+	if (GetClassName(window, (wchar_t*) buf, sizeof(wanted)/sizeof(wanted[0]))
+		&& !memcmp(buf, wanted, sizeof(wanted)))
+	{
+		// Report success and stop enumeration
+		(*(HWND*) reply) = window;
+		return FALSE;
+	}
+	else
+		return TRUE;
+}
+
 void set_native_ready (void)
 {
+	// Find browser window and subclass its window proc so we can intercept back key presses...
+	HWND hBrowserWnd = 0;
+	WNDPROC browser_wnd_proc;
+
+	EnumChildWindows(hWnd, enum_proc, (LPARAM) &hBrowserWnd);
+
+	browser_wnd_proc = (WNDPROC) GetWindowLong(hBrowserWnd, GWL_WNDPROC);
+	if (browser_wnd_proc && browser_wnd_proc != BrowserWndProcWrapper)
+	{
+		initial_browser_wnd_proc = browser_wnd_proc;
+		SetWindowLong(hBrowserWnd, GWL_WNDPROC, (LONG) BrowserWndProcWrapper);
+		BringWindowToTop(hBrowserWnd);
+	}
+
 	// Fire onNativeReady event
 	invoke_js_routine(L"cordova.require('cordova/channel').onNativeReady.fire();");
 }
@@ -1050,12 +1082,27 @@ static void call_js_script(BSTR wcs_as_bstr)
 	}
 }
 
+
+void ProcessBackKeyStroke (void)
+{
+	// I there are listeners for back button down notifications
+	if (is_back_button_event_enabled())
+	{
+		call_js_script(SysAllocString(L"cordova.fireDocumentEvent('backbutton');"));
+	}
+}
+
 LRESULT CALLBACK CordovaShellWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
 	// WindowProc for the main host application window
 
 	switch (uMsg)
 	{
+		case WM_KEYDOWN:
+			if (wParam == VK_BACK)
+				ProcessBackKeyStroke();
+			break;
+
 		case WM_CLOSE:
 			current_state = STATE_ENDING;	// The window will get deactivated before being destroyed
 											// Do not bother sending "pause" event
@@ -1082,13 +1129,18 @@ LRESULT CALLBACK CordovaShellWndProc(HWND hWnd, UINT uMsg, WPARAM
wParam, LPARAM
 			camera_notify_display_change();
 			return 0;
 
-		case WM_USER:
+		case WM_EXEC_JS_SCRIPT:
+			call_js_script((BSTR) lParam);
+			return 0;
+
+		case WM_USER_ACCEL:
 			// New accelerometer sample available ; propagate to the JS side
-			propagate_sample();
+			propagate_accel_sample();
 			return 0;
 
-		case WM_EXEC_JS_SCRIPT:
-			call_js_script((BSTR) lParam);
+		case WM_USER_COMPASS:
+			// New compass sample available ; propagate to the JS side
+			propagate_compass_sample();
 			return 0;
 
 		case WM_PARENTNOTIFY:
@@ -1129,6 +1181,16 @@ LRESULT CALLBACK CordovaShellWndProc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM
 
 //-------------------------------------------------------------------------------------------------
 
+LRESULT CALLBACK BrowserWndProcWrapper(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	if (uMsg == WM_KEYDOWN && wParam == VK_BACK)
+		ProcessBackKeyStroke();
+
+	return initial_browser_wnd_proc(hWnd, uMsg, wParam, lParam);
+}
+
+//-------------------------------------------------------------------------------------------------
+
 void create_browser_object (void)
 {
 	HRESULT hr;
@@ -1341,9 +1403,6 @@ void early_init (void)
 	ccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
 	ccex.dwICC  = ICC_BAR_CLASSES;
 	InitCommonControlsEx(&ccex);
-
-	// Initialize and check available sensors
-	setup_sensors();
 }
 
 //-------------------------------------------------------------------------------------------------
@@ -1367,6 +1426,8 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLi
 		0 // >>> small icon update
 		};
 
+	set_thread_name(-1, "Primary Thread");
+
 	early_init();
 	register_cordova_modules();
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/www/cordova.win7.js
----------------------------------------------------------------------
diff --git a/Cordova/www/cordova.win7.js b/Cordova/www/cordova.win7.js
index ea88e73..82bc68a 100644
--- a/Cordova/www/cordova.win7.js
+++ b/Cordova/www/cordova.win7.js
@@ -1,4 +1,6 @@
-// File generated at :: Fri Aug 03 2012 11:28:36 GMT+0200 (CEST)
+// commit 24969fba7ec490b3637569e573f7037015524c01
+
+// File generated at :: Thu Sep 20 2012 11:37:38 GMT+0200 (Romance Daylight Time)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one

http://git-wip-us.apache.org/repos/asf/incubator-cordova-windows/blob/26faf172/Cordova/www/events.html
----------------------------------------------------------------------
diff --git a/Cordova/www/events.html b/Cordova/www/events.html
index c662c31..5d9c5e3 100644
--- a/Cordova/www/events.html
+++ b/Cordova/www/events.html
@@ -7,9 +7,10 @@
 	<body>
         <div id='state'></div>
         <script>
-            document.addEventListener('deviceready', function () { document.getElementById('state').innerHTML
= 'Ready!'; }, false);
-            document.addEventListener('pause', function () { document.getElementById('state').innerHTML
= 'Paused!'; }, false);
-            document.addEventListener('resume', function () { document.getElementById('state').innerHTML
= 'Resumed!'; }, false);
-		</script>
+          document.addEventListener('deviceready', function () { document.getElementById('state').innerHTML
= 'Ready!'; }, false);
+          document.addEventListener('pause', function () { document.getElementById('state').innerHTML
= 'Paused!'; }, false);
+          document.addEventListener('resume', function () { document.getElementById('state').innerHTML
= 'Resumed!'; }, false);
+          document.addEventListener('backbutton', function () { document.getElementById('state').innerHTML
= 'Back!'; }, false);
+        </script>
 	</body>
 </html>
\ No newline at end of file


Mime
View raw message