diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 18:09:47 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 18:09:47 +0000 |
commit | 042d69900bda2d7043ef56a271cf26bb0f3988de (patch) | |
tree | 6d8ce92d659f956263b472e99b9828c708bcc3f3 /chrome/browser/screensaver_window_finder_gtk.cc | |
parent | d213fed9173c285912573e53234b53da6e702851 (diff) | |
download | chromium_src-042d69900bda2d7043ef56a271cf26bb0f3988de.zip chromium_src-042d69900bda2d7043ef56a271cf26bb0f3988de.tar.gz chromium_src-042d69900bda2d7043ef56a271cf26bb0f3988de.tar.bz2 |
Applied review comments from oshima for CL 7850026.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7945014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/screensaver_window_finder_gtk.cc')
-rw-r--r-- | chrome/browser/screensaver_window_finder_gtk.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/screensaver_window_finder_gtk.cc b/chrome/browser/screensaver_window_finder_gtk.cc new file mode 100644 index 0000000..a94f323 --- /dev/null +++ b/chrome/browser/screensaver_window_finder_gtk.cc @@ -0,0 +1,50 @@ +// 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 "chrome/browser/screensaver_window_finder_gtk.h" + +#include <gdk/gdk.h> +#include <gdk/gdkx.h> + +#include "base/basictypes.h" +#include "chrome/browser/ui/gtk/gtk_util.h" +#include "ui/base/x/x11_util.h" + + +ScreensaverWindowFinder::ScreensaverWindowFinder() + : exists_(false) { +} + +bool ScreensaverWindowFinder::ScreensaverWindowExists() { + gdk_error_trap_push(); + ScreensaverWindowFinder finder; + gtk_util::EnumerateTopLevelWindows(&finder); + bool got_error = gdk_error_trap_pop(); + return finder.exists_ && !got_error; +} + +bool ScreensaverWindowFinder::ShouldStopIterating(XID window) { + if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window)) + return false; + exists_ = true; + return true; +} + +bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const { + // It should occupy the full screen. + if (!ui::IsX11WindowFullScreen(window)) + return false; + + // For xscreensaver, the window should have _SCREENSAVER_VERSION property. + if (ui::PropertyExists(window, "_SCREENSAVER_VERSION")) + return true; + + // For all others, like gnome-screensaver, the window's WM_CLASS property + // should contain "screensaver". + std::string value; + if (!ui::GetStringProperty(window, "WM_CLASS", &value)) + return false; + + return value.find("screensaver") != std::string::npos; +} |