1 #include "cwmcc_internal.h"
4 #include "root_props.h"
10 void cwmcc_root_get_supported(Window win, Atom **atoms)
14 if (!prop_get_array32(win, CWMCC_ATOM(root, net_supported),
15 CWMCC_ATOM(type, atom), atoms, &num)) {
16 g_warning("Failed to read NET_SUPPORTED from 0x%lx", win);
21 void cwmcc_root_get_client_list(Window win, Window **windows)
25 if (!prop_get_array32(win, CWMCC_ATOM(root, net_client_list),
26 CWMCC_ATOM(type, window), windows, &num)) {
27 g_warning("Failed to read NET_CLIENT_LIST from 0x%lx", win);
32 void cwmcc_root_get_client_list_stacking(Window win, Window **windows)
36 if (!prop_get_array32(win, CWMCC_ATOM(root, net_client_list_stacking),
37 CWMCC_ATOM(type, window), windows, &num)) {
38 g_warning("Failed to read NET_CLIENT_LIST_STACKING from 0x%lx", win);
43 void cwmcc_root_get_number_of_desktops(Window win, gulong *desktops)
45 if (!prop_get32(win, CWMCC_ATOM(root, net_number_of_desktops),
46 CWMCC_ATOM(type, cardinal), desktops)) {
47 g_warning("Failed to read NET_NUMBER_OF_DESKTOPS from 0x%lx", win);
52 void cwmcc_root_get_desktop_geometry(Window win, gulong *w, gulong *h)
54 gulong *data = NULL, num;
56 if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_geometry),
57 CWMCC_ATOM(type, cardinal), &data, &num)) {
58 g_warning("Failed to read NET_DESKTOP_GEOMETRY from 0x%lx", win);
60 } else if (num != 2) {
61 g_warning("Read invalid NET_DESKTOP_GEOMETRY from 0x%lx", win);
70 void cwmcc_root_get_desktop_viewport(Window win, gulong *x, gulong *y)
72 gulong *data = NULL, num;
74 if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_viewport),
75 CWMCC_ATOM(type, cardinal), &data, &num)) {
76 g_warning("Failed to read NET_DESKTOP_VIEWPORT from 0x%lx", win);
78 } else if (num != 2) {
79 g_warning("Read invalid NET_DESKTOP_VIEWPORT from 0x%lx", win);
88 void cwmcc_root_get_current_desktop(Window win, gulong *desktop)
90 if (!prop_get32(win, CWMCC_ATOM(root, net_current_desktop),
91 CWMCC_ATOM(type, cardinal), desktop)) {
92 g_warning("Failed to read NET_CURRENT_DESKTOP from 0x%lx", win);
97 void cwmcc_root_get_desktop_names(Window win, char ***names)
99 if (!prop_get_strings_utf8(win,
100 CWMCC_ATOM(root, net_desktop_names), names)) {
101 g_warning("Failed to read NET_DESKTOP_NAMES from 0x%lx", win);
106 void cwmcc_root_get_active_window(Window win, Window *window)
108 if (!prop_get32(win, CWMCC_ATOM(root, net_active_window),
109 CWMCC_ATOM(type, window), window)) {
110 g_warning("Failed to read NET_ACTIVE_WINDOW from 0x%lx", win);
115 /*void cwmcc_root_get_workarea(Window win, Rect a)
119 void cwmcc_root_get_supporting_wm_check(Window win, Window *window)
121 if (!prop_get32(win, CWMCC_ATOM(root, net_supporting_wm_check),
122 CWMCC_ATOM(type, window), window)) {
123 g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win);
128 void cwmcc_root_get_desktop_layout(Window win,
129 struct Cwmcc_DesktopLayout *layout)
131 gulong *data = NULL, num;
134 /* need the number of desktops */
135 cwmcc_root_get_number_of_desktops(win, &desks);
137 layout->orientation = Cwmcc_Orientation_Horz;
138 layout->start_corner = Cwmcc_Corner_TopLeft;
140 layout->columns = desks;
142 if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_layout),
143 CWMCC_ATOM(type, cardinal), &data, &num)) {
144 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win);
145 } else if (num != 4) {
146 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win);
148 if (data[0] == Cwmcc_Orientation_Horz ||
149 data[0] == Cwmcc_Orientation_Vert)
150 layout->orientation = data[0];
151 if (data[3] == Cwmcc_Corner_TopLeft ||
152 data[3] == Cwmcc_Corner_TopRight ||
153 data[3] == Cwmcc_Corner_BottomLeft ||
154 data[3] == Cwmcc_Corner_BottomRight)
155 layout->start_corner = data[3];
156 layout->rows = data[2];
157 layout->columns = data[1];
159 /* bounds checking */
160 if (layout->orientation == Cwmcc_Orientation_Horz) {
161 if (layout->rows > desks)
162 layout->rows = desks;
163 if (layout->columns > ((desks + desks % layout->rows) /
165 layout->columns = ((desks + desks % layout->rows) /
168 if (layout->columns > desks)
169 layout->columns = desks;
170 if (layout->rows > ((desks + desks % layout->columns) /
172 layout->rows = ((desks + desks % layout->columns) /
179 void cwmcc_root_get_showing_desktop(Window win, gboolean *showing)
183 if (!prop_get32(win, CWMCC_ATOM(root, net_showing_desktop),
184 CWMCC_ATOM(type, cardinal), &a)) {
185 g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win);
191 void cwmcc_root_get_openbox_pid(Window win, gulong *pid)
193 if (!prop_get32(win, CWMCC_ATOM(root, openbox_pid),
194 CWMCC_ATOM(type, cardinal), pid)) {
195 g_warning("Failed to read OPENBOX_PID from 0x%lx", win);