OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 GtkWidget* widget, GdkEventButton* event, | 220 GtkWidget* widget, GdkEventButton* event, |
221 RenderWidgetHostViewGtk* host_view) { | 221 RenderWidgetHostViewGtk* host_view) { |
222 // We want to translate the coordinates of events that do not originate | 222 // We want to translate the coordinates of events that do not originate |
223 // from this widget to be relative to the top left of the widget. | 223 // from this widget to be relative to the top left of the widget. |
224 GtkWidget* event_widget = gtk_get_event_widget( | 224 GtkWidget* event_widget = gtk_get_event_widget( |
225 reinterpret_cast<GdkEvent*>(event)); | 225 reinterpret_cast<GdkEvent*>(event)); |
226 if (event_widget != widget) { | 226 if (event_widget != widget) { |
227 int x = 0; | 227 int x = 0; |
228 int y = 0; | 228 int y = 0; |
229 gtk_widget_get_pointer(widget, &x, &y); | 229 gtk_widget_get_pointer(widget, &x, &y); |
230 // If the mouse release happens outside our popup, force the popup to | 230 // If the mouse event happens outside our popup, force the popup to |
231 // close. We do this so a hung renderer doesn't prevent us from | 231 // close. We do this so a hung renderer doesn't prevent us from |
232 // releasing the x pointer grab. | 232 // releasing the x pointer grab. |
233 bool click_in_popup = x >= 0 && y >= 0 && x < widget->allocation.width && | 233 bool click_in_popup = x >= 0 && y >= 0 && x < widget->allocation.width && |
234 y < widget->allocation.height; | 234 y < widget->allocation.height; |
235 // We can get mouse ups from outside the render view during drags even if | 235 // Only Shutdown on mouse downs. Mouse ups can occur outside the render |
236 // we are not a popup, so only Shutdown if we are a popup (and | 236 // view if the user drags for DnD or while using the scrollbar on a select |
237 // host_view->parent_ is not null). | 237 // dropdown. Don't shutdown if we are not a popup. |
238 if (!host_view->parent_ && host_view->is_popup_first_mouse_release_ && | 238 if (event->type != GDK_BUTTON_RELEASE && host_view->parent_ && |
239 !click_in_popup) { | 239 !host_view->is_popup_first_mouse_release_ && !click_in_popup) { |
240 host_view->host_->Shutdown(); | 240 host_view->host_->Shutdown(); |
241 return FALSE; | 241 return FALSE; |
242 } | 242 } |
243 event->x = x; | 243 event->x = x; |
244 event->y = y; | 244 event->y = y; |
245 } | 245 } |
246 host_view->is_popup_first_mouse_release_ = false; | 246 host_view->is_popup_first_mouse_release_ = false; |
247 host_view->GetRenderWidgetHost()->ForwardMouseEvent( | 247 host_view->GetRenderWidgetHost()->ForwardMouseEvent( |
248 WebInputEventFactory::mouseEvent(event)); | 248 WebInputEventFactory::mouseEvent(event)); |
249 | 249 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, | 700 void RenderWidgetHostViewGtk::ReceivedSelectionText(GtkClipboard* clipboard, |
701 const gchar* text, gpointer userdata) { | 701 const gchar* text, gpointer userdata) { |
702 // If there's nothing to paste (|text| is NULL), do nothing. | 702 // If there's nothing to paste (|text| is NULL), do nothing. |
703 if (!text) | 703 if (!text) |
704 return; | 704 return; |
705 RenderWidgetHostViewGtk* host_view = | 705 RenderWidgetHostViewGtk* host_view = |
706 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); | 706 reinterpret_cast<RenderWidgetHostViewGtk*>(userdata); |
707 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), | 707 host_view->host_->Send(new ViewMsg_InsertText(host_view->host_->routing_id(), |
708 UTF8ToUTF16(text))); | 708 UTF8ToUTF16(text))); |
709 } | 709 } |
OLD | NEW |