| 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 |
| 11 #include <X11/Xcursor/Xcursor.h> |
| 12 #include <X11/extensions/XInput2.h> |
| 13 #include <X11/extensions/shape.h> |
| 11 #include <ctype.h> | 14 #include <ctype.h> |
| 12 #include <sys/ipc.h> | 15 #include <sys/ipc.h> |
| 13 #include <sys/shm.h> | 16 #include <sys/shm.h> |
| 14 | 17 |
| 15 #include <list> | 18 #include <list> |
| 16 #include <map> | 19 #include <map> |
| 20 #include <memory> |
| 17 #include <utility> | 21 #include <utility> |
| 18 #include <vector> | 22 #include <vector> |
| 19 | 23 |
| 20 #include <X11/extensions/shape.h> | |
| 21 #include <X11/extensions/XInput2.h> | |
| 22 #include <X11/Xcursor/Xcursor.h> | |
| 23 | |
| 24 #include "base/bind.h" | 24 #include "base/bind.h" |
| 25 #include "base/logging.h" | 25 #include "base/logging.h" |
| 26 #include "base/macros.h" | 26 #include "base/macros.h" |
| 27 #include "base/memory/scoped_ptr.h" | |
| 28 #include "base/memory/singleton.h" | 27 #include "base/memory/singleton.h" |
| 29 #include "base/message_loop/message_loop.h" | 28 #include "base/message_loop/message_loop.h" |
| 30 #include "base/metrics/histogram.h" | 29 #include "base/metrics/histogram.h" |
| 31 #include "base/stl_util.h" | 30 #include "base/stl_util.h" |
| 32 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
| 33 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
| 34 #include "base/strings/stringprintf.h" | 33 #include "base/strings/stringprintf.h" |
| 35 #include "base/sys_byteorder.h" | 34 #include "base/sys_byteorder.h" |
| 36 #include "base/threading/thread.h" | 35 #include "base/threading/thread.h" |
| 37 #include "base/trace_event/trace_event.h" | 36 #include "base/trace_event/trace_event.h" |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 866 |
| 868 bool SetIntArrayProperty(XID window, | 867 bool SetIntArrayProperty(XID window, |
| 869 const std::string& name, | 868 const std::string& name, |
| 870 const std::string& type, | 869 const std::string& type, |
| 871 const std::vector<int>& value) { | 870 const std::vector<int>& value) { |
| 872 DCHECK(!value.empty()); | 871 DCHECK(!value.empty()); |
| 873 XAtom name_atom = GetAtom(name.c_str()); | 872 XAtom name_atom = GetAtom(name.c_str()); |
| 874 XAtom type_atom = GetAtom(type.c_str()); | 873 XAtom type_atom = GetAtom(type.c_str()); |
| 875 | 874 |
| 876 // XChangeProperty() expects values of type 32 to be longs. | 875 // XChangeProperty() expects values of type 32 to be longs. |
| 877 scoped_ptr<long[]> data(new long[value.size()]); | 876 std::unique_ptr<long[]> data(new long[value.size()]); |
| 878 for (size_t i = 0; i < value.size(); ++i) | 877 for (size_t i = 0; i < value.size(); ++i) |
| 879 data[i] = value[i]; | 878 data[i] = value[i]; |
| 880 | 879 |
| 881 gfx::X11ErrorTracker err_tracker; | 880 gfx::X11ErrorTracker err_tracker; |
| 882 XChangeProperty(gfx::GetXDisplay(), | 881 XChangeProperty(gfx::GetXDisplay(), |
| 883 window, | 882 window, |
| 884 name_atom, | 883 name_atom, |
| 885 type_atom, | 884 type_atom, |
| 886 32, // size in bits of items in 'value' | 885 32, // size in bits of items in 'value' |
| 887 PropModeReplace, | 886 PropModeReplace, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 900 | 899 |
| 901 bool SetAtomArrayProperty(XID window, | 900 bool SetAtomArrayProperty(XID window, |
| 902 const std::string& name, | 901 const std::string& name, |
| 903 const std::string& type, | 902 const std::string& type, |
| 904 const std::vector<XAtom>& value) { | 903 const std::vector<XAtom>& value) { |
| 905 DCHECK(!value.empty()); | 904 DCHECK(!value.empty()); |
| 906 XAtom name_atom = GetAtom(name.c_str()); | 905 XAtom name_atom = GetAtom(name.c_str()); |
| 907 XAtom type_atom = GetAtom(type.c_str()); | 906 XAtom type_atom = GetAtom(type.c_str()); |
| 908 | 907 |
| 909 // XChangeProperty() expects values of type 32 to be longs. | 908 // XChangeProperty() expects values of type 32 to be longs. |
| 910 scoped_ptr<XAtom[]> data(new XAtom[value.size()]); | 909 std::unique_ptr<XAtom[]> data(new XAtom[value.size()]); |
| 911 for (size_t i = 0; i < value.size(); ++i) | 910 for (size_t i = 0; i < value.size(); ++i) |
| 912 data[i] = value[i]; | 911 data[i] = value[i]; |
| 913 | 912 |
| 914 gfx::X11ErrorTracker err_tracker; | 913 gfx::X11ErrorTracker err_tracker; |
| 915 XChangeProperty(gfx::GetXDisplay(), | 914 XChangeProperty(gfx::GetXDisplay(), |
| 916 window, | 915 window, |
| 917 name_atom, | 916 name_atom, |
| 918 type_atom, | 917 type_atom, |
| 919 32, // size in bits of items in 'value' | 918 32, // size in bits of items in 'value' |
| 920 PropModeReplace, | 919 PropModeReplace, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 windows->push_back(stack[i]); | 1121 windows->push_back(stack[i]); |
| 1123 } | 1122 } |
| 1124 | 1123 |
| 1125 return result; | 1124 return result; |
| 1126 } | 1125 } |
| 1127 | 1126 |
| 1128 bool CopyAreaToCanvas(XID drawable, | 1127 bool CopyAreaToCanvas(XID drawable, |
| 1129 gfx::Rect source_bounds, | 1128 gfx::Rect source_bounds, |
| 1130 gfx::Point dest_offset, | 1129 gfx::Point dest_offset, |
| 1131 gfx::Canvas* canvas) { | 1130 gfx::Canvas* canvas) { |
| 1132 scoped_ptr<XImage, XImageDeleter> image(XGetImage( | 1131 std::unique_ptr<XImage, XImageDeleter> image(XGetImage( |
| 1133 gfx::GetXDisplay(), drawable, source_bounds.x(), source_bounds.y(), | 1132 gfx::GetXDisplay(), drawable, source_bounds.x(), source_bounds.y(), |
| 1134 source_bounds.width(), source_bounds.height(), AllPlanes, ZPixmap)); | 1133 source_bounds.width(), source_bounds.height(), AllPlanes, ZPixmap)); |
| 1135 if (!image) { | 1134 if (!image) { |
| 1136 LOG(ERROR) << "XGetImage failed"; | 1135 LOG(ERROR) << "XGetImage failed"; |
| 1137 return false; | 1136 return false; |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 if (image->bits_per_pixel == 32) { | 1139 if (image->bits_per_pixel == 32) { |
| 1141 if ((0xff << SK_R32_SHIFT) != image->red_mask || | 1140 if ((0xff << SK_R32_SHIFT) != image->red_mask || |
| 1142 (0xff << SK_G32_SHIFT) != image->green_mask || | 1141 (0xff << SK_G32_SHIFT) != image->green_mask || |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 if (depth) | 1469 if (depth) |
| 1471 *depth = s_depth; | 1470 *depth = s_depth; |
| 1472 } | 1471 } |
| 1473 #endif | 1472 #endif |
| 1474 | 1473 |
| 1475 // ---------------------------------------------------------------------------- | 1474 // ---------------------------------------------------------------------------- |
| 1476 // End of x11_util_internal.h | 1475 // End of x11_util_internal.h |
| 1477 | 1476 |
| 1478 | 1477 |
| 1479 } // namespace ui | 1478 } // namespace ui |
| OLD | NEW |