| 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/tab_contents/chrome_web_contents_view_delegate_gtk.h" | 5 #include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_gtk.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "chrome/browser/browser_shutdown.h" | 10 #include "chrome/browser/browser_shutdown.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // take focus. We don't want that. But if we return true, the event will | 103 // take focus. We don't want that. But if we return true, the event will |
| 104 // stop being propagated, leaving focus wherever it is currently. That is | 104 // stop being propagated, leaving focus wherever it is currently. That is |
| 105 // also bad. So we return false to let the default handler run, but take | 105 // also bad. So we return false to let the default handler run, but take |
| 106 // focus first so as to trick it into thinking the view was already focused | 106 // focus first so as to trick it into thinking the view was already focused |
| 107 // and allowing the event to propagate. | 107 // and allowing the event to propagate. |
| 108 gtk_widget_grab_focus(widget); | 108 gtk_widget_grab_focus(widget); |
| 109 *return_value = FALSE; | 109 *return_value = FALSE; |
| 110 return TRUE; | 110 return TRUE; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Let the default TabContentsViewGtk::OnFocus() behaviour run. | 113 // Let the default WebContentsViewGtk::OnFocus() behaviour run. |
| 114 return FALSE; | 114 return FALSE; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ChromeWebContentsViewDelegateGtk::ShowContextMenu( | 117 void ChromeWebContentsViewDelegateGtk::ShowContextMenu( |
| 118 const content::ContextMenuParams& params) { | 118 const content::ContextMenuParams& params) { |
| 119 // Find out the RenderWidgetHostView that corresponds to the render widget on | 119 // Find out the RenderWidgetHostView that corresponds to the render widget on |
| 120 // which this context menu is showed, so that we can retrieve the last mouse | 120 // which this context menu is showed, so that we can retrieve the last mouse |
| 121 // down event on the render widget and use it as the timestamp of the | 121 // down event on the render widget and use it as the timestamp of the |
| 122 // activation event to show the context menu. | 122 // activation event to show the context menu. |
| 123 content::RenderWidgetHostView* view = NULL; | 123 content::RenderWidgetHostView* view = NULL; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 g_value_set_int(&value, child_x); | 170 g_value_set_int(&value, child_x); |
| 171 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 171 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 172 widget, "x", &value); | 172 widget, "x", &value); |
| 173 | 173 |
| 174 int child_y = std::max((allocation->height - requisition.height) / 2, 0); | 174 int child_y = std::max((allocation->height - requisition.height) / 2, 0); |
| 175 g_value_set_int(&value, child_y); | 175 g_value_set_int(&value, child_y); |
| 176 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 176 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
| 177 widget, "y", &value); | 177 widget, "y", &value); |
| 178 g_value_unset(&value); | 178 g_value_unset(&value); |
| 179 } | 179 } |
| OLD | NEW |