| 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 "ui/base/x/active_window_watcher_x.h" | 5 #include "ui/base/x/active_window_watcher_x.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 #include "ui/base/gtk/gtk_compat.h" |
| 9 | 10 |
| 10 #include "ui/base/x/active_window_watcher_x_observer.h" | 11 #include "ui/base/x/active_window_watcher_x_observer.h" |
| 11 #include "ui/base/x/root_window_property_watcher_x.h" | 12 #include "ui/base/x/root_window_property_watcher_x.h" |
| 12 #include "ui/base/x/x11_util.h" | 13 #include "ui/base/x/x11_util.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 static const char* const kNetActiveWindow = "_NET_ACTIVE_WINDOW"; | 17 static const char* const kNetActiveWindow = "_NET_ACTIVE_WINDOW"; |
| 17 | 18 |
| 18 // static | 19 // static |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 &num_items, | 78 &num_items, |
| 78 &remaining_bytes, | 79 &remaining_bytes, |
| 79 &property); | 80 &property); |
| 80 | 81 |
| 81 // Check that the property was set and contained a single 32-bit item (we | 82 // Check that the property was set and contained a single 32-bit item (we |
| 82 // don't check that remaining_bytes is 0, though, as XFCE's window manager | 83 // don't check that remaining_bytes is 0, though, as XFCE's window manager |
| 83 // seems to actually store two values in the property for some unknown | 84 // seems to actually store two values in the property for some unknown |
| 84 // reason.) | 85 // reason.) |
| 85 if (format == 32 && num_items == 1) { | 86 if (format == 32 && num_items == 1) { |
| 86 int xid = *reinterpret_cast<int*>(property); | 87 int xid = *reinterpret_cast<int*>(property); |
| 87 GdkWindow* active_window = gdk_window_lookup(xid); | 88 GdkDisplay* display = gdk_display_get_default(); |
| 89 GdkWindow* active_window = gdk_x11_window_lookup_for_display(display, xid); |
| 88 FOR_EACH_OBSERVER(ActiveWindowWatcherXObserver, observers_, | 90 FOR_EACH_OBSERVER(ActiveWindowWatcherXObserver, observers_, |
| 89 ActiveWindowChanged(active_window)); | 91 ActiveWindowChanged(active_window)); |
| 90 } | 92 } |
| 91 if (property) | 93 if (property) |
| 92 XFree(property); | 94 XFree(property); |
| 93 } | 95 } |
| 94 | 96 |
| 95 } // namespace ui | 97 } // namespace ui |
| OLD | NEW |