]> icculus.org git repositories - mikachu/openbox.git/blob - cwmcc/root_props.c
add right click in client focuses
[mikachu/openbox.git] / cwmcc / root_props.c
1 #include "cwmcc_internal.h"
2 #include "atom.h"
3 #include "prop.h"
4 #include "client_props.h"
5 #include "render/render.h"
6
7 #include <X11/Xutil.h>
8 #ifdef HAVE_STRING_H
9 #  include <string.h>
10 #endif
11
12 void cwmcc_root_get_supported(Window win, Atom **atoms)
13 {
14     gulong num;
15
16     if (!prop_get_array32(win, CWMCC_ATOM(root, net_supported),
17                           CWMCC_ATOM(type, atom), atoms, &num)) {
18         g_warning("Failed to read NET_SUPPORTED from 0x%lx", win);
19         *atoms = NULL;
20     }
21 }
22
23 void cwmcc_root_get_client_list(Window win, Window **windows)
24 {
25     gulong num;
26
27     if (!prop_get_array32(win, CWMCC_ATOM(root, net_client_list),
28                           CWMCC_ATOM(type, window), windows, &num)) {
29         g_warning("Failed to read NET_CLIENT_LIST from 0x%lx", win);
30         *windows = NULL;
31     }
32 }
33
34 void cwmcc_root_get_client_list_stacking(Window win, Window **windows)
35 {
36     gulong num;
37
38     if (!prop_get_array32(win, CWMCC_ATOM(root, net_client_list_stacking),
39                           CWMCC_ATOM(type, window), windows, &num)) {
40         g_warning("Failed to read NET_CLIENT_LIST_STACKING from 0x%lx", win);
41         *windows = NULL;
42     }
43 }
44
45 void cwmcc_root_get_number_of_desktops(Window win, gulong *desktops)
46 {
47     if (!prop_get32(win, CWMCC_ATOM(root, net_number_of_desktops),
48                     CWMCC_ATOM(type, cardinal), desktops)) {
49         g_warning("Failed to read NET_NUMBER_OF_DESKTOPS from 0x%lx", win);
50         *desktops = 1;
51     }
52 }
53
54 void cwmcc_root_get_desktop_geometry(Window win, gulong *w, gulong *h)
55 {
56     gulong *data = NULL, num;
57
58     if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_geometry),
59                     CWMCC_ATOM(type, cardinal), &data, &num)) {
60         g_warning("Failed to read NET_DESKTOP_GEOMETRY from 0x%lx", win);
61         *w = *h = 0;
62     } else if (num != 2) {
63         g_warning("Read invalid NET_DESKTOP_GEOMETRY from 0x%lx", win);
64         *w = *h = 0;
65     } else {
66         *w = data[0];
67         *h = data[1];
68     }
69     g_free(data);
70 }
71
72 void cwmcc_root_get_desktop_viewport(Window win, gulong *x, gulong *y)
73 {
74     gulong *data = NULL, num;
75
76     if (!prop_get_array32(win, CWMCC_ATOM(root, net_desktop_viewport),
77                     CWMCC_ATOM(type, cardinal), &data, &num)) {
78         g_warning("Failed to read NET_DESKTOP_VIEWPORT from 0x%lx", win);
79         *x = *y = 0;
80     } else if (num != 2) {
81         g_warning("Read invalid NET_DESKTOP_VIEWPORT from 0x%lx", win);
82         *x = *y = 0;
83     } else {
84         *x = data[0];
85         *y = data[1];
86     }
87     g_free(data);
88 }
89
90 void cwmcc_root_get_current_desktop(Window win, gulong *desktop)
91 {
92     if (!prop_get32(win, CWMCC_ATOM(root, net_current_desktop),
93                     CWMCC_ATOM(type, cardinal), desktop)) {
94         g_warning("Failed to read NET_CURRENT_DESKTOP from 0x%lx", win);
95         *desktop = 0;
96     }
97 }
98
99 void cwmcc_root_get_desktop_names(Window win, char ***names)
100 {
101     if (!prop_get_strings_utf8(win,
102                                CWMCC_ATOM(root, net_desktop_names), names)) {
103         g_warning("Failed to read NET_DESKTOP_NAMES from 0x%lx", win);
104         *names = NULL;
105     }
106 }
107
108 void cwmcc_root_get_active_window(Window win, Window *window)
109 {
110     if (!prop_get32(win, CWMCC_ATOM(root, net_active_window),
111                     CWMCC_ATOM(type, window), window)) {
112         g_warning("Failed to read NET_ACTIVE_WINDOW from 0x%lx", win);
113         *window = None;
114     }
115 }
116