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 "base/at_exit.h" | |
6 #include "base/command_line.h" | |
7 #include "base/i18n/icu_util.h" | |
8 #include "base/process_util.h" | |
9 #include "base/utf_string_conversions.h" | |
10 #include "ui/base/resource/resource_bundle.h" | |
11 #include "ui/base/ui_base_paths.h" | |
12 #include "views/desktop/desktop_views_delegate.h" | |
13 #include "views/desktop/desktop_window_view.h" | |
14 #include "views/focus/accelerator_handler.h" | |
15 #include "views/widget/widget.h" | |
16 | |
17 #if defined(OS_WIN) | |
18 #include <ole2.h> | |
19 #endif | |
20 | |
21 #if defined(USE_WAYLAND) | |
22 #include "ui/gfx/gl/gl_surface_egl.h" | |
23 #include "ui/wayland/wayland_display.h" | |
24 #include "ui/wayland/wayland_message_pump.h" | |
25 #endif | |
26 | |
27 #if defined(TOOLKIT_USES_GTK) | |
28 #include <gtk/gtk.h> | |
29 #elif defined(OS_LINUX) | |
30 #include <glib.h> | |
31 #include <glib-object.h> | |
32 #endif | |
33 | |
34 int main(int argc, char** argv) { | |
35 #if defined(OS_WIN) | |
36 OleInitialize(NULL); | |
37 #elif defined(OS_LINUX) | |
38 // Initializes gtk stuff. | |
39 g_type_init(); | |
40 #if defined(TOOLKIT_USES_GTK) && !defined(USE_WAYLAND) | |
41 gtk_init(&argc, &argv); | |
42 #endif | |
43 #endif | |
44 | |
45 CommandLine::Init(argc, argv); | |
46 | |
47 base::EnableTerminationOnHeapCorruption(); | |
48 | |
49 // The exit manager is in charge of calling the dtors of singleton objects. | |
50 base::AtExitManager exit_manager; | |
51 | |
52 ui::RegisterPathProvider(); | |
53 icu_util::Initialize(); | |
54 | |
55 ResourceBundle::InitSharedInstance("en-US"); | |
56 | |
57 #if defined(USE_WAYLAND) | |
58 // Wayland uses EGL for drawing, so we need to initialize this as early as | |
59 // possible. | |
60 if (!gfx::GLSurface::InitializeOneOff()) { | |
61 LOG(ERROR) << "Failed to initialize GLSurface"; | |
62 return -1; | |
63 } | |
64 ui::WaylandMessagePump wayland_message_pump( | |
65 ui::WaylandDisplay::GetDisplay(gfx::GLSurfaceEGL::GetNativeDisplay())); | |
66 #endif | |
67 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | |
68 | |
69 views::desktop::DesktopViewsDelegate views_delegate; | |
70 | |
71 // Desktop mode only supports a pure-views configuration. | |
72 views::Widget::SetPureViews(true); | |
73 | |
74 views::desktop::DesktopWindowView::CreateDesktopWindow( | |
75 views::desktop::DesktopWindowView::DESKTOP_DEFAULT); | |
76 views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( | |
77 ASCIIToUTF16("Sample Window 1"), SK_ColorWHITE, | |
78 gfx::Rect(500, 200, 400, 400), true); | |
79 views::desktop::DesktopWindowView::desktop_window_view->CreateTestWindow( | |
80 ASCIIToUTF16("Sample Window 2"), SK_ColorRED, | |
81 gfx::Rect(600, 450, 450, 300), false); | |
82 | |
83 views::AcceleratorHandler accelerator_handler; | |
84 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); | |
85 | |
86 #if defined(OS_WIN) | |
87 OleUninitialize(); | |
88 #endif | |
89 return 0; | |
90 } | |
OLD | NEW |