11-21-2012 06:58 PM
I am struggling to listen for playbook orientation change when a native screen is being shown over the top of a QMainWindow, resize() gets called only when the native screen isnt shown.
I have tried to add case NAVIGATOR_ORIENTATION to handle_navigator_event but it never gets called.
Anyone have experience of this?
Thanks
Solved! Go to Solution.
11-22-2012 06:16 AM - edited 11-22-2012 06:25 AM
This isn't really how you should be doing it. Qt sets up all of this stuff already. If you try to do it the 'native' way, you will be duplicating this functionality.
You will need to grab a handle to the native screen from Qt itself if you want to use the native API on top of Qt. Then you can run a thread that checks BPS events and they shouldn't interfere.
I would suggest using Qt to notify you of orientation changes though.
11-22-2012 07:06 AM
Thanks for your reply xsacha,
I think I am already doing what you suggest - the following is a function which gets called by starting a pthread.
void* MyWindow::keyboard_thread(void* args)
{
MyWindow* mw = (MyWindow*)args;
bps_initialize();
dialog_request_events(0);
screen_request_events(screencontext);
navigator_request_events(0);
virtualkeyboard_request_events(0);
if (BPS_SUCCESS != navigator_rotation_lock(false)) {
fprintf(stderr, "navigator_rotation_lock failed\n");
}
while(!exit_application)
{
while (mw->connected) {
/* Handle user input */
handle_events(mw);
}
}
keyboardthread = NULL;
gestures_cleanup();
}
handle_events checks for screen or navigator domain and handles appropriotly, I just never get NAVIGATOR_ORIENTATION event in handle_navigator_event - is there anything I could be missing?
11-22-2012 07:56 AM
Oh ok, where's your code for handling navigator events?
Is it like this?
switch (bps_event_get_code(event)) {
case NAVIGATOR_ORIENTATION: ....
...
}
11-22-2012 08:39 AM
Hi xsacha,
here's my code..
void
handle_navigator_event(bps_event_t *event) {
switch (bps_event_get_code(event)) {
case NAVIGATOR_EXIT:
exit_application = 1;
break;
case NAVIGATOR_ORIENTATION:
cout << "orienation";
cout.flush();
break;
}
}
11-22-2012 10:54 AM
out of curiousity - why did you go with separate thread for 'keyboard'?
Qt let's you 'intercept' and react to any bps (Native) events...
11-22-2012 12:09 PM
Hey BGmot,
I went with a separte pthread when everything was still very new to me in c/c++ & qt.
How do you intercept these events exactly - do you have a link to get me on the right path?
Thanks
11-22-2012 12:15 PM
11-22-2012 12:20 PM
Thank you.
so thats how it's done - properly!
Thank you both to BGmot and xsacha for your help.
Regards.
11-22-2012 06:04 PM
Sorry about this guys,
I have implemented what's suggested in the link provided for eventFilter and eventFilter function is called but I am never getting the event == to screen or navigator domain although the eventfilter function is called when the rotation of device takes place..
if (domain == navigator_get_domain()) {
handle_navigator_event(event);
} else if (domain == screen_get_domain()) {
handle_screen_event();
}
else
{
//eventfilter justs fall through to here
}
anyone any ideas why I cant get the event == to screen or navigator domain?