| OLD | NEW |
| 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 "views/widget/widget_gtk.h" | 5 #include "views/widget/widget_gtk.h" |
| 6 | 6 |
| 7 #include "app/gfx/path.h" | 7 #include "app/gfx/path.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "views/fill_layout.h" | 9 #include "views/fill_layout.h" |
| 10 #include "views/widget/default_theme_provider.h" | 10 #include "views/widget/default_theme_provider.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 : is_window_(false), | 63 : is_window_(false), |
| 64 type_(type), | 64 type_(type), |
| 65 widget_(NULL), | 65 widget_(NULL), |
| 66 window_contents_(NULL), | 66 window_contents_(NULL), |
| 67 is_mouse_down_(false), | 67 is_mouse_down_(false), |
| 68 has_capture_(false), | 68 has_capture_(false), |
| 69 last_mouse_event_was_move_(false), | 69 last_mouse_event_was_move_(false), |
| 70 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 70 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| 71 delete_on_destroy_(true), | 71 delete_on_destroy_(true), |
| 72 transparent_(false) { | 72 transparent_(false) { |
| 73 if (type_ != TYPE_CHILD) |
| 74 focus_manager_.reset(new FocusManager(this)); |
| 73 } | 75 } |
| 74 | 76 |
| 75 WidgetGtk::~WidgetGtk() { | 77 WidgetGtk::~WidgetGtk() { |
| 76 MessageLoopForUI::current()->RemoveObserver(this); | 78 MessageLoopForUI::current()->RemoveObserver(this); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void WidgetGtk::Init(GtkWidget* parent, | 81 void WidgetGtk::Init(GtkWidget* parent, |
| 80 const gfx::Rect& bounds) { | 82 const gfx::Rect& bounds) { |
| 81 // Force creation of the RootView if it hasn't been created yet. | 83 // Force creation of the RootView if it hasn't been created yet. |
| 82 GetRootView(); | 84 GetRootView(); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 393 } |
| 392 | 394 |
| 393 const Window* WidgetGtk::GetWindow() const { | 395 const Window* WidgetGtk::GetWindow() const { |
| 394 return GetWindowImpl(widget_); | 396 return GetWindowImpl(widget_); |
| 395 } | 397 } |
| 396 | 398 |
| 397 ThemeProvider* WidgetGtk::GetThemeProvider() const { | 399 ThemeProvider* WidgetGtk::GetThemeProvider() const { |
| 398 return default_theme_provider_.get(); | 400 return default_theme_provider_.get(); |
| 399 } | 401 } |
| 400 | 402 |
| 403 FocusManager* WidgetGtk::GetFocusManager() { |
| 404 return focus_manager_.get(); |
| 405 } |
| 406 |
| 401 //////////////////////////////////////////////////////////////////////////////// | 407 //////////////////////////////////////////////////////////////////////////////// |
| 402 // WidgetGtk, MessageLoopForUI::Observer implementation: | 408 // WidgetGtk, MessageLoopForUI::Observer implementation: |
| 403 | 409 |
| 410 void WidgetGtk::WillProcessEvent(GdkEvent* event) { |
| 411 } |
| 412 |
| 404 void WidgetGtk::DidProcessEvent(GdkEvent* event) { | 413 void WidgetGtk::DidProcessEvent(GdkEvent* event) { |
| 405 if (root_view_->NeedsPainting(true)) | 414 if (root_view_->NeedsPainting(true)) |
| 406 PaintNow(root_view_->GetScheduledPaintRect()); | 415 PaintNow(root_view_->GetScheduledPaintRect()); |
| 407 } | 416 } |
| 408 | 417 |
| 409 //////////////////////////////////////////////////////////////////////////////// | 418 //////////////////////////////////////////////////////////////////////////////// |
| 410 // TODO(beng): organize into sections: | 419 // TODO(beng): organize into sections: |
| 411 | 420 |
| 412 void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) { | 421 void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) { |
| 413 if (type_ == TYPE_CHILD) { | 422 if (type_ == TYPE_CHILD) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 520 } |
| 512 | 521 |
| 513 gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { | 522 gboolean WidgetGtk::OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event) { |
| 514 last_mouse_event_was_move_ = false; | 523 last_mouse_event_was_move_ = false; |
| 515 if (!has_capture_ && !is_mouse_down_) | 524 if (!has_capture_ && !is_mouse_down_) |
| 516 root_view_->ProcessOnMouseExited(); | 525 root_view_->ProcessOnMouseExited(); |
| 517 return true; | 526 return true; |
| 518 } | 527 } |
| 519 | 528 |
| 520 gboolean WidgetGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { | 529 gboolean WidgetGtk::OnKeyPress(GtkWidget* widget, GdkEventKey* event) { |
| 521 KeyEvent key_event(event); | 530 KeyEvent key_event(event, false); |
| 522 return root_view_->ProcessKeyEvent(key_event); | 531 return root_view_->ProcessKeyEvent(key_event); |
| 523 } | 532 } |
| 524 | 533 |
| 525 gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { | 534 gboolean WidgetGtk::OnKeyRelease(GtkWidget* widget, GdkEventKey* event) { |
| 526 KeyEvent key_event(event); | 535 KeyEvent key_event(event, false); |
| 527 return root_view_->ProcessKeyEvent(key_event); | 536 return root_view_->ProcessKeyEvent(key_event); |
| 528 } | 537 } |
| 529 | 538 |
| 530 gboolean WidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { | 539 gboolean WidgetGtk::OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event) { |
| 531 HandleGrabBroke(); | 540 HandleGrabBroke(); |
| 532 return false; // To let other widgets get the event. | 541 return false; // To let other widgets get the event. |
| 533 } | 542 } |
| 534 | 543 |
| 535 void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { | 544 void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { |
| 536 gtk_grab_remove(window_contents_); | 545 gtk_grab_remove(window_contents_); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 void WidgetGtk::HandleGrabBroke() { | 835 void WidgetGtk::HandleGrabBroke() { |
| 827 if (has_capture_) { | 836 if (has_capture_) { |
| 828 if (is_mouse_down_) | 837 if (is_mouse_down_) |
| 829 root_view_->ProcessMouseDragCanceled(); | 838 root_view_->ProcessMouseDragCanceled(); |
| 830 is_mouse_down_ = false; | 839 is_mouse_down_ = false; |
| 831 has_capture_ = false; | 840 has_capture_ = false; |
| 832 } | 841 } |
| 833 } | 842 } |
| 834 | 843 |
| 835 } // namespace views | 844 } // namespace views |
| OLD | NEW |