OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "chrome/browser/views/tab_contents/tab_contents_view_gtk.h" | 5 #include "chrome/browser/views/tab_contents/tab_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 tab_contents()->delegate()->TabContentsFocused(tab_contents()); | 307 tab_contents()->delegate()->TabContentsFocused(tab_contents()); |
308 } | 308 } |
309 | 309 |
310 void TabContentsViewGtk::TakeFocus(bool reverse) { | 310 void TabContentsViewGtk::TakeFocus(bool reverse) { |
311 // This is called when we the renderer asks us to take focus back (i.e., it | 311 // This is called when we the renderer asks us to take focus back (i.e., it |
312 // has iterated past the last focusable element on the page). | 312 // has iterated past the last focusable element on the page). |
313 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), | 313 gtk_widget_child_focus(GTK_WIDGET(GetTopLevelNativeWindow()), |
314 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); | 314 reverse ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD); |
315 } | 315 } |
316 | 316 |
317 bool TabContentsViewGtk::HandleKeyboardEvent( | |
318 const NativeWebKeyboardEvent& event) { | |
319 // The renderer returned a keyboard event it did not process. This may be | |
320 // a keyboard shortcut that we have to process. | |
321 if (event.type != WebInputEvent::RawKeyDown) | |
322 return false; | |
323 | |
324 views::FocusManager* focus_manager = | |
325 views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); | |
326 // We may not have a focus_manager at this point (if the tab has been switched | |
327 // by the time this message returned). | |
328 if (!focus_manager) | |
329 return false; | |
330 | |
331 bool shift_pressed = (event.modifiers & WebInputEvent::ShiftKey) == | |
332 WebInputEvent::ShiftKey; | |
333 bool ctrl_pressed = (event.modifiers & WebInputEvent::ControlKey) == | |
334 WebInputEvent::ControlKey; | |
335 bool alt_pressed = (event.modifiers & WebInputEvent::AltKey) == | |
336 WebInputEvent::AltKey; | |
337 | |
338 return focus_manager->ProcessAccelerator( | |
339 views::Accelerator(static_cast<base::KeyboardCode>(event.windowsKeyCode), | |
340 shift_pressed, ctrl_pressed, alt_pressed)); | |
341 // DANGER: |this| could be deleted now! | |
342 | |
343 // Note that we do not handle Gtk mnemonics/accelerators or binding set here | |
344 // (as it is done in BrowserWindowGtk::HandleKeyboardEvent), as we override | |
345 // Gtk behavior completely. | |
346 } | |
347 | |
348 void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { | 317 void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) { |
349 // Allow delegates to handle the context menu operation first. | 318 // Allow delegates to handle the context menu operation first. |
350 if (tab_contents()->delegate()->HandleContextMenu(params)) | 319 if (tab_contents()->delegate()->HandleContextMenu(params)) |
351 return; | 320 return; |
352 | 321 |
353 context_menu_.reset(new RenderViewContextMenuWin(tab_contents(), params)); | 322 context_menu_.reset(new RenderViewContextMenuWin(tab_contents(), params)); |
354 context_menu_->Init(); | 323 context_menu_->Init(); |
355 | 324 |
356 gfx::Point screen_point(params.x, params.y); | 325 gfx::Point screen_point(params.x, params.y); |
357 views::View::ConvertPointToScreen(GetRootView(), &screen_point); | 326 views::View::ConvertPointToScreen(GetRootView(), &screen_point); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget, | 407 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget, |
439 GdkEventMotion* event) { | 408 GdkEventMotion* event) { |
440 if (sad_tab_ != NULL) | 409 if (sad_tab_ != NULL) |
441 WidgetGtk::OnMotionNotify(widget, event); | 410 WidgetGtk::OnMotionNotify(widget, event); |
442 else if (tab_contents()->delegate()) | 411 else if (tab_contents()->delegate()) |
443 tab_contents()->delegate()->ContentsMouseEvent( | 412 tab_contents()->delegate()->ContentsMouseEvent( |
444 tab_contents(), views::Screen::GetCursorScreenPoint(), true); | 413 tab_contents(), views::Screen::GetCursorScreenPoint(), true); |
445 return FALSE; | 414 return FALSE; |
446 } | 415 } |
447 | 416 |
OLD | NEW |