Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/x11_util.h" | 9 #include "chrome/common/x11_util.h" |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 return bits_per_pixel; | 137 return bits_per_pixel; |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool IsWindowVisible(XID window) { | 140 bool IsWindowVisible(XID window) { |
| 141 XWindowAttributes win_attributes; | 141 XWindowAttributes win_attributes; |
| 142 XGetWindowAttributes(GetXDisplay(), window, &win_attributes); | 142 XGetWindowAttributes(GetXDisplay(), window, &win_attributes); |
| 143 return (win_attributes.map_state == IsViewable); | 143 return (win_attributes.map_state == IsViewable); |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool GetWindowRect(XID window, gfx::Rect* rect) { | 146 bool GetWindowRect(XID window, gfx::Rect* rect) { |
| 147 Window root_window; | 147 Window root, child; |
| 148 int x, y; | 148 int x, y; |
| 149 unsigned int width, height; | 149 unsigned int width, height; |
| 150 unsigned int border_width, depth; | 150 unsigned int border_width, depth; |
| 151 | 151 |
| 152 if (!XGetGeometry(GetXDisplay(), window, &root_window, &x, &y, | 152 if (!XGetGeometry(GetXDisplay(), window, &root, &x, &y, |
| 153 &width, &height, &border_width, &depth)) | 153 &width, &height, &border_width, &depth)) |
| 154 return false; | 154 return false; |
| 155 | 155 |
| 156 if (!XTranslateCoordinates(GetSecondaryDisplay(), window, root, | |
|
tony
2009/06/09 16:37:55
What is this for?
James Hawkins
2009/06/10 21:54:23
This translates the coordinates that are window-re
| |
| 157 0, 0, &x, &y, &child)) | |
| 158 return false; | |
| 159 | |
| 156 *rect = gfx::Rect(x, y, width, height); | 160 *rect = gfx::Rect(x, y, width, height); |
| 157 return true; | 161 return true; |
| 158 } | 162 } |
| 159 | 163 |
| 160 bool EnumerateChildWindows(XID root, EnumerateWindowsDelegate* delegate) { | |
| 161 XID parent; | |
| 162 XID* children; | |
| 163 unsigned int num_children; | |
| 164 int status = XQueryTree(GetXDisplay(), root, &root, &parent, | |
| 165 &children, &num_children); | |
| 166 if (status == 0) | |
| 167 return false; | |
| 168 | |
| 169 for (unsigned int i = 0; i < num_children; i++) { | |
| 170 if (delegate->ShouldStopIterating(children[i])) | |
| 171 break; | |
| 172 } | |
| 173 | |
| 174 XFree(children); | |
| 175 return true; | |
| 176 } | |
| 177 | |
| 178 XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) { | 164 XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) { |
| 179 static XRenderPictFormat* pictformat = NULL; | 165 static XRenderPictFormat* pictformat = NULL; |
| 180 if (pictformat) | 166 if (pictformat) |
| 181 return pictformat; | 167 return pictformat; |
| 182 | 168 |
| 183 DCHECK(QueryRenderSupport(dpy)); | 169 DCHECK(QueryRenderSupport(dpy)); |
| 184 | 170 |
| 185 pictformat = XRenderFindVisualFormat(dpy, visual); | 171 pictformat = XRenderFindVisualFormat(dpy, visual); |
| 186 CHECK(pictformat) << "XRENDER does not support default visual"; | 172 CHECK(pictformat) << "XRENDER does not support default visual"; |
| 187 | 173 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 return false; | 292 return false; |
| 307 | 293 |
| 308 if (children) | 294 if (children) |
| 309 XFree(children); | 295 XFree(children); |
| 310 | 296 |
| 311 *parent_is_root = root_window == *parent_window; | 297 *parent_is_root = root_window == *parent_window; |
| 312 return true; | 298 return true; |
| 313 } | 299 } |
| 314 | 300 |
| 315 } // namespace x11_util | 301 } // namespace x11_util |
| OLD | NEW |