| 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/login/user_controller.h" | 5 #include "chrome/browser/chromeos/login/user_controller.h" |
| 6 | 6 |
| 7 #include "views/widget/widget_gtk.h" | 7 #include "views/widget/widget_gtk.h" |
| 8 | 8 |
| 9 using views::WidgetGtk; | 9 using views::WidgetGtk; |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace chromeos { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class ControlsWidget : public WidgetGtk { | 15 class ControlsWidget : public WidgetGtk { |
| 16 public: | 16 public: |
| 17 ControlsWidget() { | 17 ControlsWidget() : WidgetGtk(new views::Widget) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 private: | 20 private: |
| 21 // WidgetGtk overrides: | 21 // WidgetGtk overrides: |
| 22 virtual void OnMap(GtkWidget* widget) OVERRIDE { | 22 virtual void OnMap(GtkWidget* widget) OVERRIDE { |
| 23 // For some reason, Controls window never gets first expose event, | 23 // For some reason, Controls window never gets first expose event, |
| 24 // which makes WM believe that the login screen is not ready. | 24 // which makes WM believe that the login screen is not ready. |
| 25 // This is a workaround to let WM show the login screen. While | 25 // This is a workaround to let WM show the login screen. While |
| 26 // this may allow WM to show unpainted window, we haven't seen any | 26 // this may allow WM to show unpainted window, we haven't seen any |
| 27 // issue (yet). We will not investigate this further because we're | 27 // issue (yet). We will not investigate this further because we're |
| 28 // migrating to different implemention (WebUI). | 28 // migrating to different implemention (WebUI). |
| 29 UpdateFreezeUpdatesProperty(GTK_WINDOW(GetNativeView()), | 29 UpdateFreezeUpdatesProperty(GTK_WINDOW(GetNativeView()), |
| 30 false /* remove */); | 30 false /* remove */); |
| 31 } | 31 } |
| 32 | 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(ControlsWidget); | 33 DISALLOW_COPY_AND_ASSIGN(ControlsWidget); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // Widget that notifies window manager about clicking on itself. | 36 // Widget that notifies window manager about clicking on itself. |
| 37 // Doesn't send anything if user is selected. | 37 // Doesn't send anything if user is selected. |
| 38 class ClickNotifyingWidget : public WidgetGtk { | 38 class ClickNotifyingWidget : public WidgetGtk { |
| 39 public: | 39 public: |
| 40 explicit ClickNotifyingWidget(UserController* controller) | 40 explicit ClickNotifyingWidget(UserController* controller) |
| 41 : controller_(controller) { | 41 : WidgetGtk(new views::Widget), |
| 42 controller_(controller) { |
| 42 } | 43 } |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { | 46 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { |
| 46 if (!controller_->IsUserSelected()) | 47 if (!controller_->IsUserSelected()) |
| 47 controller_->SelectUserRelative(0); | 48 controller_->SelectUserRelative(0); |
| 48 | 49 |
| 49 return WidgetGtk::OnButtonPress(widget, event); | 50 return WidgetGtk::OnButtonPress(widget, event); |
| 50 } | 51 } |
| 51 | 52 |
| 52 UserController* controller_; | 53 UserController* controller_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); | 55 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 views::Widget* InitWidget(views::Widget* widget, const gfx::Rect& bounds) { | 58 views::Widget* InitWidget(views::NativeWidget* native_widget, |
| 59 const gfx::Rect& bounds) { |
| 58 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 60 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 59 params.transparent = true; | 61 params.transparent = true; |
| 60 params.bounds = bounds; | 62 params.bounds = bounds; |
| 61 widget->Init(params); | 63 params.native_widget = native_widget; |
| 62 GdkWindow* gdk_window = widget->GetNativeView()->window; | 64 native_widget->GetWidget()->Init(params); |
| 65 GdkWindow* gdk_window = native_widget->GetWidget()->GetNativeView()->window; |
| 63 gdk_window_set_back_pixmap(gdk_window, NULL, false); | 66 gdk_window_set_back_pixmap(gdk_window, NULL, false); |
| 64 return widget; | 67 return native_widget->GetWidget(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 } // namespace | 70 } // namespace |
| 68 | 71 |
| 69 // static | 72 // static |
| 70 views::Widget* UserController::CreateControlsWidget(const gfx::Rect& bounds) { | 73 views::Widget* UserController::CreateControlsWidget(const gfx::Rect& bounds) { |
| 71 return InitWidget(new ControlsWidget(), bounds); | 74 return InitWidget(new ControlsWidget(), bounds); |
| 72 } | 75 } |
| 73 | 76 |
| 74 // static | 77 // static |
| 75 views::Widget* UserController::CreateClickNotifyingWidget( | 78 views::Widget* UserController::CreateClickNotifyingWidget( |
| 76 UserController* controller, | 79 UserController* controller, |
| 77 const gfx::Rect& bounds) { | 80 const gfx::Rect& bounds) { |
| 78 return InitWidget(new ClickNotifyingWidget(controller), bounds); | 81 return InitWidget(new ClickNotifyingWidget(controller), bounds); |
| 79 } | 82 } |
| 80 | 83 |
| 81 } // namespace | 84 } // namespace |
| OLD | NEW |