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

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

Issue 101009: Always simulate a mouse movement after animations in the Linux tabstrip to ma... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/tabs/tab_strip_gtk.h" 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
6 6
7 #include "base/gfx/gtk_util.h" 7 #include "base/gfx/gtk_util.h"
8 #include "base/gfx/point.h" 8 #include "base/gfx/point.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/gtk/tabs/tab_button_gtk.h" 10 #include "chrome/browser/gtk/tabs/tab_button_gtk.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return tab_width; 126 return tab_width;
127 } 127 }
128 128
129 // Overridden from AnimationDelegate: 129 // Overridden from AnimationDelegate:
130 virtual void AnimationProgressed(const Animation* animation) { 130 virtual void AnimationProgressed(const Animation* animation) {
131 tabstrip_->AnimationLayout(end_unselected_width_); 131 tabstrip_->AnimationLayout(end_unselected_width_);
132 } 132 }
133 133
134 virtual void AnimationEnded(const Animation* animation) { 134 virtual void AnimationEnded(const Animation* animation) {
135 tabstrip_->FinishAnimation(this, layout_on_completion_); 135 tabstrip_->FinishAnimation(this, layout_on_completion_);
136 // TODO(jhawkins): Remove this once each tab is its own widget.
137 SimulateMouseMotion();
136 // This object is destroyed now, so we can't do anything else after this. 138 // This object is destroyed now, so we can't do anything else after this.
137 } 139 }
138 140
139 virtual void AnimationCanceled(const Animation* animation) { 141 virtual void AnimationCanceled(const Animation* animation) {
140 AnimationEnded(animation); 142 AnimationEnded(animation);
141 } 143 }
142 144
143 protected: 145 protected:
144 // Returns the duration of the animation. 146 // Returns the duration of the animation.
145 virtual int GetDuration() const { 147 virtual int GetDuration() const {
(...skipping 30 matching lines...) Expand all
176 178
177 TabStripGtk* tabstrip_; 179 TabStripGtk* tabstrip_;
178 SlideAnimation animation_; 180 SlideAnimation animation_;
179 181
180 double start_selected_width_; 182 double start_selected_width_;
181 double start_unselected_width_; 183 double start_unselected_width_;
182 double end_selected_width_; 184 double end_selected_width_;
183 double end_unselected_width_; 185 double end_unselected_width_;
184 186
185 private: 187 private:
188 // When the animation completes, we send the Container a message to simulate
189 // a mouse moved event at the current mouse position. This tickles the Tab
190 // the mouse is currently over to show the "hot" state of the close button, or
191 // resets the hover index if it's now stale.
192 void SimulateMouseMotion() {
193 // Get default display and screen.
194 GdkDisplay* display = gdk_display_get_default();
195 GdkScreen* screen = gdk_display_get_default_screen(display);
196
197 // Get cursor position.
198 int x, y;
199 gdk_display_get_pointer(display, NULL, &x, &y, NULL);
200
201 // Reset cursor position.
202 gdk_display_warp_pointer(display, screen, x, y);
203 }
204
186 // True if a complete re-layout is required upon completion of the animation. 205 // True if a complete re-layout is required upon completion of the animation.
187 // Subclasses set this if they don't perform a complete layout 206 // Subclasses set this if they don't perform a complete layout
188 // themselves and canceling the animation may leave the strip in an 207 // themselves and canceling the animation may leave the strip in an
189 // inconsistent state. 208 // inconsistent state.
190 bool layout_on_completion_; 209 bool layout_on_completion_;
191 210
192 const Type type_; 211 const Type type_;
193 212
194 DISALLOW_COPY_AND_ASSIGN(TabAnimation); 213 DISALLOW_COPY_AND_ASSIGN(TabAnimation);
195 }; 214 };
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 double delta = end_selected_width_ - start_selected_width_; 306 double delta = end_selected_width_ - start_selected_width_;
288 return start_selected_width_ + (delta * animation_.GetCurrentValue()); 307 return start_selected_width_ + (delta * animation_.GetCurrentValue());
289 } 308 }
290 309
291 double delta = end_unselected_width_ - start_unselected_width_; 310 double delta = end_unselected_width_ - start_unselected_width_;
292 return start_unselected_width_ + (delta * animation_.GetCurrentValue()); 311 return start_unselected_width_ + (delta * animation_.GetCurrentValue());
293 } 312 }
294 313
295 virtual void AnimationEnded(const Animation* animation) { 314 virtual void AnimationEnded(const Animation* animation) {
296 tabstrip_->RemoveTabAt(index_); 315 tabstrip_->RemoveTabAt(index_);
297 HighlightCloseButton();
298 TabStripGtk::TabAnimation::AnimationEnded(animation); 316 TabStripGtk::TabAnimation::AnimationEnded(animation);
299 } 317 }
300 318
301 private: 319 private:
302 // When the animation completes, we send the Container a message to simulate
303 // a mouse moved event at the current mouse position. This tickles the Tab
304 // the mouse is currently over to show the "hot" state of the close button.
305 void HighlightCloseButton() {
306 if (tabstrip_->available_width_for_tabs_ == -1) {
307 // This function is not required (and indeed may crash!) for removes
308 // spawned by non-mouse closes and drag-detaches.
309 return;
310 }
311
312 // Get default display and screen.
313 GdkDisplay* display = gdk_display_get_default();
314 GdkScreen* screen = gdk_display_get_default_screen(display);
315
316 // Get cursor position.
317 int x, y;
318 gdk_display_get_pointer(display, NULL, &x, &y, NULL);
319
320 // Reset cusor position.
321 gdk_display_warp_pointer(display, screen, x, y);
322 }
323
324 int index_; 320 int index_;
325 321
326 DISALLOW_COPY_AND_ASSIGN(RemoveTabAnimation); 322 DISALLOW_COPY_AND_ASSIGN(RemoveTabAnimation);
327 }; 323 };
328 324
329 //////////////////////////////////////////////////////////////////////////////// 325 ////////////////////////////////////////////////////////////////////////////////
330 326
331 // Handles the movement of a Tab from one position to another. 327 // Handles the movement of a Tab from one position to another.
332 class MoveTabAnimation : public TabStripGtk::TabAnimation { 328 class MoveTabAnimation : public TabStripGtk::TabAnimation {
333 public: 329 public:
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 return TabStripModel::kNoTab; 1456 return TabStripModel::kNoTab;
1461 } 1457 }
1462 1458
1463 int TabStripGtk::NormalizeIndexToAttachedTabStrip(int index) { 1459 int TabStripGtk::NormalizeIndexToAttachedTabStrip(int index) {
1464 if (index >= model_->count()) 1460 if (index >= model_->count())
1465 return model_->count() - 1; 1461 return model_->count() - 1;
1466 if (index == TabStripModel::kNoTab) 1462 if (index == TabStripModel::kNoTab)
1467 return 0; 1463 return 0;
1468 return index; 1464 return index;
1469 } 1465 }
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