]>
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
)
12 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_supported
),
13 CWMCC_ATOM(type
, atom
), atoms
, &num
)) {
14 g_warning("Failed to read NET_SUPPORTED from 0x%lx", win
);
19 void cwmcc_root_get_client_list(Window win
, Window
**windows
)
23 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_client_list
),
24 CWMCC_ATOM(type
, window
), windows
, &num
)) {
25 g_warning("Failed to read NET_CLIENT_LIST from 0x%lx", win
);
30 void cwmcc_root_get_client_list_stacking(Window win
, Window
**windows
)
34 if (!cwmcc_prop_get_array32(win
,CWMCC_ATOM(root
, net_client_list_stacking
),
35 CWMCC_ATOM(type
, window
), windows
, &num
)) {
36 g_warning("Failed to read NET_CLIENT_LIST_STACKING from 0x%lx", win
);
41 void cwmcc_root_get_number_of_desktops(Window win
, gulong
*desktops
)
43 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_number_of_desktops
),
44 CWMCC_ATOM(type
, cardinal
), desktops
)) {
45 g_warning("Failed to read NET_NUMBER_OF_DESKTOPS from 0x%lx", win
);
50 void cwmcc_root_get_desktop_geometry(Window win
, gulong
*w
, gulong
*h
)
52 gulong
*data
= NULL
, num
;
54 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_geometry
),
55 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
56 g_warning("Failed to read NET_DESKTOP_GEOMETRY from 0x%lx", win
);
58 } else if (num
!= 2) {
59 g_warning("Read invalid NET_DESKTOP_GEOMETRY from 0x%lx", win
);
68 void cwmcc_root_get_desktop_viewport(Window win
, gulong
*x
, gulong
*y
)
70 gulong
*data
= NULL
, num
;
72 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_viewport
),
73 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
74 g_warning("Failed to read NET_DESKTOP_VIEWPORT from 0x%lx", win
);
76 } else if (num
!= 2) {
77 g_warning("Read invalid NET_DESKTOP_VIEWPORT from 0x%lx", win
);
86 void cwmcc_root_get_current_desktop(Window win
, gulong
*desktop
)
88 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_current_desktop
),
89 CWMCC_ATOM(type
, cardinal
), desktop
)) {
90 g_warning("Failed to read NET_CURRENT_DESKTOP from 0x%lx", win
);
95 void cwmcc_root_get_desktop_names(Window win
, char ***names
)
97 if (!cwmcc_prop_get_strings_utf8(win
, CWMCC_ATOM(root
, net_desktop_names
),
99 g_warning("Failed to read NET_DESKTOP_NAMES from 0x%lx", win
);
104 void cwmcc_root_get_active_window(Window win
, Window
*window
)
106 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_active_window
),
107 CWMCC_ATOM(type
, window
), window
)) {
108 g_warning("Failed to read NET_ACTIVE_WINDOW from 0x%lx", win
);
113 void cwmcc_root_get_workarea(Window win
, int **x
, int **y
, int **w
, int **h
)
115 gulong
*data
= NULL
, num
;
118 /* need the number of desktops */
119 cwmcc_root_get_number_of_desktops(win
, &desks
);
121 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_workarea
),
122 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
123 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
124 } else if (num
!= 4 * desks
) {
125 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
127 *x
= g_new(int, desks
);
128 *y
= g_new(int, desks
);
129 *w
= g_new(int, desks
);
130 *h
= g_new(int, desks
);
131 for (i
= 0; i
< desks
; ++i
) {
132 (*x
)[i
] = data
[i
* 4];
133 (*y
)[i
] = data
[i
* 4 + 1];
134 (*w
)[i
] = data
[i
* 4 + 2];
135 (*h
)[i
] = data
[i
* 4 + 3];
140 void cwmcc_root_get_supporting_wm_check(Window win
, Window
*window
)
142 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_supporting_wm_check
),
143 CWMCC_ATOM(type
, window
), window
)) {
144 g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win
);
149 void cwmcc_root_get_desktop_layout(Window win
,
150 struct Cwmcc_DesktopLayout
*layout
)
152 gulong
*data
= NULL
, num
;
155 /* need the number of desktops */
156 cwmcc_root_get_number_of_desktops(win
, &desks
);
158 layout
->orientation
= Cwmcc_Orientation_Horz
;
159 layout
->start_corner
= Cwmcc_Corner_TopLeft
;
161 layout
->columns
= desks
;
163 if (!cwmcc_prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_layout
),
164 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
165 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
166 } else if (num
!= 4) {
167 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
169 if (data
[0] == Cwmcc_Orientation_Horz
||
170 data
[0] == Cwmcc_Orientation_Vert
)
171 layout
->orientation
= data
[0];
172 if (data
[3] == Cwmcc_Corner_TopLeft
||
173 data
[3] == Cwmcc_Corner_TopRight
||
174 data
[3] == Cwmcc_Corner_BottomLeft
||
175 data
[3] == Cwmcc_Corner_BottomRight
)
176 layout
->start_corner
= data
[3];
177 layout
->rows
= data
[2];
178 layout
->columns
= data
[1];
180 /* bounds checking */
181 if (layout
->orientation
== Cwmcc_Orientation_Horz
) {
182 if (layout
->rows
> desks
)
183 layout
->rows
= desks
;
184 if (layout
->columns
> ((desks
+ desks
% layout
->rows
) /
186 layout
->columns
= ((desks
+ desks
% layout
->rows
) /
189 if (layout
->columns
> desks
)
190 layout
->columns
= desks
;
191 if (layout
->rows
> ((desks
+ desks
% layout
->columns
) /
193 layout
->rows
= ((desks
+ desks
% layout
->columns
) /
200 void cwmcc_root_get_showing_desktop(Window win
, gboolean
*showing
)
204 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, net_showing_desktop
),
205 CWMCC_ATOM(type
, cardinal
), &a
)) {
206 g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win
);
212 void cwmcc_root_get_openbox_pid(Window win
, gulong
*pid
)
214 if (!cwmcc_prop_get32(win
, CWMCC_ATOM(root
, openbox_pid
),
215 CWMCC_ATOM(type
, cardinal
), pid
)) {
216 g_warning("Failed to read OPENBOX_PID from 0x%lx", win
);
This page took 0.051102 seconds and 4 git commands to generate.