1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* Copyright (c) 2012 Jess VanDerwalker
*
* util.h
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef _UTIL_H_
#define _UTIL_H_
#include <stdlib.h>
#include <stdio.h>
#include <xcb/xcb.h>
typedef struct image_data_t {
uint8_t *data;
int length;
} image_data_t;
/**
* Return the given windows attributes reply. Caller must free memory
* allocated for reply.
* @param conn The windows connection.
* @param window The window.
* @return The window attributes reply. Null if the request fails.
*/
xcb_get_window_attributes_reply_t *
GetWindowAttributes (xcb_connection_t *conn, xcb_window_t window);
/**
* Return the geometry of the window in a geometry reply. Caller must free
* memory allocated for reply.
* @param conn The windows connection.
* @param window The window.
* @return The window's geometry reply. Null if the request for reply fails.
*/
xcb_get_geometry_reply_t *
GetWindowGeometry (xcb_connection_t *conn, xcb_window_t window);
/**
* Print out information about the existing windows attached to our
* root. Most of this code is taken from src/manage.c from the i3 code
* by Michael Stapelberg
*/
void WriteAllChildrenWindowInfo (xcb_connection_t *conn,
xcb_window_t root);
/**
* Get the image data for a window.
* @param conn The connection to the xserver.
* @param window The window.
* @return Structure containing data and data length
*/
image_data_t
GetWindowImageData (xcb_connection_t *conn, xcb_window_t window);
/**
* Write information about a window out to stdio.
* TODO: Add the ability to pass in the stream to write to.
* @param conn The connection with the window.
* @param window The window.
*/
void
WriteWindowInfo (xcb_connection_t *conn, xcb_window_t window);
/**
* Check the request cookie and determine if there is an error.
* @param conn The connection the request was sent on.
* @param cookie The cookie returned by the request.
* @param msg the string to display if there is an error with the request.
* @return int The number of the error code, if any. Otherwise zero.
*/
int
RequestCheck (xcb_connection_t *conn, xcb_void_cookie_t cookie,
char *msg);
#endif /* _UTIL_H_ */
|