Active Topics

 


Reply
Thread Tools
Posts: 958 | Thanked: 483 times | Joined on May 2010
#1
i am new to Linux / N900 / SDL programming. but I am not new to mobile development (11 years) or programming (>25 years). i have experience in C and C++ plus a few other languages.

i am currently picking up an app that someone wrote here but has since abandoned a long time ago. this app uses SDL.

the app is written in C to keep things simple. i call SDL_WM_ToggleFullScreen to get the app into full screen. everything works fine except - i can't use the CTRL-BACKSPACE key combo on the N900 to switch back out to the task viewer or desktop.

the only way i can get out is to hit the power button at the top which brings down a menu and if i wait a few seconds it then goes back out to the desktop. i can then swap to the task manager and see my app's window.

is there a way to pass the CTRL-BACKSPACE key combination back to the operating system instead of having it trapped by SDL? or is there another way to handle this?

my thoughts now are to have a key in my app that allows the user to toggle between full screen and windowed mode. but ideally i would like my app to run in full screen all the time but still give the flexibility to the user to task out and say respond to an incoming SMS.
 
Posts: 317 | Thanked: 787 times | Joined on Oct 2009 @ Krakow, Poland
#2
Using D-Bus is the answer:

Code:
#include <dbus/dbus.h>

void invokeTaskManager() {
        DBusConnection* bus = NULL;
        DBusMessage* msg = NULL;
        DBusError error;

        dbus_error_init(&error);

        bus = dbus_bus_get(DBUS_BUS_SESSION, &error);

        if (bus == NULL) {
                fprintf(stderr, "bus == NULL\n");
                return;
        }

        // create a signal and check for errors
        msg = dbus_message_new_signal("/com/nokia/hildon_desktop", // path
                        "com.nokia.hildon_desktop", // interface
                        "exit_app_view"); // method str
        if (NULL == msg) {
                fprintf(stderr, "Message Null\n");
                exit(1);
        }

        // send the message and flush the connection
        if (!dbus_connection_send(bus, msg, NULL)) {
                fprintf(stderr, "Out Of Memory!\n");
                exit(1);
        }

        dbus_connection_flush(bus);
        dbus_message_unref(msg);
}
 

The Following User Says Thank You to dwaradzyn For This Useful Post:
Posts: 958 | Thanked: 483 times | Joined on May 2010
#3
aaaaaaaaah thank u. thanks for the code snippet too.

let me try to figure out how to integrate this. i'm guessing i should run the code when i detect ctrl-backspace in SDL, yes?
 
Zas's Avatar
Posts: 196 | Thanked: 113 times | Joined on Jun 2010 @ Finland
#4
Include stdlib.h and you can use the code:
Code:
system("dbus-send /com/nokia/hildon_desktop com.nokia.hildon_desktop.exit_app_view");
to do this.

You can either add a key combination or an on screen button much like the one originally in hildon windows. Ctrl+backspace works when I code in SDL & c++. Don't know why it doesn't for you.

Last edited by Zas; 2011-06-24 at 07:00.
 

The Following User Says Thank You to Zas For This Useful Post:
Posts: 958 | Thanked: 483 times | Joined on May 2010
#5
got it working nicely. thanks!!!!

i basically capture a keycode which i designate for activating the task manager. perfect.

i don't know why ctrl-backspace doesn't work yet since i just started looking through the sources of that app. are you running in full screen mode?
 
Posts: 958 | Thanked: 483 times | Joined on May 2010
#6
hmmmmmmmmm gotta spend a bit more time debugging the code though. if i manage to get toggle to the task manager ONCE, then ctrl-backspace works nicely thereafter without needing dbus.

but if i don't toggle to the task manager for the first time, ctrl-backspace doesn't work.

Last edited by droll; 2011-06-24 at 07:10.
 
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#7
Personally I think the user should have options to have either fullscreen or not - you can still make your preference the default without actually limiting user choice to make the app full-screen or not. Of course, some apps would be hard to properly scale to both fullscreen/'normal', so can't really be picky if that's the case.
 

The Following User Says Thank You to Mentalist Traceur For This Useful Post:
Zas's Avatar
Posts: 196 | Thanked: 113 times | Joined on Jun 2010 @ Finland
#8
Maybe its the way you go to fullscreen. Have you tried creating the screen surface already as a fullscreen surface with "SDL_SWSURFACE|SDL_FULLSCREEN"
 

The Following User Says Thank You to Zas For This Useful Post:
Posts: 958 | Thanked: 483 times | Joined on May 2010
#9
nevermind. fixed it. all is fine and dandy. no need to use dbus anymore. yup, i had to use SDL_FULLSCREEN plus some other minor logic errors that the original author had in the code.

thanks folks.
 

The Following User Says Thank You to droll For This Useful Post:
JadeH's Avatar
Posts: 162 | Thanked: 64 times | Joined on Mar 2011
#10
I love SDL I wrote some good things in C+SDL before (mainly a 2d/physics engine and other small cool stuff) and got them working on PSP, linux and now n900, without much tweaking at all, pretty cool
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:19.