OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 "window_manager/mock_chrome.h" | 5 #include "window_manager/mock_chrome.h" |
6 | 6 |
7 #include <cairomm/context.h> | 7 #include <cairomm/context.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 bool PanelTitlebar::on_button_press_event(GdkEventButton* event) { | 737 bool PanelTitlebar::on_button_press_event(GdkEventButton* event) { |
738 if (event->button == 2) { | 738 if (event->button == 2) { |
739 panel_->chrome()->ClosePanel(panel_); | 739 panel_->chrome()->ClosePanel(panel_); |
740 return true; | 740 return true; |
741 } else if (event->button != 1) { | 741 } else if (event->button != 1) { |
742 return false; | 742 return false; |
743 } | 743 } |
744 mouse_down_ = true; | 744 mouse_down_ = true; |
745 mouse_down_abs_x_ = event->x_root; | 745 mouse_down_abs_x_ = event->x_root; |
746 mouse_down_abs_y_ = event->y_root; | 746 mouse_down_abs_y_ = event->y_root; |
747 mouse_down_offset_x_ = event->x; | 747 |
| 748 int width = 1, height = 1; |
| 749 get_size(width, height); |
| 750 mouse_down_offset_x_ = event->x - width; |
748 mouse_down_offset_y_ = event->y; | 751 mouse_down_offset_y_ = event->y; |
749 dragging_ = false; | 752 dragging_ = false; |
750 return true; | 753 return true; |
751 } | 754 } |
752 | 755 |
753 bool PanelTitlebar::on_button_release_event(GdkEventButton* event) { | 756 bool PanelTitlebar::on_button_release_event(GdkEventButton* event) { |
754 if (event->button != 1) { | 757 if (event->button != 1) { |
755 return false; | 758 return false; |
756 } | 759 } |
757 // Only handle clicks that started in our window. | 760 // Only handle clicks that started in our window. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 return false; | 792 return false; |
790 } | 793 } |
791 | 794 |
792 if (!dragging_) { | 795 if (!dragging_) { |
793 if (abs(event->x_root - mouse_down_abs_x_) >= kDragThreshold || | 796 if (abs(event->x_root - mouse_down_abs_x_) >= kDragThreshold || |
794 abs(event->y_root - mouse_down_abs_y_) >= kDragThreshold) { | 797 abs(event->y_root - mouse_down_abs_y_) >= kDragThreshold) { |
795 dragging_ = true; | 798 dragging_ = true; |
796 } | 799 } |
797 } | 800 } |
798 if (dragging_) { | 801 if (dragging_) { |
799 WmIpc::Message msg(WmIpc::Message::WM_MOVE_PANEL); | 802 WmIpc::Message msg(WmIpc::Message::WM_NOTIFY_PANEL_DRAGGED); |
800 msg.set_param(0, panel_->xid()); | 803 msg.set_param(0, panel_->xid()); |
801 msg.set_param(1, event->x_root - mouse_down_offset_x_); | 804 msg.set_param(1, event->x_root - mouse_down_offset_x_); |
802 msg.set_param(2, event->y_root - mouse_down_offset_y_); | 805 msg.set_param(2, event->y_root - mouse_down_offset_y_); |
803 CHECK(panel_->chrome()->wm_ipc()->SendMessage( | 806 CHECK(panel_->chrome()->wm_ipc()->SendMessage( |
804 panel_->chrome()->wm_ipc()->wm_window(), msg)); | 807 panel_->chrome()->wm_ipc()->wm_window(), msg)); |
805 } | 808 } |
806 return true; | 809 return true; |
807 } | 810 } |
808 | 811 |
809 Panel::Panel(MockChrome* chrome, | 812 Panel::Panel(MockChrome* chrome, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 titlebar_->set_focused(false); | 879 titlebar_->set_focused(false); |
877 titlebar_->Draw(); | 880 titlebar_->Draw(); |
878 return true; | 881 return true; |
879 } | 882 } |
880 | 883 |
881 MockChrome::MockChrome() | 884 MockChrome::MockChrome() |
882 : xconn_(new RealXConnection(GDK_DISPLAY())), | 885 : xconn_(new RealXConnection(GDK_DISPLAY())), |
883 atom_cache_(new AtomCache(xconn_.get())), | 886 atom_cache_(new AtomCache(xconn_.get())), |
884 wm_ipc_(new WmIpc(xconn_.get(), atom_cache_.get())), | 887 wm_ipc_(new WmIpc(xconn_.get(), atom_cache_.get())), |
885 window_under_floating_tab_(NULL) { | 888 window_under_floating_tab_(NULL) { |
| 889 WmIpc::Message msg(WmIpc::Message::WM_NOTIFY_IPC_VERSION); |
| 890 msg.set_param(0, 1); |
| 891 wm_ipc_->SendMessage(wm_ipc_->wm_window(), msg); |
886 } | 892 } |
887 | 893 |
888 ChromeWindow* MockChrome::CreateWindow(int width, int height) { | 894 ChromeWindow* MockChrome::CreateWindow(int width, int height) { |
889 std::tr1::shared_ptr<ChromeWindow> win(new ChromeWindow(this, width, height)); | 895 std::tr1::shared_ptr<ChromeWindow> win(new ChromeWindow(this, width, height)); |
890 CHECK(windows_.insert(std::make_pair(win->xid(), win)).second); | 896 CHECK(windows_.insert(std::make_pair(win->xid(), win)).second); |
891 return win.get(); | 897 return win.get(); |
892 } | 898 } |
893 | 899 |
894 void MockChrome::CloseWindow(ChromeWindow* win) { | 900 void MockChrome::CloseWindow(ChromeWindow* win) { |
895 CHECK(win); | 901 CHECK(win); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 | 991 |
986 for (int i = 0; i < FLAGS_num_panels; ++i) { | 992 for (int i = 0; i < FLAGS_num_panels; ++i) { |
987 mock_chrome.CreatePanel(filenames[i % filenames.size()], | 993 mock_chrome.CreatePanel(filenames[i % filenames.size()], |
988 titles[i % titles.size()], | 994 titles[i % titles.size()], |
989 false); // expanded=false | 995 false); // expanded=false |
990 } | 996 } |
991 | 997 |
992 Gtk::Main::run(); | 998 Gtk::Main::run(); |
993 return 0; | 999 return 0; |
994 } | 1000 } |
OLD | NEW |