summaryrefslogtreecommitdiffstats
path: root/app/active_window_watcher_x.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 18:27:06 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 18:27:06 +0000
commit9dd7e3d78c14f67c5c3d78868a3a63bbc4f90634 (patch)
tree3b7332926a05a1c8382eb27422c385b56b29cb24 /app/active_window_watcher_x.cc
parenta12f7fbe12afffb4b1b31ec0d6b0988f1f9a6554 (diff)
downloadchromium_src-9dd7e3d78c14f67c5c3d78868a3a63bbc4f90634.zip
chromium_src-9dd7e3d78c14f67c5c3d78868a3a63bbc4f90634.tar.gz
chromium_src-9dd7e3d78c14f67c5c3d78868a3a63bbc4f90634.tar.bz2
Move a bunch of random other files to src/ui/base
BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6257006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/active_window_watcher_x.cc')
-rw-r--r--app/active_window_watcher_x.cc102
1 files changed, 0 insertions, 102 deletions
diff --git a/app/active_window_watcher_x.cc b/app/active_window_watcher_x.cc
deleted file mode 100644
index 65749648..0000000
--- a/app/active_window_watcher_x.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2009 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 <X11/Xlib.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-
-#include "app/active_window_watcher_x.h"
-
-static Atom kNetActiveWindowAtom = None;
-
-// static
-ActiveWindowWatcherX* ActiveWindowWatcherX::GetInstance() {
- return Singleton<ActiveWindowWatcherX>::get();
-}
-
-// static
-void ActiveWindowWatcherX::AddObserver(Observer* observer) {
- GetInstance()->observers_.AddObserver(observer);
-}
-
-// static
-void ActiveWindowWatcherX::RemoveObserver(Observer* observer) {
- GetInstance()->observers_.RemoveObserver(observer);
-}
-
-ActiveWindowWatcherX::ActiveWindowWatcherX() {
- Init();
-}
-
-ActiveWindowWatcherX::~ActiveWindowWatcherX() {
-}
-
-void ActiveWindowWatcherX::Init() {
- GdkAtom kNetActiveWindow = gdk_atom_intern("_NET_ACTIVE_WINDOW", FALSE);
- kNetActiveWindowAtom = gdk_x11_atom_to_xatom_for_display(
- gdk_screen_get_display(gdk_screen_get_default()), kNetActiveWindow);
-
- GdkWindow* root = gdk_get_default_root_window();
-
- // Set up X Event filter to listen for PropertyChange X events. These events
- // tell us when the active window changes.
- // 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(NULL, &ActiveWindowWatcherX::OnWindowXEvent, this);
-}
-
-void ActiveWindowWatcherX::NotifyActiveWindowChanged() {
- // We don't use gdk_screen_get_active_window() because it caches
- // whether or not the window manager supports _NET_ACTIVE_WINDOW.
- // This causes problems at startup for chromiumos.
- Atom type = None;
- int format = 0; // size in bits of each item in 'property'
- long unsigned int num_items = 0, remaining_bytes = 0;
- unsigned char* property = NULL;
-
- XGetWindowProperty(gdk_x11_get_default_xdisplay(),
- GDK_WINDOW_XID(gdk_get_default_root_window()),
- kNetActiveWindowAtom,
- 0, // offset into property data to read
- 1, // length to get in 32-bit quantities
- False, // deleted
- AnyPropertyType,
- &type,
- &format,
- &num_items,
- &remaining_bytes,
- &property);
-
- // Check that the property was set and contained a single 32-bit item (we
- // don't check that remaining_bytes is 0, though, as XFCE's window manager
- // seems to actually store two values in the property for some unknown
- // reason.)
- if (format == 32 && num_items == 1) {
- int xid = *reinterpret_cast<int*>(property);
- GdkWindow* active_window = gdk_window_lookup(xid);
- FOR_EACH_OBSERVER(
- Observer,
- observers_,
- ActiveWindowChanged(active_window));
- }
- if (property)
- XFree(property);
-}
-
-GdkFilterReturn ActiveWindowWatcherX::OnWindowXEvent(GdkXEvent* xevent,
- GdkEvent* event, gpointer window_watcher) {
- ActiveWindowWatcherX* watcher = reinterpret_cast<ActiveWindowWatcherX*>(
- window_watcher);
- XEvent* xev = static_cast<XEvent*>(xevent);
-
- if (xev->xany.type == PropertyNotify &&
- xev->xproperty.atom == kNetActiveWindowAtom) {
- watcher->NotifyActiveWindowChanged();
- }
-
- return GDK_FILTER_CONTINUE;
-}