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

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

Issue 6257006: Move a bunch of random other files to src/ui/base... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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/hover_controller_gtk.h » ('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
11 #include <cstdarg> 11 #include <cstdarg>
12 #include <map> 12 #include <map>
13 13
14 #include "app/l10n_util.h" 14 #include "app/l10n_util.h"
15 #include "app/resource_bundle.h" 15 #include "app/resource_bundle.h"
16 #include "app/x11_util.h"
17 #include "base/environment.h" 16 #include "base/environment.h"
18 #include "base/i18n/rtl.h" 17 #include "base/i18n/rtl.h"
19 #include "base/linux_util.h" 18 #include "base/linux_util.h"
20 #include "base/logging.h" 19 #include "base/logging.h"
21 #include "base/nix/xdg_util.h" 20 #include "base/nix/xdg_util.h"
22 #include "base/string_number_conversions.h" 21 #include "base/string_number_conversions.h"
23 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
24 #include "chrome/browser/autocomplete/autocomplete.h" 23 #include "chrome/browser/autocomplete/autocomplete.h"
25 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 24 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
26 #include "chrome/browser/autocomplete/autocomplete_match.h" 25 #include "chrome/browser/autocomplete/autocomplete_match.h"
27 #include "chrome/browser/browser_list.h" 26 #include "chrome/browser/browser_list.h"
28 #include "chrome/browser/browser_window.h" 27 #include "chrome/browser/browser_window.h"
29 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/renderer_host/render_view_host.h" 29 #include "chrome/browser/renderer_host/render_view_host.h"
31 #include "chrome/browser/tab_contents/tab_contents.h" 30 #include "chrome/browser/tab_contents/tab_contents.h"
32 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" 31 #include "chrome/browser/ui/gtk/cairo_cached_surface.h"
33 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" 32 #include "chrome/browser/ui/gtk/gtk_theme_provider.h"
34 #include "chrome/common/renderer_preferences.h" 33 #include "chrome/common/renderer_preferences.h"
35 #include "gfx/gtk_util.h" 34 #include "gfx/gtk_util.h"
36 #include "googleurl/src/gurl.h" 35 #include "googleurl/src/gurl.h"
37 #include "grit/theme_resources.h" 36 #include "grit/theme_resources.h"
38 #include "third_party/skia/include/core/SkBitmap.h" 37 #include "third_party/skia/include/core/SkBitmap.h"
39 #include "third_party/skia/include/core/SkColor.h" 38 #include "third_party/skia/include/core/SkColor.h"
39 #include "ui/base/x/x11_util.h"
40 40
41 #if defined(OS_CHROMEOS) 41 #if defined(OS_CHROMEOS)
42 #include "chrome/browser/chromeos/frame/browser_view.h" 42 #include "chrome/browser/chromeos/frame/browser_view.h"
43 #include "chrome/browser/chromeos/native_dialog_window.h" 43 #include "chrome/browser/chromeos/native_dialog_window.h"
44 #include "chrome/browser/chromeos/options/options_window_view.h" 44 #include "chrome/browser/chromeos/options/options_window_view.h"
45 #include "views/window/window.h" 45 #include "views/window/window.h"
46 #else 46 #else
47 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 47 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
48 #endif 48 #endif
49 49
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 if (origin.x() < rect.x) 358 if (origin.x() < rect.x)
359 origin.set_x(rect.x); 359 origin.set_x(rect.x);
360 if (origin.y() < rect.y) 360 if (origin.y() < rect.y)
361 origin.set_y(rect.y); 361 origin.set_y(rect.y);
362 } 362 }
363 363
364 gtk_window_move(window, origin.x(), origin.y()); 364 gtk_window_move(window, origin.x(), origin.y());
365 365
366 // Move to user expected desktop if window is already visible. 366 // Move to user expected desktop if window is already visible.
367 if (GTK_WIDGET(window)->window) { 367 if (GTK_WIDGET(window)->window) {
368 x11_util::ChangeWindowDesktop( 368 ui::ChangeWindowDesktop(
369 x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(window)), 369 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window)),
370 x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(parent))); 370 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(parent)));
371 } 371 }
372 } 372 }
373 373
374 void MakeAppModalWindowGroup() { 374 void MakeAppModalWindowGroup() {
375 #if GTK_CHECK_VERSION(2, 14, 0) 375 #if GTK_CHECK_VERSION(2, 14, 0)
376 // Older versions of GTK+ don't give us gtk_window_group_list() which is what 376 // Older versions of GTK+ don't give us gtk_window_group_list() which is what
377 // we need to add current non-browser modal dialogs to the list. If 377 // we need to add current non-browser modal dialogs to the list. If
378 // we have 2.14+ we can do things the correct way. 378 // we have 2.14+ we can do things the correct way.
379 GtkWindowGroup* window_group = gtk_window_group_new(); 379 GtkWindowGroup* window_group = gtk_window_group_new();
380 for (BrowserList::const_iterator it = BrowserList::begin(); 380 for (BrowserList::const_iterator it = BrowserList::begin();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding); 539 gtk_box_pack_start(GTK_BOX(hbox), centering_vbox, FALSE, FALSE, padding);
540 540
541 return centering_vbox; 541 return centering_vbox;
542 } 542 }
543 543
544 bool IsScreenComposited() { 544 bool IsScreenComposited() {
545 GdkScreen* screen = gdk_screen_get_default(); 545 GdkScreen* screen = gdk_screen_get_default();
546 return gdk_screen_is_composited(screen) == TRUE; 546 return gdk_screen_is_composited(screen) == TRUE;
547 } 547 }
548 548
549 void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) { 549 void EnumerateTopLevelWindows(ui::EnumerateWindowsDelegate* delegate) {
550 std::vector<XID> stack; 550 std::vector<XID> stack;
551 if (!x11_util::GetXWindowStack(&stack)) { 551 if (!ui::GetXWindowStack(&stack)) {
552 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back 552 // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back
553 // to old school enumeration of all X windows. Some WMs parent 'top-level' 553 // to old school enumeration of all X windows. Some WMs parent 'top-level'
554 // windows in unnamed actual top-level windows (ion WM), so extend the 554 // windows in unnamed actual top-level windows (ion WM), so extend the
555 // search depth to all children of top-level windows. 555 // search depth to all children of top-level windows.
556 const int kMaxSearchDepth = 1; 556 const int kMaxSearchDepth = 1;
557 x11_util::EnumerateAllWindows(delegate, kMaxSearchDepth); 557 ui::EnumerateAllWindows(delegate, kMaxSearchDepth);
558 return; 558 return;
559 } 559 }
560 560
561 std::vector<XID>::iterator iter; 561 std::vector<XID>::iterator iter;
562 for (iter = stack.begin(); iter != stack.end(); iter++) { 562 for (iter = stack.begin(); iter != stack.end(); iter++) {
563 if (delegate->ShouldStopIterating(*iter)) 563 if (delegate->ShouldStopIterating(*iter))
564 return; 564 return;
565 } 565 }
566 } 566 }
567 567
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 DCHECK(GTK_IS_WINDOW(toplevel) && GTK_WIDGET_TOPLEVEL(toplevel) && 850 DCHECK(GTK_IS_WINDOW(toplevel) && GTK_WIDGET_TOPLEVEL(toplevel) &&
851 GTK_WIDGET_REALIZED(toplevel)); 851 GTK_WIDGET_REALIZED(toplevel));
852 852
853 // Stack the |popup| window directly above the |toplevel| window. 853 // Stack the |popup| window directly above the |toplevel| window.
854 // The popup window is a direct child of the root window, so we need to 854 // The popup window is a direct child of the root window, so we need to
855 // find a similar ancestor for the toplevel window (which might have been 855 // find a similar ancestor for the toplevel window (which might have been
856 // reparented by a window manager). We grab the server while we're doing 856 // reparented by a window manager). We grab the server while we're doing
857 // this -- otherwise, we'll get an error if the window manager reparents the 857 // this -- otherwise, we'll get an error if the window manager reparents the
858 // toplevel window right after we call GetHighestAncestorWindow(). 858 // toplevel window right after we call GetHighestAncestorWindow().
859 gdk_x11_display_grab(gtk_widget_get_display(toplevel)); 859 gdk_x11_display_grab(gtk_widget_get_display(toplevel));
860 XID toplevel_window_base = x11_util::GetHighestAncestorWindow( 860 XID toplevel_window_base = ui::GetHighestAncestorWindow(
861 x11_util::GetX11WindowFromGtkWidget(toplevel), 861 ui::GetX11WindowFromGtkWidget(toplevel),
862 x11_util::GetX11RootWindow()); 862 ui::GetX11RootWindow());
863 if (toplevel_window_base) { 863 if (toplevel_window_base) {
864 XID window_xid = x11_util::GetX11WindowFromGtkWidget(popup); 864 XID window_xid = ui::GetX11WindowFromGtkWidget(popup);
865 XID window_parent = x11_util::GetParentWindow(window_xid); 865 XID window_parent = ui::GetParentWindow(window_xid);
866 if (window_parent == x11_util::GetX11RootWindow()) { 866 if (window_parent == ui::GetX11RootWindow()) {
867 x11_util::RestackWindow(window_xid, toplevel_window_base, true); 867 ui::RestackWindow(window_xid, toplevel_window_base, true);
868 } else { 868 } else {
869 // The window manager shouldn't reparent override-redirect windows. 869 // The window manager shouldn't reparent override-redirect windows.
870 DLOG(ERROR) << "override-redirect window " << window_xid 870 DLOG(ERROR) << "override-redirect window " << window_xid
871 << "'s parent is " << window_parent 871 << "'s parent is " << window_parent
872 << ", rather than root window " 872 << ", rather than root window "
873 << x11_util::GetX11RootWindow(); 873 << ui::GetX11RootWindow();
874 } 874 }
875 } 875 }
876 gdk_x11_display_ungrab(gtk_widget_get_display(toplevel)); 876 gdk_x11_display_ungrab(gtk_widget_get_display(toplevel));
877 } 877 }
878 878
879 gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget) { 879 gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget) {
880 DCHECK(GTK_WIDGET_REALIZED(widget)); 880 DCHECK(GTK_WIDGET_REALIZED(widget));
881 881
882 GtkWidget* toplevel = gtk_widget_get_toplevel(widget); 882 GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
883 DCHECK(toplevel); 883 DCHECK(toplevel);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1241
1242 void DoCopy(BrowserWindow* window) { 1242 void DoCopy(BrowserWindow* window) {
1243 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); 1243 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard");
1244 } 1244 }
1245 1245
1246 void DoPaste(BrowserWindow* window) { 1246 void DoPaste(BrowserWindow* window) {
1247 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); 1247 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard");
1248 } 1248 }
1249 1249
1250 } // namespace gtk_util 1250 } // namespace gtk_util
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.h ('k') | chrome/browser/ui/gtk/hover_controller_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698