Fix missing pointer dereference and missing assignment.
[gwm.git] / image.c
blob4059d30d43c044a19e41b2b7f7a64b915a7f0fa1
1 /*
2 * image.c
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/>.
21 * $Id$
24 #include <config.h>
26 #include <xcb/xcb.h>
28 #include "gwm.h"
30 #include "image.h"
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 ) {
37 static uint16_t max;
39 if( !max )
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,
45 depth, len, data );
46 else {
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 );
54 y += lines;
55 height -= lines;
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,
62 depth, len, data );