3 * @brief X C Bindings window provider module for VLC media player
5 /*****************************************************************************
6 * Copyright © 2009 Rémi Denis-Courmont
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2.0
11 * of the License, or (at your option) any later version.
13 * This library 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 Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 ****************************************************************************/
31 #include <xcb/xcb_aux.h>
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
35 #include <vlc_window.h>
37 #define DISPLAY_TEXT N_("X11 display")
38 #define DISPLAY_LONGTEXT N_( \
39 "X11 hardware display to use. By default VLC will " \
40 "use the value of the DISPLAY environment variable.")
42 static int Open (vlc_object_t *);
43 static void Close (vlc_object_t *);
49 set_shortname (N_("XCB window"))
50 set_description (N_("(Experimental) XCB video window"))
51 set_category (CAT_VIDEO)
52 set_subcategory (SUBCAT_VIDEO_VOUT)
53 set_capability ("vout_window", 10)
54 set_callbacks (Open, Close)
56 add_string ("x11-display", NULL, NULL,
57 DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
60 static int Control (vout_window_t *, int, va_list ap);
63 * Create an X11 window.
65 static int Open (vlc_object_t *obj)
67 vout_window_t *wnd = (vout_window_t *)obj;
68 xcb_generic_error_t *err;
72 char *display = var_CreateGetNonEmptyString (wnd, "x11-display");
75 xcb_connection_t *conn = xcb_connect (display, &snum);
77 if (xcb_connection_has_error (conn) /*== NULL*/)
81 xcb_screen_t *scr = xcb_aux_get_screen (conn, snum);
83 xcb_window_t window = xcb_generate_id (conn);
84 ck = xcb_create_window_checked (conn, scr->root_depth, window, scr->root,
85 0, 0, wnd->width, wnd->height, 0,
86 XCB_WINDOW_CLASS_INPUT_OUTPUT,
87 scr->root_visual, 0, NULL);
88 err = xcb_request_check (conn, ck);
91 msg_Err (wnd, "creating window: X11 error %d", err->error_code);
95 /* Make sure the window is ready */
96 xcb_map_window (conn, window);
99 wnd->handle.xid = window;
101 wnd->control = Control;
105 xcb_disconnect (conn);
111 * Destroys the X11 window.
113 static void Close (vlc_object_t *obj)
115 vout_window_t *wnd = (vout_window_t *)obj;
116 xcb_connection_t *conn = wnd->p_sys;
117 xcb_window_t window = (uintptr_t)wnd->handle;
119 xcb_unmap_window (conn, window);
120 xcb_destroy_window (conn, window);
121 xcb_disconnect (conn);
125 static int Control (vout_window_t *wnd, int cmd, va_list ap)
127 msg_Err (wnd, "request %d not implemented", cmd);