Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / base / x / x11_menu_list.h
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.
4
5 #ifndef UI_BASE_X_X11_MENU_LIST_H_
6 #define UI_BASE_X_X11_MENU_LIST_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "ui/base/ui_base_export.h"
12 #include "ui/gfx/x/x11_types.h"
13
14 // A process wide singleton cache for X menus.
15 template <typename T> struct DefaultSingletonTraits;
16
17 namespace ui {
18
19 // Keeps track of created and destroyed top level menu windows.
20 class UI_BASE_EXPORT XMenuList {
21  public:
22   static XMenuList* GetInstance();
23
24   // Checks if |menu| has _NET_WM_WINDOW_TYPE property set to
25   // "_NET_WM_WINDOW_TYPE_MENU" atom and if so caches it.
26   void MaybeRegisterMenu(XID menu);
27
28   // Finds |menu| in cache and if found removes it.
29   void MaybeUnregisterMenu(XID menu);
30
31   // Inserts cached menu XIDs at the beginning of |stack|.
32   void InsertMenuWindowXIDs(std::vector<XID>* stack);
33
34  private:
35   friend struct DefaultSingletonTraits<XMenuList>;
36   XMenuList();
37   ~XMenuList();
38
39   std::vector<XID> menus_;
40   XAtom menu_type_atom_;
41   DISALLOW_COPY_AND_ASSIGN(XMenuList);
42 };
43
44 }  // namespace ui
45
46 #endif  // UI_BASE_X_X11_MENU_LIST_H_