Commit c49e894e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent 0e29f314
...@@ -524,6 +524,7 @@ void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event) ...@@ -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);
} }
......
...@@ -209,6 +209,7 @@ struct NSContainer { ...@@ -209,6 +209,7 @@ struct NSContainer {
HWND hwnd; HWND hwnd;
BSCallback *bscallback; /* hack */ BSCallback *bscallback; /* hack */
HWND reset_focus; /* hack */
}; };
typedef struct { typedef struct {
......
...@@ -81,6 +81,8 @@ static const WCHAR wszNsContainer[] = {'N','s','C','o','n','t','a','i','n','e',' ...@@ -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;
...@@ -96,13 +98,25 @@ static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP ...@@ -96,13 +98,25 @@ static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
} }
switch(msg) { switch(msg) {
case WM_SIZE: case WM_SIZE:
TRACE("(%p)->(WM_SIZE)\n", This); TRACE("(%p)->(WM_SIZE)\n", This);
nsres = nsIBaseWindow_SetSize(This->window,
LOWORD(lParam), HIWORD(lParam), TRUE);
if(NS_FAILED(nsres))
WARN("SetSize failed: %08x\n", nsres);
break;
nsres = nsIBaseWindow_SetSize(This->window, case WM_RESETFOCUS_HACK:
LOWORD(lParam), HIWORD(lParam), TRUE); /*
if(NS_FAILED(nsres)) * FIXME
WARN("SetSize failed: %08x\n", nsres); * 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 ...@@ -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) ...@@ -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));
......
...@@ -90,7 +90,7 @@ static nsresult NSAPI handle_blur(nsIDOMEventListener *iface, nsIDOMEvent *event ...@@ -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 ...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment