| 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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 Atom GetAtom(const char* name) { | 1005 Atom GetAtom(const char* name) { |
| 1006 #if defined(TOOLKIT_GTK) | 1006 #if defined(TOOLKIT_GTK) |
| 1007 return gdk_x11_get_xatom_by_name_for_display( | 1007 return gdk_x11_get_xatom_by_name_for_display( |
| 1008 gdk_display_get_default(), name); | 1008 gdk_display_get_default(), name); |
| 1009 #else | 1009 #else |
| 1010 // TODO(derat): Cache atoms to avoid round-trips to the server. | 1010 // TODO(derat): Cache atoms to avoid round-trips to the server. |
| 1011 return XInternAtom(GetXDisplay(), name, false); | 1011 return XInternAtom(GetXDisplay(), name, false); |
| 1012 #endif | 1012 #endif |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 void SetWindowClassHint(Display* display, |
| 1016 XID window, |
| 1017 std::string res_name, |
| 1018 std::string res_class) { |
| 1019 XClassHint class_hints; |
| 1020 // const_cast is safe because XSetClassHint does not modify the strings. |
| 1021 // Just to be safe, the res_name and res_class parameters are local copies, |
| 1022 // not const references. |
| 1023 class_hints.res_name = const_cast<char*>(res_name.c_str()); |
| 1024 class_hints.res_class = const_cast<char*>(res_class.c_str()); |
| 1025 XSetClassHint(display, window, &class_hints); |
| 1026 } |
| 1027 |
| 1015 XID GetParentWindow(XID window) { | 1028 XID GetParentWindow(XID window) { |
| 1016 XID root = None; | 1029 XID root = None; |
| 1017 XID parent = None; | 1030 XID parent = None; |
| 1018 XID* children = NULL; | 1031 XID* children = NULL; |
| 1019 unsigned int num_children = 0; | 1032 unsigned int num_children = 0; |
| 1020 XQueryTree(GetXDisplay(), window, &root, &parent, &children, &num_children); | 1033 XQueryTree(GetXDisplay(), window, &root, &parent, &children, &num_children); |
| 1021 if (children) | 1034 if (children) |
| 1022 XFree(children); | 1035 XFree(children); |
| 1023 return parent; | 1036 return parent; |
| 1024 } | 1037 } |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1740 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1728 << "minor_code " << static_cast<int>(error_event.minor_code) | 1741 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1729 << " (" << request_str << ")"; | 1742 << " (" << request_str << ")"; |
| 1730 } | 1743 } |
| 1731 | 1744 |
| 1732 // ---------------------------------------------------------------------------- | 1745 // ---------------------------------------------------------------------------- |
| 1733 // End of x11_util_internal.h | 1746 // End of x11_util_internal.h |
| 1734 | 1747 |
| 1735 | 1748 |
| 1736 } // namespace ui | 1749 } // namespace ui |
| OLD | NEW |