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
3 // found in the LICENSE file.
5 #include "ui/base/x/x11_menu_list.h"
7 #include "base/memory/singleton.h"
8 #include "ui/base/x/x11_util.h"
13 XMenuList
* XMenuList::GetInstance() {
14 return base::Singleton
<XMenuList
>::get();
17 XMenuList::XMenuList()
18 : menu_type_atom_(GetAtom("_NET_WM_WINDOW_TYPE_MENU")) {
21 XMenuList::~XMenuList() {
25 void XMenuList::MaybeRegisterMenu(XID menu
) {
27 if (!GetIntProperty(menu
, "_NET_WM_WINDOW_TYPE", &value
) ||
28 static_cast<XAtom
>(value
) != menu_type_atom_
) {
31 menus_
.push_back(menu
);
34 void XMenuList::MaybeUnregisterMenu(XID menu
) {
35 std::vector
<XID
>::iterator iter
= std::find(menus_
.begin(), menus_
.end(),
37 if (iter
== menus_
.end())
42 void XMenuList::InsertMenuWindowXIDs(std::vector
<XID
>* stack
) {
43 stack
->insert(stack
->begin(), menus_
.begin(), menus_
.end());