| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <unistd.h> | 5 #include <unistd.h> |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <ctime> | 9 #include <ctime> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 DEFINE_bool(start_profiler, false, "Start profiler at window manager startup."); | 49 DEFINE_bool(start_profiler, false, "Start profiler at window manager startup."); |
| 50 | 50 |
| 51 using std::string; | 51 using std::string; |
| 52 using window_manager::EventLoop; | 52 using window_manager::EventLoop; |
| 53 using window_manager::RealCompositor; | 53 using window_manager::RealCompositor; |
| 54 using window_manager::RealDBusInterface; | 54 using window_manager::RealDBusInterface; |
| 55 #if defined(COMPOSITOR_OPENGL) | 55 #if defined(COMPOSITOR_OPENGL) |
| 56 using window_manager::RealGLInterface; | 56 using window_manager::RealGLInterface; |
| 57 #elif defined(COMPOSITOR_OPENGLES) | 57 #elif defined(COMPOSITOR_OPENGLES) |
| 58 using window_manager::RealGles2Interface; | 58 using window_manager::RealGles2Interface; |
| 59 #elif defined(COMPOSITOR_XRENDER) |
| 59 #else | 60 #else |
| 60 #error COMPOSITOR_OPENGL or COMPOSITOR_OPENGLES must be defined | 61 #error COMPOSITOR_OPENGL, COMPOSITOR_OPENGLES or \ |
| 62 COMPOSITOR_XRENDER must be defined |
| 61 #endif | 63 #endif |
| 62 using window_manager::RealXConnection; | 64 using window_manager::RealXConnection; |
| 63 using window_manager::WindowManager; | 65 using window_manager::WindowManager; |
| 64 using window_manager::util::GetTimeAsString; | 66 using window_manager::util::GetTimeAsString; |
| 65 using window_manager::util::SetUpLogSymlink; | 67 using window_manager::util::SetUpLogSymlink; |
| 66 | 68 |
| 67 // This should be adjusted according to number of PROFILER_MARKER_* | 69 // This should be adjusted according to number of PROFILER_MARKER_* |
| 68 static const int kMaxNumProfilerSymbols = 100; | 70 static const int kMaxNumProfilerSymbols = 100; |
| 69 | 71 |
| 70 // Handler called by Chrome logging code on failed asserts. | 72 // Handler called by Chrome logging code on failed asserts. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 LOG(ERROR) << "Unable to open " | 142 LOG(ERROR) << "Unable to open " |
| 141 << (display_name ? display_name : "default display"); | 143 << (display_name ? display_name : "default display"); |
| 142 return EXIT_FAILURE; | 144 return EXIT_FAILURE; |
| 143 } | 145 } |
| 144 XSetIOErrorHandler(HandleXIOError); | 146 XSetIOErrorHandler(HandleXIOError); |
| 145 | 147 |
| 146 RealXConnection xconn(display); | 148 RealXConnection xconn(display); |
| 147 EventLoop event_loop; | 149 EventLoop event_loop; |
| 148 #if defined(COMPOSITOR_OPENGL) | 150 #if defined(COMPOSITOR_OPENGL) |
| 149 RealGLInterface gl_interface(&xconn); | 151 RealGLInterface gl_interface(&xconn); |
| 152 RealCompositor compositor(&event_loop, &xconn, &gl_interface); |
| 150 #elif defined(COMPOSITOR_OPENGLES) | 153 #elif defined(COMPOSITOR_OPENGLES) |
| 151 RealGles2Interface gl_interface(&xconn); | 154 RealGles2Interface gl_interface(&xconn); |
| 155 RealCompositor compositor(&event_loop, &xconn, &gl_interface); |
| 156 #elif defined(COMPOSITOR_XRENDER) |
| 157 RealCompositor compositor(&event_loop, &xconn); |
| 152 #endif | 158 #endif |
| 153 RealCompositor compositor(&event_loop, &xconn, &gl_interface); | |
| 154 RealDBusInterface dbus; | 159 RealDBusInterface dbus; |
| 155 dbus.Init(); | 160 dbus.Init(); |
| 156 | 161 |
| 157 WindowManager wm(&event_loop, &xconn, &compositor, &dbus); | 162 WindowManager wm(&event_loop, &xconn, &compositor, &dbus); |
| 158 wm.set_initialize_logging(!FLAGS_logtostderr); | 163 wm.set_initialize_logging(!FLAGS_logtostderr); |
| 159 wm.Init(); | 164 wm.Init(); |
| 160 | 165 |
| 161 // TODO: Need to also use XAddConnectionWatch()? | 166 // TODO: Need to also use XAddConnectionWatch()? |
| 162 const int x11_fd = xconn.GetConnectionFileDescriptor(); | 167 const int x11_fd = xconn.GetConnectionFileDescriptor(); |
| 163 LOG(INFO) << "X11 connection is on fd " << x11_fd; | 168 LOG(INFO) << "X11 connection is on fd " << x11_fd; |
| 164 event_loop.AddFileDescriptor( | 169 event_loop.AddFileDescriptor( |
| 165 x11_fd, NewPermanentCallback(&wm, &WindowManager::ProcessPendingEvents)); | 170 x11_fd, NewPermanentCallback(&wm, &WindowManager::ProcessPendingEvents)); |
| 166 event_loop.AddPrePollCallback( | 171 event_loop.AddPrePollCallback( |
| 167 NewPermanentCallback(&wm, &WindowManager::ProcessPendingEvents)); | 172 NewPermanentCallback(&wm, &WindowManager::ProcessPendingEvents)); |
| 168 | 173 |
| 169 event_loop.Run(); | 174 event_loop.Run(); |
| 170 return EXIT_SUCCESS; | 175 return EXIT_SUCCESS; |
| 171 } | 176 } |
| OLD | NEW |