16747b715Smrg/*
26747b715Smrg * Export window information for the Windows-OpenGL GLX implementation.
36747b715Smrg *
46747b715Smrg * Authors: Alexander Gottwald
56747b715Smrg */
66747b715Smrg
76747b715Smrg#ifdef HAVE_XWIN_CONFIG_H
86747b715Smrg#include <xwin-config.h>
96747b715Smrg#endif
106747b715Smrg#include "win.h"
116747b715Smrg#include "winpriv.h"
126747b715Smrg#include "winwindow.h"
136747b715Smrg
146747b715Smrgvoid
1535c4bbdfSmrg winCreateWindowsWindow(WindowPtr pWin);
1635c4bbdfSmrg
176747b715Smrg/**
186747b715Smrg * Return size and handles of a window.
196747b715Smrg * If pWin is NULL, then the information for the root window is requested.
206747b715Smrg */
2135c4bbdfSmrgHWND
2235c4bbdfSmrgwinGetWindowInfo(WindowPtr pWin)
236747b715Smrg{
2435c4bbdfSmrg    winTrace("%s: pWin %p XID 0x%x\n", __FUNCTION__, pWin, (unsigned int)pWin->drawable.id);
256747b715Smrg
266747b715Smrg    /* a real window was requested */
2735c4bbdfSmrg    if (pWin != NULL) {
286747b715Smrg        /* Get the window and screen privates */
296747b715Smrg        ScreenPtr pScreen = pWin->drawable.pScreen;
306747b715Smrg        winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
316747b715Smrg        winScreenInfoPtr pScreenInfo = NULL;
326747b715Smrg        HWND hwnd = NULL;
336747b715Smrg
3435c4bbdfSmrg        if (pWinScreen == NULL) {
356747b715Smrg            ErrorF("winGetWindowInfo: screen has no privates\n");
366747b715Smrg            return NULL;
376747b715Smrg        }
386747b715Smrg
396747b715Smrg        hwnd = pWinScreen->hwndScreen;
406747b715Smrg
416747b715Smrg        pScreenInfo = pWinScreen->pScreenInfo;
426747b715Smrg        /* check for multiwindow mode */
4335c4bbdfSmrg        if (pScreenInfo->fMultiWindow) {
446747b715Smrg            winWindowPriv(pWin);
456747b715Smrg
4635c4bbdfSmrg            if (pWinPriv == NULL) {
476747b715Smrg                ErrorF("winGetWindowInfo: window has no privates\n");
486747b715Smrg                return hwnd;
496747b715Smrg            }
506747b715Smrg
5135c4bbdfSmrg            if (pWinPriv->hWnd == NULL) {
5235c4bbdfSmrg                winCreateWindowsWindow(pWin);
5335c4bbdfSmrg                winDebug("winGetWindowInfo: forcing window to exist\n");
546747b715Smrg            }
556747b715Smrg
5635c4bbdfSmrg            if (pWinPriv->hWnd != NULL) {
576747b715Smrg                /* copy window handle */
586747b715Smrg                hwnd = pWinPriv->hWnd;
5935c4bbdfSmrg
6035c4bbdfSmrg                /* mark GLX active on that hwnd */
6135c4bbdfSmrg                pWinPriv->fWglUsed = TRUE;
6235c4bbdfSmrg            }
636747b715Smrg
646747b715Smrg            return hwnd;
656747b715Smrg        }
666747b715Smrg    }
6735c4bbdfSmrg    else {
686747b715Smrg        ScreenPtr pScreen = g_ScreenInfo[0].pScreen;
696747b715Smrg        winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
706747b715Smrg
7135c4bbdfSmrg        if (pWinScreen == NULL) {
726747b715Smrg            ErrorF("winGetWindowInfo: screen has no privates\n");
736747b715Smrg            return NULL;
746747b715Smrg        }
756747b715Smrg
766747b715Smrg        ErrorF("winGetWindowInfo: returning root window\n");
776747b715Smrg
786747b715Smrg        return pWinScreen->hwndScreen;
796747b715Smrg    }
806747b715Smrg
816747b715Smrg    return NULL;
826747b715Smrg}
836747b715Smrg
846747b715SmrgBool
856747b715SmrgwinCheckScreenAiglxIsSupported(ScreenPtr pScreen)
866747b715Smrg{
8735c4bbdfSmrg    winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
8835c4bbdfSmrg    winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo;
896747b715Smrg
9035c4bbdfSmrg    if (pScreenInfo->fMultiWindow)
9135c4bbdfSmrg        return TRUE;
926747b715Smrg
9335c4bbdfSmrg    return FALSE;
946747b715Smrg}
951b5d61b8Smrg
961b5d61b8Smrgvoid
971b5d61b8SmrgwinSetScreenAiglxIsActive(ScreenPtr pScreen)
981b5d61b8Smrg{
991b5d61b8Smrg    winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
1001b5d61b8Smrg    pWinScreen->fNativeGlActive = TRUE;
1011b5d61b8Smrg}
102