1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Collects every atom used by the platform implementation.

use core::ops::Index;

macro_rules! atom_manager {
    ($($name:ident $(:$lit:literal)?),*) => {
        x11rb::atom_manager! {
            /// The atoms used by `winit`
            pub Atoms: AtomsCookie {
                $($name $(:$lit)?,)*
            }
        }

        /// Indices into the `Atoms` struct.
        #[derive(Copy, Clone, Debug)]
        #[allow(non_camel_case_types)]
        pub enum AtomName {
            $($name,)*
        }

        impl AtomName {
            pub(crate) fn atom_from(
                self,
                atoms: &Atoms
            ) -> &x11rb::protocol::xproto::Atom {
                match self {
                    $(AtomName::$name => &atoms.$name,)*
                }
            }
        }
    };
}

atom_manager! {
    // General Use Atoms
    CARD32,
    UTF8_STRING,
    WM_CHANGE_STATE,
    WM_CLIENT_MACHINE,
    WM_DELETE_WINDOW,
    WM_PROTOCOLS,
    WM_STATE,
    XIM_SERVERS,

    // Assorted ICCCM Atoms
    _NET_WM_ICON,
    _NET_WM_MOVERESIZE,
    _NET_WM_NAME,
    _NET_WM_PID,
    _NET_WM_PING,
    _NET_WM_STATE,
    _NET_WM_STATE_ABOVE,
    _NET_WM_STATE_BELOW,
    _NET_WM_STATE_FULLSCREEN,
    _NET_WM_STATE_HIDDEN,
    _NET_WM_STATE_MAXIMIZED_HORZ,
    _NET_WM_STATE_MAXIMIZED_VERT,
    _NET_WM_WINDOW_TYPE,

    // Activation atoms.
    _NET_STARTUP_INFO_BEGIN,
    _NET_STARTUP_INFO,
    _NET_STARTUP_ID,

    // WM window types.
    _NET_WM_WINDOW_TYPE_DESKTOP,
    _NET_WM_WINDOW_TYPE_DOCK,
    _NET_WM_WINDOW_TYPE_TOOLBAR,
    _NET_WM_WINDOW_TYPE_MENU,
    _NET_WM_WINDOW_TYPE_UTILITY,
    _NET_WM_WINDOW_TYPE_SPLASH,
    _NET_WM_WINDOW_TYPE_DIALOG,
    _NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
    _NET_WM_WINDOW_TYPE_POPUP_MENU,
    _NET_WM_WINDOW_TYPE_TOOLTIP,
    _NET_WM_WINDOW_TYPE_NOTIFICATION,
    _NET_WM_WINDOW_TYPE_COMBO,
    _NET_WM_WINDOW_TYPE_DND,
    _NET_WM_WINDOW_TYPE_NORMAL,

    // Drag-N-Drop Atoms
    XdndAware,
    XdndEnter,
    XdndLeave,
    XdndDrop,
    XdndPosition,
    XdndStatus,
    XdndActionPrivate,
    XdndSelection,
    XdndFinished,
    XdndTypeList,
    TextUriList: b"text/uri-list",
    None: b"None",

    // Miscellaneous Atoms
    _GTK_THEME_VARIANT,
    _MOTIF_WM_HINTS,
    _NET_ACTIVE_WINDOW,
    _NET_CLIENT_LIST,
    _NET_FRAME_EXTENTS,
    _NET_SUPPORTED,
    _NET_SUPPORTING_WM_CHECK,
    _XEMBED,
    _XSETTINGS_SETTINGS
}

impl Index<AtomName> for Atoms {
    type Output = x11rb::protocol::xproto::Atom;

    fn index(&self, index: AtomName) -> &Self::Output {
        index.atom_from(self)
    }
}

pub(crate) use AtomName::*;
// Make sure `None` is still defined.
pub(crate) use core::option::Option::None;