| OLD | NEW |
| 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/chromeos/frame/panel_controller.h" | 5 #include "chrome/browser/chromeos/frame/panel_controller.h" |
| 6 | 6 |
| 7 #if defined(TOUCH_UI) | |
| 8 #include <X11/Xlib.h> | |
| 9 #include <X11/extensions/XInput2.h> | |
| 10 #endif | |
| 11 | |
| 12 #include <vector> | 7 #include <vector> |
| 13 | 8 |
| 14 #include "base/logging.h" | 9 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 17 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 18 #include "base/time.h" | 13 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 33 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/events/event.h" | 29 #include "ui/views/events/event.h" |
| 35 #include "ui/views/painter.h" | 30 #include "ui/views/painter.h" |
| 36 #include "ui/views/view.h" | 31 #include "ui/views/view.h" |
| 37 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 38 | 33 |
| 39 #if defined(TOOLKIT_USES_GTK) | 34 #if defined(TOOLKIT_USES_GTK) |
| 40 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 35 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
| 41 #endif | 36 #endif |
| 42 | 37 |
| 43 #if defined(TOUCH_UI) | |
| 44 namespace { | |
| 45 | |
| 46 gfx::Point RootLocationFromXEvent(const XEvent* xev) { | |
| 47 switch (xev->type) { | |
| 48 case ButtonPress: | |
| 49 case ButtonRelease: | |
| 50 return gfx::Point(xev->xbutton.x_root, xev->xbutton.y_root); | |
| 51 case MotionNotify: | |
| 52 return gfx::Point(xev->xmotion.x_root, xev->xmotion.y_root); | |
| 53 | |
| 54 case GenericEvent: { | |
| 55 const XIDeviceEvent* xiev = | |
| 56 static_cast<XIDeviceEvent*>(xev->xcookie.data); | |
| 57 switch (xiev->evtype) { | |
| 58 case XI_ButtonPress: | |
| 59 case XI_ButtonRelease: | |
| 60 case XI_Motion: | |
| 61 return gfx::Point(static_cast<int>(xiev->root_x), | |
| 62 static_cast<int>(xiev->root_y)); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 default: | |
| 67 NOTREACHED(); | |
| 68 } | |
| 69 | |
| 70 return gfx::Point(); | |
| 71 } | |
| 72 | |
| 73 } // namespace | |
| 74 #endif // defined(TOUCH_UI) | |
| 75 | |
| 76 namespace chromeos { | 38 namespace chromeos { |
| 77 | 39 |
| 78 static int close_button_width; | 40 static int close_button_width; |
| 79 static int close_button_height; | 41 static int close_button_height; |
| 80 static SkBitmap* close_button_n; | 42 static SkBitmap* close_button_n; |
| 81 static SkBitmap* close_button_m; | 43 static SkBitmap* close_button_m; |
| 82 static SkBitmap* close_button_h; | 44 static SkBitmap* close_button_h; |
| 83 static SkBitmap* close_button_p; | 45 static SkBitmap* close_button_p; |
| 84 static gfx::Font* active_font = NULL; | 46 static gfx::Font* active_font = NULL; |
| 85 static gfx::Font* inactive_font = NULL; | 47 static gfx::Font* inactive_font = NULL; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 290 |
| 329 bool PanelController::TitleMouseDragged(const views::MouseEvent& event) { | 291 bool PanelController::TitleMouseDragged(const views::MouseEvent& event) { |
| 330 if (!mouse_down_) | 292 if (!mouse_down_) |
| 331 return false; | 293 return false; |
| 332 if (event.type() != ui::ET_MOUSE_MOVED && | 294 if (event.type() != ui::ET_MOUSE_MOVED && |
| 333 event.type() != ui::ET_MOUSE_DRAGGED) { | 295 event.type() != ui::ET_MOUSE_DRAGGED) { |
| 334 NOTREACHED(); | 296 NOTREACHED(); |
| 335 return false; | 297 return false; |
| 336 } | 298 } |
| 337 | 299 |
| 338 #if !defined(TOUCH_UI) | |
| 339 const GdkEvent* gdk_event = event.gdk_event(); | 300 const GdkEvent* gdk_event = event.gdk_event(); |
| 340 GdkEventMotion last_motion_event = gdk_event->motion; | 301 GdkEventMotion last_motion_event = gdk_event->motion; |
| 341 int x_root = last_motion_event.x_root; | 302 int x_root = last_motion_event.x_root; |
| 342 int y_root = last_motion_event.y_root; | 303 int y_root = last_motion_event.y_root; |
| 343 #else | |
| 344 const XEvent* xev = event.native_event(); | |
| 345 gfx::Point abs_location = RootLocationFromXEvent(xev); | |
| 346 int x_root = abs_location.x(); | |
| 347 int y_root = abs_location.y(); | |
| 348 #endif | |
| 349 | 304 |
| 350 if (!dragging_) { | 305 if (!dragging_) { |
| 351 if (views::View::ExceededDragThreshold(x_root - mouse_down_abs_x_, | 306 if (views::View::ExceededDragThreshold(x_root - mouse_down_abs_x_, |
| 352 y_root - mouse_down_abs_y_)) { | 307 y_root - mouse_down_abs_y_)) { |
| 353 dragging_ = true; | 308 dragging_ = true; |
| 354 } | 309 } |
| 355 } | 310 } |
| 356 #if defined(TOOLKIT_USES_GTK) | 311 #if defined(TOOLKIT_USES_GTK) |
| 357 if (dragging_) { | 312 if (dragging_) { |
| 358 WmIpc::Message msg(WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAGGED); | 313 WmIpc::Message msg(WM_IPC_MESSAGE_WM_NOTIFY_PANEL_DRAGGED); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 views::Button* sender, const views::Event& event) { | 479 views::Button* sender, const views::Event& event) { |
| 525 if (panel_controller_ && sender == close_button_) | 480 if (panel_controller_ && sender == close_button_) |
| 526 panel_controller_->OnCloseButtonPressed(); | 481 panel_controller_->OnCloseButtonPressed(); |
| 527 } | 482 } |
| 528 | 483 |
| 529 PanelController::TitleContentView::~TitleContentView() { | 484 PanelController::TitleContentView::~TitleContentView() { |
| 530 VLOG(1) << "panel: delete " << this; | 485 VLOG(1) << "panel: delete " << this; |
| 531 } | 486 } |
| 532 | 487 |
| 533 } // namespace chromeos | 488 } // namespace chromeos |
| OLD | NEW |