OLD | NEW |
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/find_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 730 |
731 return point; | 731 return point; |
732 } | 732 } |
733 | 733 |
734 // static | 734 // static |
735 void FindBarGtk::OnParentSet(GtkWidget* widget, GtkObject* old_parent, | 735 void FindBarGtk::OnParentSet(GtkWidget* widget, GtkObject* old_parent, |
736 FindBarGtk* find_bar) { | 736 FindBarGtk* find_bar) { |
737 if (!widget->parent) | 737 if (!widget->parent) |
738 return; | 738 return; |
739 | 739 |
740 g_signal_connect(widget->parent, "set-floating-position", | 740 g_signal_connect(gtk_widget_get_parent(widget), "set-floating-position", |
741 G_CALLBACK(OnSetFloatingPosition), find_bar); | 741 G_CALLBACK(OnSetFloatingPosition), find_bar); |
742 } | 742 } |
743 | 743 |
744 // static | 744 // static |
745 void FindBarGtk::OnSetFloatingPosition(GtkFloatingContainer* floating_container, | 745 void FindBarGtk::OnSetFloatingPosition(GtkFloatingContainer* floating_container, |
746 GtkAllocation* allocation, | 746 GtkAllocation* allocation, |
747 FindBarGtk* find_bar) { | 747 FindBarGtk* find_bar) { |
748 GtkWidget* findbar = find_bar->widget(); | 748 GtkWidget* findbar = find_bar->widget(); |
749 | 749 |
750 int xposition = find_bar->GetDialogPosition(find_bar->selection_rect_).x(); | 750 int xposition = find_bar->GetDialogPosition(find_bar->selection_rect_).x(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 | 846 |
847 if (bar->theme_service_->UsingNativeTheme()) { | 847 if (bar->theme_service_->UsingNativeTheme()) { |
848 if (bar->container_width_ != allocation.width || | 848 if (bar->container_width_ != allocation.width || |
849 bar->container_height_ != allocation.height) { | 849 bar->container_height_ != allocation.height) { |
850 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( | 850 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( |
851 allocation.width, allocation.height, FRAME_MASK); | 851 allocation.width, allocation.height, FRAME_MASK); |
852 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], | 852 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], |
853 mask_points.size(), | 853 mask_points.size(), |
854 GDK_EVEN_ODD_RULE); | 854 GDK_EVEN_ODD_RULE); |
855 // Reset the shape. | 855 // Reset the shape. |
856 gdk_window_shape_combine_region(widget->window, NULL, 0, 0); | 856 GdkWindow* gdk_window = gtk_widget_get_window(widget); |
857 gdk_window_shape_combine_region(widget->window, mask_region, 0, 0); | 857 gdk_window_shape_combine_region(gdk_window, NULL, 0, 0); |
| 858 gdk_window_shape_combine_region(gdk_window, mask_region, 0, 0); |
858 gdk_region_destroy(mask_region); | 859 gdk_region_destroy(mask_region); |
859 | 860 |
860 bar->container_width_ = allocation.width; | 861 bar->container_width_ = allocation.width; |
861 bar->container_height_ = allocation.height; | 862 bar->container_height_ = allocation.height; |
862 } | 863 } |
863 | 864 |
864 GdkDrawable* drawable = GDK_DRAWABLE(e->window); | 865 GdkDrawable* drawable = GDK_DRAWABLE(e->window); |
865 GdkGC* gc = gdk_gc_new(drawable); | 866 GdkGC* gc = gdk_gc_new(drawable); |
866 gdk_gc_set_clip_rectangle(gc, &e->area); | 867 gdk_gc_set_clip_rectangle(gc, &e->area); |
867 GdkColor color = bar->theme_service_->GetBorderColor(); | 868 GdkColor color = bar->theme_service_->GetBorderColor(); |
868 gdk_gc_set_rgb_fg_color(gc, &color); | 869 gdk_gc_set_rgb_fg_color(gc, &color); |
869 | 870 |
870 // Stroke the frame border. | 871 // Stroke the frame border. |
871 std::vector<GdkPoint> points = MakeFramePolygonPoints( | 872 std::vector<GdkPoint> points = MakeFramePolygonPoints( |
872 allocation.width, allocation.height, FRAME_STROKE); | 873 allocation.width, allocation.height, FRAME_STROKE); |
873 gdk_draw_lines(drawable, gc, &points[0], points.size()); | 874 gdk_draw_lines(drawable, gc, &points[0], points.size()); |
874 | 875 |
875 g_object_unref(gc); | 876 g_object_unref(gc); |
876 } else { | 877 } else { |
877 if (bar->container_width_ != allocation.width || | 878 if (bar->container_width_ != allocation.width || |
878 bar->container_height_ != allocation.height) { | 879 bar->container_height_ != allocation.height) { |
879 // Reset the shape. | 880 // Reset the shape. |
880 gdk_window_shape_combine_region(widget->window, NULL, 0, 0); | 881 gdk_window_shape_combine_region(gtk_widget_get_window(widget), |
| 882 NULL, 0, 0); |
881 SetDialogShape(bar->container_); | 883 SetDialogShape(bar->container_); |
882 | 884 |
883 bar->container_width_ = allocation.width; | 885 bar->container_width_ = allocation.width; |
884 bar->container_height_ = allocation.height; | 886 bar->container_height_ = allocation.height; |
885 } | 887 } |
886 | 888 |
887 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 889 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
888 gdk_cairo_rectangle(cr, &e->area); | 890 gdk_cairo_rectangle(cr, &e->area); |
889 cairo_clip(cr); | 891 cairo_clip(cr); |
890 | 892 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 return FALSE; // Continue propagation. | 988 return FALSE; // Continue propagation. |
987 } | 989 } |
988 | 990 |
989 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { | 991 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { |
990 g_signal_handlers_disconnect_by_func( | 992 g_signal_handlers_disconnect_by_func( |
991 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), | 993 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), |
992 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); | 994 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); |
993 | 995 |
994 return FALSE; // Continue propagation. | 996 return FALSE; // Continue propagation. |
995 } | 997 } |
OLD | NEW |