Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Unified Diff: ui/base/x/root_window_property_watcher_x.cc

Issue 8595003: Have panels respond to changes in work area on Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile linux_view and chromeos. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/x/root_window_property_watcher_x.h ('k') | ui/base/x/work_area_watcher_x.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/x/root_window_property_watcher_x.cc
diff --git a/ui/base/x/root_window_property_watcher_x.cc b/ui/base/x/root_window_property_watcher_x.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de8b61eba4ab7c6787a0fff2f8f6a7d050c4beb5
--- /dev/null
+++ b/ui/base/x/root_window_property_watcher_x.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/x/root_window_property_watcher_x.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include "ui/base/x/active_window_watcher_x.h"
+#include "ui/base/x/work_area_watcher_x.h"
+
+namespace ui {
+
+namespace internal {
+
+// static
+RootWindowPropertyWatcherX* RootWindowPropertyWatcherX::GetInstance() {
+ return Singleton<RootWindowPropertyWatcherX>::get();
+}
+
+RootWindowPropertyWatcherX::RootWindowPropertyWatcherX() {
+ GdkWindow* root = gdk_get_default_root_window();
+
+ // Set up X Event filter to listen for PropertyChange X events.
+ // Don't use XSelectInput directly here, as gdk internally seems to cache the
+ // mask and reapply XSelectInput after this, resetting any mask we set here.
+ gdk_window_set_events(root,
+ static_cast<GdkEventMask>(gdk_window_get_events(root) |
+ GDK_PROPERTY_CHANGE_MASK));
+ gdk_window_add_filter(root,
+ &RootWindowPropertyWatcherX::OnWindowXEventThunk,
+ this);
+}
+
+RootWindowPropertyWatcherX::~RootWindowPropertyWatcherX() {
+ gdk_window_remove_filter(NULL,
+ &RootWindowPropertyWatcherX::OnWindowXEventThunk,
+ this);
+}
+
+GdkFilterReturn RootWindowPropertyWatcherX::OnWindowXEvent(
+ GdkXEvent* xevent, GdkEvent* event) {
+ XEvent* xev = static_cast<XEvent*>(xevent);
+
+ if (xev->xany.type == PropertyNotify) {
+ if (xev->xproperty.atom == ActiveWindowWatcherX::GetPropertyAtom())
+ ActiveWindowWatcherX::Notify();
+ else if (xev->xproperty.atom == WorkAreaWatcherX::GetPropertyAtom())
+ WorkAreaWatcherX::Notify();
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
+} // namespace internal
+
+} // namespace ui
« no previous file with comments | « ui/base/x/root_window_property_watcher_x.h ('k') | ui/base/x/work_area_watcher_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698