OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <gdk/gdk.h> | |
6 #include <gdk/gdkx.h> | |
7 | |
8 #include "ui/base/x/root_window_property_watcher_x.h" | |
sky
2011/11/18 17:54:22
This include should be first, then system includes
prasadt
2011/11/18 22:31:42
Done.
| |
9 | |
10 #include "ui/base/x/active_window_watcher_x.h" | |
11 #include "ui/base/x/work_area_watcher_x.h" | |
12 | |
13 namespace ui { | |
14 | |
15 // static | |
16 RootWindowPropertyWatcherX* RootWindowPropertyWatcherX::GetInstance() { | |
17 return Singleton<RootWindowPropertyWatcherX>::get(); | |
18 } | |
19 | |
20 RootWindowPropertyWatcherX::RootWindowPropertyWatcherX() { | |
21 GdkWindow* root = gdk_get_default_root_window(); | |
22 | |
23 // Set up X Event filter to listen for PropertyChange X events. | |
24 // Don't use XSelectInput directly here, as gdk internally seems to cache the | |
25 // mask and reapply XSelectInput after this, resetting any mask we set here. | |
26 gdk_window_set_events(root, | |
27 static_cast<GdkEventMask>(gdk_window_get_events(root) | | |
28 GDK_PROPERTY_CHANGE_MASK)); | |
29 gdk_window_add_filter(root, | |
30 &RootWindowPropertyWatcherX::OnWindowXEventThunk, | |
31 this); | |
32 } | |
33 | |
34 RootWindowPropertyWatcherX::~RootWindowPropertyWatcherX() { | |
35 gdk_window_remove_filter(NULL, | |
36 &RootWindowPropertyWatcherX::OnWindowXEventThunk, | |
37 this); | |
38 } | |
39 | |
40 GdkFilterReturn RootWindowPropertyWatcherX::OnWindowXEvent( | |
41 GdkXEvent* xevent, GdkEvent* event) { | |
42 XEvent* xev = static_cast<XEvent*>(xevent); | |
43 | |
44 if (xev->xany.type == PropertyNotify) { | |
45 if (xev->xproperty.atom == ActiveWindowWatcherX::GetPropertyAtom()) | |
46 ActiveWindowWatcherX::Notify(); | |
47 else if (xev->xproperty.atom == WorkAreaWatcherX::GetPropertyAtom()) | |
48 WorkAreaWatcherX::Notify(); | |
49 } | |
50 | |
51 return GDK_FILTER_CONTINUE; | |
52 } | |
53 | |
54 } // namespace ui | |
OLD | NEW |