Index: chrome/browser/ui/gtk/gtk_util.cc |
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc |
index 8839f0a56c222e7c920dd6bc8dc080ad96184a93..843ea7ee7ef70bb4124ec89e33be2026763e08d2 100644 |
--- a/chrome/browser/ui/gtk/gtk_util.cc |
+++ b/chrome/browser/ui/gtk/gtk_util.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/ui/gtk/gtk_util.h" |
#include <cairo/cairo.h> |
+#include <dlfcn.h> |
#include <algorithm> |
#include <cstdarg> |
@@ -25,7 +26,6 @@ |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_list.h" |
-#include "chrome/browser/ui/browser_tabstrip.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/gtk/browser_window_gtk.h" |
#include "chrome/browser/ui/gtk/gtk_theme_service.h" |
@@ -278,16 +278,6 @@ gboolean PaintNoBackground(GtkWidget* widget, |
return TRUE; |
} |
-WebContents* GetBrowserWindowSelectedWebContents(BrowserWindow* window) { |
- BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( |
- window); |
- return chrome::GetActiveWebContents(browser_window->browser()); |
-} |
- |
-GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) { |
- return gtk_window_get_focus(window->GetNativeWindow()); |
-} |
- |
} // namespace |
namespace gtk_util { |
@@ -1013,16 +1003,16 @@ void ApplyMessageDialogQuirks(GtkWidget* dialog) { |
// against the current render view host, otherwise emit the specified |signal| |
// against the focused widget. |
// TODO(suzhe): This approach does not work for plugins. |
-void DoCutCopyPaste(BrowserWindow* window, |
+void DoCutCopyPaste(GtkWindow* window, |
+ WebContents* web_contents, |
void (RenderWidgetHost::*method)(), |
const char* signal) { |
- GtkWidget* widget = GetBrowserWindowFocusedWidget(window); |
+ GtkWidget* widget = gtk_window_get_focus(window); |
if (widget == NULL) |
return; // Do nothing if no focused widget. |
- WebContents* current_tab = GetBrowserWindowSelectedWebContents(window); |
- if (current_tab && widget == current_tab->GetContentNativeView()) { |
- (current_tab->GetRenderViewHost()->*method)(); |
+ if (web_contents && widget == web_contents->GetContentNativeView()) { |
+ (web_contents->GetRenderViewHost()->*method)(); |
} else { |
guint id; |
if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0) |
@@ -1030,16 +1020,63 @@ void DoCutCopyPaste(BrowserWindow* window, |
} |
} |
-void DoCut(BrowserWindow* window) { |
- DoCutCopyPaste(window, &RenderWidgetHost::Cut, "cut-clipboard"); |
+void DoCut(GtkWindow* window, WebContents* web_contents) { |
+ DoCutCopyPaste(window, web_contents, |
+ &RenderWidgetHost::Cut, "cut-clipboard"); |
} |
-void DoCopy(BrowserWindow* window) { |
- DoCutCopyPaste(window, &RenderWidgetHost::Copy, "copy-clipboard"); |
+void DoCopy(GtkWindow* window, WebContents* web_contents) { |
+ DoCutCopyPaste(window, web_contents, |
+ &RenderWidgetHost::Copy, "copy-clipboard"); |
} |
-void DoPaste(BrowserWindow* window) { |
- DoCutCopyPaste(window, &RenderWidgetHost::Paste, "paste-clipboard"); |
+void DoPaste(GtkWindow* window, WebContents* web_contents) { |
+ DoCutCopyPaste(window, web_contents, |
+ &RenderWidgetHost::Paste, "paste-clipboard"); |
+} |
+ |
+// Ubuntu patches their verrsion of GTK+ so that there is always a |
Evan Stade
2012/08/10 01:52:30
sp: verrsion
jennb
2012/08/10 18:45:42
Done.
|
+// gripper in the bottom right corner of the window. We dynamically |
+// look up this symbol because it's a non-standard Ubuntu extension to |
+// GTK+. We always need to disable this feature since we can't |
+// communicate this to WebKit easily. |
+typedef void (*gtk_window_set_has_resize_grip_func)(GtkWindow*, gboolean); |
+gtk_window_set_has_resize_grip_func gtk_window_set_has_resize_grip_sym; |
+ |
+void DisableResizeGrip(GtkWindow* window) { |
+ static bool resize_grip_looked_up = false; |
+ if (!resize_grip_looked_up) { |
+ resize_grip_looked_up = true; |
+ gtk_window_set_has_resize_grip_sym = |
+ reinterpret_cast<gtk_window_set_has_resize_grip_func>( |
+ dlsym(NULL, "gtk_window_set_has_resize_grip")); |
+ } |
+ if (gtk_window_set_has_resize_grip_sym) |
+ gtk_window_set_has_resize_grip_sym(window, FALSE); |
+} |
+ |
+GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge) { |
+ switch (edge) { |
+ case GDK_WINDOW_EDGE_NORTH_WEST: |
+ return GDK_TOP_LEFT_CORNER; |
+ case GDK_WINDOW_EDGE_NORTH: |
+ return GDK_TOP_SIDE; |
+ case GDK_WINDOW_EDGE_NORTH_EAST: |
+ return GDK_TOP_RIGHT_CORNER; |
+ case GDK_WINDOW_EDGE_WEST: |
+ return GDK_LEFT_SIDE; |
+ case GDK_WINDOW_EDGE_EAST: |
+ return GDK_RIGHT_SIDE; |
+ case GDK_WINDOW_EDGE_SOUTH_WEST: |
+ return GDK_BOTTOM_LEFT_CORNER; |
+ case GDK_WINDOW_EDGE_SOUTH: |
+ return GDK_BOTTOM_SIDE; |
+ case GDK_WINDOW_EDGE_SOUTH_EAST: |
+ return GDK_BOTTOM_RIGHT_CORNER; |
+ default: |
+ NOTREACHED(); |
+ } |
+ return GDK_LAST_CURSOR; |
} |
} // namespace gtk_util |