Chromium Code Reviews| 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 "chrome/browser/screensaver_window_finder_linux.h" | 5 #include "chrome/browser/screensaver_window_finder_linux.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_util.h" | 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 12 #include "ui/base/x/x11_util.h" | 12 #include "ui/base/x/x11_util.h" |
| 13 | 13 |
| 14 | 14 |
| 15 ScreensaverWindowFinder::ScreensaverWindowFinder() | 15 ScreensaverWindowFinder::ScreensaverWindowFinder() |
| 16 : exists_(false) { | 16 : exists_(false) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool ScreensaverWindowFinder::ScreensaverWindowExists() { | 19 bool ScreensaverWindowFinder::ScreensaverWindowExists() { |
| 20 #if defined(USE_AURA) | |
|
oshima
2011/09/19 15:52:39
I think this file should not be linked with aura.
Emmanuel Saint-loubert-Bié
2011/09/19 20:15:36
Done.
| |
| 21 return false; | |
| 22 #else | |
| 20 gdk_error_trap_push(); | 23 gdk_error_trap_push(); |
| 21 ScreensaverWindowFinder finder; | 24 ScreensaverWindowFinder finder; |
| 22 gtk_util::EnumerateTopLevelWindows(&finder); | 25 gtk_util::EnumerateTopLevelWindows(&finder); |
| 23 bool got_error = gdk_error_trap_pop(); | 26 bool got_error = gdk_error_trap_pop(); |
| 24 return finder.exists_ && !got_error; | 27 return finder.exists_ && !got_error; |
| 28 #endif | |
| 25 } | 29 } |
| 26 | 30 |
| 27 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) { | 31 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) { |
| 28 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window)) | 32 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window)) |
| 29 return false; | 33 return false; |
| 30 exists_ = true; | 34 exists_ = true; |
| 31 return true; | 35 return true; |
| 32 } | 36 } |
| 33 | 37 |
| 34 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const { | 38 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const { |
| 35 // It should occupy the full screen. | 39 // It should occupy the full screen. |
| 36 if (!ui::IsX11WindowFullScreen(window)) | 40 if (!ui::IsX11WindowFullScreen(window)) |
| 37 return false; | 41 return false; |
| 38 | 42 |
| 39 // For xscreensaver, the window should have _SCREENSAVER_VERSION property. | 43 // For xscreensaver, the window should have _SCREENSAVER_VERSION property. |
| 40 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION")) | 44 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION")) |
| 41 return true; | 45 return true; |
| 42 | 46 |
| 43 // For all others, like gnome-screensaver, the window's WM_CLASS property | 47 // For all others, like gnome-screensaver, the window's WM_CLASS property |
| 44 // should contain "screensaver". | 48 // should contain "screensaver". |
| 45 std::string value; | 49 std::string value; |
| 46 if (!ui::GetStringProperty(window, "WM_CLASS", &value)) | 50 if (!ui::GetStringProperty(window, "WM_CLASS", &value)) |
| 47 return false; | 51 return false; |
| 48 | 52 |
| 49 return value.find("screensaver") != std::string::npos; | 53 return value.find("screensaver") != std::string::npos; |
| 50 } | 54 } |
| OLD | NEW |