]>
Dogcows Code - chaz/openbox/blob - cwmcc/root_props.c
1 #include "cwmcc_internal.h"
4 #include "root_props.h"
8 void cwmcc_root_get_supported(Window win
, Atom
**atoms
, gulong
*num
)
10 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_supported
),
11 CWMCC_ATOM(type
, atom
), atoms
, num
)) {
12 g_warning("Failed to read NET_SUPPORTED from 0x%lx", win
);
18 void cwmcc_root_get_client_list(Window win
, Window
**windows
, gulong
*num
)
20 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_client_list
),
21 CWMCC_ATOM(type
, window
), windows
, num
)) {
22 g_warning("Failed to read NET_CLIENT_LIST from 0x%lx", win
);
28 void cwmcc_root_get_client_list_stacking(Window win
, Window
**windows
,
31 if (!cwmcc_prop_get_array32(win
,CWMCC_ATOM(root
, net_client_list_stacking
),
32 CWMCC_ATOM(type
, window
), windows
, num
)) {
33 g_warning("Failed to read NET_CLIENT_LIST_STACKING from 0x%lx", win
);
39 void cwmcc_root_get_number_of_desktops(Window win
, gulong
*desktops
)
41 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_number_of_desktops
),
42 CWMCC_ATOM(type
, cardinal
), desktops
)) {
43 g_warning("Failed to read NET_NUMBER_OF_DESKTOPS from 0x%lx", win
);
48 void cwmcc_root_get_desktop_geometry(Window win
, gulong
*w
, gulong
*h
)
50 gulong
*data
= NULL
, num
;
52 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_geometry
),
53 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
54 g_warning("Failed to read NET_DESKTOP_GEOMETRY from 0x%lx", win
);
56 } else if (num
!= 2) {
57 g_warning("Read invalid NET_DESKTOP_GEOMETRY from 0x%lx", win
);
66 void cwmcc_root_get_desktop_viewport(Window win
, gulong
*x
, gulong
*y
)
68 gulong
*data
= NULL
, num
;
70 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_viewport
),
71 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
72 g_warning("Failed to read NET_DESKTOP_VIEWPORT from 0x%lx", win
);
74 } else if (num
!= 2) {
75 g_warning("Read invalid NET_DESKTOP_VIEWPORT from 0x%lx", win
);
84 void cwmcc_root_get_current_desktop(Window win
, gulong
*desktop
)
86 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_current_desktop
),
87 CWMCC_ATOM(type
, cardinal
), desktop
)) {
88 g_warning("Failed to read NET_CURRENT_DESKTOP from 0x%lx", win
);
93 void cwmcc_root_get_desktop_names(Window win
, char ***names
)
95 if (!cwmcc_prop_get_strings_utf8(win
, CWMCC_ATOM(root
, net_desktop_names
),
97 g_warning("Failed to read NET_DESKTOP_NAMES from 0x%lx", win
);
102 void cwmcc_root_get_active_window(Window win
, Window
*window
)
104 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_active_window
),
105 CWMCC_ATOM(type
, window
), window
)) {
106 g_warning("Failed to read NET_ACTIVE_WINDOW from 0x%lx", win
);
111 void cwmcc_root_get_workarea(Window win
, int **x
, int **y
, int **w
, int **h
)
113 gulong
*data
= NULL
, num
;
116 /* need the number of desktops */
117 cwmcc_root_get_number_of_desktops(win
, &desks
);
119 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_workarea
),
120 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
121 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
122 } else if (num
!= 4 * desks
) {
123 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
125 *x
= g_new(int, desks
);
126 *y
= g_new(int, desks
);
127 *w
= g_new(int, desks
);
128 *h
= g_new(int, desks
);
129 for (i
= 0; i
< desks
; ++i
) {
130 (*x
)[i
] = data
[i
* 4];
131 (*y
)[i
] = data
[i
* 4 + 1];
132 (*w
)[i
] = data
[i
* 4 + 2];
133 (*h
)[i
] = data
[i
* 4 + 3];
138 void cwmcc_root_get_supporting_wm_check(Window win
, Window
*window
)
140 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_supporting_wm_check
),
141 CWMCC_ATOM(type
, window
), window
)) {
142 g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win
);
147 void cwmcc_root_get_desktop_layout(Window win
,
148 struct Cwmcc_DesktopLayout
*layout
)
150 gulong
*data
= NULL
, num
;
153 /* need the number of desktops */
154 cwmcc_root_get_number_of_desktops(win
, &desks
);
156 layout
->orientation
= Cwmcc_Orientation_Horz
;
157 layout
->start_corner
= Cwmcc_Corner_TopLeft
;
159 layout
->columns
= desks
;
161 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_layout
),
162 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
163 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
164 } else if (num
!= 4) {
165 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
167 if (data
[0] == Cwmcc_Orientation_Horz
||
168 data
[0] == Cwmcc_Orientation_Vert
)
169 layout
->orientation
= data
[0];
170 if (data
[3] == Cwmcc_Corner_TopLeft
||
171 data
[3] == Cwmcc_Corner_TopRight
||
172 data
[3] == Cwmcc_Corner_BottomLeft
||
173 data
[3] == Cwmcc_Corner_BottomRight
)
174 layout
->start_corner
= data
[3];
175 layout
->rows
= data
[2];
176 layout
->columns
= data
[1];
178 /* bounds checking */
179 if (layout
->orientation
== Cwmcc_Orientation_Horz
) {
180 if (layout
->rows
> desks
)
181 layout
->rows
= desks
;
182 if (layout
->columns
> ((desks
+ desks
% layout
->rows
) /
184 layout
->columns
= ((desks
+ desks
% layout
->rows
) /
187 if (layout
->columns
> desks
)
188 layout
->columns
= desks
;
189 if (layout
->rows
> ((desks
+ desks
% layout
->columns
) /
191 layout
->rows
= ((desks
+ desks
% layout
->columns
) /
198 void cwmcc_root_get_showing_desktop(Window win
, gboolean
*showing
)
202 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_showing_desktop
),
203 CWMCC_ATOM(type
, cardinal
), &a
)) {
204 g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win
);
210 void cwmcc_root_get_openbox_pid(Window win
, gulong
*pid
)
212 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, openbox_pid
),
213 CWMCC_ATOM(type
, cardinal
), pid
)) {
214 g_warning("Failed to read OPENBOX_PID from 0x%lx", win
);
This page took 0.048861 seconds and 4 git commands to generate.