diff options
Diffstat (limited to 'xorg-server/hw/xwin/winmultiwindowwndproc.c')
-rw-r--r-- | xorg-server/hw/xwin/winmultiwindowwndproc.c | 219 |
1 files changed, 91 insertions, 128 deletions
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c index 381818789..af6bb528e 100644 --- a/xorg-server/hw/xwin/winmultiwindowwndproc.c +++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c @@ -35,6 +35,10 @@ #ifdef HAVE_XWIN_CONFIG_H #include <xwin-config.h> #endif +#define GC tempGC // This is to avoid name conflicts when including the next headers which also define GC +#include <X11/Xutil.h> +#undef GC + #include "win.h" #include "dixevents.h" #include "winmultiwindowclass.h" @@ -44,6 +48,14 @@ extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle); +#ifdef XKB +#ifndef XKB_IN_SERVER +#define XKB_IN_SERVER +#endif +#include <xkbsrv.h> +#endif + + /* * Local globals */ @@ -316,11 +328,10 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static Bool s_fTracking = FALSE; Bool needRestack = FALSE; LRESULT ret; + static Bool hasEnteredSizeMove = FALSE; -#if CYGDEBUG winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam); -#endif /* Check if the Windows window property for our X window pointer is valid */ if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) { @@ -352,32 +363,13 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) fWMMsgInitialized = TRUE; -#if 0 - /* - * Print some debugging information - */ - - ErrorF("hWnd %08X\n", hwnd); - ErrorF("pWin %08X\n", pWin); - ErrorF("pDraw %08X\n", pDraw); - ErrorF("\ttype %08X\n", pWin->drawable.type); - ErrorF("\tclass %08X\n", pWin->drawable.class); - ErrorF("\tdepth %08X\n", pWin->drawable.depth); - ErrorF("\tbitsPerPixel %08X\n", pWin->drawable.bitsPerPixel); - ErrorF("\tid %08X\n", pWin->drawable.id); - ErrorF("\tx %08X\n", pWin->drawable.x); - ErrorF("\ty %08X\n", pWin->drawable.y); - ErrorF("\twidth %08X\n", pWin->drawable.width); - ErrorF("\thenght %08X\n", pWin->drawable.height); - ErrorF("\tpScreen %08X\n", pWin->drawable.pScreen); - ErrorF("\tserialNumber %08X\n", pWin->drawable.serialNumber); - ErrorF("g_iWindowPrivateKey %p\n", g_iWindowPrivateKey); - ErrorF("pWinPriv %08X\n", pWinPriv); - ErrorF("s_pScreenPriv %08X\n", s_pScreenPriv); - ErrorF("s_pScreenInfo %08X\n", s_pScreenInfo); - ErrorF("hwndScreen %08X\n", hwndScreen); -#endif } + #ifdef _DEBUG + else if (message!=WM_CREATE) + { + winDebug("Warning: message 0x%x received when WIN_WINDOW_PROP NULL\n",message); + } + #endif /* Branch on message type */ switch (message) { @@ -409,10 +401,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) GetWindowRect(hwnd, &rWindow); hRgnWindow = CreateRectRgnIndirect(&rWindow); SetWindowRgn(hwnd, hRgnWindow, TRUE); - DeleteObject(hRgnWindow); } - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) XMING_SIGNATURE); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE); return 0; @@ -593,6 +584,9 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_MOUSELEAVE: + /* We can't do anything without privates */ + if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) + break; /* Mouse has left our client area */ /* Flag that we are no longer tracking */ @@ -744,7 +738,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000)) break; -#if CYGWINDOWING_DEBUG +#ifdef WINDBG if (wParam == VK_ESCAPE) { /* Place for debug: put any tests and dumps here */ WINDOWPLACEMENT windPlace; @@ -754,25 +748,25 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) windPlace.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hwnd, &windPlace); pRect = &windPlace.rcNormalPosition; - ErrorF("\nCYGWINDOWING Dump:\n" + winDebug ("\nCYGWINDOWING Dump:\n" "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x, pDraw->y, pDraw->width, pDraw->height); - ErrorF("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left, + pRect->top, pRect->right - pRect->left, + pRect->bottom - pRect->top); if (GetClientRect(hwnd, &rc)) { pRect = &rc; - ErrorF("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left, + pRect->top, pRect->right - pRect->left, + pRect->bottom - pRect->top); } if (GetWindowRect(hwnd, &rc)) { pRect = &rc; - ErrorF("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left, - pRect->top, pRect->right - pRect->left, - pRect->bottom - pRect->top); + winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left, + pRect->top, pRect->right - pRect->left, + pRect->bottom - pRect->top); } - ErrorF("\n"); + winDebug ("\n"); } #endif @@ -807,9 +801,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Tell our Window Manager thread to activate the window */ wmMsg.msg = WM_WM_ACTIVATE; - if (fWMMsgInitialized) - if (!pWin || !pWin->overrideRedirect) /* for OOo menus */ - winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); + if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */) + winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg); } /* Prevent the mouse wheel from stalling when another window is minimized */ if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE && @@ -844,7 +837,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Branch on if the window was killed in X already */ if (pWinPriv && !pWinPriv->fXKilled) { - ErrorF("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n"); + winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n"); /* Tell our Window Manager thread to kill the window */ wmMsg.msg = WM_WM_KILL; @@ -860,7 +853,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_MOVE: /* Adjust the X Window to the moved Windows window */ - winAdjustXWindow(pWin, hwnd); + if (!hasEnteredSizeMove) winAdjustXWindow (pWin, hwnd); + /* else: Wait for WM_EXITSIZEMOVE */ return 0; case WM_SHOWWINDOW: @@ -908,13 +902,10 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) else { /* It is an overridden window so make it top of Z stack */ HWND forHwnd = GetForegroundWindow(); - -#if CYGWINDOWING_DEBUG - ErrorF("overridden window is shown\n"); -#endif + winDebug ("overridden window is shown\n"); if (forHwnd != NULL) { if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR) - XMING_SIGNATURE) { + VCXSRV_SIGNATURE) { if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); @@ -939,6 +930,26 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* for applications like xterm */ return ValidateSizing(hwnd, pWin, wParam, lParam); + case WM_WINDOWPOSCHANGING: + { + /* + When window is moved or resized, force it to be redrawn, so that + any OpenGL content is re-drawn correctly, rather than copying bits + (which seem to be wrong, either because we are copying the wrong + window in the window heirarchy, or because we don't have the bits + drawn by OpenGL at all) + + XXX: really this should check if any child has fWglUsed set, but + that might be expensive to check.... + */ + if (g_fNativeGl) + { + LPWINDOWPOS pWinPos = (LPWINDOWPOS)lParam; + pWinPos->flags |= SWP_NOCOPYBITS; + } + } + break; + case WM_WINDOWPOSCHANGED: { LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam; @@ -993,9 +1004,19 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) */ break; + case WM_ENTERSIZEMOVE: + hasEnteredSizeMove = TRUE; + return 0; + + case WM_EXITSIZEMOVE: + /* Adjust the X Window to the moved Windows window */ + hasEnteredSizeMove = FALSE; + winAdjustXWindow (pWin, hwnd); + return 0; + case WM_SIZE: /* see dix/window.c */ -#if CYGWINDOWING_DEBUG +#ifdef WINDBG { char buf[64]; @@ -1012,84 +1033,28 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) default: strcpy(buf, "UNKNOWN_FLAG"); } - ErrorF("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n", - (int) LOWORD(lParam), (int) HIWORD(lParam), buf, - (int) (GetTickCount())); + winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n", + (int) LOWORD(lParam), (int) HIWORD(lParam), buf, + (int) (GetTickCount())); } #endif - /* Adjust the X Window to the moved Windows window */ - winAdjustXWindow(pWin, hwnd); - return 0; /* end of WM_SIZE handler */ - - case WM_STYLECHANGING: - /* - When the style changes, adjust the Windows window size so the client area remains the same size, - and adjust the Windows window position so that the client area remains in the same place. - */ - { - RECT newWinRect; - DWORD dwExStyle; - DWORD dwStyle; - DWORD newStyle = ((STYLESTRUCT *) lParam)->styleNew; - WINDOWINFO wi; - - dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - winDebug("winTopLevelWindowProc - WM_STYLECHANGING from %08x %08x\n", - dwStyle, dwExStyle); - - if (wParam == GWL_EXSTYLE) - dwExStyle = newStyle; - - if (wParam == GWL_STYLE) - dwStyle = newStyle; - - winDebug("winTopLevelWindowProc - WM_STYLECHANGING to %08x %08x\n", - dwStyle, dwExStyle); - - /* Get client rect in screen coordinates */ - wi.cbSize = sizeof(WINDOWINFO); - GetWindowInfo(hwnd, &wi); - - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING client area {%d, %d, %d, %d}, {%d x %d}\n", - wi.rcClient.left, wi.rcClient.top, wi.rcClient.right, - wi.rcClient.bottom, wi.rcClient.right - wi.rcClient.left, - wi.rcClient.bottom - wi.rcClient.top); - - newWinRect = wi.rcClient; - if (!AdjustWindowRectEx(&newWinRect, dwStyle, FALSE, dwExStyle)) - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING AdjustWindowRectEx failed\n"); - - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING window area should be {%d, %d, %d, %d}, {%d x %d}\n", - newWinRect.left, newWinRect.top, newWinRect.right, - newWinRect.bottom, newWinRect.right - newWinRect.left, - newWinRect.bottom - newWinRect.top); - - /* - Style change hasn't happened yet, so we can't adjust the window size yet, as the winAdjustXWindow() - which WM_SIZE does will use the current (unchanged) style. Instead make a note to change it when - WM_STYLECHANGED is received... - */ - pWinPriv->hDwp = BeginDeferWindowPos(1); - pWinPriv->hDwp = - DeferWindowPos(pWinPriv->hDwp, hwnd, NULL, newWinRect.left, - newWinRect.top, newWinRect.right - newWinRect.left, - newWinRect.bottom - newWinRect.top, - SWP_NOACTIVATE | SWP_NOZORDER); + if (!hasEnteredSizeMove) + { + /* Adjust the X Window to the moved Windows window */ + winAdjustXWindow (pWin, hwnd); + if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow(); } - return 0; + /* else: wait for WM_EXITSIZEMOVE */ + return 0; /* end of WM_SIZE handler */ case WM_STYLECHANGED: + /* when the style changes, adjust the window size so the client area remains the same */ { - if (pWinPriv->hDwp) { - EndDeferWindowPos(pWinPriv->hDwp); - pWinPriv->hDwp = NULL; - } - winDebug("winTopLevelWindowProc - WM_STYLECHANGED done\n"); + LONG x,y; + DrawablePtr pDraw = &pWin->drawable; + x = pDraw->x - wBorderWidth(pWin); + y = pDraw->y - wBorderWidth(pWin); + winPositionWindowMultiWindow(pWin, x, y); } return 0; @@ -1097,10 +1062,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Check if this window needs to be made active when clicked */ if (!GetProp(pWinPriv->hWnd, WIN_NEEDMANAGE_PROP)) { -#if CYGMULTIWINDOW_DEBUG - ErrorF("winTopLevelWindowProc - WM_MOUSEACTIVATE - " - "MA_NOACTIVATE\n"); -#endif + winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - " + "MA_NOACTIVATE\n"); /* */ return MA_NOACTIVATE; |