OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/browser_main_chromeos.h" |
6 | 6 |
| 7 #include "base/lazy_instance.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/singleton.h" | |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
11 | 11 |
12 class MessageLoopObserver : public MessageLoopForUI::Observer { | 12 class MessageLoopObserver : public MessageLoopForUI::Observer { |
13 virtual void WillProcessEvent(GdkEvent* event) { | 13 virtual void WillProcessEvent(GdkEvent* event) { |
14 // On chromeos we want to map Alt-left click to right click. | 14 // On chromeos we want to map Alt-left click to right click. |
15 // This code only changes presses and releases. We could decide to also | 15 // This code only changes presses and releases. We could decide to also |
16 // modify drags and crossings. It doesn't seem to be a problem right now | 16 // modify drags and crossings. It doesn't seem to be a problem right now |
17 // with our support for context menus (the only real need we have). | 17 // with our support for context menus (the only real need we have). |
18 // There are some inconsistent states both with what we have and what | 18 // There are some inconsistent states both with what we have and what |
(...skipping 12 matching lines...) Expand all Loading... |
31 event->button.state &= ~(GDK_MOD1_MASK | GDK_BUTTON1_MASK); | 31 event->button.state &= ~(GDK_MOD1_MASK | GDK_BUTTON1_MASK); |
32 // Add the third (right) button state. | 32 // Add the third (right) button state. |
33 event->button.state |= GDK_BUTTON3_MASK; | 33 event->button.state |= GDK_BUTTON3_MASK; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 virtual void DidProcessEvent(GdkEvent* event) { | 37 virtual void DidProcessEvent(GdkEvent* event) { |
38 } | 38 } |
39 }; | 39 }; |
40 | 40 |
| 41 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( |
| 42 base::LINKER_INITIALIZED); |
| 43 |
41 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { | 44 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { |
42 static Singleton<MessageLoopObserver> observer; | |
43 | |
44 BrowserMainPartsPosix::PostMainMessageLoopStart(); | 45 BrowserMainPartsPosix::PostMainMessageLoopStart(); |
45 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 46 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
46 message_loop->AddObserver(observer.get()); | 47 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
47 } | 48 } |
48 | 49 |
49 // static | 50 // static |
50 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | 51 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( |
51 const MainFunctionParams& parameters) { | 52 const MainFunctionParams& parameters) { |
52 return new BrowserMainPartsChromeos(parameters); | 53 return new BrowserMainPartsChromeos(parameters); |
53 } | 54 } |
OLD | NEW |