OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 #include "chrome/browser/ui/gtk/reload_button_gtk.h" | 67 #include "chrome/browser/ui/gtk/reload_button_gtk.h" |
68 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" | 68 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" |
69 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 69 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
70 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 70 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
71 #include "chrome/browser/ui/gtk/task_manager_gtk.h" | 71 #include "chrome/browser/ui/gtk/task_manager_gtk.h" |
72 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" | 72 #include "chrome/browser/ui/gtk/update_recommended_dialog.h" |
73 #include "chrome/browser/ui/omnibox/location_bar.h" | 73 #include "chrome/browser/ui/omnibox/location_bar.h" |
74 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 74 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
75 #include "chrome/browser/ui/page_info_bubble.h" | 75 #include "chrome/browser/ui/page_info_bubble.h" |
76 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 76 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
77 #include "chrome/browser/ui/tabs/tab_mru_list_manager.h" | |
77 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 78 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
78 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" | 79 #include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h" |
79 #include "chrome/browser/web_applications/web_app.h" | 80 #include "chrome/browser/web_applications/web_app.h" |
80 #include "chrome/browser/website_settings.h" | 81 #include "chrome/browser/website_settings.h" |
81 #include "chrome/common/chrome_notification_types.h" | 82 #include "chrome/common/chrome_notification_types.h" |
82 #include "chrome/common/chrome_switches.h" | 83 #include "chrome/common/chrome_switches.h" |
83 #include "chrome/common/pref_names.h" | 84 #include "chrome/common/pref_names.h" |
84 #include "content/public/browser/download_manager.h" | 85 #include "content/public/browser/download_manager.h" |
85 #include "content/public/browser/native_web_keyboard_event.h" | 86 #include "content/public/browser/native_web_keyboard_event.h" |
86 #include "content/public/browser/notification_service.h" | 87 #include "content/public/browser/notification_service.h" |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1789 g_signal_connect(window_, "delete-event", | 1790 g_signal_connect(window_, "delete-event", |
1790 G_CALLBACK(OnMainWindowDeleteEventThunk), this); | 1791 G_CALLBACK(OnMainWindowDeleteEventThunk), this); |
1791 g_signal_connect(window_, "destroy", | 1792 g_signal_connect(window_, "destroy", |
1792 G_CALLBACK(OnMainWindowDestroyThunk), this); | 1793 G_CALLBACK(OnMainWindowDestroyThunk), this); |
1793 g_signal_connect(window_, "configure-event", | 1794 g_signal_connect(window_, "configure-event", |
1794 G_CALLBACK(OnConfigureThunk), this); | 1795 G_CALLBACK(OnConfigureThunk), this); |
1795 g_signal_connect(window_, "window-state-event", | 1796 g_signal_connect(window_, "window-state-event", |
1796 G_CALLBACK(OnWindowStateThunk), this); | 1797 G_CALLBACK(OnWindowStateThunk), this); |
1797 g_signal_connect(window_, "key-press-event", | 1798 g_signal_connect(window_, "key-press-event", |
1798 G_CALLBACK(OnKeyPressThunk), this); | 1799 G_CALLBACK(OnKeyPressThunk), this); |
1800 g_signal_connect(window_, "key-release-event", | |
1801 G_CALLBACK(OnKeyReleaseThunk), this); | |
1799 g_signal_connect(window_, "motion-notify-event", | 1802 g_signal_connect(window_, "motion-notify-event", |
1800 G_CALLBACK(OnMouseMoveEventThunk), this); | 1803 G_CALLBACK(OnMouseMoveEventThunk), this); |
1801 g_signal_connect(window_, "button-press-event", | 1804 g_signal_connect(window_, "button-press-event", |
1802 G_CALLBACK(OnButtonPressEventThunk), this); | 1805 G_CALLBACK(OnButtonPressEventThunk), this); |
1803 g_signal_connect(window_, "focus-in-event", | 1806 g_signal_connect(window_, "focus-in-event", |
1804 G_CALLBACK(OnFocusInThunk), this); | 1807 G_CALLBACK(OnFocusInThunk), this); |
1805 g_signal_connect(window_, "focus-out-event", | 1808 g_signal_connect(window_, "focus-out-event", |
1806 G_CALLBACK(OnFocusOutThunk), this); | 1809 G_CALLBACK(OnFocusOutThunk), this); |
1807 } | 1810 } |
1808 | 1811 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2213 // override their accelerators, except if there is a priority keybinding | 2216 // override their accelerators, except if there is a priority keybinding |
2214 // handler registered (it should take precedence). | 2217 // handler registered (it should take precedence). |
2215 gboolean BrowserWindowGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { | 2218 gboolean BrowserWindowGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { |
2216 if (extension_keybinding_registry_->HasPriorityHandler(event)) | 2219 if (extension_keybinding_registry_->HasPriorityHandler(event)) |
2217 return FALSE; | 2220 return FALSE; |
2218 | 2221 |
2219 // If a widget besides the native view is focused, we have to try to handle | 2222 // If a widget besides the native view is focused, we have to try to handle |
2220 // the custom accelerators before letting it handle them. | 2223 // the custom accelerators before letting it handle them. |
2221 WebContents* current_web_contents = | 2224 WebContents* current_web_contents = |
2222 browser()->GetSelectedWebContents(); | 2225 browser()->GetSelectedWebContents(); |
2226 | |
2227 guint modifier = event->state & gtk_accelerator_get_default_mod_mask(); | |
2228 bool is_tab_mru_switch = CommandLine::ForCurrentProcess()->HasSwitch( | |
2229 switches::kEnableTabMRUSwitch); | |
sky
2012/06/15 19:47:39
spacing is off. Rather than checking switch value,
NaveenBobbili (Motorola)
2012/06/25 09:44:23
Done.
| |
2230 if (GDK_CONTROL_MASK == modifier && is_tab_mru_switch) { | |
2231 if ((event->keyval == GDK_KEY_asciitilde) || | |
2232 (event->keyval == GDK_KEY_quoteleft)) { | |
2233 browser()->tab_mru_list_manager()->CommitActiveTabChanges(); | |
2234 } | |
2235 else | |
2236 browser()->tab_mru_list_manager()->PauseStackUpdates(); | |
2237 } | |
2238 | |
2223 // The current tab might not have a render view if it crashed. | 2239 // The current tab might not have a render view if it crashed. |
2224 if (!current_web_contents || !current_web_contents->GetContentNativeView() || | 2240 if (!current_web_contents || !current_web_contents->GetContentNativeView() || |
2225 !gtk_widget_is_focus(current_web_contents->GetContentNativeView())) { | 2241 !gtk_widget_is_focus(current_web_contents->GetContentNativeView())) { |
2226 int command_id = GetCustomCommandId(event); | 2242 int command_id = GetCustomCommandId(event); |
2227 if (command_id == -1) | 2243 if (command_id == -1) |
2228 command_id = GetPreHandleCommandId(event); | 2244 command_id = GetPreHandleCommandId(event); |
2229 | 2245 |
2230 if (command_id != -1 && browser_->ExecuteCommandIfEnabled(command_id)) | 2246 if (command_id != -1 && browser_->ExecuteCommandIfEnabled(command_id)) |
2231 return TRUE; | 2247 return TRUE; |
2232 | 2248 |
2233 // Propagate the key event to child widget first, so we don't override their | 2249 // Propagate the key event to child widget first, so we don't override their |
2234 // accelerators. | 2250 // accelerators. |
2235 if (!gtk_window_propagate_key_event(GTK_WINDOW(widget), event)) { | 2251 if (!gtk_window_propagate_key_event(GTK_WINDOW(widget), event)) { |
2236 if (!gtk_window_activate_key(GTK_WINDOW(widget), event)) { | 2252 if (!gtk_window_activate_key(GTK_WINDOW(widget), event)) { |
2237 gtk_bindings_activate_event(GTK_OBJECT(widget), event); | 2253 gtk_bindings_activate_event(GTK_OBJECT(widget), event); |
2238 } | 2254 } |
2239 } | 2255 } |
2240 } else { | 2256 } else { |
2241 bool rv = gtk_window_propagate_key_event(GTK_WINDOW(widget), event); | 2257 bool rv = gtk_window_propagate_key_event(GTK_WINDOW(widget), event); |
2242 DCHECK(rv); | 2258 DCHECK(rv); |
2243 } | 2259 } |
2244 | 2260 |
2245 // Prevents the default handler from handling this event. | 2261 // Prevents the default handler from handling this event. |
2246 return TRUE; | 2262 return TRUE; |
2247 } | 2263 } |
2248 | 2264 |
2265 gboolean BrowserWindowGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { | |
2266 bool is_tab_mru_switch = CommandLine::ForCurrentProcess()->HasSwitch( | |
2267 switches::kEnableTabMRUSwitch); | |
sky
2012/06/15 19:47:39
spacing is off.
NaveenBobbili (Motorola)
2012/06/25 09:44:23
Done.
| |
2268 if (is_tab_mru_switch && | |
2269 (event->keyval == GDK_KEY_Control_L || | |
2270 event->keyval == GDK_KEY_Control_R)) { | |
2271 browser()->tab_mru_list_manager()->CommitActiveTabChanges(); | |
2272 } | |
2273 | |
2274 return FALSE; | |
2275 } | |
2276 | |
2249 gboolean BrowserWindowGtk::OnMouseMoveEvent(GtkWidget* widget, | 2277 gboolean BrowserWindowGtk::OnMouseMoveEvent(GtkWidget* widget, |
2250 GdkEventMotion* event) { | 2278 GdkEventMotion* event) { |
2251 // This method is used to update the mouse cursor when over the edge of the | 2279 // This method is used to update the mouse cursor when over the edge of the |
2252 // custom frame. If the custom frame is off or we're over some other widget, | 2280 // custom frame. If the custom frame is off or we're over some other widget, |
2253 // do nothing. | 2281 // do nothing. |
2254 if (!UseCustomFrame() || event->window != gtk_widget_get_window(widget)) { | 2282 if (!UseCustomFrame() || event->window != gtk_widget_get_window(widget)) { |
2255 // Reset the cursor. | 2283 // Reset the cursor. |
2256 if (frame_cursor_) { | 2284 if (frame_cursor_) { |
2257 frame_cursor_ = NULL; | 2285 frame_cursor_ = NULL; |
2258 gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)), NULL); | 2286 gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)), NULL); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2601 wm_type == ui::WM_OPENBOX || | 2629 wm_type == ui::WM_OPENBOX || |
2602 wm_type == ui::WM_XFWM4); | 2630 wm_type == ui::WM_XFWM4); |
2603 } | 2631 } |
2604 | 2632 |
2605 // static | 2633 // static |
2606 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2634 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2607 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2635 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2608 browser_window_gtk->Init(); | 2636 browser_window_gtk->Init(); |
2609 return browser_window_gtk; | 2637 return browser_window_gtk; |
2610 } | 2638 } |
OLD | NEW |