| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "ui/base/gtk/gtk_compat.h" |
| 8 | 9 |
| 9 #include "ui/base/x/active_window_watcher_x.h" | 10 #include "ui/base/x/active_window_watcher_x.h" |
| 10 | 11 |
| 11 namespace ui { | 12 namespace ui { |
| 12 | 13 |
| 13 static Atom g_net_active_window_atom = None; | 14 static Atom g_net_active_window_atom = None; |
| 14 | 15 |
| 15 // static | 16 // static |
| 16 ActiveWindowWatcherX* ActiveWindowWatcherX::GetInstance() { | 17 ActiveWindowWatcherX* ActiveWindowWatcherX::GetInstance() { |
| 17 return Singleton<ActiveWindowWatcherX>::get(); | 18 return Singleton<ActiveWindowWatcherX>::get(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 &num_items, | 81 &num_items, |
| 81 &remaining_bytes, | 82 &remaining_bytes, |
| 82 &property); | 83 &property); |
| 83 | 84 |
| 84 // Check that the property was set and contained a single 32-bit item (we | 85 // Check that the property was set and contained a single 32-bit item (we |
| 85 // don't check that remaining_bytes is 0, though, as XFCE's window manager | 86 // don't check that remaining_bytes is 0, though, as XFCE's window manager |
| 86 // seems to actually store two values in the property for some unknown | 87 // seems to actually store two values in the property for some unknown |
| 87 // reason.) | 88 // reason.) |
| 88 if (format == 32 && num_items == 1) { | 89 if (format == 32 && num_items == 1) { |
| 89 int xid = *reinterpret_cast<int*>(property); | 90 int xid = *reinterpret_cast<int*>(property); |
| 90 GdkWindow* active_window = gdk_window_lookup(xid); | 91 GdkDisplay *display = gdk_display_get_default(); |
| 92 GdkWindow* active_window = gdk_x11_window_lookup_for_display(display, xid); |
| 91 FOR_EACH_OBSERVER( | 93 FOR_EACH_OBSERVER( |
| 92 Observer, | 94 Observer, |
| 93 observers_, | 95 observers_, |
| 94 ActiveWindowChanged(active_window)); | 96 ActiveWindowChanged(active_window)); |
| 95 } | 97 } |
| 96 if (property) | 98 if (property) |
| 97 XFree(property); | 99 XFree(property); |
| 98 } | 100 } |
| 99 | 101 |
| 100 GdkFilterReturn ActiveWindowWatcherX::OnWindowXEvent(GdkXEvent* xevent, | 102 GdkFilterReturn ActiveWindowWatcherX::OnWindowXEvent(GdkXEvent* xevent, |
| 101 GdkEvent* event) { | 103 GdkEvent* event) { |
| 102 XEvent* xev = static_cast<XEvent*>(xevent); | 104 XEvent* xev = static_cast<XEvent*>(xevent); |
| 103 | 105 |
| 104 if (xev->xany.type == PropertyNotify && | 106 if (xev->xany.type == PropertyNotify && |
| 105 xev->xproperty.atom == g_net_active_window_atom) { | 107 xev->xproperty.atom == g_net_active_window_atom) { |
| 106 NotifyActiveWindowChanged(); | 108 NotifyActiveWindowChanged(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 return GDK_FILTER_CONTINUE; | 111 return GDK_FILTER_CONTINUE; |
| 110 } | 112 } |
| 111 | 113 |
| 112 } // namespace ui | 114 } // namespace ui |
| OLD | NEW |