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