Re: detect window iconified/maximized in SDL
Hi, > BTW. another, perhaps a simpler, way with SDL is to track the FocusOut > and FocusIn events. I think our pre-installed games do that. So when > your window has the focus, run it, otherwise keep it paused. A problem seems to be that fullscreen SDL apps (like mine) do not get the FocusIn/Out Events. Also the Enter/LeaveNotify events are with xcrossing mode NotifyGrab/Ungrab and thus do not generate SDL events. regards, -- Willem-Jan de Hoog ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, You might want to check out hildon-games-wrapper0 (Nokia-open) before starting from scratch. We have SDL games that receive these events in Diablo (and Fremantle). BR; Kimmo On Mon, 2009-03-30 at 09:42 +0200, ext Kees Jongenburger wrote: > On Mon, Mar 30, 2009 at 8:15 AM, Quim Gil wrote: > > Hi, > > > > CCing Kuisma, Maemo SW maintainer of the SDL packages. > > > > ext Kees Jongenburger wrote: > >> Hi, > >> > >> Should we/I start a small libsdl project on garage to address such issues? > > > > And what would be the goal of such garage project? Isn't enough to file > > bugs/patches against > > > > http://repository.maemo.org/pool/fremantle/free/libs/libsdl1.2/ > > http://repository.maemo.org/pool/fremantle/free/libs/libsdl-mixer1.2/ > > http://repository.maemo.org/pool/fremantle/free/libs/libsdl-image1.2/ > > Perhaps. Apparently a programs that does not listen to dbus events is not > maemo > friendly and a typical SDL programs will do just that(not listen to > the events). If we can easily modify the SDL lib > to map these event to standard events that would be great. > > But not everything can and should be abstracted away sometime t's > better to provide good examples, > certainly if we need to integrate the dbus hander in the main loop.:p > > Greetings > > > > > > > >> > >> > >> Greetings > >> On Thu, Mar 26, 2009 at 9:35 PM, W. de Hoog wrote: > >>> Hi, > >>> > Do you have a separate thread that listens on the libosso callback stuff? > That could work also if it "locks up" the main loop when display is > turned off and > (like your main thread) doesn't use SDL to wait for events. > >>> I do not have a seperate thread for it. I did register my callback but > >>> as I mailed, it is not being called back when the display goes on or > >>> off. This is very weird and disappointing. > >>> > You can in select() listen on that file descriptor. You could look for > an example here: > http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c > >>> Thanks for the link. However this seems a bit beyond my reach. > >>> > >>> > >>> regards, > >>> > >>> -- > >>> Willem-Jan de Hoog > > > > -- > > Quim Gil > > open source advocate > > Maemo Software @ Nokia > > > ___ > maemo-developers mailing list > maemo-developers@maemo.org > https://lists.maemo.org/mailman/listinfo/maemo-developers ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
On Mon, Mar 30, 2009 at 8:15 AM, Quim Gil wrote: > Hi, > > CCing Kuisma, Maemo SW maintainer of the SDL packages. > > ext Kees Jongenburger wrote: >> Hi, >> >> Should we/I start a small libsdl project on garage to address such issues? > > And what would be the goal of such garage project? Isn't enough to file > bugs/patches against > > http://repository.maemo.org/pool/fremantle/free/libs/libsdl1.2/ > http://repository.maemo.org/pool/fremantle/free/libs/libsdl-mixer1.2/ > http://repository.maemo.org/pool/fremantle/free/libs/libsdl-image1.2/ Perhaps. Apparently a programs that does not listen to dbus events is not maemo friendly and a typical SDL programs will do just that(not listen to the events). If we can easily modify the SDL lib to map these event to standard events that would be great. But not everything can and should be abstracted away sometime t's better to provide good examples, certainly if we need to integrate the dbus hander in the main loop.:p Greetings > > >> >> >> Greetings >> On Thu, Mar 26, 2009 at 9:35 PM, W. de Hoog wrote: >>> Hi, >>> Do you have a separate thread that listens on the libosso callback stuff? That could work also if it "locks up" the main loop when display is turned off and (like your main thread) doesn't use SDL to wait for events. >>> I do not have a seperate thread for it. I did register my callback but >>> as I mailed, it is not being called back when the display goes on or >>> off. This is very weird and disappointing. >>> You can in select() listen on that file descriptor. You could look for an example here: http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c >>> Thanks for the link. However this seems a bit beyond my reach. >>> >>> >>> regards, >>> >>> -- >>> Willem-Jan de Hoog > > -- > Quim Gil > open source advocate > Maemo Software @ Nokia > ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, CCing Kuisma, Maemo SW maintainer of the SDL packages. ext Kees Jongenburger wrote: > Hi, > > Should we/I start a small libsdl project on garage to address such issues? And what would be the goal of such garage project? Isn't enough to file bugs/patches against http://repository.maemo.org/pool/fremantle/free/libs/libsdl1.2/ http://repository.maemo.org/pool/fremantle/free/libs/libsdl-mixer1.2/ http://repository.maemo.org/pool/fremantle/free/libs/libsdl-image1.2/ > > > Greetings > On Thu, Mar 26, 2009 at 9:35 PM, W. de Hoog wrote: >> Hi, >> >>> Do you have a separate thread that listens on the libosso callback stuff? >>> That could work also if it "locks up" the main loop when display is turned >>> off and >>> (like your main thread) doesn't use SDL to wait for events. >> I do not have a seperate thread for it. I did register my callback but >> as I mailed, it is not being called back when the display goes on or >> off. This is very weird and disappointing. >> >>> You can in select() listen on that file descriptor. You could look for an >>> example here: >>> http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c >> Thanks for the link. However this seems a bit beyond my reach. >> >> >> regards, >> >> -- >> Willem-Jan de Hoog -- Quim Gil open source advocate Maemo Software @ Nokia ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi Kees, > Should we/I start a small libsdl project on garage to address such issues? I am all for these issues being addressed. But I ran out of ideas. As mailed previously the window manager seems to not notify every event (or not all info for the event) and I also tried to listen to all dbus signals but the sdl app does not seem to get them. Tried it by creating an SDL thread that ran while(dbus_connection_read_write_dispatch(connection, -1)); or by calling dbus_connection_dispatch from the main loop. Still I do not get the on/dimmed/off events. So yes I would like to work on a solution but I need ideas where to start looking. regards, -- Willem-Jan de Hoog ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, Should we/I start a small libsdl project on garage to address such issues? Greetings On Thu, Mar 26, 2009 at 9:35 PM, W. de Hoog wrote: > Hi, > >> Do you have a separate thread that listens on the libosso callback stuff? >> That could work also if it "locks up" the main loop when display is turned >> off and >> (like your main thread) doesn't use SDL to wait for events. > I do not have a seperate thread for it. I did register my callback but > as I mailed, it is not being called back when the display goes on or > off. This is very weird and disappointing. > >> You can in select() listen on that file descriptor. You could look for an >> example here: >> http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c > Thanks for the link. However this seems a bit beyond my reach. > > > regards, > > -- > Willem-Jan de Hoog > ___ > maemo-developers mailing list > maemo-developers@maemo.org > https://lists.maemo.org/mailman/listinfo/maemo-developers > ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, > Do you have a separate thread that listens on the libosso callback stuff? > That could work also if it "locks up" the main loop when display is turned > off and > (like your main thread) doesn't use SDL to wait for events. I do not have a seperate thread for it. I did register my callback but as I mailed, it is not being called back when the display goes on or off. This is very weird and disappointing. > You can in select() listen on that file descriptor. You could look for an > example here: > http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c Thanks for the link. However this seems a bit beyond my reach. regards, -- Willem-Jan de Hoog ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
RE: detect window iconified/maximized in SDL
Hi, From: maemo-developers-boun...@maemo.org [maemo-developers-boun...@maemo.org] On Behalf Of ext W. de Hoog [wdeh...@exalondelft.nl] Sent: Wednesday, March 25, 2009 19:20 >> Note that it's not enough just to use SDL function to wait for events when >> it's >> invisible / idle. SDL does 10Hz polling even when waiting for events which >> will >> drain battery pretty soon. (I filed a bug about that for upstream SDL >> several >> years ago, it's still not fixed, but there's a broken patch available.) http://bugzilla.libsdl.org/show_bug.cgi?id=323 >That is sad. Indeed... I was thinking of using an SDL semaphore in the main loop >that is locked/unlocked when osso notifies of display on/off. This would >not do much then I guess. Do you have a separate thread that listens on the libosso callback stuff? That could work also if it "locks up" the main loop when display is turned off and (like your main thread) doesn't use SDL to wait for events. >> Because of this, in my own SDL code I use select() when the process should >> be idle in RAM longer times without draining battery. You can get the SDL X >> socket file descriptor like this: > >Please forgive my ignorence but I do not understand the link between >select() and GetUISocket(). You can in select() listen on that file descriptor. You could look for an example here: http://hg.berlios.de/repos/hatari/file/c6567e2a430d/src/control.c - Eero PS. Except for some performance issues, Hatari emulator should work fine on N8x0 devices. I just haven't had time to package the latest version. A configuration suitable for N8x0 is included with the sources: http://hg.berlios.de/repos/hatari/file/c6567e2a430d/etc/ Some stuff for the emulator is available from here: http://koti.mbnet.fi/tammat/hatari/ ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, about these good SDL tips. Could you please help updating and documenting better SDL at http://wiki.maemo.org/Game_development ? It would benefit everybody. Thanks! ext W. de Hoog wrote: > Hi, > >> BTW. another, perhaps a simpler, way with SDL is to track the FocusOut -- Quim Gil open source advocate Maemo Software @ Nokia ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, > BTW. another, perhaps a simpler, way with SDL is to track the FocusOut > and FocusIn events. I think our pre-installed games do that. So when > your window has the focus, run it, otherwise keep it paused. When I listen to SDL_SYSWMEVENT I get xevent type 33 when I switch to my app or switch away from it (the app is fullscreen only). The data seems always to be 0 so I do not know if focus is in or out. Code I use: case SDL_SYSWMEVENT: printf("Xevent: %d:%d", event.syswm.msg->event.xevent.type, event.syswm.msg->event.xevent.xclient.format); printf(" %d:%d", event.syswm.msg->event.xevent.xclient.data.b[0], event.syswm.msg->event.xevent.xclient.data.s[0]); printf(" %d\n", event.syswm.msg->event.xevent.xclient.message_type); output is: Xevent: 33:8 0:0 327 Xevent: 33:8 0:0 327 -- Willem-Jan de Hoog ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
Hi, > Note that it's not enough just to use SDL function to wait for events when > it's > invisible / idle. SDL does 10Hz polling even when waiting for events which > will > drain battery pretty soon. (I filed a bug about that for upstream SDL several > years ago, it's still not fixed, but there's a broken patch available.) That is sad. I was thinking of using an SDL semaphore in the main loop that is locked/unlocked when osso notifies of display on/off. This would not do much then I guess. > Because of this, in my own SDL code I use select() when the process should > be idle in RAM longer times without draining battery. You can get the SDL X > socket file descriptor like this: Please forgive my ignorence but I do not understand the link between select() and GetUISocket(). -- Willem-Jan de Hoog ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
RE: detect window iconified/maximized in SDL
Hi, From: maemo-developers-boun...@maemo.org [maemo-developers-boun...@maemo.org] On Behalf Of Hamalainen Kimmo (Nokia-D/Helsinki) On Wed, 2009-03-25 at 09:14 +0100, Hamalainen Kimmo (Nokia-D/Helsinki) > > I would like to detect when an SDL application gets iconified. Than I > > can pause it to save power. In theory the SDL_ACTIVEEVENT should be > > generated and event.active should give me the info I need however I do > > not get these type of events. Note that it's not enough just to use SDL function to wait for events when it's invisible / idle. SDL does 10Hz polling even when waiting for events which will drain battery pretty soon. (I filed a bug about that for upstream SDL several years ago, it's still not fixed, but there's a broken patch available.) Because of this, in my own SDL code I use select() when the process should be idle in RAM longer times without draining battery. You can get the SDL X socket file descriptor like this: -- /** * Return the X connection socket or zero */ static int GetUISocket(void) { SDL_SysWMinfo info; SDL_VERSION(&info.version); if (!SDL_GetWMInfo(&info)) { return 0; } return ConnectionNumber(info.info.x11.display); } Your program could use something like that also with an an explicit (user invoked) pause functionality. - Eero ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
On Wed, 2009-03-25 at 09:14 +0100, Hamalainen Kimmo (Nokia-D/Helsinki) wrote: > On Tue, 2009-03-24 at 22:23 +0100, ext W. de Hoog wrote: > > Hi, > > > > I would like to detect when an SDL application gets iconified. Than I > > can pause it to save power. In theory the SDL_ACTIVEEVENT should be > > generated and event.active should give me the info I need however I do > > not get these type of events. > > > > Anybody know of how to get the correct events or another way to detect > > the iconification? BTW. another, perhaps a simpler, way with SDL is to track the FocusOut and FocusIn events. I think our pre-installed games do that. So when your window has the focus, run it, otherwise keep it paused. BR; Kimmo > In Diablo, you can probably receive notification when WM_STATE changes > to IconicState > (WM_STATE is described in > http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.3.1) > somehow with SDL. > > In Fremantle, we are not using the iconic state and you need to track > _MB_CURRENT_APP_WINDOW property on the root window to see if you are > visible. I think SDL knows nothing of this property, but maybe the > support could be added there... > > -Kimmo > > > > > regards, > > > > ___ > maemo-developers mailing list > maemo-developers@maemo.org > https://lists.maemo.org/mailman/listinfo/maemo-developers ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers
Re: detect window iconified/maximized in SDL
On Tue, 2009-03-24 at 22:23 +0100, ext W. de Hoog wrote: > Hi, > > I would like to detect when an SDL application gets iconified. Than I > can pause it to save power. In theory the SDL_ACTIVEEVENT should be > generated and event.active should give me the info I need however I do > not get these type of events. > > Anybody know of how to get the correct events or another way to detect > the iconification? In Diablo, you can probably receive notification when WM_STATE changes to IconicState (WM_STATE is described in http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.3.1) somehow with SDL. In Fremantle, we are not using the iconic state and you need to track _MB_CURRENT_APP_WINDOW property on the root window to see if you are visible. I think SDL knows nothing of this property, but maybe the support could be added there... -Kimmo > > regards, > ___ maemo-developers mailing list maemo-developers@maemo.org https://lists.maemo.org/mailman/listinfo/maemo-developers