pacificIT / chromiumembedded

Automatically exported from code.google.com/p/chromiumembedded
0 stars 1 forks source link

Denying input focus by implementing CefFocusHandler::OnSetFocus allows the client application to receive focus #559

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add an implementation of CefFocusHandler::OnSetFocus in CefClient and 
disallow focus to be set. ( simply return true )
2. Run CefClient
3. Load http://www.google.com
4. Click on the search box
5. Type any key

What is the expected output? What do you see instead?
CefClient should not be allowed to receive focus, however it has input focus 
and receives keyboard events.

What version of the product are you using? On what operating system?
Using Cef at revision 551 running under Windows 7.

Please provide any additional information below.
The problems seems to be in WebWidgetHost::MouseEvent, the MouseDown event 
cause a focus message to be sent to the webWidget without being intercepted by 
CefFocusHandler::OnSetFocus, thus incorrectly allowing focus to be set.

Original issue reported on code.google.com by mihai.o....@gmail.com on 29 Mar 2012 at 2:40

GoogleCodeExporter commented 9 years ago
I've added a patch containing a quick fix to this issue.

Original comment by mihai.o....@gmail.com on 29 Mar 2012 at 4:15

Attachments:

GoogleCodeExporter commented 9 years ago
The OnSystemSetFocus() method proposed in issue 563 can be used to solve this 
issue as well.

Original comment by magreenb...@gmail.com on 2 Apr 2012 at 3:15

GoogleCodeExporter commented 9 years ago
OnSystemSetFocus function, which is at a higher level, is not visible for 
webviewhost, where the MouseDown and, consequently, WM_SETFOCUS events occur. 
Solution for this issue was to send focus to the parent window, which will fire 
the event to the application, and after that will set the focus back to the 
webviewhost.

Original comment by iohan...@gmail.com on 2 Apr 2012 at 4:35

GoogleCodeExporter commented 9 years ago
@comment #3: I'd rather avoid bouncing the focus between parent and child 
windows after receiving a mouse click in the child window. It's better to just 
set the focus to the child window directly. See the fix in issue #563 (revision 
568).

Original comment by magreenb...@gmail.com on 2 Apr 2012 at 4:44

GoogleCodeExporter commented 9 years ago
Thank you. It should work now.

Original comment by iohan...@gmail.com on 2 Apr 2012 at 4:51

GoogleCodeExporter commented 9 years ago
@comment #4. I think we should check whether webviewhost already has focus 
before calling SetFocus(true), otherwise OnSetFocus will be called for each 
mouse click.

Original comment by iohan...@gmail.com on 2 Apr 2012 at 5:28

GoogleCodeExporter commented 9 years ago
@comment#6: Agreed, I'll fix it shortly.

Original comment by magreenb...@gmail.com on 2 Apr 2012 at 5:41

GoogleCodeExporter commented 9 years ago
Revision 569 avoids calling OnSetFocus multiple times.

Original comment by magreenb...@gmail.com on 2 Apr 2012 at 7:40