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

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

Issue 155555: A quick fix for Issue 13711 (the second part)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <gtk/gtk.h> 9 #include <gtk/gtk.h>
9 10
10 #include "base/mime_util.h" 11 #include "base/mime_util.h"
11 #include "base/gfx/point.h" 12 #include "base/gfx/point.h"
12 #include "base/gfx/rect.h" 13 #include "base/gfx/rect.h"
13 #include "base/gfx/size.h" 14 #include "base/gfx/size.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 #include "chrome/browser/download/download_shelf.h" 17 #include "chrome/browser/download/download_shelf.h"
17 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h" 18 #include "chrome/browser/gtk/blocked_popup_container_view_gtk.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Used with gtk_container_foreach to change the sizes of the children of 96 // Used with gtk_container_foreach to change the sizes of the children of
96 // |fixed_|. 97 // |fixed_|.
97 void SetSizeRequest(GtkWidget* widget, gpointer userdata) { 98 void SetSizeRequest(GtkWidget* widget, gpointer userdata) {
98 gfx::Size* size = static_cast<gfx::Size*>(userdata); 99 gfx::Size* size = static_cast<gfx::Size*>(userdata);
99 if (widget->allocation.width != size->width() || 100 if (widget->allocation.width != size->width() ||
100 widget->allocation.height != size->height()) { 101 widget->allocation.height != size->height()) {
101 gtk_widget_set_size_request(widget, size->width(), size->height()); 102 gtk_widget_set_size_request(widget, size->width(), size->height());
102 } 103 }
103 } 104 }
104 105
106 int GdkEventKeyToLayoutIndependentKeyval(const GdkEventKey* event) {
107 // This function is a copy of WebKit::gdkEventToWindowsKeyCode() but returns
108 // a GDK key value instead of a Windows virtual key code.
109 static const int kHardwareCodeToGdkKeyval[] = {
110 0, // 0x00:
111 0, // 0x01:
112 0, // 0x02:
113 0, // 0x03:
114 0, // 0x04:
115 0, // 0x05:
116 0, // 0x06:
117 0, // 0x07:
118 0, // 0x08:
119 0, // 0x09: GDK_Escape
120 GDK_1, // 0x0A: GDK_1
121 GDK_2, // 0x0B: GDK_2
122 GDK_3, // 0x0C: GDK_3
123 GDK_4, // 0x0D: GDK_4
124 GDK_5, // 0x0E: GDK_5
125 GDK_6, // 0x0F: GDK_6
126 GDK_7, // 0x10: GDK_7
127 GDK_8, // 0x11: GDK_8
128 GDK_9, // 0x12: GDK_9
129 GDK_0, // 0x13: GDK_0
130 GDK_minus, // 0x14: GDK_minus
131 GDK_equal, // 0x15: GDK_equal
132 0, // 0x16: GDK_BackSpace
133 0, // 0x17: GDK_Tab
134 GDK_q, // 0x18: GDK_q
135 GDK_w, // 0x19: GDK_w
136 GDK_e, // 0x1A: GDK_e
137 GDK_r, // 0x1B: GDK_r
138 GDK_t, // 0x1C: GDK_t
139 GDK_y, // 0x1D: GDK_y
140 GDK_u, // 0x1E: GDK_u
141 GDK_i, // 0x1F: GDK_i
142 GDK_o, // 0x20: GDK_o
143 GDK_p, // 0x21: GDK_p
144 GDK_bracketleft, // 0x22: GDK_bracketleft
145 GDK_bracketright, // 0x23: GDK_bracketright
146 0, // 0x24: GDK_Return
147 0, // 0x25: GDK_Control_L
148 GDK_a, // 0x26: GDK_a
149 GDK_s, // 0x27: GDK_s
150 GDK_d, // 0x28: GDK_d
151 GDK_f, // 0x29: GDK_f
152 GDK_g, // 0x2A: GDK_g
153 GDK_h, // 0x2B: GDK_h
154 GDK_j, // 0x2C: GDK_j
155 GDK_k, // 0x2D: GDK_k
156 GDK_l, // 0x2E: GDK_l
157 GDK_semicolon, // 0x2F: GDK_semicolon
158 GDK_apostrophe, // 0x30: GDK_apostrophe
159 GDK_grave, // 0x31: GDK_grave
160 0, // 0x32: GDK_Shift_L
161 GDK_backslash, // 0x33: GDK_backslash
162 GDK_z, // 0x34: GDK_z
163 GDK_x, // 0x35: GDK_x
164 GDK_c, // 0x36: GDK_c
165 GDK_v, // 0x37: GDK_v
166 GDK_b, // 0x38: GDK_b
167 GDK_n, // 0x39: GDK_n
168 GDK_m, // 0x3A: GDK_m
169 GDK_comma, // 0x3B: GDK_comma
170 GDK_period, // 0x3C: GDK_period
171 GDK_slash, // 0x3D: GDK_slash
172 0, // 0x3E: GDK_Shift_R
173 };
174
175 // If this |event->keyval| represents an ASCII character, we use it for
176 // accelerators. Otherwise, we look up a table from a hardware keycode to
177 // keyval and use its result.
178 wchar_t c = gdk_keyval_to_unicode(event->keyval);
179 if (c <= 0x7F)
180 return event->keyval;
181
182 if (event->hardware_keycode < arraysize(kHardwareCodeToGdkKeyval)) {
183 int keyval = kHardwareCodeToGdkKeyval[event->hardware_keycode];
184 if (keyval)
185 return keyval;
186 }
187
188 return event->keyval;
189 }
190
105 } // namespace 191 } // namespace
106 192
107 // A helper class that handles DnD for drops in the renderer. In GTK parlance, 193 // A helper class that handles DnD for drops in the renderer. In GTK parlance,
108 // this handles destination-side DnD, but not source-side DnD. 194 // this handles destination-side DnD, but not source-side DnD.
109 class WebDragDest { 195 class WebDragDest {
110 public: 196 public:
111 explicit WebDragDest(TabContents* tab_contents, GtkWidget* widget) 197 explicit WebDragDest(TabContents* tab_contents, GtkWidget* widget)
112 : tab_contents_(tab_contents), 198 : tab_contents_(tab_contents),
113 widget_(widget), 199 widget_(widget),
114 context_(NULL), 200 context_(NULL),
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 // Since GtkIMContext signal handlers don't use GdkEventKey objects, its 641 // Since GtkIMContext signal handlers don't use GdkEventKey objects, its
556 // |event.os_event| values are dummy values (or NULL.) 642 // |event.os_event| values are dummy values (or NULL.)
557 // We should filter out these pseudo key events to prevent unexpected 643 // We should filter out these pseudo key events to prevent unexpected
558 // behaviors caused by them. 644 // behaviors caused by them.
559 if (event.type == WebKit::WebInputEvent::Char) 645 if (event.type == WebKit::WebInputEvent::Char)
560 return; 646 return;
561 647
562 BrowserWindowGtk* browser_window = 648 BrowserWindowGtk* browser_window =
563 BrowserWindowGtk::GetBrowserWindowForNativeWindow(window); 649 BrowserWindowGtk::GetBrowserWindowForNativeWindow(window);
564 DCHECK(browser_window); 650 DCHECK(browser_window);
565 browser_window->HandleAccelerator(event.os_event->keyval, 651 browser_window->HandleAccelerator(
652 GdkEventKeyToLayoutIndependentKeyval(event.os_event),
566 static_cast<GdkModifierType>(event.os_event->state)); 653 static_cast<GdkModifierType>(event.os_event->state));
567 } 654 }
568 655
569 void TabContentsViewGtk::Observe(NotificationType type, 656 void TabContentsViewGtk::Observe(NotificationType type,
570 const NotificationSource& source, 657 const NotificationSource& source,
571 const NotificationDetails& details) { 658 const NotificationDetails& details) {
572 switch (type.value) { 659 switch (type.value) {
573 case NotificationType::TAB_CONTENTS_CONNECTED: { 660 case NotificationType::TAB_CONTENTS_CONNECTED: {
574 // No need to remove the SadTabGtk's widget from the container since 661 // No need to remove the SadTabGtk's widget from the container since
575 // the new RenderWidgetHostViewGtk instance already removed all the 662 // the new RenderWidgetHostViewGtk instance already removed all the
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 857 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
771 widget, "x", &value); 858 widget, "x", &value);
772 859
773 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 860 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
774 g_value_set_int(&value, child_y); 861 g_value_set_int(&value, child_y);
775 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 862 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
776 widget, "y", &value); 863 widget, "y", &value);
777 g_value_unset(&value); 864 g_value_unset(&value);
778 } 865 }
779 } 866 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698