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

Unified Diff: ui/base/x/x11_util.cc

Issue 10990010: Fix tab dragging in unity2d (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add null check for return value of XShapeGetRectangles Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/x/x11_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/x/x11_util.cc
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 8a1d5e6697e46b61d9d2641c9a7e6c5e9973dda1..d93df2702a55928fde300342d03c84b14f2434ee 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -19,6 +19,7 @@
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/randr.h>
+#include <X11/extensions/shape.h>
#include "base/bind.h"
#include "base/command_line.h"
@@ -323,6 +324,19 @@ bool IsRandRAvailable() {
return is_randr_available;
}
+bool IsShapeAvailable() {
+ static bool is_shape_available = false;
+ static bool is_shape_availability_cached = false;
sadrul 2012/09/25 16:37:20 I think you can just do: static bool is_shape_ava
+ if (is_shape_availability_cached)
+ return is_shape_available;
+
+ int dummy;
+ is_shape_available = XShapeQueryExtension(ui::GetXDisplay(), &dummy, &dummy);
+ is_shape_availability_cached = true;
+ return is_shape_available;
+
+}
+
} // namespace
bool XDisplayExists() {
@@ -612,6 +626,45 @@ bool GetWindowRect(XID window, gfx::Rect* rect) {
return true;
}
+
+bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
+ gfx::Rect window_rect;
+ if (!GetWindowRect(window, &window_rect))
+ return false;
+
+ if (!window_rect.Contains(screen_loc))
+ return false;
+
+ if (!IsShapeAvailable())
+ return true;
+
+ // According to http://www.x.org/releases/X11R7.6/doc/libXext/shapelib.html,
+ // if an X display supports the shape extension the bounds of a window are
+ // defined as the intersection of the window bounds and the interior
+ // rectangles. This means to determine if a point is inside a window for the
+ // purpose of input handling we have to check the rectangles in the ShapeInput
+ // list.
+ int dummy;
+ int input_rects_size = 0;
+ XRectangle* input_rects = XShapeGetRectangles(
+ ui::GetXDisplay(), window, ShapeInput, &input_rects_size, &dummy);
+ if (!input_rects)
+ return true;
+ bool is_in_input_rects = false;
+ for (int i = 0; i < input_rects_size; ++i) {
+ gfx::Rect input_rect =
+ gfx::Rect(input_rects[i].x, input_rects[i].y,
+ input_rects[i].width, input_rects[i].height);
+ if (input_rect.Contains(screen_loc)) {
+ is_in_input_rects = true;
+ break;
+ }
+ }
+ XFree(input_rects);
+ return is_in_input_rects;
+}
+
+
bool PropertyExists(XID window, const std::string& property_name) {
Atom type = None;
int format = 0; // size in bits of each item in 'property'
« no previous file with comments | « ui/base/x/x11_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698