1 | /* |
2 | * Copyright © 2001, 2007 Red Hat, Inc. |
3 | * Copyright 2024 Igalia S.L. |
4 | * |
5 | * Permission to use, copy, modify, distribute, and sell this software and its |
6 | * documentation for any purpose is hereby granted without fee, provided that |
7 | * the above copyright notice appear in all copies and that both that |
8 | * copyright notice and this permission notice appear in supporting |
9 | * documentation, and that the name of Red Hat not be used in advertising or |
10 | * publicity pertaining to distribution of the software without specific, |
11 | * written prior permission. Red Hat makes no representations about the |
12 | * suitability of this software for any purpose. It is provided "as is" |
13 | * without express or implied warranty. |
14 | * |
15 | * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL |
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT |
17 | * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
18 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
19 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 | * |
22 | * Author: Owen Taylor, Red Hat, Inc. |
23 | */ |
24 | #ifndef XSETTINGS_CLIENT_H |
25 | #define XSETTINGS_CLIENT_H |
26 | |
27 | #ifdef __cplusplus |
28 | extern "C" { |
29 | #endif /* __cplusplus */ |
30 | |
31 | typedef struct _XSettingsBuffer XSettingsBuffer; |
32 | typedef struct _XSettingsColor XSettingsColor; |
33 | typedef struct _XSettingsList XSettingsList; |
34 | typedef struct _XSettingsSetting XSettingsSetting; |
35 | |
36 | /* Types of settings possible. Enum values correspond to |
37 | * protocol values. |
38 | */ |
39 | typedef enum |
40 | { |
41 | XSETTINGS_TYPE_INT = 0, |
42 | XSETTINGS_TYPE_STRING = 1, |
43 | XSETTINGS_TYPE_COLOR = 2 |
44 | } XSettingsType; |
45 | |
46 | typedef enum |
47 | { |
48 | XSETTINGS_SUCCESS, |
49 | XSETTINGS_NO_MEM, |
50 | XSETTINGS_ACCESS, |
51 | XSETTINGS_FAILED, |
52 | XSETTINGS_NO_ENTRY, |
53 | XSETTINGS_DUPLICATE_ENTRY |
54 | } XSettingsResult; |
55 | |
56 | struct _XSettingsBuffer |
57 | { |
58 | char byte_order; |
59 | size_t len; |
60 | unsigned char *data; |
61 | unsigned char *pos; |
62 | }; |
63 | |
64 | struct _XSettingsColor |
65 | { |
66 | unsigned short red, green, blue, alpha; |
67 | }; |
68 | |
69 | struct _XSettingsList |
70 | { |
71 | XSettingsSetting *setting; |
72 | XSettingsList *next; |
73 | }; |
74 | |
75 | struct _XSettingsSetting |
76 | { |
77 | char *name; |
78 | XSettingsType type; |
79 | |
80 | union { |
81 | int v_int; |
82 | char *v_string; |
83 | XSettingsColor v_color; |
84 | } data; |
85 | |
86 | unsigned long last_change_serial; |
87 | }; |
88 | |
89 | XSettingsSetting *xsettings_setting_copy (XSettingsSetting *setting); |
90 | void xsettings_setting_free (XSettingsSetting *setting); |
91 | int xsettings_setting_equal (XSettingsSetting *setting_a, |
92 | XSettingsSetting *setting_b); |
93 | |
94 | void xsettings_list_free (XSettingsList *list); |
95 | XSettingsList *xsettings_list_copy (XSettingsList *list); |
96 | XSettingsResult xsettings_list_insert (XSettingsList **list, |
97 | XSettingsSetting *setting); |
98 | XSettingsSetting *xsettings_list_lookup (XSettingsList *list, |
99 | const char *name); |
100 | XSettingsResult xsettings_list_delete (XSettingsList **list, |
101 | const char *name); |
102 | |
103 | char xsettings_byte_order (void); |
104 | |
105 | #define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) |
106 | |
107 | typedef struct _XSettingsClient XSettingsClient; |
108 | |
109 | typedef enum |
110 | { |
111 | XSETTINGS_ACTION_NEW, |
112 | XSETTINGS_ACTION_CHANGED, |
113 | XSETTINGS_ACTION_DELETED |
114 | } XSettingsAction; |
115 | |
116 | typedef void (*XSettingsNotifyFunc) (const char *name, |
117 | XSettingsAction action, |
118 | XSettingsSetting *setting, |
119 | void *cb_data); |
120 | typedef Bool (*XSettingsWatchFunc) (Window window, |
121 | Bool is_start, |
122 | long mask, |
123 | void *cb_data); |
124 | typedef void (*XSettingsGrabFunc) (Display *display); |
125 | |
126 | XSettingsClient *xsettings_client_new (Display *display, |
127 | int screen, |
128 | XSettingsNotifyFunc notify, |
129 | XSettingsWatchFunc watch, |
130 | void *cb_data); |
131 | XSettingsClient *xsettings_client_new_with_grab_funcs (Display *display, |
132 | int screen, |
133 | XSettingsNotifyFunc notify, |
134 | XSettingsWatchFunc watch, |
135 | void *cb_data, |
136 | XSettingsGrabFunc grab, |
137 | XSettingsGrabFunc ungrab); |
138 | void xsettings_client_set_grab_func (XSettingsClient *client, |
139 | XSettingsGrabFunc grab); |
140 | void xsettings_client_set_ungrab_func (XSettingsClient *client, |
141 | XSettingsGrabFunc ungrab); |
142 | void xsettings_client_destroy (XSettingsClient *client); |
143 | Bool xsettings_client_process_event (XSettingsClient *client, |
144 | const XEvent *xev); |
145 | XSettingsResult xsettings_client_get_setting (XSettingsClient *client, |
146 | const char *name, |
147 | XSettingsSetting **setting); |
148 | |
149 | #ifdef __cplusplus |
150 | } |
151 | #endif /* __cplusplus */ |
152 | |
153 | #endif /* XSETTINGS_CLIENT_H */ |
154 | |