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

Side by Side Diff: chrome/browser/ui/gtk/gtk_window_util.cc

Issue 183923030: Almost finish moving context_menu_node_ from RenderViewImpl to RenderFrameImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 9 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
OLDNEW
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/gtk_window_util.h" 5 #include "chrome/browser/ui/gtk/gtk_window_util.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include "content/public/browser/render_frame_host.h"
8 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
9 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
10 #include "content/public/browser/web_contents_view.h" 11 #include "content/public/browser/web_contents_view.h"
11 #include "ui/base/base_window.h" 12 #include "ui/base/base_window.h"
12 13
13 using content::RenderWidgetHost; 14 using content::RenderFrameHost;
14 using content::WebContents; 15 using content::WebContents;
15 16
16 namespace gtk_window_util { 17 namespace gtk_window_util {
17 18
18 const int kFrameBorderThickness = 4; 19 const int kFrameBorderThickness = 4;
19 const int kResizeAreaCornerSize = 16; 20 const int kResizeAreaCornerSize = 16;
20 21
21 // Keep track of the last click time and the last click position so we can 22 // Keep track of the last click time and the last click position so we can
22 // filter out extra GDK_BUTTON_PRESS events when a double click happens. 23 // filter out extra GDK_BUTTON_PRESS events when a double click happens.
23 static guint32 last_click_time; 24 static guint32 last_click_time;
24 static int last_click_x; 25 static int last_click_x;
25 static int last_click_y; 26 static int last_click_y;
26 27
27 // Performs Cut/Copy/Paste operation on the |window|. 28 // Performs Cut/Copy/Paste operation on the |window|.
28 // If the current render view is focused, then just call the specified |method| 29 // If the current render view is focused, then just call the specified |method|
29 // against the current render view host, otherwise emit the specified |signal| 30 // against the current render view host, otherwise emit the specified |signal|
30 // against the focused widget. 31 // against the focused widget.
31 // TODO(suzhe): This approach does not work for plugins. 32 // TODO(suzhe): This approach does not work for plugins.
32 void DoCutCopyPaste(GtkWindow* window, 33 void DoCutCopyPaste(GtkWindow* window,
33 WebContents* web_contents, 34 WebContents* web_contents,
34 void (RenderWidgetHost::*method)(), 35 void (RenderFrameHost::*method)(),
35 const char* signal) { 36 const char* signal) {
36 GtkWidget* widget = gtk_window_get_focus(window); 37 GtkWidget* widget = gtk_window_get_focus(window);
37 if (widget == NULL) 38 if (widget == NULL)
38 return; // Do nothing if no focused widget. 39 return; // Do nothing if no focused widget.
39 40
40 if (web_contents && 41 if (web_contents &&
41 widget == web_contents->GetView()->GetContentNativeView()) { 42 widget == web_contents->GetView()->GetContentNativeView()) {
42 (web_contents->GetRenderViewHost()->*method)(); 43 RenderFrameHost* frame = web_contents->GetFocusedFrame();
44 (frame->*method)();
43 } else { 45 } else {
44 guint id; 46 guint id;
45 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0) 47 if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0)
46 g_signal_emit(widget, id, 0); 48 g_signal_emit(widget, id, 0);
47 } 49 }
48 } 50 }
49 51
50 void DoCut(GtkWindow* window, WebContents* web_contents) { 52 void DoCut(GtkWindow* window, WebContents* web_contents) {
51 DoCutCopyPaste(window, web_contents, 53 DoCutCopyPaste(window, web_contents,
52 &RenderWidgetHost::Cut, "cut-clipboard"); 54 &RenderFrameHost::Cut, "cut-clipboard");
53 } 55 }
54 56
55 void DoCopy(GtkWindow* window, WebContents* web_contents) { 57 void DoCopy(GtkWindow* window, WebContents* web_contents) {
56 DoCutCopyPaste(window, web_contents, 58 DoCutCopyPaste(window, web_contents,
57 &RenderWidgetHost::Copy, "copy-clipboard"); 59 &RenderFrameHost::Copy, "copy-clipboard");
58 } 60 }
59 61
60 void DoPaste(GtkWindow* window, WebContents* web_contents) { 62 void DoPaste(GtkWindow* window, WebContents* web_contents) {
61 DoCutCopyPaste(window, web_contents, 63 DoCutCopyPaste(window, web_contents,
62 &RenderWidgetHost::Paste, "paste-clipboard"); 64 &RenderFrameHost::Paste, "paste-clipboard");
63 } 65 }
64 66
65 // Ubuntu patches their version of GTK+ so that there is always a 67 // Ubuntu patches their version of GTK+ so that there is always a
66 // gripper in the bottom right corner of the window. We dynamically 68 // gripper in the bottom right corner of the window. We dynamically
67 // look up this symbol because it's a non-standard Ubuntu extension to 69 // look up this symbol because it's a non-standard Ubuntu extension to
68 // GTK+. We always need to disable this feature since we can't 70 // GTK+. We always need to disable this feature since we can't
69 // communicate this to WebKit easily. 71 // communicate this to WebKit easily.
70 typedef void (*gtk_window_set_has_resize_grip_func)(GtkWindow*, gboolean); 72 typedef void (*gtk_window_set_has_resize_grip_func)(GtkWindow*, gboolean);
71 gtk_window_set_has_resize_grip_func gtk_window_set_has_resize_grip_sym; 73 gtk_window_set_has_resize_grip_func gtk_window_set_has_resize_grip_sym;
72 74
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 *edge = GDK_WINDOW_EDGE_WEST; 299 *edge = GDK_WINDOW_EDGE_WEST;
298 else if (east.Contains(x, y)) 300 else if (east.Contains(x, y))
299 *edge = GDK_WINDOW_EDGE_EAST; 301 *edge = GDK_WINDOW_EDGE_EAST;
300 else 302 else
301 return false; // The cursor must be outside the window. 303 return false; // The cursor must be outside the window.
302 } 304 }
303 return true; 305 return true;
304 } 306 }
305 307
306 } // namespace gtk_window_util 308 } // namespace gtk_window_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698