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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc

Issue 989993002: x11: Use scoped_ptr<> for X11 objects where it makes sense. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 9 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 | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <vector> 5 #include <vector>
6 6
7 #include <X11/extensions/shape.h> 7 #include <X11/extensions/shape.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of X11 macros which conflict with gtest. 10 // Get rid of X11 macros which conflict with gtest.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 params.bounds = gfx::Rect(100, 100, 100, 100); 149 params.bounds = gfx::Rect(100, 100, 100, 100);
150 widget->Init(params); 150 widget->Init(params);
151 return widget.Pass(); 151 return widget.Pass();
152 } 152 }
153 153
154 // Returns the list of rectangles which describe |xid|'s bounding region via the 154 // Returns the list of rectangles which describe |xid|'s bounding region via the
155 // X shape extension. 155 // X shape extension.
156 std::vector<gfx::Rect> GetShapeRects(XID xid) { 156 std::vector<gfx::Rect> GetShapeRects(XID xid) {
157 int dummy; 157 int dummy;
158 int shape_rects_size; 158 int shape_rects_size;
159 XRectangle* shape_rects = XShapeGetRectangles(gfx::GetXDisplay(), 159 gfx::XScopedPtr<XRectangle[]> shape_rects(XShapeGetRectangles(
160 xid, 160 gfx::GetXDisplay(), xid, ShapeBounding, &shape_rects_size, &dummy));
161 ShapeBounding,
162 &shape_rects_size,
163 &dummy);
164 161
165 std::vector<gfx::Rect> shape_vector; 162 std::vector<gfx::Rect> shape_vector;
166 for (int i = 0; i < shape_rects_size; ++i) { 163 for (int i = 0; i < shape_rects_size; ++i) {
167 shape_vector.push_back(gfx::Rect( 164 const XRectangle& rect = shape_rects[i];
168 shape_rects[i].x, 165 shape_vector.push_back(gfx::Rect(rect.x, rect.y, rect.width, rect.height));
169 shape_rects[i].y,
170 shape_rects[i].width,
171 shape_rects[i].height));
172 } 166 }
173 XFree(shape_rects);
174 return shape_vector; 167 return shape_vector;
175 } 168 }
176 169
177 // Returns true if one of |rects| contains point (x,y). 170 // Returns true if one of |rects| contains point (x,y).
178 bool ShapeRectContainsPoint(const std::vector<gfx::Rect>& shape_rects, 171 bool ShapeRectContainsPoint(const std::vector<gfx::Rect>& shape_rects,
179 int x, 172 int x,
180 int y) { 173 int y) {
181 gfx::Point point(x, y); 174 gfx::Point point(x, y);
182 for (size_t i = 0; i < shape_rects.size(); ++i) { 175 for (size_t i = 0; i < shape_rects.size(); ++i) {
183 if (shape_rects[i].Contains(point)) 176 if (shape_rects[i].Contains(point))
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 EXPECT_EQ(ui::ET_MOUSEWHEEL, second_recorder.mouse_events()[0].type()); 583 EXPECT_EQ(ui::ET_MOUSEWHEEL, second_recorder.mouse_events()[0].type());
591 EXPECT_EQ(gfx::Point(-25, -25).ToString(), 584 EXPECT_EQ(gfx::Point(-25, -25).ToString(),
592 second_recorder.mouse_events()[0].location().ToString()); 585 second_recorder.mouse_events()[0].location().ToString());
593 586
594 PretendCapture(nullptr); 587 PretendCapture(nullptr);
595 first.GetNativeWindow()->RemovePreTargetHandler(&first_recorder); 588 first.GetNativeWindow()->RemovePreTargetHandler(&first_recorder);
596 second.GetNativeWindow()->RemovePreTargetHandler(&second_recorder); 589 second.GetNativeWindow()->RemovePreTargetHandler(&second_recorder);
597 } 590 }
598 591
599 } // namespace views 592 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698