mshtml: Reset focus after loading the page in edit mode.

This commit is contained in:
Jacek Caban 2007-11-12 01:23:47 +01:00 committed by Alexandre Julliard
parent 0e29f314f5
commit c49e894e9f
4 changed files with 28 additions and 8 deletions

View File

@ -524,6 +524,7 @@ void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event)
void handle_edit_load(HTMLDocument *This) void handle_edit_load(HTMLDocument *This)
{ {
This->nscontainer->reset_focus = GetFocus();
get_editor_controller(This->nscontainer); get_editor_controller(This->nscontainer);
} }

View File

@ -209,6 +209,7 @@ struct NSContainer {
HWND hwnd; HWND hwnd;
BSCallback *bscallback; /* hack */ BSCallback *bscallback; /* hack */
HWND reset_focus; /* hack */
}; };
typedef struct { typedef struct {

View File

@ -81,6 +81,8 @@ static const WCHAR wszNsContainer[] = {'N','s','C','o','n','t','a','i','n','e','
static ATOM nscontainer_class; static ATOM nscontainer_class;
#define WM_RESETFOCUS_HACK WM_USER+600
static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
NSContainer *This; NSContainer *This;
@ -103,6 +105,18 @@ static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
LOWORD(lParam), HIWORD(lParam), TRUE); LOWORD(lParam), HIWORD(lParam), TRUE);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
WARN("SetSize failed: %08x\n", nsres); WARN("SetSize failed: %08x\n", nsres);
break;
case WM_RESETFOCUS_HACK:
/*
* FIXME
* Gecko grabs focus in edit mode and some apps don't like it.
* We should somehow prevent grabbing focus.
*/
if(This->reset_focus) {
SetFocus(This->reset_focus);
This->reset_focus = NULL;
}
} }
return DefWindowProcW(hwnd, msg, wParam, lParam); return DefWindowProcW(hwnd, msg, wParam, lParam);
@ -1293,6 +1307,9 @@ static nsresult NSAPI nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow *ifa
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
if(This->reset_focus)
PostMessageW(This->hwnd, WM_RESETFOCUS_HACK, 0, 0);
return nsIBaseWindow_SetFocus(This->window); return nsIBaseWindow_SetFocus(This->window);
} }
@ -1558,6 +1575,7 @@ NSContainer *NSContainer_Create(HTMLDocument *doc, NSContainer *parent)
ret->content_listener = NULL; ret->content_listener = NULL;
ret->editor_controller = NULL; ret->editor_controller = NULL;
ret->editor = NULL; ret->editor = NULL;
ret->reset_focus = NULL;
if(parent) if(parent)
nsIWebBrowserChrome_AddRef(NSWBCHROME(parent)); nsIWebBrowserChrome_AddRef(NSWBCHROME(parent));

View File

@ -90,7 +90,7 @@ static nsresult NSAPI handle_blur(nsIDOMEventListener *iface, nsIDOMEvent *event
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
if(This->doc && This->doc->focus && !is_doc_child_focus(This)) { if(!This->reset_focus && This->doc && This->doc->focus && !is_doc_child_focus(This)) {
This->doc->focus = FALSE; This->doc->focus = FALSE;
notif_focus(This->doc); notif_focus(This->doc);
} }
@ -104,7 +104,7 @@ static nsresult NSAPI handle_focus(nsIDOMEventListener *iface, nsIDOMEvent *even
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
if(This->doc && !This->doc->focus) { if(!This->reset_focus && This->doc && !This->doc->focus) {
This->doc->focus = TRUE; This->doc->focus = TRUE;
notif_focus(This->doc); notif_focus(This->doc);
} }