OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // If this gets included after the gtk headers, then a bunch of compiler | 7 // If this gets included after the gtk headers, then a bunch of compiler |
8 // errors happen because of a "#define Status int" in Xlib.h, which interacts | 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts |
9 // badly with net::URLRequestStatus::Status. | 9 // badly with net::URLRequestStatus::Status. |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 RenderWidgetHostViewGtk* host_view) { | 209 RenderWidgetHostViewGtk* host_view) { |
210 // Whenever we lose focus, set the cursor back to that of our parent window, | 210 // Whenever we lose focus, set the cursor back to that of our parent window, |
211 // which should be the default arrow. | 211 // which should be the default arrow. |
212 gdk_window_set_cursor(widget->window, NULL); | 212 gdk_window_set_cursor(widget->window, NULL); |
213 // If we are showing a context menu, maintain the illusion that webkit has | 213 // If we are showing a context menu, maintain the illusion that webkit has |
214 // focus. | 214 // focus. |
215 if (!host_view->is_showing_context_menu_) | 215 if (!host_view->is_showing_context_menu_) |
216 host_view->GetRenderWidgetHost()->Blur(); | 216 host_view->GetRenderWidgetHost()->Blur(); |
217 | 217 |
218 // Prevents us from stealing input context focus in OnGrabNotify() handler. | 218 // Prevents us from stealing input context focus in OnGrabNotify() handler. |
219 host_view->was_focused_before_grab_ = false; | 219 host_view->was_imcontext_focused_before_grab_ = false; |
220 | 220 |
221 // Disable the GtkIMContext object. | 221 // Disable the GtkIMContext object. |
222 host_view->im_context_->OnFocusOut(); | 222 host_view->im_context_->OnFocusOut(); |
223 | 223 |
224 return TRUE; | 224 return TRUE; |
225 } | 225 } |
226 | 226 |
227 // Called when we are shadowed or unshadowed by a keyboard grab (which will | 227 // Called when we are shadowed or unshadowed by a keyboard grab (which will |
228 // occur for activatable popups, such as dropdown menus). Popup windows do not | 228 // occur for activatable popups, such as dropdown menus). Popup windows do not |
229 // take focus, so we never get a focus out or focus in event when they are | 229 // take focus, so we never get a focus out or focus in event when they are |
230 // shown, and must rely on this signal instead. | 230 // shown, and must rely on this signal instead. |
231 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, | 231 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, |
232 RenderWidgetHostViewGtk* host_view) { | 232 RenderWidgetHostViewGtk* host_view) { |
233 if (was_grabbed) { | 233 if (was_grabbed) { |
234 if (host_view->was_focused_before_grab_) | 234 if (host_view->was_imcontext_focused_before_grab_) |
235 host_view->im_context_->OnFocusIn(); | 235 host_view->im_context_->OnFocusIn(); |
236 } else { | 236 } else { |
237 host_view->was_focused_before_grab_ = host_view->HasFocus(); | 237 host_view->was_imcontext_focused_before_grab_ = |
238 if (host_view->was_focused_before_grab_) { | 238 host_view->im_context_->is_focused(); |
| 239 if (host_view->was_imcontext_focused_before_grab_) { |
239 gdk_window_set_cursor(widget->window, NULL); | 240 gdk_window_set_cursor(widget->window, NULL); |
240 host_view->im_context_->OnFocusOut(); | 241 host_view->im_context_->OnFocusOut(); |
241 } | 242 } |
242 } | 243 } |
243 } | 244 } |
244 | 245 |
245 static gboolean OnButtonPressReleaseEvent( | 246 static gboolean OnButtonPressReleaseEvent( |
246 GtkWidget* widget, | 247 GtkWidget* widget, |
247 GdkEventButton* event, | 248 GdkEventButton* event, |
248 RenderWidgetHostViewGtk* host_view) { | 249 RenderWidgetHostViewGtk* host_view) { |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) | 503 RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) |
503 : host_(widget_host), | 504 : host_(widget_host), |
504 about_to_validate_and_paint_(false), | 505 about_to_validate_and_paint_(false), |
505 is_hidden_(false), | 506 is_hidden_(false), |
506 is_loading_(false), | 507 is_loading_(false), |
507 is_showing_context_menu_(false), | 508 is_showing_context_menu_(false), |
508 overlay_color_(0), | 509 overlay_color_(0), |
509 overlay_animation_(this), | 510 overlay_animation_(this), |
510 parent_(NULL), | 511 parent_(NULL), |
511 is_popup_first_mouse_release_(true), | 512 is_popup_first_mouse_release_(true), |
512 was_focused_before_grab_(false), | 513 was_imcontext_focused_before_grab_(false), |
513 do_x_grab_(false), | 514 do_x_grab_(false), |
514 is_fullscreen_(false), | 515 is_fullscreen_(false), |
515 destroy_handler_id_(0), | 516 destroy_handler_id_(0), |
516 dragged_at_horizontal_edge_(0), | 517 dragged_at_horizontal_edge_(0), |
517 dragged_at_vertical_edge_(0), | 518 dragged_at_vertical_edge_(0), |
518 compositing_surface_(gfx::kNullPluginWindow), | 519 compositing_surface_(gfx::kNullPluginWindow), |
519 last_mouse_down_(NULL) { | 520 last_mouse_down_(NULL) { |
520 host_->SetView(this); | 521 host_->SetView(this); |
521 } | 522 } |
522 | 523 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 } | 1185 } |
1185 | 1186 |
1186 // static | 1187 // static |
1187 RenderWidgetHostView* | 1188 RenderWidgetHostView* |
1188 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1189 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1189 gfx::NativeView widget) { | 1190 gfx::NativeView widget) { |
1190 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1191 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
1191 kRenderWidgetHostViewKey); | 1192 kRenderWidgetHostViewKey); |
1192 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1193 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
1193 } | 1194 } |
OLD | NEW |