OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_main_extra_parts_x11.h" | 5 #include "chrome/browser/chrome_browser_main_extra_parts_x11.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/threading/sequenced_task_runner_handle.h" | 13 #include "base/threading/sequenced_task_runner_handle.h" |
14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/ui/browser_list.h" |
15 #include "chrome/common/chrome_result_codes.h" | 16 #include "chrome/common/chrome_result_codes.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
19 #include "ui/base/x/x11_util_internal.h" | 20 #include "ui/base/x/x11_util_internal.h" |
20 #include "ui/events/platform/x11/x11_event_source.h" | 21 #include "ui/events/platform/x11/x11_event_source.h" |
| 22 #include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
21 | 23 |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 // Indicates that we're currently responding to an IO error (by shutting down). | 28 // Indicates that we're currently responding to an IO error (by shutting down). |
27 bool g_in_x11_io_error_handler = false; | 29 bool g_in_x11_io_error_handler = false; |
28 | 30 |
29 // Number of seconds to wait for UI thread to get an IO error if we get it on | 31 // Number of seconds to wait for UI thread to get an IO error if we get it on |
30 // the background thread. | 32 // the background thread. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (ui::X11EventSource::HasInstance()) { | 106 if (ui::X11EventSource::HasInstance()) { |
105 // Get a timestamp from the X server. This makes our requests to the server | 107 // Get a timestamp from the X server. This makes our requests to the server |
106 // less likely to be thrown away by the window manager. Put the timestamp | 108 // less likely to be thrown away by the window manager. Put the timestamp |
107 // in a command line flag so we can forward it to an existing browser | 109 // in a command line flag so we can forward it to an existing browser |
108 // process if necessary. | 110 // process if necessary. |
109 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 111 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
110 switches::kWmUserTimeMs, | 112 switches::kWmUserTimeMs, |
111 base::Uint64ToString( | 113 base::Uint64ToString( |
112 ui::X11EventSource::GetInstance()->UpdateLastSeenServerTime())); | 114 ui::X11EventSource::GetInstance()->UpdateLastSeenServerTime())); |
113 } | 115 } |
| 116 |
| 117 display::Desktop* desktop = views::X11DesktopHandler::get(); |
| 118 display::Desktop::SetDesktopInstance(desktop); |
| 119 desktop->AddObserver(this); |
114 #endif | 120 #endif |
115 } | 121 } |
116 | 122 |
117 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { | 123 void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { |
118 // Unset the X11 error handlers. The X11 error handlers log the errors using a | 124 // Unset the X11 error handlers. The X11 error handlers log the errors using a |
119 // |PostTask()| on the message-loop. But since the message-loop is in the | 125 // |PostTask()| on the message-loop. But since the message-loop is in the |
120 // process of terminating, this can cause errors. | 126 // process of terminating, this can cause errors. |
121 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); | 127 ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); |
122 } | 128 } |
| 129 |
| 130 void ChromeBrowserMainExtraPartsX11::OnWorkspaceChanged( |
| 131 const std::string& new_workspace) { |
| 132 BrowserList::ReorderAfterWorkspaceChange(new_workspace); |
| 133 } |
OLD | NEW |