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

Side by Side Diff: chrome/browser/screensaver_window_finder_linux.cc

Issue 7945014: Applied review comments from oshima for CL 7850026. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/screensaver_window_finder_linux.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/screensaver_window_finder_linux.h"
6
7 #include <gdk/gdk.h>
8 #include <gdk/gdkx.h>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/ui/gtk/gtk_util.h"
12 #include "ui/base/x/x11_util.h"
13
14
15 ScreensaverWindowFinder::ScreensaverWindowFinder()
16 : exists_(false) {
17 }
18
19 bool ScreensaverWindowFinder::ScreensaverWindowExists() {
20 #if defined(USE_AURA)
21 return false;
22 #else
23 gdk_error_trap_push();
24 ScreensaverWindowFinder finder;
25 gtk_util::EnumerateTopLevelWindows(&finder);
26 bool got_error = gdk_error_trap_pop();
27 return finder.exists_ && !got_error;
28 #endif
29 }
30
31 bool ScreensaverWindowFinder::ShouldStopIterating(XID window) {
32 if (!ui::IsWindowVisible(window) || !IsScreensaverWindow(window))
33 return false;
34 exists_ = true;
35 return true;
36 }
37
38 bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const {
39 // It should occupy the full screen.
40 if (!ui::IsX11WindowFullScreen(window))
41 return false;
42
43 // For xscreensaver, the window should have _SCREENSAVER_VERSION property.
44 if (ui::PropertyExists(window, "_SCREENSAVER_VERSION"))
45 return true;
46
47 // For all others, like gnome-screensaver, the window's WM_CLASS property
48 // should contain "screensaver".
49 std::string value;
50 if (!ui::GetStringProperty(window, "WM_CLASS", &value))
51 return false;
52
53 return value.find("screensaver") != std::string::npos;
54 }
OLDNEW
« no previous file with comments | « chrome/browser/screensaver_window_finder_linux.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698