zhangqd / chromiumembedded

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

Linux: Use Aura instead of GTK+ #1258

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Chromium is removing support for the GTK+ Linux port (http://crbug.com/297026). 
It will be necessary to re-implement Linux support using Aura instead of GTK+.

Original issue reported on code.google.com by magreenb...@gmail.com on 23 Apr 2014 at 9:10

GoogleCodeExporter commented 9 years ago
The GTK+ dependency has been removed from libcef and the initial Aura/X11 
implementation has been added in trunk revision 1708. The cefsimple sample app 
now uses X11 only. The cefclient sample app uses a combination of GTK+ and X11.

The following pieces remain to be implemented:
- Print dialog.
- JavaScript dialogs (alert, confirm, prompt).
- input type="file" dialog.
- Context menus.
- Drag&drop.
- CefBrowserHost::RunFileDialog
- CefBrowserHost::SendKeyEvent
- CefBrowserHost::SendMouse*Event.

Default dialog and context menu implementations may no longer be provided by 
CEF on Linux since they depend on a UI toolkit. Appropriate callback APIs will 
be added if they don't already exist.

Original comment by magreenb...@gmail.com on 22 May 2014 at 9:02

GoogleCodeExporter commented 9 years ago
Context menus added in revision 1710.

Original comment by magreenb...@gmail.com on 23 May 2014 at 5:47

GoogleCodeExporter commented 9 years ago
Drag&drop support is added in revision 1759 and requires proper handling of the 
"XdndProxy" property on the top-level window. This currently works in cefsimple 
but not cefclient (perhaps due to 
https://bugzilla.gnome.org/show_bug.cgi?id=653264).

Original comment by magreenb...@gmail.com on 8 Jul 2014 at 10:38

GoogleCodeExporter commented 9 years ago
SendKeyEvent and SendMouse*Event support was added as part of issue #1257.

Original comment by magreenb...@gmail.com on 8 Jul 2014 at 10:40

GoogleCodeExporter commented 9 years ago
@#3: Also includes a patch for https://crbug.com/392262 (drag&drop not working 
with http://html5demos.com/drag).

Original comment by magreenb...@gmail.com on 8 Jul 2014 at 10:45

GoogleCodeExporter commented 9 years ago
Revision 1760 adds a GTK implementation of CefJSDialogHandler to cefclient.

Original comment by magreenb...@gmail.com on 9 Jul 2014 at 5:13

GoogleCodeExporter commented 9 years ago
Revision 1761 adds a GTK implementation of CefDialogHandler to cefclient.

Original comment by magreenb...@gmail.com on 9 Jul 2014 at 6:04

GoogleCodeExporter commented 9 years ago
Revision 1762 adds new CefPrintHandler and CefPrintSettings classes to support 
printing, and adds a GTK implementation of CefPrintHandler in cefclient.

All missing functionality has now been implemented.

Some work remains to clean up the integration between GTK and X11 in cefclient:
- Fix drag&drop in cefclient.
- Find a cleaner way to embed the CEF X11 window (gdk_window_foreign_new 
perhaps?).

Original comment by magreenb...@gmail.com on 10 Jul 2014 at 3:46

GoogleCodeExporter commented 9 years ago
The lack of drag/drop is a blocker for us on using 2062 for linux. Is there any 
workaround that you are aware of?

Original comment by jmay...@google.com on 25 Sep 2014 at 4:14

GoogleCodeExporter commented 9 years ago
@#9: Drag&drop works if CEF creates the X11 top-level window versus parenting 
the CEF-created window to a GTK window. The problem is likely some interaction 
between GTK and X11.

Original comment by magreenb...@gmail.com on 25 Sep 2014 at 4:18

GoogleCodeExporter commented 9 years ago
That is good to know. Is that a change we can make to our existing client app? 
Is there any documentation on how to do that?

Original comment by jmay...@google.com on 25 Sep 2014 at 4:22

GoogleCodeExporter commented 9 years ago
@#11: That depends on the requirements of your existing client app. See for 
example the cefsimple application which creates a single top-level CEF window.

Original comment by magreenb...@gmail.com on 25 Sep 2014 at 4:25

GoogleCodeExporter commented 9 years ago
Perfect. Thanks.

Original comment by jmay...@google.com on 25 Sep 2014 at 4:25

GoogleCodeExporter commented 9 years ago
No luck on a fix for this yet, I tried a few things including forwarding 
drag/drop events from the GTK window to the X11 window. I'm still trying a few 
other things.

In light of this and other issues like the text caret not showing up in the 
CefClient URL bar and focus not staying unless the mouse is over the url bar, 
I'm wondering what the future holds for linux apps similar to CefClient that 
need their own UI. It seems that GTK is not a good option with the conflicts 
that are happening with X11. If you were to write a new client, what UI 
framework would it use?

Original comment by jcmay...@gmail.com on 9 Oct 2014 at 7:03

GoogleCodeExporter commented 9 years ago
@#14: I think whatever UI framework the client application uses there will 
still be some problematic edge cases when interacting with xlib. Those can 
likely be resolved on a case-by-case basis, but that won't address the greater 
problem of supporting multiple different window managers on Linux (x11, 
wayland, etc).

The best generic solution is likely an Ozone-level[1] embedding API. That 
basically means the client handles all UI interaction and provides a surface 
(GL texture) that the browser is rendered into. This is similar in concept to 
the current off-screen rendering implementation (where CEF exposes methods for 
input events, etc.) but without any specific window manager (xlib) or UI 
framework (gtk) dependencies.

[1] http://www.chromium.org/developers/design-documents/ozone

Original comment by magreenb...@gmail.com on 9 Oct 2014 at 7:21

GoogleCodeExporter commented 9 years ago
Thanks. Any chance updating to GTK3 could resolve this?

Original comment by jcmay...@gmail.com on 9 Oct 2014 at 7:30

GoogleCodeExporter commented 9 years ago
@#16: I don't know, sorry. Someone will likely need to debug GTK and/or xlib to 
figure out why they aren't playing nice together.

Original comment by magreenb...@gmail.com on 9 Oct 2014 at 7:49

GoogleCodeExporter commented 9 years ago
Most of the CEF apps on Linux that I know use GTK UI. I mostly use wxWidgets 
toolkit that also uses GTK under the hood. Is CEF planning to abandon GTK 
completely, will there be no example that uses GTK? Will we be on our own with 
all the xlib/gtk integration issues coming?

Original comment by czarek.t...@gmail.com on 10 Oct 2014 at 6:13

GoogleCodeExporter commented 9 years ago
Just FYI, I am working on this and have a discussion on it going in the forums 
until I zero in on a patch. You can see the thread here.

http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=12203&p=23049#p23049

Original comment by jmay...@google.com on 17 Oct 2014 at 12:15

GoogleCodeExporter commented 9 years ago
I think https://code.google.com/p/chromiumembedded/issues/detail?id=1208 may be 
related to the changes required for this bug. 

I have a patch to get the basic HTML 5 drag/drop test working but a remaining 
problem is that simply moving the window doesn't trigger a ConfigureNotify in 
CefWindowX211::DispatchEvent(). So 
window_tree_host->set_screen_bounds(current_bounds); is never called and the 
hosts bounds in screen coordinates are never updated. 

I think this is a problem with how CefWindowXX11 is updating the host. If we 
can find a way for a move (of either the X11 window or its parent in the 
CefClient case) to properly trigger code to call set_screen_bounds(), then with 
my patch, I think issue 1208 will be fixed as well.

Original comment by jmay...@google.com on 20 Oct 2014 at 8:55

GoogleCodeExporter commented 9 years ago
Okay, I solved the window moving not updating the screen bounds issue by 
setting the screen bounds in the CefWindowX11's FocusIn event handler. This 
fixes the basic html5 drag/drop issue but DOES NOT address issue 1208 so they 
aren't directly related. The combo issue much be much lower level.

Patch for this issue coming.

Original comment by jmay...@google.com on 20 Oct 2014 at 9:16

GoogleCodeExporter commented 9 years ago
Attached is a patch to address the broken HTML5 Drag/Drop test for the 
CefClient. This is a change against the version of window_x11.cc in the 2062 
release branch.

This patch has the following changes
1) Fix memory leak in FindChild helper. The returned array should be freed with 
XFree.
2) Add FindTopLevelParent() helper to find the proper top level parent window 
for the app hosting a Cef window. This topmost window will have its XDndProxy 
set to be the child of the CefWindowX11 window.
3) Move drag and drop proxy setting code out of the ConfigureNotify event and 
into Show where it is called when the window is first shown. If the window is 
hidden and shown again, the proxy is only set again if the windows topmost 
parent has changed or if its child window has changed.
4) Changed the ConfigureNotify event to call 
window_tree_host->set_screen_bounds() with the screen bounds and not the 
relative bounds.
5) Finally as a workaround for moving the main app window not updating the 
screen bounds, this is also updated in the FocusIn handler.

If there are better fixes here I'm open to trying them.

Original comment by jmay...@google.com on 20 Oct 2014 at 9:59

Attachments:

GoogleCodeExporter commented 9 years ago
Even with my last patch, drag/drop of files is still not working in cefsimple 
or cefclient.

Example link http://html5demos.com/drag-anything  using the 
"getData(e.dataTransfer.types[0]) based on detected content type" option.

Original comment by jmay...@google.com on 20 Oct 2014 at 10:41

GoogleCodeExporter commented 9 years ago
It seems that supporting drag/drop of files will require other changes. 
Non-file drag/drop operations (i.e. from another browser window like Chrome) 
seem to go directly to the DesktopWindowTreeHostX11.

Howver, in the CefSimple case, dragging a file triggers Xdnd ClientMessages on 
the CefWindowX11, which are ignored.

In the CefClient case, no code is triggered in CefWindowX11, nor in the main 
GTK window. I even added a "drag-motion" handler on the main GTK window and 
logged a message. That handler never gets hit.

Original comment by jmay...@google.com on 21 Oct 2014 at 1:38

GoogleCodeExporter commented 9 years ago
It seems that the CefWindowX11 usage of XdndProxy is not affecting drag and 
drop from the OS (from file system viewer when dragging a file like an image). 
The DND ClientMessages never hit the actual browsers DesktopWindowTreeHostX11 
nor its DesktopDragDropClientAuraX11 code. The messages go to CefWindowX11 
instead.

Original comment by jmay...@google.com on 21 Oct 2014 at 10:07

GoogleCodeExporter commented 9 years ago
Just checking if there is anything I can do to help move this one along? The 
lack of drag and drop is a blocker for us. If we can at least get dnd working 
within the cef browser page itself via my patch, that would help.

Original comment by jmay...@google.com on 23 Oct 2014 at 7:28

GoogleCodeExporter commented 9 years ago
@#22: Thanks for the patch. One minor comment:

1. Line 25:
+  ::Window* children = NULL;

Should be None instead of NULL.

I'll merge the changes once I've had a chance to test them in trunk.

Original comment by magreenb...@gmail.com on 23 Oct 2014 at 7:40

GoogleCodeExporter commented 9 years ago
Okay, thanks. Would you like a new copy of the patch with that change?

Original comment by jmay...@google.com on 23 Oct 2014 at 7:55

GoogleCodeExporter commented 9 years ago
@#28: Nope, no need.

Original comment by magreenb...@gmail.com on 23 Oct 2014 at 7:55

GoogleCodeExporter commented 9 years ago
@#22: Thanks, drag&drop fix added in trunk revision 1893, 2171 branch revision 
1894 and 2062 branch revision 1895.

@#27: It should actually be NULL since it's a pointer and now a ::Window object.

Original comment by magreenb...@gmail.com on 27 Oct 2014 at 10:22

GoogleCodeExporter commented 9 years ago
Excellent. Thanks Marshall. 

Original comment by jcmay...@gmail.com on 27 Oct 2014 at 10:32

GoogleCodeExporter commented 9 years ago
The remaining open item (improve CEF X11 window behavior in cefclient GTK 
example) has been moved to issue #1417. Marking this issue as fixed. Please 
create new issues for any new bugs or feature requests.

Original comment by magreenb...@gmail.com on 27 Oct 2014 at 10:33

GoogleCodeExporter commented 9 years ago
Do you want me to file a new issue for drag/drop of files from the OS?

Original comment by jcmay...@gmail.com on 27 Oct 2014 at 10:36

GoogleCodeExporter commented 9 years ago
@#33: Please do.

Original comment by magreenb...@gmail.com on 27 Oct 2014 at 11:06

GoogleCodeExporter commented 9 years ago
okay, issue 1418 has been entered

https://code.google.com/p/chromiumembedded/issues/detail?id=1418

Original comment by jcmay...@gmail.com on 27 Oct 2014 at 11:17