Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 400012: Refactor the keyboard events handling code related to RenderViewHostDelegate:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 // This is called when we the renderer asks us to take focus back (i.e., it has 312 // This is called when we the renderer asks us to take focus back (i.e., it has
313 // iterated past the last focusable element on the page). 313 // iterated past the last focusable element on the page).
314 void TabContentsViewGtk::TakeFocus(bool reverse) { 314 void TabContentsViewGtk::TakeFocus(bool reverse) {
315 if (!tab_contents()->delegate()->TakeFocus(reverse)) { 315 if (!tab_contents()->delegate()->TakeFocus(reverse)) {
316 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), 316 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()),
317 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); 317 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD);
318 } 318 }
319 } 319 }
320 320
321 bool TabContentsViewGtk::HandleKeyboardEvent(
322 const NativeWebKeyboardEvent& event) {
323 // This may be an accelerator. Try to pass it on to our browser window
324 // to handle.
325 GtkWindow* window = GetTopLevelNativeWindow();
326 if (!window) {
327 NOTREACHED();
328 return false;
329 }
330
331 // Filter out pseudo key events created by GtkIMContext signal handlers.
332 // Since GtkIMContext signal handlers don't use GdkEventKey objects, its
333 // |event.os_event| values are dummy values (or NULL.)
334 // We should filter out these pseudo key events to prevent unexpected
335 // behaviors caused by them.
336 // We should also filter out the KeyUp event as it should not be processed
337 // as an accelerator.
338 if (event.type == WebKit::WebInputEvent::Char ||
339 event.type == WebKit::WebInputEvent::KeyUp)
340 return false;
341
342 BrowserWindowGtk* browser_window =
343 BrowserWindowGtk::GetBrowserWindowForNativeWindow(window);
344
345 // If this is a dialog, the top level window isn't a browser. In this case,
346 // we just return false.
347 return browser_window ?
348 browser_window->HandleKeyboardEvent(event.os_event) : false;
349 }
350
351 void TabContentsViewGtk::Observe(NotificationType type, 321 void TabContentsViewGtk::Observe(NotificationType type,
352 const NotificationSource& source, 322 const NotificationSource& source,
353 const NotificationDetails& details) { 323 const NotificationDetails& details) {
354 switch (type.value) { 324 switch (type.value) {
355 case NotificationType::TAB_CONTENTS_CONNECTED: { 325 case NotificationType::TAB_CONTENTS_CONNECTED: {
356 // No need to remove the SadTabGtk's widget from the container since 326 // No need to remove the SadTabGtk's widget from the container since
357 // the new RenderWidgetHostViewGtk instance already removed all the 327 // the new RenderWidgetHostViewGtk instance already removed all the
358 // vbox's children. 328 // vbox's children.
359 sad_tab_.reset(); 329 sad_tab_.reset();
360 break; 330 break;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 443 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
474 widget, "x", &value); 444 widget, "x", &value);
475 445
476 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 446 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
477 g_value_set_int(&value, child_y); 447 g_value_set_int(&value, child_y);
478 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 448 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
479 widget, "y", &value); 449 widget, "y", &value);
480 g_value_unset(&value); 450 g_value_unset(&value);
481 } 451 }
482 } 452 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents_view_gtk.h ('k') | chrome/browser/tab_contents/tab_contents_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698