| 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 "ui/gfx/skia_utils_gtk.h" | |
| 11 #include "ui/views/window/non_client_view.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 | |
| 15 BubbleWindow::BubbleWindow(views::Widget* window, | |
| 16 DialogStyle style) | |
| 17 : views::NativeWidgetGtk(window), | |
| 18 style_(style) { | |
| 19 } | |
| 20 | |
| 21 void BubbleWindow::InitNativeWidget(const views::Widget::InitParams& params) { | |
| 22 views::NativeWidgetGtk::InitNativeWidget(params); | |
| 23 | |
| 24 // Turn on double buffering so that the hosted GtkWidgets does not | |
| 25 // flash as in http://crosbug.com/9065. | |
| 26 EnableDoubleBuffer(true); | |
| 27 | |
| 28 GdkColor background_color = | |
| 29 gfx::SkColorToGdkColor(kBubbleWindowBackgroundColor); | |
| 30 gtk_widget_modify_bg(GetNativeView(), GTK_STATE_NORMAL, &background_color); | |
| 31 | |
| 32 // A work-around for http://crosbug.com/8538. All GdkWindow of top-level | |
| 33 // GtkWindow should participate _NET_WM_SYNC_REQUEST protocol and window | |
| 34 // manager should only show the window after getting notified. And we | |
| 35 // should only notify window manager after at least one paint is done. | |
| 36 // TODO(xiyuan): Figure out the right fix. | |
| 37 gtk_widget_realize(GetNativeView()); | |
| 38 gdk_window_set_back_pixmap(GetNativeView()->window, NULL, FALSE); | |
| 39 gtk_widget_realize(window_contents()); | |
| 40 gdk_window_set_back_pixmap(window_contents()->window, NULL, FALSE); | |
| 41 } | |
| 42 | |
| 43 views::NonClientFrameView* BubbleWindow::CreateNonClientFrameView() { | |
| 44 views::Widget* window = GetWidget(); | |
| 45 return new BubbleFrameView(window, window->widget_delegate(), style_); | |
| 46 } | |
| 47 | |
| 48 views::Widget* BubbleWindow::Create( | |
| 49 gfx::NativeWindow parent, | |
| 50 DialogStyle style, | |
| 51 views::WidgetDelegate* widget_delegate) { | |
| 52 views::Widget* window = new views::Widget; | |
| 53 BubbleWindow* bubble_window = new BubbleWindow(window, style); | |
| 54 views::Widget::InitParams params; | |
| 55 params.delegate = widget_delegate; | |
| 56 params.native_widget = bubble_window; | |
| 57 params.parent = GTK_WIDGET(parent); | |
| 58 params.bounds = gfx::Rect(); | |
| 59 window->Init(params); | |
| 60 | |
| 61 return window; | |
| 62 } | |
| 63 | |
| 64 } // namespace chromeos | |
| OLD | NEW |