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
New Contributor
adampigg
Posts: 7
Registered: ‎02-06-2013
My Device: Dev Alpha A
My Carrier: Three UK

Cant disable screen idle on a Plain Qt app

Hi

 

Im using the following code, which i _think_ should stop the screen from idling.  Im using a DevAlphaA for testing.

 

viewer is a QmlApplicationViewer, and is the top level widget.  The property appears to get set Ok as i confirm and print it out in the qDebug, yet the screen still sleeps.

 

The hide() is in there to see if hiding and showing helped, but it didnt.

 

Any help appreciated!

 

qDebug() << "On a blackberry!";

viewer->setOrientation(QmlApplicationViewer::smileyfrustrated:creenOrientationLockPortrait);
viewer->setMainQmlFile(QLatin1String("app/native/qml/pgz-farmbreakout/main-blackberry.qml"));
viewer->setResizeMode(QDeclarativeView::smileyfrustrated:izeRootObjectToView);
viewer->setGeometry(0, 0, 768, 1280);

int idle_mode = SCREEN_IDLE_MODE_KEEP_AWAKE;
int ret = 0;

WId winId = viewer->winId();
ret = screen_set_window_property_iv(screen_window_t(winId), SCREEN_PROPERTY_IDLE_MODE, &idle_mode);

viewer->hide();

screen_get_window_property_iv(screen_window_t(winId), SCREEN_PROPERTY_IDLE_MODE, &idle_mode);

qDebug() << "Idle Mode:" << idle_mode << SCREEN_IDLE_MODE_KEEP_AWAKE << ret << winId;

viewer->showFullScreen();

Please use plain text.
Developer
torpesco
Posts: 121
Registered: ‎01-29-2011
My Device: Z10, PlayBook
My Carrier: Wind Mobile

Re: Cant disable screen idle on a Plain Qt app

I briefly had something like that before switching to the Cascades method. A friend with a device confirmed it worked for me...

 

Unfortunately, it seems that I didn't actually commit that code to my repository before replacing it. :smileysad:

 

I have a feeling, though, that I used screen_set_display_property_iv(). I'm not positive, though. I know I tried controlling the screen brightness with that, but it did not work at all...

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Cant disable screen idle on a Plain Qt app

In Native app I would call screen_post_window() to make sure this property change 'applied' as it is of 'Delayed execution' type.

Not sure what to do with QML. Doesn't QML have some similar property? i.e. do you have to access underlying native Window to set this up?

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Cant disable screen idle on a Plain Qt app

Here you go - did you see screenIdleMode property of bb::cascades::Window ?

Please use plain text.
New Contributor
adampigg
Posts: 7
Registered: ‎02-06-2013
My Device: Dev Alpha A
My Carrier: Three UK

Re: Cant disable screen idle on a Plain Qt app

Im not sure i can call screen_post_window becuase i dont know the buffer argument. However, i did try hiding and showing the window to force a refresh as suggested on IRC but that didnt work either :smileysad:
Please use plain text.
New Contributor
adampigg
Posts: 7
Registered: ‎02-06-2013
My Device: Dev Alpha A
My Carrier: Three UK

Re: Cant disable screen idle on a Plain Qt app

Im not using cascades, im using plain Qt + QML. I can write some native c++ if needed, but not cascades.
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Cant disable screen idle on a Plain Qt app

try flushing the screen context after you update the window properties.

you can retrieve the context from the window handle.

see ::smileysurprised:nWindowAttached() in this file:

https://github.com/blackberry/Cascades-Community-Samples/blob/master/HelloCamera/src/hellocameraapp....

 

 

Please use plain text.
New Contributor
adampigg
Posts: 7
Registered: ‎02-06-2013
My Device: Dev Alpha A
My Carrier: Three UK

Re: Cant disable screen idle on a Plain Qt app

Thanks for the suggestion. the code compiles but has no effect....its driving me nuts!
Please use plain text.
New Contributor
adampigg
Posts: 7
Registered: ‎02-06-2013
My Device: Dev Alpha A
My Carrier: Three UK

Re: Cant disable screen idle on a Plain Qt app

Finally fixed it!

Thanks for all the help. The code i was using turned out to be right, but i wasnt setting the property on the correct window. For performance reasons, i set the viewport of the viewer to a QGLWidget, and when i used the handle of GLWidget it works correctly.

Thanks again for the help
Please use plain text.
Developer
torpesco
Posts: 121
Registered: ‎01-29-2011
My Device: Z10, PlayBook
My Carrier: Wind Mobile

Re: Cant disable screen idle on a Plain Qt app

Gotta love those subtleties... Glad you figured it out!

Please use plain text.