Fetching the Window ID


#1

Jules,

In Linux Juce application, trying to get the X Window ID of a Juce component using Component::getWindowHandle, and I have a question.

Peeking into the code for getWindowHandle, it calls getNativeHandle().

void* Component::getWindowHandle() const throw()
{
        const ComponentPeer* const peer = getPeer();

        if (peer != 0)
                return peer->getNativeHandle();
                
        return 0;
}

and getNativeHandle returns a hwnd:

        void* getNativeHandle() const
        {
                return (void*) hwnd;
        }

Isn’t hwnd a handle to a window that is specific to Windows? Will this also work for Linux X Windows?


#2

I’m using a console program called xwininfo to verify the X Window ID. Looking at the code, I don’t understand how Component::getWindowHandle should be returning the correct value.

In the attached screen shot, xwininfo returns the decimal value of 69206029 - which is the correct Window ID.

[attachment=0]ss2.png[/attachment]


#3

Persumably you’ve been looking in juce_win32_Windowing.cpp and not juce_linux_Windowing.cpp?


#4

Jules, my apologies. I was looking in juce_amalgamated.cpp and missed getNativeHandle for the Linux native windowing code. I should be looking at individual files instead of the amalgamated from now on. Thanks.


#5

Jules, I got it working and can now return the windowH as an integer value with Linux call to component::getWindowHandle. I have to do some more modifications to the Video Player but I should be able to post the Media Player sample app to the Sample Apps cookbook by the end of the week. Thanks a million.


#6

Cool, well done.


#7

To anyone else who has to find the X Window ID in Linux, here is the code sample:

// First add the Component to the Desktop
addToDesktop(ComponentPeer::windowIsResizable,0);

int windowID;
windowID = (int) getWindowHandle();