From: Michael Stapelberg Date: Sun, 9 Oct 2011 12:40:15 +0000 (+0100) Subject: Move fake_configure_notify to libi3 X-Git-Tag: 4.1~113^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=29c185dd0b88cb845513117461d0ca513843abaf;p=i3%2Fi3 Move fake_configure_notify to libi3 --- diff --git a/include/libi3.h b/include/libi3.h index 079d160b..123e5895 100644 --- a/include/libi3.h +++ b/include/libi3.h @@ -5,6 +5,9 @@ #ifndef _LIBI3_H #define _LIBI3_H +#include +#include + /** * Try to get the socket path from X11 and return NULL if it doesn’t work. * @@ -67,4 +70,12 @@ int ipc_send_message(int sockfd, uint32_t message_size, int ipc_recv_message(int sockfd, uint32_t message_type, uint32_t *reply_length, uint8_t **reply); +/** + * Generates a configure_notify event and sends it to the given window + * Applications need this to think they’ve configured themselves correctly. + * The truth is, however, that we will manage them. + * + */ +void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width); + #endif diff --git a/include/xcb.h b/include/xcb.h index 185163b4..5bc40d2a 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -102,14 +102,6 @@ void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc, uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t width, uint32_t height); -/** - * Generates a configure_notify event and sends it to the given window - * Applications need this to think they’ve configured themselves correctly. - * The truth is, however, that we will manage them. - * - */ -void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window, int border_width); - /** * Generates a configure_notify_event with absolute coordinates (relative to * the X root window, not to the client’s frame) for the given client. diff --git a/libi3/fake_configure_notify.c b/libi3/fake_configure_notify.c new file mode 100644 index 00000000..5f954cfa --- /dev/null +++ b/libi3/fake_configure_notify.c @@ -0,0 +1,49 @@ +/* + * vim:ts=4:sw=4:expandtab + * + * i3 - an improved dynamic tiling window manager + * + * © 2009-2011 Michael Stapelberg and contributors + * + * See file LICENSE for license information. + * + */ +#include +#include + +#include +#include + +#include "libi3.h" + +/* + * Generates a configure_notify event and sends it to the given window + * Applications need this to think they’ve configured themselves correctly. + * The truth is, however, that we will manage them. + * + */ +void fake_configure_notify(xcb_connection_t *conn, xcb_rectangle_t r, xcb_window_t window, int border_width) { + /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes. + * In order to properly initialize these bytes, we allocate 32 bytes even + * though we only need less for an xcb_configure_notify_event_t */ + void *event = scalloc(32); + xcb_configure_notify_event_t *generated_event = event; + + generated_event->event = window; + generated_event->window = window; + generated_event->response_type = XCB_CONFIGURE_NOTIFY; + + generated_event->x = r.x; + generated_event->y = r.y; + generated_event->width = r.width; + generated_event->height = r.height; + + generated_event->border_width = border_width; + generated_event->above_sibling = XCB_NONE; + generated_event->override_redirect = false; + + xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)generated_event); + xcb_flush(conn); + + free(event); +} diff --git a/src/xcb.c b/src/xcb.c index 09f0fb25..31d78703 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -162,45 +162,13 @@ void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect); } -/* - * Generates a configure_notify event and sends it to the given window - * Applications need this to think they’ve configured themselves correctly. - * The truth is, however, that we will manage them. - * - */ -void fake_configure_notify(xcb_connection_t *conn, Rect r, xcb_window_t window, int border_width) { - /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes. - * In order to properly initialize these bytes, we allocate 32 bytes even - * though we only need less for an xcb_configure_notify_event_t */ - void *event = scalloc(32); - xcb_configure_notify_event_t *generated_event = event; - - generated_event->event = window; - generated_event->window = window; - generated_event->response_type = XCB_CONFIGURE_NOTIFY; - - generated_event->x = r.x; - generated_event->y = r.y; - generated_event->width = r.width; - generated_event->height = r.height; - - generated_event->border_width = border_width; - generated_event->above_sibling = XCB_NONE; - generated_event->override_redirect = false; - - xcb_send_event(conn, false, window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char*)generated_event); - xcb_flush(conn); - - free(event); -} - /* * Generates a configure_notify_event with absolute coordinates (relative to the X root * window, not to the client’s frame) for the given client. * */ void fake_absolute_configure_notify(Con *con) { - Rect absolute; + xcb_rectangle_t absolute; if (con->window == NULL) return;