1 | //! Collects every atom used by the platform implementation. |
2 | |
3 | use core::ops::Index; |
4 | |
5 | macro_rules! atom_manager { |
6 | ($($name:ident $(:$lit:literal)?),*) => { |
7 | x11rb::atom_manager! { |
8 | /// The atoms used by `winit` |
9 | pub Atoms: AtomsCookie { |
10 | $($name $(:$lit)?,)* |
11 | } |
12 | } |
13 | |
14 | /// Indices into the `Atoms` struct. |
15 | #[derive(Copy, Clone, Debug)] |
16 | #[allow(non_camel_case_types)] |
17 | pub enum AtomName { |
18 | $($name,)* |
19 | } |
20 | |
21 | impl AtomName { |
22 | pub(crate) fn atom_from( |
23 | self, |
24 | atoms: &Atoms |
25 | ) -> &x11rb::protocol::xproto::Atom { |
26 | match self { |
27 | $(AtomName::$name => &atoms.$name,)* |
28 | } |
29 | } |
30 | } |
31 | }; |
32 | } |
33 | |
34 | atom_manager! { |
35 | // General Use Atoms |
36 | CARD32, |
37 | UTF8_STRING, |
38 | WM_CHANGE_STATE, |
39 | WM_CLIENT_MACHINE, |
40 | WM_DELETE_WINDOW, |
41 | WM_PROTOCOLS, |
42 | WM_STATE, |
43 | XIM_SERVERS, |
44 | |
45 | // Assorted ICCCM Atoms |
46 | _NET_WM_ICON, |
47 | _NET_WM_MOVERESIZE, |
48 | _NET_WM_NAME, |
49 | _NET_WM_PID, |
50 | _NET_WM_PING, |
51 | _NET_WM_STATE, |
52 | _NET_WM_STATE_ABOVE, |
53 | _NET_WM_STATE_BELOW, |
54 | _NET_WM_STATE_FULLSCREEN, |
55 | _NET_WM_STATE_HIDDEN, |
56 | _NET_WM_STATE_MAXIMIZED_HORZ, |
57 | _NET_WM_STATE_MAXIMIZED_VERT, |
58 | _NET_WM_WINDOW_TYPE, |
59 | |
60 | // Activation atoms. |
61 | _NET_STARTUP_INFO_BEGIN, |
62 | _NET_STARTUP_INFO, |
63 | _NET_STARTUP_ID, |
64 | |
65 | // WM window types. |
66 | _NET_WM_WINDOW_TYPE_DESKTOP, |
67 | _NET_WM_WINDOW_TYPE_DOCK, |
68 | _NET_WM_WINDOW_TYPE_TOOLBAR, |
69 | _NET_WM_WINDOW_TYPE_MENU, |
70 | _NET_WM_WINDOW_TYPE_UTILITY, |
71 | _NET_WM_WINDOW_TYPE_SPLASH, |
72 | _NET_WM_WINDOW_TYPE_DIALOG, |
73 | _NET_WM_WINDOW_TYPE_DROPDOWN_MENU, |
74 | _NET_WM_WINDOW_TYPE_POPUP_MENU, |
75 | _NET_WM_WINDOW_TYPE_TOOLTIP, |
76 | _NET_WM_WINDOW_TYPE_NOTIFICATION, |
77 | _NET_WM_WINDOW_TYPE_COMBO, |
78 | _NET_WM_WINDOW_TYPE_DND, |
79 | _NET_WM_WINDOW_TYPE_NORMAL, |
80 | |
81 | // Drag-N-Drop Atoms |
82 | XdndAware, |
83 | XdndEnter, |
84 | XdndLeave, |
85 | XdndDrop, |
86 | XdndPosition, |
87 | XdndStatus, |
88 | XdndActionPrivate, |
89 | XdndSelection, |
90 | XdndFinished, |
91 | XdndTypeList, |
92 | TextUriList: b"text/uri-list" , |
93 | None: b"None" , |
94 | |
95 | // Miscellaneous Atoms |
96 | _GTK_THEME_VARIANT, |
97 | _MOTIF_WM_HINTS, |
98 | _NET_ACTIVE_WINDOW, |
99 | _NET_CLIENT_LIST, |
100 | _NET_FRAME_EXTENTS, |
101 | _NET_SUPPORTED, |
102 | _NET_SUPPORTING_WM_CHECK, |
103 | _XEMBED, |
104 | _XSETTINGS_SETTINGS |
105 | } |
106 | |
107 | impl Index<AtomName> for Atoms { |
108 | type Output = x11rb::protocol::xproto::Atom; |
109 | |
110 | fn index(&self, index: AtomName) -> &Self::Output { |
111 | index.atom_from(self) |
112 | } |
113 | } |
114 | |
115 | pub(crate) use AtomName::*; |
116 | // Make sure `None` is still defined. |
117 | pub(crate) use core::option::Option::None; |
118 | |