Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
maribou
Posts: 40
Registered: ‎04-01-2009
My Device: Torch 9810
Accepted Solution

WebWorks screen context in native extension

I am trying to build a native extension for WebWorks (BB10) to control screen timeout for my app.


Ideally I'd like to set a longer timeout when my app is in foreground, without affecting the timeout settings of the device itself. I can see SCREEN_PROPERTY_IDLE_TIMEOUT in <screen.h>, which I hope could be used for this purpose.


If that is not possible, the other approach would be to set the screen to SCREEN_IDLE_MODE_KEEP_AWAKE and back to SCREEN_IDLE_MODE_NORMAL based on timing controlled by the JavaScript code.

 

I got as far as

  (a) getting memoryJnext sample work in my app and

  (b) finding screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_IDLE_MODE, &idle_mode) code snippet.


The question is how do I assign WebWorks app windows context to screen_win?

New Contributor
danteoh
Posts: 2
Registered: ‎12-15-2012
My Device: Dev Alpha

Re: WebWorks screen context in native extension

Did you ever find a solution to this? I'm working on an exercise app in WebWorks as well and its pretty useless if the screen shuts off during a workout!
Developer
cwong15
Posts: 193
Registered: ‎02-27-2009
My Device: Not Specified

Re: WebWorks screen context in native extension

I've been looking for a solution too. The main problem seems to be that when you are thrown into the middle of a WebWorks extension, you don't have any handle to a screen_window_t. So the native core API seems to be a dead end. On the other hand, the Cascades API has a static Application::instance() that seems to offer a path to the window API we need. So I found this API, and the IDE seems to be happy to compile it, but I don't have an extension set up to test it. Please do tell me if this works:

 

bb::cascades::Application::instance()->mainWindow()->setScreenIdleMode(SCREEN_IDLE_MODE_KEEP_AWAKE);

 

 

 

 

BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: WebWorks screen context in native extension

We've been working on this in Dev Rel too. The challenge is getting access to the WebWorks screen as you've found. Unfortunately, we can't use the Cascades API in WebWorks, only Qt, C++ and C APIs work. We tried a few things already that didn't work, and are continuing to investigate some other options.

Tim Windsor
Open Source Technical Lead
BlackBerry Development Advisor
twindsor
Posts: 832
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: WebWorks screen context in native extension

We figured it out.

 

Extension is now live here: https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10/PreventSleep

Tim Windsor
Open Source Technical Lead
Developer
cwong15
Posts: 193
Registered: ‎02-27-2009
My Device: Not Specified

Re: WebWorks screen context in native extension

That's great! Thanks for providing a way to handle what would sometimes be a crippling limitation in WebWorks. Of course, since the BB10 emulator does not seem to sleep at all, I will just have to take your word for it that this works :-)