OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents_view_gtk.h" | 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 // This is called when we the renderer asks us to take focus back (i.e., it has | 314 // This is called when we the renderer asks us to take focus back (i.e., it has |
315 // iterated past the last focusable element on the page). | 315 // iterated past the last focusable element on the page). |
316 void TabContentsViewGtk::TakeFocus(bool reverse) { | 316 void TabContentsViewGtk::TakeFocus(bool reverse) { |
317 if (!tab_contents()->delegate()->TakeFocus(reverse)) { | 317 if (!tab_contents()->delegate()->TakeFocus(reverse)) { |
318 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), | 318 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), |
319 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); | 319 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); |
320 } | 320 } |
321 } | 321 } |
322 | 322 |
323 void TabContentsViewGtk::HandleKeyboardEvent( | 323 bool TabContentsViewGtk::HandleKeyboardEvent( |
324 const NativeWebKeyboardEvent& event) { | 324 const NativeWebKeyboardEvent& event) { |
325 // This may be an accelerator. Try to pass it on to our browser window | 325 // This may be an accelerator. Try to pass it on to our browser window |
326 // to handle. | 326 // to handle. |
327 GtkWindow* window = GetTopLevelNativeWindow(); | 327 GtkWindow* window = GetTopLevelNativeWindow(); |
328 if (!window) { | 328 if (!window) { |
329 NOTREACHED(); | 329 NOTREACHED(); |
330 return; | 330 return false; |
331 } | 331 } |
332 | 332 |
333 // Filter out pseudo key events created by GtkIMContext signal handlers. | 333 // Filter out pseudo key events created by GtkIMContext signal handlers. |
334 // Since GtkIMContext signal handlers don't use GdkEventKey objects, its | 334 // Since GtkIMContext signal handlers don't use GdkEventKey objects, its |
335 // |event.os_event| values are dummy values (or NULL.) | 335 // |event.os_event| values are dummy values (or NULL.) |
336 // We should filter out these pseudo key events to prevent unexpected | 336 // We should filter out these pseudo key events to prevent unexpected |
337 // behaviors caused by them. | 337 // behaviors caused by them. |
338 // We should also filter out the KeyUp event as it should not be processed | 338 // We should also filter out the KeyUp event as it should not be processed |
339 // as an accelerator. | 339 // as an accelerator. |
340 if (event.type == WebKit::WebInputEvent::Char || | 340 if (event.type == WebKit::WebInputEvent::Char || |
341 event.type == WebKit::WebInputEvent::KeyUp) | 341 event.type == WebKit::WebInputEvent::KeyUp) |
342 return; | 342 return false; |
343 | 343 |
344 BrowserWindowGtk* browser_window = | 344 BrowserWindowGtk* browser_window = |
345 BrowserWindowGtk::GetBrowserWindowForNativeWindow(window); | 345 BrowserWindowGtk::GetBrowserWindowForNativeWindow(window); |
346 DCHECK(browser_window); | 346 DCHECK(browser_window); |
347 browser_window->HandleKeyboardEvent(event.os_event); | 347 return browser_window->HandleKeyboardEvent(event.os_event); |
348 } | 348 } |
349 | 349 |
350 void TabContentsViewGtk::Observe(NotificationType type, | 350 void TabContentsViewGtk::Observe(NotificationType type, |
351 const NotificationSource& source, | 351 const NotificationSource& source, |
352 const NotificationDetails& details) { | 352 const NotificationDetails& details) { |
353 switch (type.value) { | 353 switch (type.value) { |
354 case NotificationType::TAB_CONTENTS_CONNECTED: { | 354 case NotificationType::TAB_CONTENTS_CONNECTED: { |
355 // No need to remove the SadTabGtk's widget from the container since | 355 // No need to remove the SadTabGtk's widget from the container since |
356 // the new RenderWidgetHostViewGtk instance already removed all the | 356 // the new RenderWidgetHostViewGtk instance already removed all the |
357 // vbox's children. | 357 // vbox's children. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 462 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
463 widget, "x", &value); | 463 widget, "x", &value); |
464 | 464 |
465 int child_y = std::max(half_view_height - (requisition.height / 2), 0); | 465 int child_y = std::max(half_view_height - (requisition.height / 2), 0); |
466 g_value_set_int(&value, child_y); | 466 g_value_set_int(&value, child_y); |
467 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 467 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
468 widget, "y", &value); | 468 widget, "y", &value); |
469 g_value_unset(&value); | 469 g_value_unset(&value); |
470 } | 470 } |
471 } | 471 } |
OLD | NEW |