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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 #endif // defined(USE_AURA) | 253 #endif // defined(USE_AURA) |
254 | 254 |
255 bool IsShapeAvailable() { | 255 bool IsShapeAvailable() { |
256 int dummy; | 256 int dummy; |
257 static bool is_shape_available = | 257 static bool is_shape_available = |
258 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); | 258 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); |
259 return is_shape_available; | 259 return is_shape_available; |
260 | 260 |
261 } | 261 } |
262 | 262 |
| 263 // A list of bogus sizes in mm that X detects that should be ignored. |
| 264 // See crbug.com/136533. The first element maintains the minimum |
| 265 // size required to be valid size. |
| 266 const unsigned long kInvalidDisplaySizeList[][2] = { |
| 267 {40, 30}, |
| 268 {50, 40}, |
| 269 {160, 90}, |
| 270 {160, 100}, |
| 271 }; |
| 272 |
263 } // namespace | 273 } // namespace |
264 | 274 |
265 bool XDisplayExists() { | 275 bool XDisplayExists() { |
266 return (gfx::GetXDisplay() != NULL); | 276 return (gfx::GetXDisplay() != NULL); |
267 } | 277 } |
268 | 278 |
269 bool IsXInput2Available() { | 279 bool IsXInput2Available() { |
270 return DeviceDataManager::GetInstance()->IsXInput2Available(); | 280 return DeviceDataManager::GetInstance()->IsXInput2Available(); |
271 } | 281 } |
272 | 282 |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 // TODO(erg): Actually doing this correctly would require pulling out xrandr, | 1337 // TODO(erg): Actually doing this correctly would require pulling out xrandr, |
1328 // which we don't even do in the desktop screen yet. | 1338 // which we don't even do in the desktop screen yet. |
1329 ::XDisplay* display = gfx::GetXDisplay(); | 1339 ::XDisplay* display = gfx::GetXDisplay(); |
1330 ::Screen* screen = DefaultScreenOfDisplay(display); | 1340 ::Screen* screen = DefaultScreenOfDisplay(display); |
1331 int width = WidthOfScreen(screen); | 1341 int width = WidthOfScreen(screen); |
1332 int height = HeightOfScreen(screen); | 1342 int height = HeightOfScreen(screen); |
1333 return window_rect.size() == gfx::Size(width, height); | 1343 return window_rect.size() == gfx::Size(width, height); |
1334 #endif | 1344 #endif |
1335 } | 1345 } |
1336 | 1346 |
| 1347 bool IsXDisplaySizeBlackListed(unsigned long mm_width, |
| 1348 unsigned long mm_height) { |
| 1349 // Ignore if the reported display is smaller than minimum size. |
| 1350 if (mm_width <= kInvalidDisplaySizeList[0][0] || |
| 1351 mm_height <= kInvalidDisplaySizeList[0][1]) { |
| 1352 LOG(WARNING) << "Smaller than minimum display size"; |
| 1353 return true; |
| 1354 } |
| 1355 for (unsigned long i = 1 ; i < arraysize(kInvalidDisplaySizeList); ++i) { |
| 1356 const unsigned long* size = kInvalidDisplaySizeList[i]; |
| 1357 if (mm_width == size[0] && mm_height == size[1]) { |
| 1358 LOG(WARNING) << "Black listed display size detected:" |
| 1359 << size[0] << "x" << size[1]; |
| 1360 return true; |
| 1361 } |
| 1362 } |
| 1363 return false; |
| 1364 } |
| 1365 |
1337 const unsigned char* XRefcountedMemory::front() const { | 1366 const unsigned char* XRefcountedMemory::front() const { |
1338 return x11_data_; | 1367 return x11_data_; |
1339 } | 1368 } |
1340 | 1369 |
1341 size_t XRefcountedMemory::size() const { | 1370 size_t XRefcountedMemory::size() const { |
1342 return length_; | 1371 return length_; |
1343 } | 1372 } |
1344 | 1373 |
1345 XRefcountedMemory::~XRefcountedMemory() { | 1374 XRefcountedMemory::~XRefcountedMemory() { |
1346 XFree(x11_data_); | 1375 XFree(x11_data_); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1533 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1505 << "minor_code " << static_cast<int>(error_event.minor_code) | 1534 << "minor_code " << static_cast<int>(error_event.minor_code) |
1506 << " (" << request_str << ")"; | 1535 << " (" << request_str << ")"; |
1507 } | 1536 } |
1508 | 1537 |
1509 // ---------------------------------------------------------------------------- | 1538 // ---------------------------------------------------------------------------- |
1510 // End of x11_util_internal.h | 1539 // End of x11_util_internal.h |
1511 | 1540 |
1512 | 1541 |
1513 } // namespace ui | 1542 } // namespace ui |
OLD | NEW |