From 36df22a9b06d00d8e2ca97c274317d61e117c5fc Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 23 Jul 2010 12:54:07 +0000 Subject: Fix a GDI bitmap resource leak of window icons Internal WM workaround for Java AWT bug --- xorg-server/hw/xwin/winmultiwindowwindow.c | 10 ++++++++++ xorg-server/hw/xwin/winmultiwindowwm.c | 24 ++++++++++++++++++++++++ xorg-server/hw/xwin/winwin32rootless.c | 14 +++++++------- 3 files changed, 41 insertions(+), 7 deletions(-) (limited to 'xorg-server/hw/xwin') diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c index 99f812e49..80cae7636 100644 --- a/xorg-server/hw/xwin/winmultiwindowwindow.c +++ b/xorg-server/hw/xwin/winmultiwindowwindow.c @@ -543,6 +543,8 @@ winDestroyWindowsWindow (WindowPtr pWin) MSG msg; winWindowPriv(pWin); BOOL oldstate = winInDestroyWindowsWindow; + HICON hIcon; + HICON hIconSm; #if CYGMULTIWINDOW_DEBUG winDebug ("winDestroyWindowsWindow\n"); @@ -554,6 +556,10 @@ winDestroyWindowsWindow (WindowPtr pWin) winInDestroyWindowsWindow = TRUE; + /* Store the info we need to destroy after this window is gone */ + hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0); + hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0); + SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL); /* Destroy the Windows window */ DestroyWindow (pWinPriv->hWnd); @@ -561,6 +567,10 @@ winDestroyWindowsWindow (WindowPtr pWin) /* Null our handle to the Window so referencing it will cause an error */ pWinPriv->hWnd = NULL; + /* Destroy any icons we created for this window */ + winDestroyIcon(hIcon); + winDestroyIcon(hIconSm); + /* Process all messages on our queue */ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c index ea1ff517d..913f01bac 100644 --- a/xorg-server/hw/xwin/winmultiwindowwm.c +++ b/xorg-server/hw/xwin/winmultiwindowwm.c @@ -1023,6 +1023,30 @@ winMultiWindowXMsgProc (void *pArg) } } } + else if (event.type == ConfigureNotify) + { + if (!event.xconfigure.send_event) + { + /* + Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT + doesn't explicitly know about (See sun bug #6434227) + + XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic + ConfigureNotify events to update window location if it's identified the + WM as a non-reparenting WM it knows about (compiz or lookingglass) + + Rather than tell all sorts of lies to get XWM to recognize us as one of + those, simply send a synthetic ConfigureNotify for every non-synthetic one + */ + XEvent event_send = event; + event_send.xconfigure.send_event = TRUE; + event_send.xconfigure.event = event.xconfigure.window; + XSendEvent(event.xconfigure.display, + event.xconfigure.window, + True, StructureNotifyMask, + &event_send); + } + } else if (event.type == PropertyNotify && event.xproperty.atom == atmWmName) { diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c index 85a932f75..862d5ba98 100644 --- a/xorg-server/hw/xwin/winwin32rootless.c +++ b/xorg-server/hw/xwin/winwin32rootless.c @@ -365,8 +365,8 @@ void winMWExtWMDestroyFrame (RootlessFrameID wid) { win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid; - HICON hiconClass; - HICON hiconSmClass; + HICON hicon; + HICON hiconSm; HMODULE hInstance; int iReturn; char pszClass[CLASS_NAME_LENGTH]; @@ -397,8 +397,8 @@ winMWExtWMDestroyFrame (RootlessFrameID wid) /* Store the info we need to destroy after this window is gone */ hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE); - hiconClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON); - hiconSmClass = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM); + hicon = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICON); + hiconSm = (HICON) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HICONSM); iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH); pRLWinPriv->fClose = TRUE; @@ -418,11 +418,11 @@ winMWExtWMDestroyFrame (RootlessFrameID wid) #if CYGMULTIWINDOW_DEBUG winDebug ("winMWExtWMDestroyFramew - %d Deleting Icon: ", iReturn); #endif - - winDestroyIcon(hiconClass); - winDestroyIcon(hiconSmClass); } + winDestroyIcon(hiconClass); + winDestroyIcon(hiconSmClass); + #if CYGMULTIWINDOW_DEBUG winDebug ("winMWExtWMDestroyFrame - done\n"); #endif -- cgit v1.2.3