Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_browser_window_gtk.cc |
| diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.cc b/chrome/browser/ui/panels/panel_browser_window_gtk.cc |
| index 571291e85c28086f5954c01b7beda3e19da406a8..ffa884b58cc18f54af23caebf2fa4126f8c4f95d 100644 |
| --- a/chrome/browser/ui/panels/panel_browser_window_gtk.cc |
| +++ b/chrome/browser/ui/panels/panel_browser_window_gtk.cc |
| @@ -181,10 +181,6 @@ void PanelBrowserWindowGtk::DestroyPanelBrowser() { |
| DestroyBrowser(); |
| } |
| -NativePanelTesting* PanelBrowserWindowGtk::GetNativePanelTesting() { |
| - return this; |
| -} |
| - |
| void PanelBrowserWindowGtk::SetBoundsImpl() { |
| gtk_window_move(window_, bounds_.x(), bounds_.y()); |
| gtk_window_resize(window(), bounds_.width(), bounds_.height()); |
| @@ -201,12 +197,15 @@ void PanelBrowserWindowGtk::DidProcessEvent(GdkEvent* event) { |
| gdouble new_x_double; |
| gdouble new_y_double; |
| + gdouble old_x_double; |
| + gdouble old_y_double; |
| gdk_event_get_root_coords(event, &new_x_double, &new_y_double); |
| + gdk_event_get_root_coords(last_mouse_down_, &old_x_double, &old_y_double); |
| gint new_x = static_cast<gint>(new_x_double); |
| gint new_y = static_cast<gint>(new_y_double); |
| - gint old_x = static_cast<gint>(last_mouse_down_->button.x_root); |
| - gint old_y = static_cast<gint>(last_mouse_down_->button.y_root); |
| + gint old_x = static_cast<gint>(old_x_double); |
| + gint old_y = static_cast<gint>(old_y_double); |
| if (drag_widget_) { |
| panel_->manager()->Drag(new_x - old_x); |
| @@ -315,3 +314,78 @@ gboolean PanelBrowserWindowGtk::OnDragButtonReleased(GtkWidget* widget, |
| &PanelBrowserWindowGtk::EndDrag, false)); |
| return TRUE; |
| } |
| + |
| +// NativePanelTesting implementation. |
| +class NativePanelTestingGtk : public NativePanelTesting { |
|
jianli
2011/08/11 20:52:09
Please move this subclass to the anonymous namespa
prasadt
2011/08/11 21:07:56
Need it in header file.
|
| + public: |
| + explicit NativePanelTestingGtk( |
| + PanelBrowserWindowGtk* panel_browser_window_gtk); |
| + |
| + private: |
| + virtual void PressLeftMouseButtonTitlebar( |
| + const gfx::Point& point) OVERRIDE; |
| + virtual void ReleaseMouseButtonTitlebar() OVERRIDE; |
| + virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; |
| + virtual void CancelDragTitlebar() OVERRIDE; |
| + virtual void FinishDragTitlebar() OVERRIDE; |
| + |
| + PanelBrowserWindowGtk* panel_browser_window_gtk_; |
| +}; |
| + |
| +NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
|
jianli
2011/08/11 20:52:09
Please add the comment for indicate it is static.
prasadt
2011/08/11 21:07:56
Done.
|
| + return new NativePanelTestingGtk(static_cast<PanelBrowserWindowGtk*>( |
| + native_panel)); |
| +} |
| + |
| +NativePanelTestingGtk::NativePanelTestingGtk( |
| + PanelBrowserWindowGtk* panel_browser_window_gtk) : |
| + panel_browser_window_gtk_(panel_browser_window_gtk) { |
| +} |
| + |
| +void NativePanelTestingGtk::PressLeftMouseButtonTitlebar( |
| + const gfx::Point& point) { |
| + GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS); |
| + event->button.button = 1; |
| + event->button.x_root = point.x(); |
| + event->button.y_root = point.y(); |
| + panel_browser_window_gtk_->OnTitlebarButtonPressEvent( |
| + panel_browser_window_gtk_->titlebar_widget(), |
| + reinterpret_cast<GdkEventButton*>(event)); |
| + gdk_event_free(event); |
| + MessageLoopForUI::current()->RunAllPending(); |
| +} |
| + |
| +void NativePanelTestingGtk::ReleaseMouseButtonTitlebar() { |
| + panel_browser_window_gtk_->OnTitlebarButtonReleaseEvent(NULL, NULL); |
| + MessageLoopForUI::current()->RunAllPending(); |
| +} |
| + |
| +void NativePanelTestingGtk::DragTitlebar(int delta_x, int delta_y) { |
| + if (!panel_browser_window_gtk_->drag_widget_) { |
| + panel_browser_window_gtk_->CreateDragWidget(); |
| + panel_browser_window_gtk_->panel_->manager()->StartDragging( |
| + panel_browser_window_gtk_->panel_.get()); |
| + } |
| + GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); |
| + gdk_event_get_root_coords(panel_browser_window_gtk_->last_mouse_down_, |
| + &event->motion.x_root, &event->motion.y_root); |
| + event->motion.x_root += delta_x; |
| + event->motion.y_root += delta_y; |
| + panel_browser_window_gtk_->DidProcessEvent(event); |
| + gdk_event_free(event); |
| + MessageLoopForUI::current()->RunAllPending(); |
| +} |
| + |
| +void NativePanelTestingGtk::CancelDragTitlebar() { |
| + panel_browser_window_gtk_->OnDragFailed( |
| + panel_browser_window_gtk_->drag_widget_, NULL, |
| + GTK_DRAG_RESULT_USER_CANCELLED); |
| + MessageLoopForUI::current()->RunAllPending(); |
| +} |
| + |
| +void NativePanelTestingGtk::FinishDragTitlebar() { |
| + panel_browser_window_gtk_->OnDragFailed( |
| + panel_browser_window_gtk_->drag_widget_, NULL, |
| + GTK_DRAG_RESULT_NO_TARGET); |
| + MessageLoopForUI::current()->RunAllPending(); |
| +} |