libxcb_x11_plugin_la_SOURCES = \
xcb/xcb_vlc.h \
xcb/x11.c \
- xcb/common.c \
+ xcb/pictures.c \
xcb/events.c
libxcb_x11_plugin_la_CFLAGS = $(AM_CFLAGS) \
$(XCB_CFLAGS) $(XCB_SHM_CFLAGS)
libxcb_xv_plugin_la_SOURCES = \
xcb/xcb_vlc.h \
xcb/xvideo.c \
- xcb/common.c \
+ xcb/pictures.c \
xcb/events.c
libxcb_xv_plugin_la_CFLAGS = $(AM_CFLAGS) \
$(XCB_CFLAGS) $(XCB_SHM_CFLAGS) $(XCB_XV_CFLAGS)
/**
* Check for an error
*/
-int CheckError (vout_display_t *vd, xcb_connection_t *conn,
- const char *str, xcb_void_cookie_t ck)
+int XCB_error_Check (vout_display_t *vd, xcb_connection_t *conn,
+ const char *str, xcb_void_cookie_t ck)
{
xcb_generic_error_t *err;
* Create a VLC video X window object, connect to the corresponding X server,
* find the corresponding X server screen.
*/
-vout_window_t *GetWindow (vout_display_t *vd,
- xcb_connection_t **restrict pconn,
- const xcb_screen_t **restrict pscreen,
- uint8_t *restrict pdepth,
- uint16_t *restrict pwidth,
- uint16_t *restrict pheight)
+vout_window_t *XCB_parent_Create (vout_display_t *vd,
+ xcb_connection_t **restrict pconn,
+ const xcb_screen_t **restrict pscreen,
+ uint8_t *restrict pdepth,
+ uint16_t *restrict pwidth,
+ uint16_t *restrict pheight)
{
vout_window_cfg_t cfg = {
.type = VOUT_WINDOW_TYPE_XID,
* @param conn XCB connection
* @param scr target XCB screen
*/
-xcb_cursor_t CreateBlankCursor (xcb_connection_t *conn,
+xcb_cursor_t XCB_cursor_Create (xcb_connection_t *conn,
const xcb_screen_t *scr)
{
xcb_cursor_t cur = xcb_generate_id (conn);
/**
* Process incoming X events.
*/
-int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, bool *visible)
+int XCB_Manage (vout_display_t *vd, xcb_connection_t *conn, bool *visible)
{
xcb_generic_event_t *ev;
XCB_WINDOW_CLASS_INPUT_OUTPUT,
vid, mask, values);
cm = xcb_map_window_checked (conn, sys->window);
- if (CheckError (vd, conn, "cannot create X11 window", cc)
- || CheckError (vd, conn, "cannot map X11 window", cm))
+ if (XCB_error_Check (vd, conn, "cannot create X11 window", cc)
+ || XCB_error_Check (vd, conn, "cannot map X11 window", cm))
return VLC_EGENERIC;
msg_Dbg (vd, "using X11 window %08"PRIx32, sys->window);
const xcb_screen_t *scr;
uint16_t width, height;
uint8_t depth;
- sys->embed = GetWindow (vd, &conn, &scr, &depth, &width, &height);
+ sys->embed = XCB_parent_Create (vd, &conn, &scr, &depth, &width, &height);
if (sys->embed == NULL)
{
free (sys);
goto error;
}
- sys->cursor = CreateBlankCursor (conn, scr);
+ sys->cursor = XCB_cursor_Create (conn, scr);
sys->visible = false;
/* Setup vout_display_t once everything is fine */
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
values);
- if (CheckError (vd, sys->conn, "cannot resize X11 window", ck))
+ if (XCB_error_Check (vd, sys->conn, "cannot resize X11 window", ck))
return VLC_EGENERIC;
glViewport (0, 0, place.width, place.height);
{
vout_display_sys_t *sys = vd->sys;
- ManageEvent (vd, sys->conn, &sys->visible);
+ XCB_Manage (vd, sys->conn, &sys->visible);
}
* @param conn XCB connection to the X server (to fetch key mappings)
* @return NULL on error, or a key handling context.
*/
-key_handler_t *CreateKeyHandler (vlc_object_t *obj, xcb_connection_t *conn)
+key_handler_t *XCB_keyHandler_Create (vlc_object_t *obj,
+ xcb_connection_t *conn)
{
key_handler_t *ctx = malloc (sizeof (*ctx));
if (!ctx)
return ctx;
}
-void DestroyKeyHandler (key_handler_t *ctx)
+void XCB_keyHandler_Destroy (key_handler_t *ctx)
{
xcb_key_symbols_free (ctx->syms);
free (ctx);
* @param ev XCB event to process
* @return 0 if the event was handled and free()'d, non-zero otherwise
*/
-int ProcessKeyEvent (key_handler_t *ctx, xcb_generic_event_t *ev)
+int XCB_keyHandler_Process (key_handler_t *ctx, xcb_generic_event_t *ev)
{
assert (ctx);
#else /* HAVE_XCB_KEYSYMS */
-key_handler_t *CreateKeyHandler (vlc_object_t *obj, xcb_connection_t *conn)
+key_handler_t *XCB_keyHandler_Create (vlc_object_t *obj,
+ xcb_connection_t *conn)
{
msg_Err (obj, "X11 key press support not compiled-in");
(void) conn;
return NULL;
}
-void DestroyKeyHandler (key_handler_t *ctx)
+void XCB_keyHandler_Destroy (key_handler_t *ctx)
{
(void) ctx;
abort ();
}
-int ProcessKeyEvent (key_handler_t *ctx, xcb_generic_event_t *ev)
+int XCB_keyHandler_Process (key_handler_t *ctx, xcb_generic_event_t *ev)
{
(void) ctx;
(void) ev;
/**
- * @file common.c
- * @brief Common code for XCB video output plugins
+ * @file pictures.c
+ * @brief Pictures management code for XCB video output plugins
*/
/*****************************************************************************
- * Copyright © 2009 Rémi Denis-Courmont
+ * Copyright © 2009-2013 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
#include "xcb_vlc.h"
/** Check MIT-SHM shared memory support */
-bool CheckSHM (vlc_object_t *obj, xcb_connection_t *conn)
+bool XCB_shm_Check (vlc_object_t *obj, xcb_connection_t *conn)
{
#ifdef HAVE_SYS_SHM_H
xcb_shm_query_version_cookie_t ck;
* format. If a attach is true, the segment is attached to
* the X server (MIT-SHM extension).
*/
-int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t size,
- xcb_connection_t *conn, bool attach)
+int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res,
+ size_t size, xcb_connection_t *conn, bool attach)
{
res->p_sys = malloc (sizeof(*res->p_sys));
if (!res->p_sys)
segment = xcb_generate_id (conn);
ck = xcb_shm_attach_checked (conn, segment, id, 1);
- switch (CheckError (vd, conn, "shared memory server-side error", ck))
+ switch (XCB_error_Check (vd, conn, "shared memory server-side error",
+ ck))
{
case 0:
break;
buf.shm_perm.mode |= S_IRGRP|S_IROTH;
shmctl (id, IPC_SET, &buf);
ck = xcb_shm_attach_checked (conn, segment, id, 1);
- if (CheckError (vd, conn, "same error on retry", ck) == 0)
+ if (XCB_error_Check (vd, conn, "same error on retry", ck) == 0)
break;
/* fall through */
}
/**
* Release picture private data: detach the shared memory segment.
*/
-void PictureResourceFree (picture_resource_t *res, xcb_connection_t *conn)
+void XCB_pictures_Free (picture_resource_t *res, xcb_connection_t *conn)
{
#ifdef HAVE_SYS_SHM_H
xcb_shm_seg_t segment = res->p_sys->segment;
p_sys->conn = conn;
if (var_InheritBool (wnd, "keyboard-events"))
- p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
+ p_sys->keys = XCB_keyHandler_Create (VLC_OBJECT(wnd), conn);
else
p_sys->keys = NULL;
p_sys->root = scr->root;
* request from this thread must be completed at this point. */
if ((p_sys->keys != NULL)
&& vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW))
- DestroyKeyHandler (p_sys->keys);
+ XCB_keyHandler_Destroy (p_sys->keys);
xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
return VLC_SUCCESS;
{
vlc_cancel (p_sys->thread);
vlc_join (p_sys->thread, NULL);
- DestroyKeyHandler (p_sys->keys);
+ XCB_keyHandler_Destroy (p_sys->keys);
}
xcb_disconnect (conn);
free (wnd->display.x11);
int canc = vlc_savecancel ();
while ((ev = xcb_poll_for_event (conn)) != NULL)
{
- if (ProcessKeyEvent (p_sys->keys, ev) == 0)
+ if (XCB_keyHandler_Process (p_sys->keys, ev) == 0)
continue;
msg_Dbg (wnd, "unhandled event: %"PRIu8, ev->response_type);
free (ev);
if (var_InheritBool (wnd, "keyboard-events"))
{
- p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
+ p_sys->keys = XCB_keyHandler_Create (VLC_OBJECT(wnd), conn);
if (p_sys->keys != NULL)
{
const uint32_t mask = XCB_CW_EVENT_MASK;
CacheAtoms (p_sys);
if ((p_sys->keys != NULL)
&& vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW))
- DestroyKeyHandler (p_sys->keys);
+ XCB_keyHandler_Destroy (p_sys->keys);
xcb_flush (conn);
(void) cfg;
xcb_connection_t *conn;
const xcb_screen_t *scr;
uint16_t width, height;
- sys->embed = GetWindow (vd, &conn, &scr, &(uint8_t){ 0 }, &width, &height);
+ sys->embed = XCB_parent_Create (vd, &conn, &scr,
+ &(uint8_t){ 0 }, &width, &height);
if (sys->embed == NULL)
{
free (sys);
/* Create graphic context (I wonder why the heck do we need this) */
xcb_create_gc (conn, sys->gc, sys->window, 0, NULL);
- if (CheckError (vd, conn, "cannot create X11 window", c))
+ if (XCB_error_Check (vd, conn, "cannot create X11 window", c))
goto error;
}
msg_Dbg (vd, "using X11 window %08"PRIx32, sys->window);
msg_Dbg (vd, "using X11 graphic context %08"PRIx32, sys->gc);
- sys->cursor = CreateBlankCursor (conn, scr);
+ sys->cursor = XCB_cursor_Create (conn, scr);
sys->visible = false;
- sys->shm = CheckSHM (obj, conn);
+ sys->shm = XCB_shm_Check (obj, conn);
/* Setup vout_display_t once everything is fine */
res->p->i_lines = pic->p->i_lines;
res->p->i_pitch = pic->p->i_pitch;
- if (PictureResourceAlloc (vd, res, res->p->i_pitch * res->p->i_lines,
- sys->conn, sys->shm))
+ if (XCB_pictures_Alloc (vd, res, res->p->i_pitch * res->p->i_lines,
+ sys->conn, sys->shm))
break;
pic_array[count] = picture_NewFromResource (&vd->fmt, res);
if (!pic_array[count])
{
- PictureResourceFree (res, sys->conn);
+ XCB_pictures_Free (res, sys->conn);
memset (res, 0, sizeof(*res));
break;
}
{
vout_display_sys_t *sys = vd->sys;
- ManageEvent (vd, sys->conn, &sys->visible);
+ XCB_Manage (vd, sys->conn, &sys->visible);
}
static void ResetPictures (vout_display_t *vd)
if (!res->p->p_pixels)
break;
- PictureResourceFree (res, sys->conn);
+ XCB_pictures_Free (res, sys->conn);
}
picture_pool_Delete (sys->pool);
sys->pool = NULL;
#include <vlc_picture.h>
#include <vlc_vout_display.h>
-int ManageEvent (vout_display_t *vd, xcb_connection_t *conn, bool *);
-
/* keys.c */
typedef struct key_handler_t key_handler_t;
-key_handler_t *CreateKeyHandler (vlc_object_t *, xcb_connection_t *);
-void DestroyKeyHandler (key_handler_t *);
-int ProcessKeyEvent (key_handler_t *, xcb_generic_event_t *);
+key_handler_t *XCB_keyHandler_Create (vlc_object_t *, xcb_connection_t *);
+void XCB_keyHandler_Destroy (key_handler_t *);
+int XCB_keyHandler_Process (key_handler_t *, xcb_generic_event_t *);
-/* common.c */
-struct vout_window_t *GetWindow (vout_display_t *obj, xcb_connection_t **,
- const xcb_screen_t **, uint8_t *depth,
- uint16_t *width, uint16_t *height);
-bool CheckSHM (vlc_object_t *obj, xcb_connection_t *conn);
-xcb_cursor_t CreateBlankCursor (xcb_connection_t *, const xcb_screen_t *);
+/* events.c */
+int XCB_error_Check (vout_display_t *, xcb_connection_t *conn,
+ const char *str, xcb_void_cookie_t);
+
+struct vout_window_t *XCB_parent_Create (vout_display_t *obj,
+ xcb_connection_t **,
+ const xcb_screen_t **, uint8_t *depth,
+ uint16_t *width, uint16_t *height);
+xcb_cursor_t XCB_cursor_Create (xcb_connection_t *, const xcb_screen_t *);
-int CheckError (vout_display_t *, xcb_connection_t *conn,
- const char *str, xcb_void_cookie_t);
+int XCB_Manage (vout_display_t *vd, xcb_connection_t *conn, bool *);
+
+/* common.c */
+bool XCB_shm_Check (vlc_object_t *obj, xcb_connection_t *conn);
/* FIXME
* maybe it would be better to split this header in 2 */
{
xcb_shm_seg_t segment;
};
-int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t size,
- xcb_connection_t *conn, bool attach);
-void PictureResourceFree (picture_resource_t *res, xcb_connection_t *conn);
-
+int XCB_pictures_Alloc (vout_display_t *, picture_resource_t *, size_t size,
+ xcb_connection_t *, bool attach);
+void XCB_pictures_Free (picture_resource_t *, xcb_connection_t *);
const xcb_screen_t *screen;
uint16_t width, height;
uint8_t depth;
- p_sys->embed = GetWindow (vd, &conn, &screen, &depth, &width, &height);
+ p_sys->embed = XCB_parent_Create (vd, &conn, &screen,
+ &depth, &width, &height);
if (p_sys->embed == NULL)
{
free (p_sys);
p_sys->embed->handle.xid, 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual, mask, list);
- if (!CheckError (vd, conn, "cannot create X11 window", c))
+ if (!XCB_error_Check (vd, conn, "cannot create X11 window", c))
{
msg_Dbg (vd, "using X11 visual ID 0x%"PRIx32
" (depth: %"PRIu8")", f->visual, f->depth);
}
/* Create cursor */
- p_sys->cursor = CreateBlankCursor (conn, screen);
+ p_sys->cursor = XCB_cursor_Create (conn, screen);
- p_sys->shm = CheckSHM (obj, conn);
+ p_sys->shm = XCB_shm_Check (obj, conn);
/* */
vout_display_info_t info = vd->info;
if (!res->p->p_pixels)
break;
- PictureResourceFree (res, NULL);
+ XCB_pictures_Free (res, NULL);
}
picture_pool_Delete (p_sys->pool);
}
res->p[i].i_pitch = pitches[i];
}
- if (PictureResourceAlloc (vd, res, p_sys->att->data_size,
- p_sys->conn, p_sys->shm))
+ if (XCB_pictures_Alloc (vd, res, p_sys->att->data_size,
+ p_sys->conn, p_sys->shm))
break;
/* Allocate further planes as specified by XVideo */
pic_array[count] = picture_NewFromResource (&vd->fmt, res);
if (!pic_array[count])
{
- PictureResourceFree (res, p_sys->conn);
+ XCB_pictures_Free (res, p_sys->conn);
memset (res, 0, sizeof(*res));
break;
}
{
vout_display_sys_t *p_sys = vd->sys;
- ManageEvent (vd, p_sys->conn, &p_sys->visible);
+ XCB_Manage (vd, p_sys->conn, &p_sys->visible);
}
static int EnumAdaptors (vlc_object_t *obj, const char *var,