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

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc

Issue 8414004: GTK: Constrain the clip area on tabstrip draws. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add comment for estade Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 qsort(rects, num_rects, sizeof(GdkRectangle), CompareGdkRectangles); 2000 qsort(rects, num_rects, sizeof(GdkRectangle), CompareGdkRectangles);
2001 std::vector<int> tabs_to_repaint; 2001 std::vector<int> tabs_to_repaint;
2002 if (!IsDragSessionActive() && 2002 if (!IsDragSessionActive() &&
2003 CanPaintOnlyFavicons(rects, num_rects, &tabs_to_repaint)) { 2003 CanPaintOnlyFavicons(rects, num_rects, &tabs_to_repaint)) {
2004 PaintOnlyFavicons(event, tabs_to_repaint); 2004 PaintOnlyFavicons(event, tabs_to_repaint);
2005 g_free(rects); 2005 g_free(rects);
2006 return TRUE; 2006 return TRUE;
2007 } 2007 }
2008 g_free(rects); 2008 g_free(rects);
2009 2009
2010 // TODO(jhawkins): Ideally we'd like to only draw what's needed in the damage 2010 // Ideally we'd like to only draw what's needed in the damage rect, but the
2011 // rect, but the tab widgets overlap each other, and painting on one widget 2011 // tab widgets overlap each other. To get the proper visual look, we need to
2012 // will cause an expose-event to be sent to the widgets underneath. The 2012 // draw tabs from the rightmost to the leftmost tab. So if we have a dirty
2013 // underlying widget does not need to be redrawn as we control the order of 2013 // rectangle in the center of the tabstrip, we'll have to draw all the tabs
2014 // expose-events. Currently we hack it to redraw the entire tabstrip. We 2014 // to the left of it.
2015 // could change the damage rect to just contain the tabs + the new tab button. 2015 //
2016 // TODO(erg): Figure out why we can't have clip rects that don't start from
2017 // x=0. jhawkins had a big comment here about how painting on one widget will
2018 // cause an expose-event to be sent to the widgets underneath, but that
2019 // should still obey clip rects, but doesn't seem to.
2020 if (active_animation_.get() || drag_controller_.get()) {
2021 // If we have an active animation or the tab is being dragged, no matter
2022 // what GTK tells us our dirty rectangles are, we need to redraw the entire
2023 // tabstrip.
2024 event->area.width = bounds_.width();
2025 } else {
2026 // Expand whatever dirty rectangle we were given to the area from the
2027 // leftmost edge of the tabstrip to the rightmost edge of the dirty
2028 // rectangle given.
2029 //
2030 // Doing this frees up CPU when redrawing the tabstrip with throbbing
2031 // tabs. The most likely tabs to throb are pinned or minitabs which live on
2032 // the very leftmost of the tabstrip.
2033 event->area.width += event->area.x;
2034 }
2035
2016 event->area.x = 0; 2036 event->area.x = 0;
2017 event->area.y = 0; 2037 event->area.y = 0;
2018 event->area.width = bounds_.width();
2019 event->area.height = bounds_.height(); 2038 event->area.height = bounds_.height();
2020 gdk_region_union_with_rect(event->region, &event->area); 2039 gdk_region_union_with_rect(event->region, &event->area);
2021 2040
2022 // Paint the New Tab button. 2041 // Paint the New Tab button.
2023 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()), 2042 gtk_container_propagate_expose(GTK_CONTAINER(tabstrip_.get()),
2024 newtab_button_->widget(), event); 2043 newtab_button_->widget(), event);
2025 2044
2026 // Paint the tabs in reverse order, so they stack to the left. 2045 // Paint the tabs in reverse order, so they stack to the left.
2027 TabGtk* selected_tab = NULL; 2046 TabGtk* selected_tab = NULL;
2028 int tab_count = GetTabCount(); 2047 int tab_count = GetTabCount();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 2212
2194 // Let the middle mouse button initiate clicks as well. 2213 // Let the middle mouse button initiate clicks as well.
2195 gtk_util::SetButtonTriggersNavigation(button->widget()); 2214 gtk_util::SetButtonTriggersNavigation(button->widget());
2196 g_signal_connect(button->widget(), "clicked", 2215 g_signal_connect(button->widget(), "clicked",
2197 G_CALLBACK(OnNewTabClickedThunk), this); 2216 G_CALLBACK(OnNewTabClickedThunk), this);
2198 gtk_widget_set_can_focus(button->widget(), FALSE); 2217 gtk_widget_set_can_focus(button->widget(), FALSE);
2199 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); 2218 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0);
2200 2219
2201 return button; 2220 return button;
2202 } 2221 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698