| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/x/x11_menu_list.h" | 5 #include "ui/base/x/x11_menu_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "ui/base/x/x11_util.h" | 10 #include "ui/base/x/x11_util.h" |
| 11 #include "ui/gfx/x/x11_atom_cache.h" |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 | 14 |
| 14 // static | 15 // static |
| 15 XMenuList* XMenuList::GetInstance() { | 16 XMenuList* XMenuList::GetInstance() { |
| 16 return base::Singleton<XMenuList>::get(); | 17 return base::Singleton<XMenuList>::get(); |
| 17 } | 18 } |
| 18 | 19 |
| 19 XMenuList::XMenuList() | 20 XMenuList::XMenuList() |
| 20 : menu_type_atom_(GetAtom("_NET_WM_WINDOW_TYPE_MENU")) { | 21 : menu_type_atom_(gfx::GetAtom("_NET_WM_WINDOW_TYPE_MENU")) {} |
| 21 } | |
| 22 | 22 |
| 23 XMenuList::~XMenuList() { | 23 XMenuList::~XMenuList() { |
| 24 menus_.clear(); | 24 menus_.clear(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void XMenuList::MaybeRegisterMenu(XID menu) { | 27 void XMenuList::MaybeRegisterMenu(XID menu) { |
| 28 int value = 0; | 28 int value = 0; |
| 29 if (!GetIntProperty(menu, "_NET_WM_WINDOW_TYPE", &value) || | 29 if (!GetIntProperty(menu, "_NET_WM_WINDOW_TYPE", &value) || |
| 30 static_cast<XAtom>(value) != menu_type_atom_) { | 30 static_cast<XAtom>(value) != menu_type_atom_) { |
| 31 return; | 31 return; |
| 32 } | 32 } |
| 33 menus_.push_back(menu); | 33 menus_.push_back(menu); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void XMenuList::MaybeUnregisterMenu(XID menu) { | 36 void XMenuList::MaybeUnregisterMenu(XID menu) { |
| 37 std::vector<XID>::iterator iter = std::find(menus_.begin(), menus_.end(), | 37 std::vector<XID>::iterator iter = std::find(menus_.begin(), menus_.end(), |
| 38 menu); | 38 menu); |
| 39 if (iter == menus_.end()) | 39 if (iter == menus_.end()) |
| 40 return; | 40 return; |
| 41 menus_.erase(iter); | 41 menus_.erase(iter); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void XMenuList::InsertMenuWindowXIDs(std::vector<XID>* stack) { | 44 void XMenuList::InsertMenuWindowXIDs(std::vector<XID>* stack) { |
| 45 stack->insert(stack->begin(), menus_.begin(), menus_.end()); | 45 stack->insert(stack->begin(), menus_.begin(), menus_.end()); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace ui | 48 } // namespace ui |
| OLD | NEW |