XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Sep 23日 06:36

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 2017年 Jun 12日 02:57 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
An event that is currently missing from the widget engine:

wakefromsleep
sent when the computer wakes from sleep mode

Description
This event is sent when the computer wakes from sleep mode.
Timers are stopped when the computer goes to sleep and are not restarted until onWakeFromSleep is called. There is usually a delay of about 15 seconds between when the computer wakes and when this event is sent. This is to give the networking stack time to recover before the Widget timers start to function again.

Example

widget.onWakeFromSleep = handleWake;

The absence of this event means that some essential tasks that need to be performed on wake up cannot be performed. The above is an extract from the yahoo widget documentation showing how it should work in an existing javascript engine.

Usage:
When ActiveX controls are used to interface to system functions such as windows media player, after a system hibernate and restart the underlying connection is not always maintained between the component and the widget leading to an error and a subsequent hang. If the onWakeFromSleep event was implemented, the ActiveX object could be reinstantiated to ensure the connection is remade. Currently Xwidget is unable to do this.


Last edited by yereverluvinuncleber on 2017年 Jun 28日 05:05, edited 1 time in total.

Top
 Profile  
 
PostPosted: 2017年 Jun 14日 04:19 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
If anyone knows how to detect when a widget has awoken from sleep then please tell me. For the moment I will use a one-per-minute timer and I'll check the time difference, if it is greater than three minutes then I will restart the widget.


Top
 Profile  
 
PostPosted: 2017年 Jun 19日 10:44 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
How to implement the wakeFromSleep function in javascript.

First some variable declarations:
Code:
 var time = new Date();
 var savedTime = time;


This is how Yahoo widget would have implemented the wakeFromSleep function
Code:
//==============================
// reload after sleep
//==============================
//widget.onWakeFromSleep = function () {
//   lprint("onWakeFromSleep");
//   reloadWidget();
//};



This is the Xwidget code that is called from a timer called sleepTimer
Code:
// timer to check sleep once a minute
// sets a value, check the value and if the difference is
// greater than three minutes then assume the PC has been
// asleep and restart the widget.
//==============================
// reload after sleep
//==============================
function sleepTimerOnUpdate(Sender)
{
    var theDate = new Date();
    secsDif = parseInt(theDate.getTime() / 1000, 10) - parseInt((savedTime) / 1000, 10);

    if (secsDif >= 180) {      // 3 mins pause causes a restart
        print("Running the sleep timer - the difference is an abnormal " + secsDif + " secs");
        //widget.cmd("!Reload");   // does not work FFS
        savedTime = new Date();
        startup(); // have to call the startup function as there is no working reload function in Xwidget
    } else {
        //print("Running the sleep timer - the difference is " + secsDif + " secs");
        savedTime = new Date();
    }
}
//=====================
//End function
//=====================


Top
 Profile  
 
PostPosted: 2017年 Jun 19日 10:47 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 556
The main issue here is that once the wakeFromSleep function has been called there is no option to reload or restart the widget within Xwidget. That is necessary to reconnect the ActiveX object. This is a deficiency within Xwidget that is documented here: http://bbs.xwidget.com/viewtopic.php?f=8&t=6102


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group