| 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 | |
| 66 #if defined(OS_FREEBSD) | 61 #if defined(OS_FREEBSD) |
| 67 #include <sys/sysctl.h> | 62 #include <sys/sysctl.h> |
| 68 #include <sys/types.h> | 63 #include <sys/types.h> |
| 69 #endif | 64 #endif |
| 70 | 65 |
| 71 namespace ui { | 66 namespace ui { |
| 72 | 67 |
| 73 namespace { | 68 namespace { |
| 74 | 69 |
| 75 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) { | 70 int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) { |
| (...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 << "X error received: " | 1405 << "X error received: " |
| 1411 << "serial " << error_event.serial << ", " | 1406 << "serial " << error_event.serial << ", " |
| 1412 << "error_code " << static_cast<int>(error_event.error_code) | 1407 << "error_code " << static_cast<int>(error_event.error_code) |
| 1413 << " (" << error_str << "), " | 1408 << " (" << error_str << "), " |
| 1414 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1409 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1415 << "minor_code " << static_cast<int>(error_event.minor_code) | 1410 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1416 << " (" << request_str << ")"; | 1411 << " (" << request_str << ")"; |
| 1417 } | 1412 } |
| 1418 | 1413 |
| 1419 #if !defined(OS_CHROMEOS) | 1414 #if !defined(OS_CHROMEOS) |
| 1420 void ChooseVisualForWindow(Visual** visual, int* depth) { | 1415 void ChooseVisualForWindow(bool enable_transparent_visuals, |
| 1416 Visual** visual, |
| 1417 int* depth) { |
| 1421 static Visual* s_visual = NULL; | 1418 static Visual* s_visual = NULL; |
| 1422 static int s_depth = 0; | 1419 static int s_depth = 0; |
| 1423 | 1420 |
| 1424 if (!s_visual) { | 1421 if (!s_visual) { |
| 1425 XDisplay* display = gfx::GetXDisplay(); | 1422 XDisplay* display = gfx::GetXDisplay(); |
| 1426 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False); | 1423 XAtom NET_WM_CM_S0 = XInternAtom(display, "_NET_WM_CM_S0", False); |
| 1427 | 1424 |
| 1428 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1425 if (enable_transparent_visuals && |
| 1429 switches::kEnableTransparentVisuals) && | |
| 1430 XGetSelectionOwner(display, NET_WM_CM_S0) != None) { | 1426 XGetSelectionOwner(display, NET_WM_CM_S0) != None) { |
| 1431 // Choose the first ARGB8888 visual | 1427 // Choose the first ARGB8888 visual |
| 1432 XVisualInfo visual_template; | 1428 XVisualInfo visual_template; |
| 1433 visual_template.screen = 0; | 1429 visual_template.screen = 0; |
| 1434 | 1430 |
| 1435 int visuals_len; | 1431 int visuals_len; |
| 1436 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( | 1432 gfx::XScopedPtr<XVisualInfo[]> visual_list(XGetVisualInfo( |
| 1437 display, VisualScreenMask, &visual_template, &visuals_len)); | 1433 display, VisualScreenMask, &visual_template, &visuals_len)); |
| 1438 for (int i = 0; i < visuals_len; ++i) { | 1434 for (int i = 0; i < visuals_len; ++i) { |
| 1439 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In | 1435 // Why support only 8888 ARGB? Because it's all that GTK+ supports. In |
| 1440 // gdkvisual-x11.cc, they look for this specific visual and use it for | 1436 // gdkvisual-x11.cc, they look for this specific visual and use it for |
| 1441 // all their alpha channel using needs. | 1437 // 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 | |
| 1448 const XVisualInfo& info = visual_list[i]; | 1438 const XVisualInfo& info = visual_list[i]; |
| 1449 if (info.depth == 32 && info.visual->red_mask == 0xff0000 && | 1439 if (info.depth == 32 && info.visual->red_mask == 0xff0000 && |
| 1450 info.visual->green_mask == 0x00ff00 && | 1440 info.visual->green_mask == 0x00ff00 && |
| 1451 info.visual->blue_mask == 0x0000ff) { | 1441 info.visual->blue_mask == 0x0000ff) { |
| 1452 s_visual = info.visual; | 1442 s_visual = info.visual; |
| 1453 s_depth = info.depth; | 1443 s_depth = info.depth; |
| 1454 break; | 1444 break; |
| 1455 } | 1445 } |
| 1456 } | 1446 } |
| 1457 } else { | 1447 } else { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1472 if (depth) | 1462 if (depth) |
| 1473 *depth = s_depth; | 1463 *depth = s_depth; |
| 1474 } | 1464 } |
| 1475 #endif | 1465 #endif |
| 1476 | 1466 |
| 1477 // ---------------------------------------------------------------------------- | 1467 // ---------------------------------------------------------------------------- |
| 1478 // End of x11_util_internal.h | 1468 // End of x11_util_internal.h |
| 1479 | 1469 |
| 1480 | 1470 |
| 1481 } // namespace ui | 1471 } // namespace ui |
| OLD | NEW |