OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel_browser_window_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/gtk/browser_titlebar.h" | 9 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { | 463 bool PanelBrowserWindowGtk::IsAnimatingBounds() const { |
464 return bounds_animator_.get() && bounds_animator_->is_animating(); | 464 return bounds_animator_.get() && bounds_animator_->is_animating(); |
465 } | 465 } |
466 | 466 |
467 void PanelBrowserWindowGtk::WillProcessEvent(GdkEvent* event) { | 467 void PanelBrowserWindowGtk::WillProcessEvent(GdkEvent* event) { |
468 // Nothing to do. | 468 // Nothing to do. |
469 } | 469 } |
470 | 470 |
471 void PanelBrowserWindowGtk::DidProcessEvent(GdkEvent* event) { | 471 void PanelBrowserWindowGtk::DidProcessEvent(GdkEvent* event) { |
472 DCHECK(last_mouse_down_); | 472 DCHECK(last_mouse_down_); |
473 if (event->type != GDK_MOTION_NOTIFY || !panel_->draggable()) | 473 if (event->type != GDK_MOTION_NOTIFY || |
| 474 !panel_->manager()->CanDrag(panel_.get())) |
474 return; | 475 return; |
475 | 476 |
476 gdouble new_x_double; | 477 gdouble new_x_double; |
477 gdouble new_y_double; | 478 gdouble new_y_double; |
478 gdouble old_x_double; | 479 gdouble old_x_double; |
479 gdouble old_y_double; | 480 gdouble old_y_double; |
480 gdk_event_get_root_coords(event, &new_x_double, &new_y_double); | 481 gdk_event_get_root_coords(event, &new_x_double, &new_y_double); |
481 gdk_event_get_root_coords(last_mouse_down_, &old_x_double, &old_y_double); | 482 gdk_event_get_root_coords(last_mouse_down_, &old_x_double, &old_y_double); |
482 | 483 |
483 gint new_x = static_cast<gint>(new_x_double); | 484 gint new_x = static_cast<gint>(new_x_double); |
484 gint new_y = static_cast<gint>(new_y_double); | 485 gint new_y = static_cast<gint>(new_y_double); |
485 gint old_x = static_cast<gint>(old_x_double); | 486 gint old_x = static_cast<gint>(old_x_double); |
486 gint old_y = static_cast<gint>(old_y_double); | 487 gint old_y = static_cast<gint>(old_y_double); |
487 | 488 |
488 if (!drag_widget_ && | 489 if (!drag_widget_ && |
489 gtk_drag_check_threshold(titlebar_widget(), old_x, | 490 gtk_drag_check_threshold(titlebar_widget(), old_x, |
490 old_y, new_x, new_y)) { | 491 old_y, new_x, new_y)) { |
491 CreateDragWidget(); | 492 CreateDragWidget(); |
492 if (!system_drag_disabled_for_testing_) { | 493 if (!system_drag_disabled_for_testing_) { |
493 GtkTargetList* list = ui::GetTargetListFromCodeMask(ui::CHROME_TAB); | 494 GtkTargetList* list = ui::GetTargetListFromCodeMask(ui::CHROME_TAB); |
494 gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, 1, last_mouse_down_); | 495 gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, 1, last_mouse_down_); |
495 // gtk_drag_begin increments reference count for GtkTargetList. So unref | 496 // gtk_drag_begin increments reference count for GtkTargetList. So unref |
496 // it here to reduce the reference count. | 497 // it here to reduce the reference count. |
497 gtk_target_list_unref(list); | 498 gtk_target_list_unref(list); |
498 } | 499 } |
499 panel_->manager()->StartDragging(panel_.get()); | 500 panel_->manager()->StartDragging(panel_.get()); |
500 } | 501 } |
501 | 502 |
502 if (drag_widget_) { | 503 if (drag_widget_) { |
503 panel_->manager()->Drag(new_x - old_x); | 504 panel_->manager()->Drag(new_x - old_x, new_y - old_y); |
504 gdk_event_free(last_mouse_down_); | 505 gdk_event_free(last_mouse_down_); |
505 last_mouse_down_ = gdk_event_copy(event); | 506 last_mouse_down_ = gdk_event_copy(event); |
506 } | 507 } |
507 } | 508 } |
508 | 509 |
509 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { | 510 void PanelBrowserWindowGtk::AnimationEnded(const ui::Animation* animation) { |
510 titlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); | 511 titlebar()->SendEnterNotifyToCloseButtonIfUnderMouse(); |
511 | 512 |
512 content::NotificationService::current()->Notify( | 513 content::NotificationService::current()->Notify( |
513 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 514 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 } | 812 } |
812 } | 813 } |
813 | 814 |
814 bool NativePanelTestingGtk::IsWindowSizeKnown() const { | 815 bool NativePanelTestingGtk::IsWindowSizeKnown() const { |
815 return panel_browser_window_gtk_->window_size_known_; | 816 return panel_browser_window_gtk_->window_size_known_; |
816 } | 817 } |
817 | 818 |
818 bool NativePanelTestingGtk::IsAnimatingBounds() const { | 819 bool NativePanelTestingGtk::IsAnimatingBounds() const { |
819 return panel_browser_window_gtk_->IsAnimatingBounds(); | 820 return panel_browser_window_gtk_->IsAnimatingBounds(); |
820 } | 821 } |
OLD | NEW |