OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file defines utility functions for X11 (Linux only). This code has been | 5 // This file defines utility functions for X11 (Linux only). This code has been |
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support | 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support |
7 // remains woefully incomplete. | 7 // remains woefully incomplete. |
8 | 8 |
9 #include "ui/base/x/x11_util.h" | 9 #include "ui/base/x/x11_util.h" |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "ui/gfx/geometry/insets.h" | 51 #include "ui/gfx/geometry/insets.h" |
52 #include "ui/gfx/geometry/point.h" | 52 #include "ui/gfx/geometry/point.h" |
53 #include "ui/gfx/geometry/point_conversions.h" | 53 #include "ui/gfx/geometry/point_conversions.h" |
54 #include "ui/gfx/geometry/rect.h" | 54 #include "ui/gfx/geometry/rect.h" |
55 #include "ui/gfx/geometry/size.h" | 55 #include "ui/gfx/geometry/size.h" |
56 #include "ui/gfx/image/image_skia.h" | 56 #include "ui/gfx/image/image_skia.h" |
57 #include "ui/gfx/image/image_skia_rep.h" | 57 #include "ui/gfx/image/image_skia_rep.h" |
58 #include "ui/gfx/skia_util.h" | 58 #include "ui/gfx/skia_util.h" |
59 #include "ui/gfx/x/x11_error_tracker.h" | 59 #include "ui/gfx/x/x11_error_tracker.h" |
60 | 60 |
| 61 #if !defined(OS_CHROMEOS) |
| 62 #include "base/command_line.h" |
| 63 #include "ui/gfx/x/x11_switches.h" |
| 64 #endif |
| 65 |
61 #if defined(OS_FREEBSD) | 66 #if defined(OS_FREEBSD) |
62 #include <sys/sysctl.h> | 67 #include <sys/sysctl.h> |
63 #include <sys/types.h> | 68 #include <sys/types.h> |
64 #endif | 69 #endif |
65 | 70 |
66 namespace ui { | 71 namespace ui { |
67 | 72 |
68 namespace { | 73 namespace { |
69 | 74 |
70 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) { | 75 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) { |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 << "X error received: " | 1410 << "X error received: " |
1406 << "serial " << error_event.serial << ", " | 1411 << "serial " << error_event.serial << ", " |
1407 << "error_code " << static_cast<int>(error_event.error_code) | 1412 << "error_code " << static_cast<int>(error_event.error_code) |
1408 << " (" << error_str << "), " | 1413 << " (" << error_str << "), " |
1409 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1414 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1410 << "minor_code " << static_cast<int>(error_event.minor_code) | 1415 << "minor_code " << static_cast<int>(error_event.minor_code) |
1411 << " (" << request_str << ")"; | 1416 << " (" << request_str << ")"; |
1412 } | 1417 } |
1413 | 1418 |
1414 #if !defined(OS_CHROMEOS) | 1419 #if !defined(OS_CHROMEOS) |
1415 void ChooseVisualForWindow(bool enable_transparent_visuals, | 1420 void ChooseVisualForWindow(Visual** visual, int* depth) { |
1416 Visual** visual, | |
1417 int* depth) { | |
1418 static Visual* s_visual = NULL; | 1421 static Visual* s_visual = NULL; |
1419 static int s_depth = 0; | 1422 static int s_depth = 0; |
1420 | 1423 |
1421 if (!s_visual) { | 1424 if (!s_visual) { |
1422 XDisplay* display = gfx::GetXDisplay(); | 1425 XDisplay* display = gfx::GetXDisplay(); |
1423 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False); | 1426 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False); |
1424 | 1427 |
1425 if (enable_transparent_visuals && | 1428 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1429 switches::kEnableTransparentVisuals) && |
1426 XGetSelectionOwner(display, NET_WM_CM_S0) != None) { | 1430 XGetSelectionOwner(display, NET_WM_CM_S0) != None) { |
1427 // Choose the first ARGB8888 visual | 1431 // Choose the first ARGB8888 visual |
1428 XVisualInfo visual_template; | 1432 XVisualInfo visual_template; |
1429 visual_template.screen = 0; | 1433 visual_template.screen = 0; |
1430 | 1434 |
1431 int visuals_len; | 1435 int visuals_len; |
1432 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( | 1436 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( |
1433 display, VisualScreenMask, &visual_template, &visuals_len)); | 1437 display, VisualScreenMask, &visual_template, &visuals_len)); |
1434 for (int i = 0; i < visuals_len; ++i) { | 1438 for (int i = 0; i < visuals_len; ++i) { |
1435 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In | 1439 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In |
1436 // gdkvisual-x11.cc, they look for this specific visual and use it for | 1440 // gdkvisual-x11.cc, they look for this specific visual and use it for |
1437 // all their alpha channel using needs. | 1441 // all their alpha channel using needs. |
| 1442 // |
| 1443 // TODO(erg): While the following does find a valid visual, some GL |
| 1444 // drivers |
| 1445 // don't believe that this has an alpha channel. According to marcheu@, |
| 1446 // this should work on open source driver though. (It doesn't work with |
| 1447 // NVidia's binaries currently.) http://crbug.com/369209 |
1438 const XVisualInfo& info = visual_list[i]; | 1448 const XVisualInfo& info = visual_list[i]; |
1439 if (info.depth == 32 && info.visual->red_mask == 0xff0000 && | 1449 if (info.depth == 32 && info.visual->red_mask == 0xff0000 && |
1440 info.visual->green_mask == 0x00ff00 && | 1450 info.visual->green_mask == 0x00ff00 && |
1441 info.visual->blue_mask == 0x0000ff) { | 1451 info.visual->blue_mask == 0x0000ff) { |
1442 s_visual = info.visual; | 1452 s_visual = info.visual; |
1443 s_depth = info.depth; | 1453 s_depth = info.depth; |
1444 break; | 1454 break; |
1445 } | 1455 } |
1446 } | 1456 } |
1447 } else { | 1457 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
1462 if (depth) | 1472 if (depth) |
1463 *depth = s_depth; | 1473 *depth = s_depth; |
1464 } | 1474 } |
1465 #endif | 1475 #endif |
1466 | 1476 |
1467 // ---------------------------------------------------------------------------- | 1477 // ---------------------------------------------------------------------------- |
1468 // End of x11_util_internal.h | 1478 // End of x11_util_internal.h |
1469 | 1479 |
1470 | 1480 |
1471 } // namespace ui | 1481 } // namespace ui |
OLD | NEW |