| 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 17 matching lines...) Expand all Loading... |
| 28 if (window) { | 28 if (window) { |
| 29 GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), | 29 GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window), |
| 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 gfx::Point origin; |
| 39 if (screen_coordinates) { | 39 if (screen_coordinates) { |
| 40 gfx::Point point = ui::GetWidgetScreenPosition(widget); | 40 origin = gfx::PointAtOffsetFromOrigin(ui::GetWidgetScreenOffset(widget)); |
| 41 x = point.x(); | |
| 42 y = point.y(); | |
| 43 } else { | 41 } else { |
| 42 gint x, y; |
| 44 gtk_widget_translate_coordinates(widget, GTK_WIDGET(window), | 43 gtk_widget_translate_coordinates(widget, GTK_WIDGET(window), |
| 45 0, 0, &x, &y); | 44 0, 0, &x, &y); |
| 45 origin = gfx::Point(x, y); |
| 46 } | 46 } |
| 47 bounds->set_origin(gfx::Point(x, y)); | 47 bounds->set_origin(origin); |
| 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 |