From 97aaa22fb796662afd3ad4052d4f7d1c5945bb70 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 20 Sep 2010 09:22:54 +0000 Subject: opengl window was not always created/moved to the correct place --- xorg-server/hw/xwin/glx/indirect.c | 1 + xorg-server/hw/xwin/glx/winpriv.c | 19 ++++++++++++++++--- xorg-server/hw/xwin/winmultiwindowwindow.c | 28 ++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) (limited to 'xorg-server') diff --git a/xorg-server/hw/xwin/glx/indirect.c b/xorg-server/hw/xwin/glx/indirect.c index 516cb6af0..6dd00c483 100644 --- a/xorg-server/hw/xwin/glx/indirect.c +++ b/xorg-server/hw/xwin/glx/indirect.c @@ -875,6 +875,7 @@ glxWinPositionWindow(WindowPtr pWin, int x, int y) pWin->drawable.width, pWin->drawable.height, FALSE); + winDebug("Move window %x, %x, %d, %d, %d, %d\n",pWinPriv->hWnd,GetParent(pWinPriv->hWnd), pWin->drawable.x, pWin->drawable.y, pWin->drawable.width, pWin->drawable.height); } return result; } diff --git a/xorg-server/hw/xwin/glx/winpriv.c b/xorg-server/hw/xwin/glx/winpriv.c index 6c16c31ae..c689bae08 100644 --- a/xorg-server/hw/xwin/glx/winpriv.c +++ b/xorg-server/hw/xwin/glx/winpriv.c @@ -57,6 +57,8 @@ HWND winGetWindowInfo(WindowPtr pWin) { if (pWin->parent && pWin->parent->parent) { + int offsetx; + int offsety; int ExtraClass=(pWin->realized)?WS_VISIBLE:0; HWND hWndParent; WindowPtr pParent=pWin->parent; @@ -70,24 +72,35 @@ HWND winGetWindowInfo(WindowPtr pWin) } if (!hWndParent) hWndParent=hwnd; + if (pParent) + { + offsetx=pParent->drawable.x; + offsety=pParent->drawable.y; + } + else + { + offsetx=0; + offsety=0; + } pWinPriv->hWnd=CreateWindowExA(WS_EX_TRANSPARENT, WIN_GL_WINDOW_CLASS, "", WS_CHILD |WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ExtraClass, - pWin->drawable.x, - pWin->drawable.y, + pWin->drawable.x-offsetx, + pWin->drawable.y-offsety, pWin->drawable.width, pWin->drawable.height, hWndParent, NULL, GetModuleHandle(NULL), NULL); + winDebug("Window created %x %x %d %d %d %d\n",pWinPriv->hWnd,hWndParent,pWin->drawable.x-offsetx,pWin->drawable.y-offsety,pWin->drawable.width, pWin->drawable.height); pWinPriv->GlCtxWnd=TRUE; } else { winCreateWindowsWindow(pWin); - ErrorF("winGetWindowInfo: forcing window to exist...\n"); + winDebug("winGetWindowInfo: forcing window to exist...\n"); } } if (pWinPriv->hWnd != NULL) diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c index 44fdd8ac3..5e8c51c30 100644 --- a/xorg-server/hw/xwin/winmultiwindowwindow.c +++ b/xorg-server/hw/xwin/winmultiwindowwindow.c @@ -636,17 +636,37 @@ winUpdateWindowsWindow (WindowPtr pWin) } else if (hWnd != NULL) { - if (pWinPriv->OpenGlWindow) + if (pWinPriv->GlCtxWnd) { + /* We do not need to destroy the window but to reparent it and move it to the + correct place when it is an opengl window */ + int offsetx; + int offsety; HWND hParentWnd; + WindowPtr pParent=pWin->parent; + while (pParent) { - winWindowPriv(pWin->parent); - ErrorF("Window handle = %x\n",pWinPriv->hWnd); + winWindowPriv(pParent); hParentWnd=pWinPriv->hWnd; + if (hParentWnd) + break; + pParent=pParent->parent; + } + + if (pParent) + { + offsetx=pParent->drawable.x; + offsety=pParent->drawable.y; + } + else + { + offsetx=0; + offsety=0; } + winDebug ("-winUpdateWindowsWindow: %x changing parent to %x and moving to %d,%d\n",pWinPriv->hWnd,hParentWnd,pWin->drawable.x-offsetx,pWin->drawable.y-offsety); SetParent(pWinPriv->hWnd,hParentWnd); - SetWindowPos(pWinPriv->hWnd,NULL,0,0,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW); + SetWindowPos(pWinPriv->hWnd,NULL,pWin->drawable.x-offsetx,pWin->drawable.y-offsety,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW); } else { -- cgit v1.2.3