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

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

Issue 8196001: content: Split web_drag_dest_gtk.cc into chrome/ and content/ parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix viewgtk compile Created 9 years, 2 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 | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/tab_contents_drag_source.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_util.h" 5 #include "chrome/browser/ui/gtk/gtk_util.h"
6 6
7 #include <cairo/cairo.h> 7 #include <cairo/cairo.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ui/gfx/gtk_util.h" 45 #include "ui/gfx/gtk_util.h"
46 #include "ui/gfx/image/image.h" 46 #include "ui/gfx/image/image.h"
47 47
48 #if defined(OS_CHROMEOS) 48 #if defined(OS_CHROMEOS)
49 #include "chrome/browser/chromeos/frame/browser_view.h" 49 #include "chrome/browser/chromeos/frame/browser_view.h"
50 #include "chrome/browser/chromeos/native_dialog_window.h" 50 #include "chrome/browser/chromeos/native_dialog_window.h"
51 #else 51 #else
52 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 52 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
53 #endif 53 #endif
54 54
55 using WebKit::WebDragOperationsMask;
56 using WebKit::WebDragOperation;
57 using WebKit::WebDragOperationNone;
58 using WebKit::WebDragOperationCopy;
59 using WebKit::WebDragOperationLink;
60 using WebKit::WebDragOperationMove;
61
62 namespace { 55 namespace {
63 56
64 #if defined(GOOGLE_CHROME_BUILD) 57 #if defined(GOOGLE_CHROME_BUILD)
65 static const char* kIconName = "google-chrome"; 58 static const char* kIconName = "google-chrome";
66 #else 59 #else
67 static const char* kIconName = "chromium-browser"; 60 static const char* kIconName = "chromium-browser";
68 #endif 61 #endif
69 62
70 const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>"; 63 const char kBoldLabelMarkup[] = "<span weight='bold'>%s</span>";
71 64
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0); 494 GtkWidget* centering_vbox = gtk_vbox_new(FALSE, 0);
502 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0); 495 gtk_box_pack_start(GTK_BOX(centering_vbox), widget, TRUE, FALSE, 0);
503 if (pack_at_end) 496 if (pack_at_end)
504 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); 497 gtk_box_pack_end(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding);
505 else 498 else
506 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); 499 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding);
507 500
508 return centering_vbox; 501 return centering_vbox;
509 } 502 }
510 503
511 bool IsScreenComposited() {
512 GdkScreen* screen = gdk_screen_get_default();
513 return gdk_screen_is_composited(screen) == TRUE;
514 }
515
516 void EnumerateTopLevelWindows(ui::EnumerateWindowsDelegate* delegate) { 504 void EnumerateTopLevelWindows(ui::EnumerateWindowsDelegate* delegate) {
517 std::vector<XID> stack; 505 std::vector<XID> stack;
518 if (!ui::GetXWindowStack(ui::GetX11RootWindow(), &stack)) { 506 if (!ui::GetXWindowStack(ui::GetX11RootWindow(), &stack)) {
519 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back 507 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back
520 // to old school enumeration of all X windows. Some WMs parent 'top-level' 508 // to old school enumeration of all X windows. Some WMs parent 'top-level'
521 // windows in unnamed actual top-level windows (ion WM), so extend the 509 // windows in unnamed actual top-level windows (ion WM), so extend the
522 // search depth to all children of top-level windows. 510 // search depth to all children of top-level windows.
523 const int kMaxSearchDepth = 1; 511 const int kMaxSearchDepth = 1;
524 ui::EnumerateAllWindows(delegate, kMaxSearchDepth); 512 ui::EnumerateAllWindows(delegate, kMaxSearchDepth);
525 return; 513 return;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; 701 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
714 } 702 }
715 } 703 }
716 704
717 if (hint_style) 705 if (hint_style)
718 g_free(hint_style); 706 g_free(hint_style);
719 if (rgba_style) 707 if (rgba_style)
720 g_free(rgba_style); 708 g_free(rgba_style);
721 } 709 }
722 710
723 gfx::Point ScreenPoint(GtkWidget* widget) {
724 int x, y;
725 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y,
726 NULL);
727 return gfx::Point(x, y);
728 }
729
730 gfx::Point ClientPoint(GtkWidget* widget) {
731 int x, y;
732 gtk_widget_get_pointer(widget, &x, &y);
733 return gfx::Point(x, y);
734 }
735
736 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { 711 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) {
737 GdkPoint point = {ltr ? x : width - x, y}; 712 GdkPoint point = {ltr ? x : width - x, y};
738 return point; 713 return point;
739 } 714 }
740 715
741 std::string BuildTooltipTitleFor(string16 title, const GURL& url) { 716 std::string BuildTooltipTitleFor(string16 title, const GURL& url) {
742 const std::string& url_str = url.possibly_invalid_spec(); 717 const std::string& url_str = url.possibly_invalid_spec();
743 const std::string& title_str = UTF16ToUTF8(title); 718 const std::string& title_str = UTF16ToUTF8(title);
744 719
745 std::string truncated_url = UTF16ToUTF8(ui::TruncateString( 720 std::string truncated_url = UTF16ToUTF8(ui::TruncateString(
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1151
1177 void InitLabelSizeRequestAndEllipsizeMode(GtkWidget* label) { 1152 void InitLabelSizeRequestAndEllipsizeMode(GtkWidget* label) {
1178 GtkRequisition size; 1153 GtkRequisition size;
1179 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_NONE); 1154 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_NONE);
1180 gtk_widget_set_size_request(label, -1, -1); 1155 gtk_widget_set_size_request(label, -1, -1);
1181 gtk_widget_size_request(label, &size); 1156 gtk_widget_size_request(label, &size);
1182 gtk_widget_set_size_request(label, size.width, size.height); 1157 gtk_widget_set_size_request(label, size.width, size.height);
1183 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); 1158 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
1184 } 1159 }
1185 1160
1186 GdkDragAction WebDragOpToGdkDragAction(WebDragOperationsMask op) {
1187 GdkDragAction action = static_cast<GdkDragAction>(0);
1188 if (op & WebDragOperationCopy)
1189 action = static_cast<GdkDragAction>(action | GDK_ACTION_COPY);
1190 if (op & WebDragOperationLink)
1191 action = static_cast<GdkDragAction>(action | GDK_ACTION_LINK);
1192 if (op & WebDragOperationMove)
1193 action = static_cast<GdkDragAction>(action | GDK_ACTION_MOVE);
1194 return action;
1195 }
1196
1197 WebDragOperationsMask GdkDragActionToWebDragOp(GdkDragAction action) {
1198 WebDragOperationsMask op = WebDragOperationNone;
1199 if (action & GDK_ACTION_COPY)
1200 op = static_cast<WebDragOperationsMask>(op | WebDragOperationCopy);
1201 if (action & GDK_ACTION_LINK)
1202 op = static_cast<WebDragOperationsMask>(op | WebDragOperationLink);
1203 if (action & GDK_ACTION_MOVE)
1204 op = static_cast<WebDragOperationsMask>(op | WebDragOperationMove);
1205 return op;
1206 }
1207
1208 void ApplyMessageDialogQuirks(GtkWidget* dialog) { 1161 void ApplyMessageDialogQuirks(GtkWidget* dialog) {
1209 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { 1162 if (gtk_window_get_modal(GTK_WINDOW(dialog))) {
1210 // Work around a KDE 3 window manager bug. 1163 // Work around a KDE 3 window manager bug.
1211 scoped_ptr<base::Environment> env(base::Environment::Create()); 1164 scoped_ptr<base::Environment> env(base::Environment::Create());
1212 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 == 1165 if (base::nix::DESKTOP_ENVIRONMENT_KDE3 ==
1213 base::nix::GetDesktopEnvironment(env.get())) 1166 base::nix::GetDesktopEnvironment(env.get()))
1214 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); 1167 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
1215 } 1168 }
1216 } 1169 }
1217 1170
(...skipping 25 matching lines...) Expand all
1243 1196
1244 void DoCopy(BrowserWindow* window) { 1197 void DoCopy(BrowserWindow* window) {
1245 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); 1198 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard");
1246 } 1199 }
1247 1200
1248 void DoPaste(BrowserWindow* window) { 1201 void DoPaste(BrowserWindow* window) {
1249 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); 1202 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard");
1250 } 1203 }
1251 1204
1252 } // namespace gtk_util 1205 } // namespace gtk_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/tab_contents_drag_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698