System.Windows.Forms.XplatUIX11.DestroyWindow C# (CSharp) Method

DestroyWindow() private method

private DestroyWindow ( IntPtr handle ) : void
handle System.IntPtr
return void
		internal override void DestroyWindow(IntPtr handle) {
			Hwnd	hwnd;
			hwnd = Hwnd.ObjectFromHandle(handle);
			
			// The window should never ever be a zombie here, since we should
			// wait until it's completely dead before returning from 
			// "destroying" calls, but just in case....
			if (hwnd == null || hwnd.zombie) {
				#if DriverDebug || DriverDebugDestroy
					Console.WriteLine("window {0:X} already destroyed", handle.ToInt32());
				#endif
				return;
			}

			#if DriverDebug || DriverDebugDestroy
				Console.WriteLine("Destroying window {0}", XplatUI.Window(hwnd.client_window));
			#endif

			SendParentNotify (hwnd.Handle, Msg.WM_DESTROY, int.MaxValue, int.MaxValue);
				
			CleanupCachedWindows (hwnd);

			ArrayList windows = new ArrayList ();

			AccumulateDestroyedHandles (Control.ControlNativeWindow.ControlFromHandle(hwnd.Handle), windows);


			foreach (Hwnd h in windows) {
				SendMessage (h.Handle, Msg.WM_DESTROY, IntPtr.Zero, IntPtr.Zero);
				h.zombie = true;				
			}

			lock (XlibLock) {
				if (hwnd.whole_window != IntPtr.Zero) {
					#if DriverDebug || DriverDebugDestroy
					Console.WriteLine ("XDestroyWindow (whole_window = {0:X})", hwnd.whole_window.ToInt32());
					#endif
					Keyboard.DestroyICForWindow (hwnd.whole_window);
					XDestroyWindow(DisplayHandle, hwnd.whole_window);
				}
				else if (hwnd.client_window != IntPtr.Zero) {
					#if DriverDebug || DriverDebugDestroy
					Console.WriteLine ("XDestroyWindow (client_window = {0:X})", hwnd.client_window.ToInt32());
					#endif
					Keyboard.DestroyICForWindow (hwnd.client_window);
					XDestroyWindow(DisplayHandle, hwnd.client_window);
				}

			}
		}
XplatUIX11