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_gtk.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) | |
21 return false; | |
22 #else | |
23 gdk_error_trap_push(); | 20 gdk_error_trap_push(); |
24 ScreensaverWindowFinder finder; | 21 ScreensaverWindowFinder finder; |
25 gtk_util::EnumerateTopLevelWindows(&finder); | 22 gtk_util::EnumerateTopLevelWindows(&finder); |
26 bool got_error = gdk_error_trap_pop(); | 23 bool got_error = gdk_error_trap_pop(); |
27 return finder.exists_ && !got_error; | 24 return finder.exists_ && !got_error; |
28 #endif | |
29 } | 25 } |
30 | 26 |
31 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) { | 27 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) { |
32 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window)) | 28 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window)) |
33 return false; | 29 return false; |
34 exists_ = true; | 30 exists_ = true; |
35 return true; | 31 return true; |
36 } | 32 } |
37 | 33 |
38 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const { | 34 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const { |
39 // It should occupy the full screen. | 35 // It should occupy the full screen. |
40 if (!ui::IsX11WindowFullScreen(window)) | 36 if (!ui::IsX11WindowFullScreen(window)) |
41 return false; | 37 return false; |
42 | 38 |
43 // For xscreensaver, the window should have _SCREENSAVER_VERSION property. | 39 // For xscreensaver, the window should have _SCREENSAVER_VERSION property. |
44 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION")) | 40 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION")) |
45 return true; | 41 return true; |
46 | 42 |
47 // For all others, like gnome-screensaver, the window's WM_CLASS property | 43 // For all others, like gnome-screensaver, the window's WM_CLASS property |
48 // should contain "screensaver". | 44 // should contain "screensaver". |
49 std::string value; | 45 std::string value; |
50 if (!ui::GetStringProperty(window, "WM_CLASS", &value)) | 46 if (!ui::GetStringProperty(window, "WM_CLASS", &value)) |
51 return false; | 47 return false; |
52 | 48 |
53 return value.find("screensaver") != std::string::npos; | 49 return value.find("screensaver") != std::string::npos; |
54 } | 50 } |
OLD | NEW |