| 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() : WidgetGtk(WidgetGtk::TYPE_WINDOW) { | 17 ControlsWidget() { |
| 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 : WidgetGtk(WidgetGtk::TYPE_WINDOW), | 41 : controller_(controller) { |
| 42 controller_(controller) { | |
| 43 } | 42 } |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { | 45 gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) { |
| 47 if (!controller_->IsUserSelected()) | 46 if (!controller_->IsUserSelected()) |
| 48 controller_->SelectUserRelative(0); | 47 controller_->SelectUserRelative(0); |
| 49 | 48 |
| 50 return WidgetGtk::OnButtonPress(widget, event); | 49 return WidgetGtk::OnButtonPress(widget, event); |
| 51 } | 50 } |
| 52 | 51 |
| 53 UserController* controller_; | 52 UserController* controller_; |
| 54 | 53 |
| 55 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); | 54 DISALLOW_COPY_AND_ASSIGN(ClickNotifyingWidget); |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 WidgetGtk* InitWidget(WidgetGtk* widget, const gfx::Rect& bounds) { | 57 views::Widget* InitWidget(views::Widget* widget, const gfx::Rect& bounds) { |
| 59 widget->MakeTransparent(); | 58 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_WINDOW); |
| 60 widget->Init(NULL, bounds); | 59 params.transparent = true; |
| 60 params.bounds = bounds; |
| 61 widget->Init(params); |
| 61 GdkWindow* gdk_window = widget->GetNativeView()->window; | 62 GdkWindow* gdk_window = widget->GetNativeView()->window; |
| 62 gdk_window_set_back_pixmap(gdk_window, NULL, false); | 63 gdk_window_set_back_pixmap(gdk_window, NULL, false); |
| 63 return widget; | 64 return widget; |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace | 67 } // namespace |
| 67 | 68 |
| 68 // static | 69 // static |
| 69 views::Widget* UserController::CreateControlsWidget(const gfx::Rect& bounds) { | 70 views::Widget* UserController::CreateControlsWidget(const gfx::Rect& bounds) { |
| 70 return InitWidget(new ControlsWidget(), bounds); | 71 return InitWidget(new ControlsWidget(), bounds); |
| 71 } | 72 } |
| 72 | 73 |
| 73 // static | 74 // static |
| 74 views::Widget* UserController::CreateClickNotifyingWidget( | 75 views::Widget* UserController::CreateClickNotifyingWidget( |
| 75 UserController* controller, | 76 UserController* controller, |
| 76 const gfx::Rect& bounds) { | 77 const gfx::Rect& bounds) { |
| 77 return InitWidget(new ClickNotifyingWidget(controller), bounds); | 78 return InitWidget(new ClickNotifyingWidget(controller), bounds); |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| OLD | NEW |