protected override void OnEnter(EventArgs e) { if (WebBrowserFocus != null) { WebBrowserFocus.Activate(); } #if GTK m_wrapper.SetInputFocus(); #endif base.OnEnter(e); }
protected override void OnLeave(EventArgs e) { if (WebBrowserFocus != null && !IsBusy) { WebBrowserFocus.Deactivate(); } #if GTK m_wrapper.RemoveInputFocus(); #endif base.OnLeave(e); }
protected override void WndProc(ref Message m) { const int WM_GETDLGCODE = 0x87; const int DLGC_WANTALLKEYS = 0x4; const int WM_MOUSEACTIVATE = 0x21; const int MA_ACTIVATE = 0x1; const int WM_IME_SETCONTEXT = 0x0281; if (!DesignMode) { switch (m.Msg) { case WM_GETDLGCODE: m.Result = (IntPtr)DLGC_WANTALLKEYS; return; case WM_MOUSEACTIVATE: // TODO FIXME: port for Linux if (Xpcom.IsWindows) { m.Result = (IntPtr)MA_ACTIVATE; if (!GeckoFX.Microsoft.User32.IsChild(Handle, GeckoFX.Microsoft.User32.GetFocus())) { this.Focus(); } return; } return; case WM_IME_SETCONTEXT: if (!DisableWmImeSetContext) { //Console.WriteLine("WM_IME_SETCONTEXT {0} {1}", m.WParam, m.LParam.ToString("X8")); if (m.WParam == IntPtr.Zero) { // zero WebBrowserFocus.Deactivate(); } else { // non-zero (1) WebBrowserFocus.Activate(); } return; } break; } } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { const int WM_GETDLGCODE = 0x87; const int DLGC_WANTALLKEYS = 0x4; const int WM_MOUSEACTIVATE = 0x21; const int MA_ACTIVATE = 0x1; const int WM_IME_SETCONTEXT = 0x0281; const int WM_PAINT = 0x000F; const int WM_SETFOCUS = 0x0007; const int WM_KILLFOCUS = 0x0008; const int ISC_SHOWUICOMPOSITIONWINDOW = unchecked ((int)0x80000000); if (!DesignMode) { IntPtr focus; switch (m.Msg) { case WM_GETDLGCODE: m.Result = (IntPtr)DLGC_WANTALLKEYS; return; case WM_SETFOCUS: break; case WM_MOUSEACTIVATE: // TODO FIXME: port for Linux if (Xpcom.IsWindows) { m.Result = (IntPtr)MA_ACTIVATE; focus = User32.GetFocus(); // Console.WriteLine( "focus {0:X8}, Handle {1:X8}", focus.ToInt32(), Handle.ToInt32() ); if (!IsSubWindow(Handle, focus)) { // var str = string.Format( "+WM_MOUSEACTIVATE {0:X8} lastfocus", focus.ToInt32() ); // System.Diagnostics.Debug.WriteLine( str ); Console.WriteLine("Activating"); if (WebBrowserFocus != null) { WebBrowserFocus.Activate(); } if (Window != null) { Services.WindowWatcher.ActiveWindow = Window; } } else { // var str = string.Format( "-WM_MOUSEACTIVATE {0:X8} lastfocus", focus.ToInt32() ); // System.Diagnostics.Debug.WriteLine( str ); } if (Window != null && !Window.Equals(Services.WindowWatcher.ActiveWindow)) { if (WebBrowserFocus != null) { WebBrowserFocus.Activate(); } if (Window != null) { Services.WindowWatcher.ActiveWindow = Window; } } return; } return; //http://msdn.microsoft.com/en-US/library/windows/desktop/dd374142%28v=vs.85%29.aspx case WM_IME_SETCONTEXT: focus = User32.GetFocus(); if (User32.IsChild(Handle, focus)) { break; } if (WebBrowserFocus != null) { // var str = string.Format( "WM_IME_SETCONTEXT {0} {1} {2} (focus on {3})", m.HWnd.ToString( "X8" ), m.WParam, m.LParam.ToString( "X8" ), focus.ToString( "X8" ) ); // System.Diagnostics.Debug.WriteLine( str ); var param = m.LParam.ToInt64(); if ((param & ISC_SHOWUICOMPOSITIONWINDOW) != 0) { } if (m.WParam == IntPtr.Zero) { // zero RemoveInputFocus(); WebBrowserFocus.Deactivate(); } else { // non-zero (1) WebBrowserFocus.Activate(); SetInputFocus(); } return; } break; case WM_PAINT: break; } } // Firefox 17+ can crash when handing this windows message so we just ignore it. if (m.Msg == 0x128 /*WM_UPDATEUISTATE*/) { return; } base.WndProc(ref m); }