4 * Part of gwm, the Gratuitous Window Manager,
5 * by Gary Wong, <gtw@gnu.org>.
7 * Copyright (C) 2009 Gary Wong
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of version 3 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 extern xcb_void_cookie_t
put_image( xcb_drawable_t drawable
, xcb_gcontext_t gc
,
33 uint16_t width
, uint16_t height
, int16_t x
,
34 int16_t y
, uint8_t left_pad
, uint8_t depth
,
35 uint32_t len
, const uint8_t *data
) {
40 max
= xcb_get_setup( c
)->maximum_request_length
<< 2;
42 if( len
+ sizeof (xcb_put_image_request_t
) < max
)
43 return xcb_put_image( c
, XCB_IMAGE_FORMAT_Z_PIXMAP
, drawable
,
44 gc
, width
, height
, x
, y
, left_pad
,
47 int linesize
= len
/ height
;
48 int lines
= ( max
- sizeof (xcb_put_image_request_t
) ) / linesize
;
50 while( height
> lines
) {
51 xcb_put_image( c
, XCB_IMAGE_FORMAT_Z_PIXMAP
, drawable
,
52 gc
, width
, lines
, x
, y
, left_pad
,
53 depth
, lines
* linesize
, data
);
56 len
-= lines
* linesize
;
57 data
+= lines
* linesize
;
60 return xcb_put_image( c
, XCB_IMAGE_FORMAT_Z_PIXMAP
, drawable
,
61 gc
, width
, height
, x
, y
, left_pad
,