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

Side by Side Diff: ui/base/idle/screensaver_window_finder_x11.cc

Issue 2924343002: Move ui::GetAtom to gfx::GetAtom (Closed)
Patch Set: fix CrOs build Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/idle/screensaver_window_finder_x11.h" 5 #include "ui/base/idle/screensaver_window_finder_x11.h"
6 6
7 #include <X11/extensions/scrnsaver.h> 7 #include <X11/extensions/scrnsaver.h>
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 #include "ui/gfx/x/x11_atom_cache.h"
10 #include "ui/gfx/x/x11_error_tracker.h" 11 #include "ui/gfx/x/x11_error_tracker.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
14 ScreensaverWindowFinder::ScreensaverWindowFinder() 15 ScreensaverWindowFinder::ScreensaverWindowFinder()
15 : exists_(false) { 16 : exists_(false) {
16 } 17 }
17 18
18 bool ScreensaverWindowFinder::ScreensaverWindowExists() { 19 bool ScreensaverWindowFinder::ScreensaverWindowExists() {
19 XScreenSaverInfo info; 20 XScreenSaverInfo info;
20 XDisplay* display = gfx::GetXDisplay(); 21 XDisplay* display = gfx::GetXDisplay();
21 XID root = DefaultRootWindow(display); 22 XID root = DefaultRootWindow(display);
22 static int xss_event_base; 23 static int xss_event_base;
23 static int xss_error_base; 24 static int xss_error_base;
24 static bool have_xss = 25 static bool have_xss =
25 XScreenSaverQueryExtension(display, &xss_event_base, &xss_error_base); 26 XScreenSaverQueryExtension(display, &xss_event_base, &xss_error_base);
26 if (have_xss && XScreenSaverQueryInfo(display, root, &info) && 27 if (have_xss && XScreenSaverQueryInfo(display, root, &info) &&
27 info.state == ScreenSaverOn) { 28 info.state == ScreenSaverOn) {
28 return true; 29 return true;
29 } 30 }
30 31
31 // Ironically, xscreensaver does not conform to the XScreenSaver protocol, so 32 // Ironically, xscreensaver does not conform to the XScreenSaver protocol, so
32 // info.state == ScreenSaverOff or info.state == ScreenSaverDisabled does not 33 // info.state == ScreenSaverOff or info.state == ScreenSaverDisabled does not
33 // necessarily mean that a screensaver is not active, so add a special check 34 // necessarily mean that a screensaver is not active, so add a special check
34 // for xscreensaver. 35 // for xscreensaver.
35 static XAtom lock_atom = GetAtom("LOCK"); 36 XAtom lock_atom = gfx::GetAtom("LOCK");
36 std::vector<int> atom_properties; 37 std::vector<int> atom_properties;
37 if (GetIntArrayProperty(root, "_SCREENSAVER_STATUS", &atom_properties) && 38 if (GetIntArrayProperty(root, "_SCREENSAVER_STATUS", &atom_properties) &&
38 atom_properties.size() > 0) { 39 atom_properties.size() > 0) {
39 if (atom_properties[0] == static_cast<int>(lock_atom)) { 40 if (atom_properties[0] == static_cast<int>(lock_atom)) {
40 return true; 41 return true;
41 } 42 }
42 } 43 }
43 44
44 // Also check the top level windows to see if any of them are screensavers. 45 // Also check the top level windows to see if any of them are screensavers.
45 gfx::X11ErrorTracker err_tracker; 46 gfx::X11ErrorTracker err_tracker;
(...skipping 21 matching lines...) Expand all
67 // For all others, like gnome-screensaver, the window's WM_CLASS property 68 // For all others, like gnome-screensaver, the window's WM_CLASS property
68 // should contain "screensaver". 69 // should contain "screensaver".
69 std::string value; 70 std::string value;
70 if (!ui::GetStringProperty(window, "WM_CLASS", &value)) 71 if (!ui::GetStringProperty(window, "WM_CLASS", &value))
71 return false; 72 return false;
72 73
73 return value.find("screensaver") != std::string::npos; 74 return value.find("screensaver") != std::string::npos;
74 } 75 }
75 76
76 } // namespace ui 77 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc ('k') | ui/base/x/selection_owner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698