Howto grab all Maemo5 zoom key events in SDL/SDL_gles app?

Howto grab all Maemo5 zoom key events in SDL/SDL_gles app?

Till Harbaum
Karma: 664
2010-05-02 11:26 UTC
Hi,

i'd like to access the zoom keys in a SDL/SDL_gles app (the 3d globe
i uploaded to extras-devel).

The odd thing is that my solution only partly works. Some key presses actually
reach my app as function key presses, but still most of them reach the volume
control. So when repeatedly pressing the zoom buttons my app zooms but also
the volume is changed.

I am using the following code which is inspired by code from scummvm. I am
calling this code once immediately after the SDL setup is done.

Any idea why this still delivers some key events to the volume control?

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) ) {

/* We use the SDL GFX display (we're using the GFX window too after all) */
Display *dpy = info.info.x11.display;
unsigned long val = 1;
Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0);
info.info.x11.lock_func();
Window win = info.info.x11.window;
XUnmapWindow(dpy,win);
XChangeProperty (dpy,win,atom_zoom,XA_INTEGER,32,PropModeReplace,(unsigned char *) &val,1);
XMapWindow(dpy,win);
info.info.x11.unlock_func();
}

Till
  •  Reply

Re: Howto grab all Maemo5 zoom key events in SDL/SDL_gles app?

Frantisek Dufka
Karma: 642
2010-05-03 09:00 UTC
Till Harbaum / Lists wrote:
> Any idea why this still delivers some key events to the volume control?

Maybe sometimes there is another window active which doesn't have the
_HILDON_ZOOM_KEY_ATOM set? Something specific to GLES and/or double
buffering? Does it work with simple SDL app without GLES?


>
> SDL_SysWMinfo info;
> SDL_VERSION(&info.version);
> if ( SDL_GetWMInfo(&info) ) {
>
> /* We use the SDL GFX display (we're using the GFX window too after all) */
> Display *dpy = info.info.x11.display;
> unsigned long val = 1;
> Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0);
> info.info.x11.lock_func();
> Window win = info.info.x11.window;
> XUnmapWindow(dpy,win);
> XChangeProperty (dpy,win,atom_zoom,XA_INTEGER,32,PropModeReplace,(unsigned char *) &val,1);
> XMapWindow(dpy,win);
> info.info.x11.unlock_func();
> }

Does it work for you otherwise? Works better for me without
XUnmapWindow(dpy,win)/XMapWindow(dpy,win) pair, just XChangeProperty.
But maybe that's because I am messing with info.info.x11.fswindow and
info.info.x11.wmwindow and SDL doesn't like (un)mapping those directly.

I am not sure why there are three X windows in info.info.x11 structure
(fswindow, wmwindow and window). From brief look into SDL sources it
seems to me like the 'window' is used when SDL is initialized with not
owned pre-created window passed to SDL via SDL_WINDOWID variable,
otherwise wmwindow and fswindow are used depending of full screen state.
In case you are not using SDL_WINDOWID maybe setting wmwindow and
fswindow would help you with volume keys?

Frantisek

  •  Reply

Re: Howto grab all Maemo5 zoom key events in SDL/SDL_gles app?

2010-05-03 10:43 UTC
On Sun, 2010-05-02 at 13:26 +0200, ext Till Harbaum / Lists wrote:
> Hi,
>
> i'd like to access the zoom keys in a SDL/SDL_gles app (the 3d globe
> i uploaded to extras-devel).
>
> The odd thing is that my solution only partly works. Some key presses actually
> reach my app as function key presses, but still most of them reach the volume
> control. So when repeatedly pressing the zoom buttons my app zooms but also
> the volume is changed.
>
> I am using the following code which is inspired by code from scummvm. I am
> calling this code once immediately after the SDL setup is done.
>
> Any idea why this still delivers some key events to the volume control?

It could be that _NET_ACTIVE_WINDOW or MB_CURRENT_APP_WINDOW on the root
window does not correspond to your window. The volume app is tracking
one of these (I think _NET_ACTIVE_WINDOW) to determine the window whose
ZOOM_KEY window property matters.

-Kimmo

>
> SDL_SysWMinfo info;
> SDL_VERSION(&info.version);
> if ( SDL_GetWMInfo(&info) ) {
>
> /* We use the SDL GFX display (we're using the GFX window too after all) */
> Display *dpy = info.info.x11.display;
> unsigned long val = 1;
> Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0);
> info.info.x11.lock_func();
> Window win = info.info.x11.window;
> XUnmapWindow(dpy,win);
> XChangeProperty (dpy,win,atom_zoom,XA_INTEGER,32,PropModeReplace,(unsigned char *) &val,1);
> XMapWindow(dpy,win);
> info.info.x11.unlock_func();
> }
>
> Till

  •  Reply

Re: Howto grab all Maemo5 zoom key events in SDL/SDL_gles app?

Eero Tamminen
Karma: 161
2010-05-12 14:28 UTC
Hi,

Hamalainen Kimmo (Nokia-D/Helsinki) wrote:
> On Sun, 2010-05-02 at 13:26 +0200, ext Till Harbaum / Lists wrote:
>> i'd like to access the zoom keys in a SDL/SDL_gles app (the 3d globe
>> i uploaded to extras-devel).
>>
>> The odd thing is that my solution only partly works. Some key presses actually
>> reach my app as function key presses, but still most of them reach the volume
>> control. So when repeatedly pressing the zoom buttons my app zooms but also
>> the volume is changed.
>>
>> I am using the following code which is inspired by code from scummvm. I am
>> calling this code once immediately after the SDL setup is done.
>>
>> Any idea why this still delivers some key events to the volume control?
>
> It could be that _NET_ACTIVE_WINDOW or MB_CURRENT_APP_WINDOW on the root
> window does not correspond to your window. The volume app is tracking
> one of these (I think _NET_ACTIVE_WINDOW) to determine the window whose
> ZOOM_KEY window property matters.

Maemo SDL doesn't seem to set all required window properties for
fullscreen windows for tracking of the topmost application to work
properly. See this bug:
https://bugs.maemo.org/show_bug.cgi?id=6175#c3

"xprop -root" produces this when there's a fullscreen SDL window:
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x3e00002

_MB_CURRENT_APP_WINDOW(WINDOW): window id # 0x3e00001

I.e. for SDL applications the value in these properties differ,
unlike for normal applications.

_MB_CURRENT_APP_WINDOW is the fullscreen SDL window and
_NET_ACTIVE_WINDOW is the non-fullscreen SDL window.

(I think SDL uses fullscreen window for output and non-fullscreen
one for input.)


- Eero
  •  Reply