]>
Dogcows Code - chaz/openbox/blob - cwmcc/root_props.c
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
, int **x
, int **y
, int **w
, int **h
)
117 gulong
*data
= NULL
, num
;
120 /* need the number of desktops */
121 cwmcc_root_get_number_of_desktops(win
, &desks
);
123 if (!prop_get_array32(win
, CWMCC_ATOM(root
, net_workarea
),
124 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
125 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
126 } else if (num
!= 4 * desks
) {
127 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
129 *x
= g_new(int, desks
);
130 *y
= g_new(int, desks
);
131 *w
= g_new(int, desks
);
132 *h
= g_new(int, desks
);
133 for (i
= 0; i
< desks
; ++i
) {
134 (*x
)[i
] = data
[i
* 4];
135 (*y
)[i
] = data
[i
* 4 + 1];
136 (*w
)[i
] = data
[i
* 4 + 2];
137 (*h
)[i
] = data
[i
* 4 + 3];
142 void cwmcc_root_get_supporting_wm_check(Window win
, Window
*window
)
144 if (!prop_get32(win
, CWMCC_ATOM(root
, net_supporting_wm_check
),
145 CWMCC_ATOM(type
, window
), window
)) {
146 g_warning("Failed to read NET_SUPPORTING_WM_CHECK from 0x%lx", win
);
151 void cwmcc_root_get_desktop_layout(Window win
,
152 struct Cwmcc_DesktopLayout
*layout
)
154 gulong
*data
= NULL
, num
;
157 /* need the number of desktops */
158 cwmcc_root_get_number_of_desktops(win
, &desks
);
160 layout
->orientation
= Cwmcc_Orientation_Horz
;
161 layout
->start_corner
= Cwmcc_Corner_TopLeft
;
163 layout
->columns
= desks
;
165 if (!prop_get_array32(win
, CWMCC_ATOM(root
, net_desktop_layout
),
166 CWMCC_ATOM(type
, cardinal
), &data
, &num
)) {
167 g_warning("Failed to read NET_DESKTOP_LAYOUT from 0x%lx", win
);
168 } else if (num
!= 4) {
169 g_warning("Read invalid NET_DESKTOP_LAYOUT from 0x%lx", win
);
171 if (data
[0] == Cwmcc_Orientation_Horz
||
172 data
[0] == Cwmcc_Orientation_Vert
)
173 layout
->orientation
= data
[0];
174 if (data
[3] == Cwmcc_Corner_TopLeft
||
175 data
[3] == Cwmcc_Corner_TopRight
||
176 data
[3] == Cwmcc_Corner_BottomLeft
||
177 data
[3] == Cwmcc_Corner_BottomRight
)
178 layout
->start_corner
= data
[3];
179 layout
->rows
= data
[2];
180 layout
->columns
= data
[1];
182 /* bounds checking */
183 if (layout
->orientation
== Cwmcc_Orientation_Horz
) {
184 if (layout
->rows
> desks
)
185 layout
->rows
= desks
;
186 if (layout
->columns
> ((desks
+ desks
% layout
->rows
) /
188 layout
->columns
= ((desks
+ desks
% layout
->rows
) /
191 if (layout
->columns
> desks
)
192 layout
->columns
= desks
;
193 if (layout
->rows
> ((desks
+ desks
% layout
->columns
) /
195 layout
->rows
= ((desks
+ desks
% layout
->columns
) /
202 void cwmcc_root_get_showing_desktop(Window win
, gboolean
*showing
)
206 if (!prop_get32(win
, CWMCC_ATOM(root
, net_showing_desktop
),
207 CWMCC_ATOM(type
, cardinal
), &a
)) {
208 g_warning("Failed to read NET_SHOWING_DESKTOP from 0x%lx", win
);
214 void cwmcc_root_get_openbox_pid(Window win
, gulong
*pid
)
216 if (!prop_get32(win
, CWMCC_ATOM(root
, openbox_pid
),
217 CWMCC_ATOM(type
, cardinal
), pid
)) {
218 g_warning("Failed to read OPENBOX_PID from 0x%lx", win
);
This page took 0.044765 seconds and 5 git commands to generate.