Search code examples
firefox-addonx11jsctypes

Menu enumeration functions in X11?


I'm converting this test for screensaver stuff from linux code to js-ctypes.

It uses X11 heavily but I can't find any menu functions.

This is the code I'm trying convert:

1012     XMenuList::GetInstance()->InsertMenuWindowXIDs(&windows);
1013     // Enumerate the menus first.
1014     for (iter = windows.begin(); iter != windows.end(); iter++) {
1015       if (delegate->ShouldStopIterating(*iter))
1016         return true;
1017     }
1018     windows.clear();

this code is found here: http://mxr.mozilla.org/chromium/source/src/ui/base/x/x11_util.cc#1012

Basically im trying to enumerate through windows but they check for menus too when looking for screensaver.

I came across this note:

X11, by itself, doesn't do menus. That is why toolkits like GTK, Qt, Motif, etc were created.

http://www.linuxquestions.org/questions/programming-9/x11-menus-how-to-839904/

Does this mean I should ctypes.open another library other then X11, does anyone know which one? I can't find.

Thanks

This is my code in progress: https://github.com/Noitidart/_scratchpad/blob/master/ScreensaverWindowExists.js#L365

This is the freedocs page im using for x11 functions: http://www.xfree86.org/4.4.0/manindex3.html


Solution

  • If you look at the source here, you can see that a menu, for Mozilla, is just a window that has _NET_WM_WINDOW_TYPE property set to _NET_WM_WINDOW_TYPE_MENU.

    The desktop standard says such windows are menus that are "torn off" their main application window and pinned to the desktop. You don't need any special library to detect this, just use normal property manipulation functions.

    I don't quite understand why a screensaver would need that though.