OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/frame/bubble_window.h" | |
6 | |
7 #include <gtk/gtk.h> | |
8 | |
9 #include "chrome/browser/chromeos/frame/bubble_frame_view.h" | |
10 #include "chrome/browser/chromeos/frame/bubble_window_views.h" | |
11 #include "ui/gfx/skia_utils_gtk.h" | |
12 #include "views/window/non_client_view.h" | |
13 | |
14 namespace chromeos { | |
15 | |
16 BubbleWindow::BubbleWindow(views::Widget* window, | |
17 BubbleWindowStyle style) | |
18 : views::NativeWidgetGtk(window), | |
19 style_(style) { | |
20 } | |
21 | |
22 void BubbleWindow::InitNativeWidget(const views::Widget::InitParams& params) { | |
23 #if defined(USE_AURA) | |
24 // TODO(saintlou): Switch to alicet@chromium.org PureView when landed | |
25 #else | |
26 views::NativeWidgetGtk::InitNativeWidget(params); | |
27 | |
28 // Turn on double buffering so that the hosted GtkWidgets does not | |
29 // flash as in http://crosbug.com/9065. | |
30 EnableDoubleBuffer(true); | |
31 | |
32 GdkColor background_color = | |
33 gfx::SkColorToGdkColor(kBubbleWindowBackgroundColor); | |
34 gtk_widget_modify_bg(GetNativeView(), GTK_STATE_NORMAL, &background_color); | |
35 | |
36 // A work-around for http://crosbug.com/8538. All GdkWindow of top-level | |
37 // GtkWindow should participate _NET_WM_SYNC_REQUEST protocol and window | |
38 // manager should only show the window after getting notified. And we | |
39 // should only notify window manager after at least one paint is done. | |
40 // TODO(xiyuan): Figure out the right fix. | |
41 gtk_widget_realize(GetNativeView()); | |
42 gdk_window_set_back_pixmap(GetNativeView()->window, NULL, FALSE); | |
43 gtk_widget_realize(window_contents()); | |
44 gdk_window_set_back_pixmap(window_contents()->window, NULL, FALSE); | |
45 #endif | |
46 } | |
47 | |
48 views::NonClientFrameView* BubbleWindow::CreateNonClientFrameView() { | |
49 views::Widget* window = GetWidget(); | |
50 return new BubbleFrameView(window, window->widget_delegate(), style_); | |
51 } | |
52 | |
53 views::Widget* BubbleWindow::Create( | |
54 gfx::NativeWindow parent, | |
55 BubbleWindowStyle style, | |
56 views::WidgetDelegate* widget_delegate) { | |
57 #if defined(USE_AURA) | |
58 // TODO(saintlou): | |
59 return NULL; | |
60 #else | |
61 // TODO(saintlou): Ultimately we do not want 2 classes for BubbleWindows. | |
62 // Furthermore the 2 other styles (STYLE_XBAR & STYLE_THROBBER) are only used | |
63 // in LoginHtmlDialog::Show() which will be deprecated soon. | |
64 if (views::Widget::IsPureViews()) { | |
65 if ((style & STYLE_XBAR) || (style & STYLE_THROBBER)) | |
66 NOTIMPLEMENTED(); | |
67 BubbleWindowViews* window = new BubbleWindowViews(style); | |
68 views::Widget::InitParams params; | |
69 params.delegate = widget_delegate; | |
70 params.parent = GTK_WIDGET(parent); | |
71 params.bounds = gfx::Rect(); | |
72 window->Init(params); | |
73 window->SetBackgroundColor(); | |
74 return window; | |
75 } | |
76 | |
77 views::Widget* window = new views::Widget; | |
78 BubbleWindow* bubble_window = new BubbleWindow(window, style); | |
79 views::Widget::InitParams params; | |
80 params.delegate = widget_delegate; | |
81 params.native_widget = bubble_window; | |
82 params.parent = GTK_WIDGET(parent); | |
83 params.bounds = gfx::Rect(); | |
84 window->Init(params); | |
85 | |
86 return window; | |
87 #endif | |
88 } | |
89 | |
90 } // namespace chromeos | |
OLD | NEW |