OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <X11/Xlib.h> | 5 #include <X11/Xlib.h> |
6 #include <gdk/gdk.h> | 6 #include <gdk/gdk.h> |
7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
8 | 8 |
9 #include "app/active_window_watcher_x.h" | 9 #include "app/active_window_watcher_x.h" |
10 | 10 |
11 static Atom kNetActiveWindowAtom = None; | 11 static Atom kNetActiveWindowAtom = None; |
12 | 12 |
13 // static | 13 // static |
| 14 ActiveWindowWatcherX* ActiveWindowWatcherX::GetInstance() { |
| 15 return Singleton<ActiveWindowWatcherX>::get(); |
| 16 } |
| 17 |
| 18 // static |
14 void ActiveWindowWatcherX::AddObserver(Observer* observer) { | 19 void ActiveWindowWatcherX::AddObserver(Observer* observer) { |
15 Singleton<ActiveWindowWatcherX>::get()->observers_.AddObserver(observer); | 20 ActiveWindowWatcherX::GetInstance()->observers_.AddObserver(observer); |
16 } | 21 } |
17 | 22 |
18 // static | 23 // static |
19 void ActiveWindowWatcherX::RemoveObserver(Observer* observer) { | 24 void ActiveWindowWatcherX::RemoveObserver(Observer* observer) { |
20 Singleton<ActiveWindowWatcherX>::get()->observers_.RemoveObserver(observer); | 25 ActiveWindowWatcherX::GetInstance()->observers_.RemoveObserver(observer); |
21 } | 26 } |
22 | 27 |
23 ActiveWindowWatcherX::ActiveWindowWatcherX() { | 28 ActiveWindowWatcherX::ActiveWindowWatcherX() { |
24 Init(); | 29 Init(); |
25 } | 30 } |
26 | 31 |
27 ActiveWindowWatcherX::~ActiveWindowWatcherX() { | 32 ActiveWindowWatcherX::~ActiveWindowWatcherX() { |
28 } | 33 } |
29 | 34 |
30 void ActiveWindowWatcherX::Init() { | 35 void ActiveWindowWatcherX::Init() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 window_watcher); | 93 window_watcher); |
89 XEvent* xev = static_cast<XEvent*>(xevent); | 94 XEvent* xev = static_cast<XEvent*>(xevent); |
90 | 95 |
91 if (xev->xany.type == PropertyNotify && | 96 if (xev->xany.type == PropertyNotify && |
92 xev->xproperty.atom == kNetActiveWindowAtom) { | 97 xev->xproperty.atom == kNetActiveWindowAtom) { |
93 watcher->NotifyActiveWindowChanged(); | 98 watcher->NotifyActiveWindowChanged(); |
94 } | 99 } |
95 | 100 |
96 return GDK_FILTER_CONTINUE; | 101 return GDK_FILTER_CONTINUE; |
97 } | 102 } |
OLD | NEW |