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 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 static_cast<ViewID>(view_id)); | 30 static_cast<ViewID>(view_id)); |
31 if (!widget) | 31 if (!widget) |
32 return; | 32 return; |
33 *success = true; | 33 *success = true; |
34 | 34 |
35 GtkAllocation allocation; | 35 GtkAllocation allocation; |
36 gtk_widget_get_allocation(widget, &allocation); | 36 gtk_widget_get_allocation(widget, &allocation); |
37 *bounds = gfx::Rect(allocation.width, allocation.height); | 37 *bounds = gfx::Rect(allocation.width, allocation.height); |
38 gint x, y; | 38 gint x, y; |
39 if (screen_coordinates) { | 39 if (screen_coordinates) { |
40 gfx::Point point = ui::GetWidgetScreenPosition(widget); | 40 gfx::Vector2d offset = ui::GetWidgetScreenOffset(widget); |
41 x = point.x(); | 41 x = offset.x(); |
42 y = point.y(); | 42 y = offset.y(); |
Peter Kasting
2012/10/27 01:01:39
Nit: This causes us to translate back and forth fr
danakj
2012/10/29 19:17:20
Done.
| |
43 } else { | 43 } else { |
44 gtk_widget_translate_coordinates(widget, GTK_WIDGET(window), | 44 gtk_widget_translate_coordinates(widget, GTK_WIDGET(window), |
45 0, 0, &x, &y); | 45 0, 0, &x, &y); |
46 } | 46 } |
47 bounds->set_origin(gfx::Point(x, y)); | 47 bounds->set_origin(gfx::Point(x, y)); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void TestingAutomationProvider::SetWindowBounds(int handle, | 51 void TestingAutomationProvider::SetWindowBounds(int handle, |
52 const gfx::Rect& bounds, | 52 const gfx::Rect& bounds, |
53 bool* success) { | 53 bool* success) { |
54 *success = false; | 54 *success = false; |
55 GtkWindow* window = window_tracker_->GetResource(handle); | 55 GtkWindow* window = window_tracker_->GetResource(handle); |
56 if (window) { | 56 if (window) { |
57 gtk_window_move(window, bounds.x(), bounds.height()); | 57 gtk_window_move(window, bounds.x(), bounds.height()); |
58 gtk_window_resize(window, bounds.width(), bounds.height()); | 58 gtk_window_resize(window, bounds.width(), bounds.height()); |
59 *success = true; | 59 *success = true; |
60 } | 60 } |
61 } | 61 } |
OLD | NEW |