| Index: ui/base/x/x11_util.cc
|
| diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
|
| index f36aa0101cebfc17d925b5d7a2c1fd764f98e6c1..b253a778b79bba0667d4f8f161559244cd90d92b 100644
|
| --- a/ui/base/x/x11_util.cc
|
| +++ b/ui/base/x/x11_util.cc
|
| @@ -53,6 +53,11 @@
|
| #include "ui/gfx/skia_util.h"
|
| #include "ui/gfx/x/x11_error_tracker.h"
|
|
|
| +#if !defined(OS_CHROMEOS)
|
| +#include "base/command_line.h"
|
| +#include "ui/gfx/x/x11_switches.h"
|
| +#endif
|
| +
|
| #if defined(OS_FREEBSD)
|
| #include <sys/sysctl.h>
|
| #include <sys/types.h>
|
| @@ -1409,6 +1414,64 @@ void LogErrorEventDescription(XDisplay* dpy,
|
| << " (" << request_str << ")";
|
| }
|
|
|
| +#if !defined(OS_CHROMEOS)
|
| +void ChooseVisualForWindow(Visual** visual, int* depth) {
|
| + static Visual* s_visual = NULL;
|
| + static int s_depth = 0;
|
| +
|
| + if (!s_visual) {
|
| + XDisplay* display = gfx::GetXDisplay();
|
| + XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False);
|
| +
|
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableTransparentVisuals) &&
|
| + XGetSelectionOwner(display, NET_WM_CM_S0) != None) {
|
| + // Choose the first ARGB8888 visual
|
| + XVisualInfo visual_template;
|
| + visual_template.screen = 0;
|
| +
|
| + int visuals_len;
|
| + gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo(
|
| + display, VisualScreenMask, &visual_template, &visuals_len));
|
| + for (int i = 0; i < visuals_len; ++i) {
|
| + // Why support only 8888 ARGB? Because it's all that GTK+ supports. In
|
| + // gdkvisual-x11.cc, they look for this specific visual and use it for
|
| + // all their alpha channel using needs.
|
| + //
|
| + // TODO(erg): While the following does find a valid visual, some GL
|
| + // drivers
|
| + // don't believe that this has an alpha channel. According to marcheu@,
|
| + // this should work on open source driver though. (It doesn't work with
|
| + // NVidia's binaries currently.) http://crbug.com/369209
|
| + const XVisualInfo& info = visual_list[i];
|
| + if (info.depth == 32 && info.visual->red_mask == 0xff0000 &&
|
| + info.visual->green_mask == 0x00ff00 &&
|
| + info.visual->blue_mask == 0x0000ff) {
|
| + s_visual = info.visual;
|
| + s_depth = info.depth;
|
| + break;
|
| + }
|
| + }
|
| + } else {
|
| + XWindowAttributes windowAttribs;
|
| + Window root = XDefaultRootWindow(display);
|
| + Status status = XGetWindowAttributes(display, root, &windowAttribs);
|
| + DCHECK(status != 0);
|
| + s_visual = windowAttribs.visual;
|
| + s_depth = windowAttribs.depth;
|
| + }
|
| + } // !s_visual
|
| +
|
| + DCHECK(s_visual);
|
| + DCHECK(s_depth > 0);
|
| +
|
| + if (visual)
|
| + *visual = s_visual;
|
| + if (depth)
|
| + *depth = s_depth;
|
| +}
|
| +#endif
|
| +
|
| // ----------------------------------------------------------------------------
|
| // End of x11_util_internal.h
|
|
|
|
|