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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 #endif // defined(USE_AURA) | 252 #endif // defined(USE_AURA) |
253 | 253 |
254 bool IsShapeAvailable() { | 254 bool IsShapeAvailable() { |
255 int dummy; | 255 int dummy; |
256 static bool is_shape_available = | 256 static bool is_shape_available = |
257 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); | 257 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); |
258 return is_shape_available; | 258 return is_shape_available; |
259 | 259 |
260 } | 260 } |
261 | 261 |
| 262 // A list of bogus sizes in mm that X detects that should be ignored. |
| 263 // See crbug.com/136533. The first element maintains the minimum |
| 264 // size required to be valid size. |
| 265 const unsigned long kInvalidDisplaySizeList[][2] = { |
| 266 {40, 30}, |
| 267 {50, 40}, |
| 268 {160, 90}, |
| 269 {160, 100}, |
| 270 }; |
| 271 |
262 } // namespace | 272 } // namespace |
263 | 273 |
264 bool XDisplayExists() { | 274 bool XDisplayExists() { |
265 return (gfx::GetXDisplay() != NULL); | 275 return (gfx::GetXDisplay() != NULL); |
266 } | 276 } |
267 | 277 |
268 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { | 278 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { |
269 int dummy; | 279 int dummy; |
270 Bool pixmaps_supported; | 280 Bool pixmaps_supported; |
271 // Query the server's support for XSHM. | 281 // Query the server's support for XSHM. |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 // TODO(erg): Actually doing this correctly would require pulling out xrandr, | 1316 // TODO(erg): Actually doing this correctly would require pulling out xrandr, |
1307 // which we don't even do in the desktop screen yet. | 1317 // which we don't even do in the desktop screen yet. |
1308 ::XDisplay* display = gfx::GetXDisplay(); | 1318 ::XDisplay* display = gfx::GetXDisplay(); |
1309 ::Screen* screen = DefaultScreenOfDisplay(display); | 1319 ::Screen* screen = DefaultScreenOfDisplay(display); |
1310 int width = WidthOfScreen(screen); | 1320 int width = WidthOfScreen(screen); |
1311 int height = HeightOfScreen(screen); | 1321 int height = HeightOfScreen(screen); |
1312 return window_rect.size() == gfx::Size(width, height); | 1322 return window_rect.size() == gfx::Size(width, height); |
1313 #endif | 1323 #endif |
1314 } | 1324 } |
1315 | 1325 |
| 1326 bool IsXDisplaySizeBlackListed(unsigned long mm_width, |
| 1327 unsigned long mm_height) { |
| 1328 // Ignore if the reported display is smaller than minimum size. |
| 1329 if (mm_width <= kInvalidDisplaySizeList[0][0] || |
| 1330 mm_height <= kInvalidDisplaySizeList[0][1]) { |
| 1331 LOG(WARNING) << "Smaller than minimum display size"; |
| 1332 return true; |
| 1333 } |
| 1334 for (unsigned long i = 1 ; i < arraysize(kInvalidDisplaySizeList); ++i) { |
| 1335 const unsigned long* size = kInvalidDisplaySizeList[i]; |
| 1336 if (mm_width == size[0] && mm_height == size[1]) { |
| 1337 LOG(WARNING) << "Black listed display size detected:" |
| 1338 << size[0] << "x" << size[1]; |
| 1339 return true; |
| 1340 } |
| 1341 } |
| 1342 return false; |
| 1343 } |
| 1344 |
1316 const unsigned char* XRefcountedMemory::front() const { | 1345 const unsigned char* XRefcountedMemory::front() const { |
1317 return x11_data_; | 1346 return x11_data_; |
1318 } | 1347 } |
1319 | 1348 |
1320 size_t XRefcountedMemory::size() const { | 1349 size_t XRefcountedMemory::size() const { |
1321 return length_; | 1350 return length_; |
1322 } | 1351 } |
1323 | 1352 |
1324 XRefcountedMemory::~XRefcountedMemory() { | 1353 XRefcountedMemory::~XRefcountedMemory() { |
1325 XFree(x11_data_); | 1354 XFree(x11_data_); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1512 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1484 << "minor_code " << static_cast<int>(error_event.minor_code) | 1513 << "minor_code " << static_cast<int>(error_event.minor_code) |
1485 << " (" << request_str << ")"; | 1514 << " (" << request_str << ")"; |
1486 } | 1515 } |
1487 | 1516 |
1488 // ---------------------------------------------------------------------------- | 1517 // ---------------------------------------------------------------------------- |
1489 // End of x11_util_internal.h | 1518 // End of x11_util_internal.h |
1490 | 1519 |
1491 | 1520 |
1492 } // namespace ui | 1521 } // namespace ui |
OLD | NEW |