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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 XCustomCursorCache() {} | 218 XCustomCursorCache() {} |
219 ~XCustomCursorCache() { | 219 ~XCustomCursorCache() { |
220 Clear(); | 220 Clear(); |
221 } | 221 } |
222 | 222 |
223 std::map< ::Cursor, XCustomCursor*> cache_; | 223 std::map< ::Cursor, XCustomCursor*> cache_; |
224 DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache); | 224 DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache); |
225 }; | 225 }; |
226 | 226 |
227 bool IsShapeAvailable() { | |
228 int dummy; | |
229 static bool is_shape_available = | |
230 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); | |
231 return is_shape_available; | |
232 | |
233 } | |
234 | |
235 } // namespace | 227 } // namespace |
236 | 228 |
237 bool IsXInput2Available() { | 229 bool IsXInput2Available() { |
238 return DeviceDataManager::GetInstance()->IsXInput2Available(); | 230 return DeviceDataManager::GetInstance()->IsXInput2Available(); |
239 } | 231 } |
240 | 232 |
241 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { | 233 static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { |
242 int dummy; | 234 int dummy; |
243 Bool pixmaps_supported; | 235 Bool pixmaps_supported; |
244 // Query the server's support for XSHM. | 236 // Query the server's support for XSHM. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 black.red = black.green = black.blue = 0; | 456 black.red = black.green = black.blue = 0; |
465 Pixmap blank = XCreateBitmapFromData(xdisplay, | 457 Pixmap blank = XCreateBitmapFromData(xdisplay, |
466 DefaultRootWindow(xdisplay), | 458 DefaultRootWindow(xdisplay), |
467 nodata, 8, 8); | 459 nodata, 8, 8); |
468 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, | 460 invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank, |
469 &black, &black, 0, 0); | 461 &black, &black, 0, 0); |
470 XFreePixmap(xdisplay, blank); | 462 XFreePixmap(xdisplay, blank); |
471 return invisible_cursor; | 463 return invisible_cursor; |
472 } | 464 } |
473 | 465 |
| 466 bool IsShapeExtensionAvailable() { |
| 467 int dummy; |
| 468 static bool is_shape_available = |
| 469 XShapeQueryExtension(gfx::GetXDisplay(), &dummy, &dummy); |
| 470 return is_shape_available; |
| 471 } |
| 472 |
474 XID GetX11RootWindow() { | 473 XID GetX11RootWindow() { |
475 return DefaultRootWindow(gfx::GetXDisplay()); | 474 return DefaultRootWindow(gfx::GetXDisplay()); |
476 } | 475 } |
477 | 476 |
478 bool GetCurrentDesktop(int* desktop) { | 477 bool GetCurrentDesktop(int* desktop) { |
479 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); | 478 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); |
480 } | 479 } |
481 | 480 |
482 void SetHideTitlebarWhenMaximizedProperty(XID window, | 481 void SetHideTitlebarWhenMaximizedProperty(XID window, |
483 HideTitlebarWhenMaximized property) { | 482 HideTitlebarWhenMaximized property) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 bool WindowContainsPoint(XID window, gfx::Point screen_loc) { | 571 bool WindowContainsPoint(XID window, gfx::Point screen_loc) { |
573 TRACE_EVENT0("ui", "WindowContainsPoint"); | 572 TRACE_EVENT0("ui", "WindowContainsPoint"); |
574 | 573 |
575 gfx::Rect window_rect; | 574 gfx::Rect window_rect; |
576 if (!GetWindowRect(window, &window_rect)) | 575 if (!GetWindowRect(window, &window_rect)) |
577 return false; | 576 return false; |
578 | 577 |
579 if (!window_rect.Contains(screen_loc)) | 578 if (!window_rect.Contains(screen_loc)) |
580 return false; | 579 return false; |
581 | 580 |
582 if (!IsShapeAvailable()) | 581 if (!IsShapeExtensionAvailable()) |
583 return true; | 582 return true; |
584 | 583 |
585 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html, | 584 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html, |
586 // if an X display supports the shape extension the bounds of a window are | 585 // if an X display supports the shape extension the bounds of a window are |
587 // defined as the intersection of the window bounds and the interior | 586 // defined as the intersection of the window bounds and the interior |
588 // rectangles. This means to determine if a point is inside a window for the | 587 // rectangles. This means to determine if a point is inside a window for the |
589 // purpose of input handling we have to check the rectangles in the ShapeInput | 588 // purpose of input handling we have to check the rectangles in the ShapeInput |
590 // list. | 589 // list. |
591 // According to http://www.x.org/releases/current/doc/xextproto/shape.html, | 590 // According to http://www.x.org/releases/current/doc/xextproto/shape.html, |
592 // we need to also respect the ShapeBounding rectangles. | 591 // we need to also respect the ShapeBounding rectangles. |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1371 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1373 << "minor_code " << static_cast<int>(error_event.minor_code) | 1372 << "minor_code " << static_cast<int>(error_event.minor_code) |
1374 << " (" << request_str << ")"; | 1373 << " (" << request_str << ")"; |
1375 } | 1374 } |
1376 | 1375 |
1377 // ---------------------------------------------------------------------------- | 1376 // ---------------------------------------------------------------------------- |
1378 // End of x11_util_internal.h | 1377 // End of x11_util_internal.h |
1379 | 1378 |
1380 | 1379 |
1381 } // namespace ui | 1380 } // namespace ui |
OLD | NEW |