Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Side by Side Diff: ui/base/x/x11_util.cc

Issue 153953006: Takes ShapeBounding rectangles into consideration in WindowContainsPoint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Takes ShapeBounding rectangles into consideration in WindowContainsPoint (comments) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 648
649 if (!IsShapeAvailable()) 649 if (!IsShapeAvailable())
650 return true; 650 return true;
651 651
652 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html, 652 // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html,
653 // if an X display supports the shape extension the bounds of a window are 653 // if an X display supports the shape extension the bounds of a window are
654 // defined as the intersection of the window bounds and the interior 654 // defined as the intersection of the window bounds and the interior
655 // rectangles. This means to determine if a point is inside a window for the 655 // rectangles. This means to determine if a point is inside a window for the
656 // purpose of input handling we have to check the rectangles in the ShapeInput 656 // purpose of input handling we have to check the rectangles in the ShapeInput
657 // list. 657 // list.
658 int dummy; 658 // According to http://www.x.org/releases/current/doc/xextproto/shape.html,
659 int input_rects_size = 0; 659 // we need to also respect the ShapeBounding rectangles.
660 XRectangle* input_rects = XShapeGetRectangles( 660 // The effective input region of a window is defined to be the intersection
661 gfx::GetXDisplay(), window, ShapeInput, &input_rects_size, &dummy); 661 // of the client input region with both the default input region and the
662 if (!input_rects) 662 // client bounding region. Any portion of the client input region that is not
663 return true; 663 // included in both the default input region and the client bounding region
664 bool is_in_input_rects = false; 664 // will not be included in the effective input region on the screen.
665 for (int i = 0; i < input_rects_size; ++i) { 665 int rectangle_kind[] = {ShapeInput, ShapeBounding};
666 // The ShapeInput rects appear to be in window space, so we have to 666 for (size_t kind_index = 0;
667 // translate by the window_rect's offset to map to screen space. 667 kind_index < arraysize(rectangle_kind);
668 gfx::Rect input_rect = 668 kind_index++) {
669 gfx::Rect(input_rects[i].x + window_rect.x(), 669 int dummy;
670 input_rects[i].y + window_rect.y(), 670 int shape_rects_size = 0;
671 input_rects[i].width, input_rects[i].height); 671 XRectangle* shape_rects = XShapeGetRectangles(gfx::GetXDisplay(),
672 if (input_rect.Contains(screen_loc)) { 672 window,
673 is_in_input_rects = true; 673 rectangle_kind[kind_index],
674 break; 674 &shape_rects_size,
675 &dummy);
676 if (!shape_rects)
677 continue;
678 bool is_in_shape_rects = false;
679 for (int i = 0; i < shape_rects_size; ++i) {
680 // The ShapeInput and ShapeBounding rects are to be in window space, so we
681 // have to translate by the window_rect's offset to map to screen space.
682 gfx::Rect shape_rect =
683 gfx::Rect(shape_rects[i].x + window_rect.x(),
684 shape_rects[i].y + window_rect.y(),
685 shape_rects[i].width, shape_rects[i].height);
686 if (shape_rect.Contains(screen_loc)) {
687 is_in_shape_rects = true;
688 break;
689 }
675 } 690 }
691 XFree(shape_rects);
692 if (!is_in_shape_rects)
693 return false;
676 } 694 }
677 XFree(input_rects); 695 return true;
678 return is_in_input_rects;
679 } 696 }
680 697
681 698
682 bool PropertyExists(XID window, const std::string& property_name) { 699 bool PropertyExists(XID window, const std::string& property_name) {
683 Atom type = None; 700 Atom type = None;
684 int format = 0; // size in bits of each item in 'property' 701 int format = 0; // size in bits of each item in 'property'
685 unsigned long num_items = 0; 702 unsigned long num_items = 0;
686 unsigned char* property = NULL; 703 unsigned char* property = NULL;
687 704
688 int result = GetProperty(window, property_name, 1, 705 int result = GetProperty(window, property_name, 1,
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 << "request_code " << static_cast<int>(error_event.request_code) << ", " 1550 << "request_code " << static_cast<int>(error_event.request_code) << ", "
1534 << "minor_code " << static_cast<int>(error_event.minor_code) 1551 << "minor_code " << static_cast<int>(error_event.minor_code)
1535 << " (" << request_str << ")"; 1552 << " (" << request_str << ")";
1536 } 1553 }
1537 1554
1538 // ---------------------------------------------------------------------------- 1555 // ----------------------------------------------------------------------------
1539 // End of x11_util_internal.h 1556 // End of x11_util_internal.h
1540 1557
1541 1558
1542 } // namespace ui 1559 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698