#undef True
#undef False
+
+#define PANE_DATA_TYPE struct xcb_data
#include "core.h"
enum my_atoms {
cairo_region_t *need_update;
} *panes;
};
+#include "core-pane.h"
/* panes->r.x is NEVER_DRAWN if the pane has not been drawn */
#define NEVER_DRAWN (-60000)
static struct panes *get_pixmap(struct pane *home safe,
struct pane *p safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
struct panes **pp, *ps;
for (pp = &xd->panes; (ps = *pp) != NULL; pp = &(*pp)->next) {
{
/* If this is only display, then refuse to close this one */
struct call_return cr;
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
if (xd->noclose) {
call("Message", ci->focus, 0, NULL, xd->noclose);
DEF_CMD(xcb_set_noclose)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
free(xd->noclose);
xd->noclose = NULL;
DEF_CMD(xcb_external_viewer)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
const char *path = ci->str;
struct pids *p;
int pid;
DEF_CMD(xcb_fullscreen)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
xcb_client_message_event_t msg = {};
msg.response_type = XCB_CLIENT_MESSAGE;
DEF_CMD(xcb_close)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
xcb_destroy_window(xd->conn, xd->win);
kbd_free(xd);
DEF_CMD(xcb_free)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
pango_font_description_free(xd->fd);
cairo_destroy(xd->cairo);
xcb_disconnect(xd->conn);
if (xd->need_update)
cairo_region_destroy(xd->need_update);
- unalloc(xd, pane);
return 1;
}
DEF_CMD(xcb_clear)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
const char *attr = ci->str;
struct panes *src = NULL, *dest;
struct rgb bg;
DEF_CMD(xcb_text_size)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
const char *attr = ci->str2 ?: "";
const char *str = ci->str ?: "";
int scale = ci->num2;
DEF_CMD(xcb_draw_text)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
const char *str = ci->str;
const char *attr = ci->str2;
int scale = 1000;
* p->cx, p->cy of a size so that 'x' will fit across and
* 'y' will fit down.
*/
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
bool stretch = ci->num & 16;
int pos = ci->num;
int w = ci->focus->w, h = ci->focus->h;
DEF_CMD(xcb_refresh_post)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
struct panes *ps;
time_start(TIME_WINDOW);
/* FIXME: should I consider resizing the window?
* For now, just ensure we redraw everything.
*/
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
cairo_rectangle_int_t r = {
.x = 0,
.y = 0,
DEF_CMD(xcb_pane_close)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
struct panes **pp, *ps;
for (pp = &xd->panes; (ps = *pp) != NULL; pp = &(*pp)->next) {
DEF_CMD(xcb_notify_display)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
comm_call(ci->comm2, "callback:display", ci->home, xd->last_event);
return 1;
}
static void handle_button(struct pane *home safe,
xcb_button_press_event_t *be safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
bool press = (be->response_type & 0x7f) == XCB_BUTTON_PRESS;
char mod[2+2+2+1];
char key[2+2+2+9+1+1];
static void handle_motion(struct pane *home safe,
xcb_motion_notify_event_t *mne safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
xcb_query_pointer_cookie_t c;
xcb_query_pointer_reply_t *qpr;
int ret;
static void handle_focus(struct pane *home safe, xcb_focus_in_event_t *fie safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
bool in = (fie->response_type & 0x7f) == XCB_FOCUS_IN;
struct pane *p;
struct mark *pt;
static void handle_key_press(struct pane *home safe,
xcb_key_press_event_t *kpe safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
xkb_keycode_t keycode = kpe->detail;
xcb_keysym_t keysym;
xkb_keysym_t sym;
static void handle_xkb_event(struct pane *home safe,
xcb_generic_event_t *ev safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
switch (ev->pad0) {
xcb_xkb_new_keyboard_notify_event_t *nkne;
static void handle_configure(struct pane *home safe,
xcb_configure_notify_event_t *cne safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
pane_resize(home, 0, 0, cne->width, cne->height);
cairo_xcb_surface_set_size(xd->surface, cne->width, cne->height);
static void handle_expose(struct pane *home safe,
xcb_expose_event_t *ee safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
cairo_rectangle_int_t r = {
.x = ee->x,
.y = ee->y,
static void handle_client_message(struct pane *home safe,
xcb_client_message_event_t *cme safe)
{
- struct xcb_data *xd = home->data;
+ struct xcb_data *xd = &home->data;
if (cme->type == xd->atoms[a_WM_PROTOCOLS] &&
cme->format == 32 &&
DEF_CMD(xcb_input)
{
- struct xcb_data *xd = ci->home->data;
+ struct xcb_data *xd = &ci->home->data;
xcb_generic_event_t *ev;
int ret = 1;
if (xcb_connection_has_error(conn))
return NULL;
- alloc(xd, pane);
+ p = pane_register(pane_root(focus), 1, &xcb_handle.c);
+ if (!p)
+ return NULL;
+ xd = &p->data;
xd->motion_blocked = True;
xd->in_focus = True;
xcb_map_window(conn, xd->win);
xcb_flush(conn);
- p = pane_register(pane_root(focus), 1, &xcb_handle.c, xd);
- if (!p)
- goto abort;
pane_resize(p, 0, 0, xd->charwidth*80, xd->lineheight*26);
call_comm("event:read", p, &xcb_input, xcb_get_file_descriptor(conn));
call_comm("event:poll", p, &xcb_input);
xcb_disconnect(conn);
free(xd->display);
free(xd->disp_auth);
- unalloc(xd, pane);
return NULL;
}