The attached patch provides initial support for running PythonCE on windows mobile powered smartphone devices. The same CAB file will now install and operator on both Pocket PC and Smartphone devices.
The changes are as follows:
1) Altered the cab file inf file to remove potential warnings during installation about incompatible screen sizes.
2) Altered window creation code such that failure to query the size of the Software Input Panel (SIP) is not considered a fatal error. Smartphones do not have SIPs, so SIP related API calls will always return error codes.
3) Sent a couple of smartphone specific window messages to the main edit control. These messages override the behaviour of the '1' key on a cellphone's keypad when in mutli-tap mode such that the user has easy access to symbols such as ()@: etc as often needed when entering Python source code. On Pocket PC powered devices these additional messages will be ignored.
4) Fixed a race condition which appeared to be falling over more often than it does on the pocket pc platform. When the second thread within python.exe is started up the main thread suspends itself (via a call to SuspendThread) until it is woken up by the second thread after it has performed initialisation (via a call to ResumeThread).
The issue is if the newly created thread manages to execute it's call to ResumeThread before the main thread has gained control of the processor again after creating the new thread. This leads to the situation of the main thread entering it's call to SuspendThread and never being woken up (due to the second thread having called ResumeThread before we suspended).
The solution I have used is to utilise a named event instead. The main thread creates an event called "PythonStartup", the newly created thread simply sets this event to the signaled state when completed, and the main thread waits for it to be become signaled. This means the main thread can detect when the second thread has completed initalisation even if it completes before we wait for it to occur on the main thread.