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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 1485093003: ui: use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
11 #include <ctype.h> 11 #include <ctype.h>
12 #include <sys/ipc.h> 12 #include <sys/ipc.h>
13 #include <sys/shm.h> 13 #include <sys/shm.h>
14 14
15 #include <list> 15 #include <list>
16 #include <map> 16 #include <map>
17 #include <utility> 17 #include <utility>
18 #include <vector> 18 #include <vector>
19 19
20 #include <X11/extensions/shape.h> 20 #include <X11/extensions/shape.h>
21 #include <X11/extensions/XInput2.h> 21 #include <X11/extensions/XInput2.h>
22 #include <X11/Xcursor/Xcursor.h> 22 #include <X11/Xcursor/Xcursor.h>
23 23
24 #include "base/bind.h" 24 #include "base/bind.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
27 #include "base/memory/singleton.h" 27 #include "base/memory/singleton.h"
28 #include "base/message_loop/message_loop.h" 28 #include "base/message_loop/message_loop.h"
29 #include "base/metrics/histogram.h" 29 #include "base/metrics/histogram.h"
30 #include "base/stl_util.h"
30 #include "base/strings/string_number_conversions.h" 31 #include "base/strings/string_number_conversions.h"
31 #include "base/strings/string_util.h" 32 #include "base/strings/string_util.h"
32 #include "base/strings/stringprintf.h" 33 #include "base/strings/stringprintf.h"
33 #include "base/sys_byteorder.h" 34 #include "base/sys_byteorder.h"
34 #include "base/threading/thread.h" 35 #include "base/threading/thread.h"
35 #include "base/trace_event/trace_event.h" 36 #include "base/trace_event/trace_event.h"
36 #include "skia/ext/image_operations.h" 37 #include "skia/ext/image_operations.h"
37 #include "third_party/skia/include/core/SkBitmap.h" 38 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "third_party/skia/include/core/SkPostConfig.h" 39 #include "third_party/skia/include/core/SkPostConfig.h"
39 #include "ui/base/x/x11_menu_list.h" 40 #include "ui/base/x/x11_menu_list.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 XWindowAttributes win_attributes; 552 XWindowAttributes win_attributes;
552 if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes)) 553 if (!XGetWindowAttributes(gfx::GetXDisplay(), window, &win_attributes))
553 return false; 554 return false;
554 if (win_attributes.map_state != IsViewable) 555 if (win_attributes.map_state != IsViewable)
555 return false; 556 return false;
556 557
557 // Minimized windows are not visible. 558 // Minimized windows are not visible.
558 std::vector<XAtom> wm_states; 559 std::vector<XAtom> wm_states;
559 if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) { 560 if (GetAtomArrayProperty(window, "_NET_WM_STATE", &wm_states)) {
560 XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN"); 561 XAtom hidden_atom = GetAtom("_NET_WM_STATE_HIDDEN");
561 if (std::find(wm_states.begin(), wm_states.end(), hidden_atom) != 562 if (ContainsValue(wm_states, hidden_atom)) {
sky 2015/12/01 22:08:31 nit: nuke {}
tfarina 2015/12/02 20:31:41 Done.
562 wm_states.end()) {
563 return false; 563 return false;
564 } 564 }
565 } 565 }
566 566
567 // Some compositing window managers (notably kwin) do not actually unmap 567 // Some compositing window managers (notably kwin) do not actually unmap
568 // windows on desktop switch, so we also must check the current desktop. 568 // windows on desktop switch, so we also must check the current desktop.
569 int window_desktop, current_desktop; 569 int window_desktop, current_desktop;
570 return (!GetWindowDesktop(window, &window_desktop) || 570 return (!GetWindowDesktop(window, &window_desktop) ||
571 !GetCurrentDesktop(&current_desktop) || 571 !GetCurrentDesktop(&current_desktop) ||
572 window_desktop == kAllDesktops || 572 window_desktop == kAllDesktops ||
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 if (depth) 1470 if (depth)
1471 *depth = s_depth; 1471 *depth = s_depth;
1472 } 1472 }
1473 #endif 1473 #endif
1474 1474
1475 // ---------------------------------------------------------------------------- 1475 // ----------------------------------------------------------------------------
1476 // End of x11_util_internal.h 1476 // End of x11_util_internal.h
1477 1477
1478 1478
1479 } // namespace ui 1479 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698