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