]> git.sur5r.net Git - i3/i3/blob - libi3/fake_configure_notify.c
5f954cfa8e0c4314ff860be0db511243d2a3d301
[i3/i3] / libi3 / fake_configure_notify.c
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * © 2009-2011 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #include <stdlib.h>
12 #include <stdbool.h>
13
14 #include <xcb/xcb.h>
15 #include <xcb/xproto.h>
16
17 #include "libi3.h"
18
19 /*
20  * Generates a configure_notify event and sends it to the given window
21  * Applications need this to think they’ve configured themselves correctly.
22  * The truth is, however, that we will manage them.
23  *
24  */
25 void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width) {
26     /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
27      * In order to properly initialize these bytes, we allocate 32 bytes even
28      * though we only need less for an xcb_configure_notify_event_t */
29     void *event = scalloc(32);
30     xcb_configure_notify_event_t *generated_event = event;
31
32     generated_event->event = window;
33     generated_event->window = window;
34     generated_event->response_type = XCB_CONFIGURE_NOTIFY;
35
36     generated_event->x = r.x;
37     generated_event->y = r.y;
38     generated_event->width = r.width;
39     generated_event->height = r.height;
40
41     generated_event->border_width = border_width;
42     generated_event->above_sibling = XCB_NONE;
43     generated_event->override_redirect = false;
44
45     xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)generated_event);
46     xcb_flush(conn);
47
48     free(event);
49 }