#define DISPLAY_TEXT N_("X11 display")
#define DISPLAY_LONGTEXT N_( \
- "X11 hardware display to use. By default VLC will " \
- "use the value of the DISPLAY environment variable.")
+ "Video will be rendered with this X11 display. " \
+ "If empty, the default display will be used.")
-#define XID_TEXT N_("ID of the video output X window")
+#define XID_TEXT N_("X11 window ID")
#define XID_LONGTEXT N_( \
- "VLC can embed its video output in an existing X11 window. " \
- "This is the X identifier of that window (0 means none).")
+ "Video will be embedded in this pre-existing window. " \
+ "If zero, a new window will be created.")
-static int Open (vlc_object_t *);
-static void Close (vlc_object_t *);
-static int EmOpen (vlc_object_t *);
-static void EmClose (vlc_object_t *);
+static int Open (vout_window_t *, const vout_window_cfg_t *);
+static void Close (vout_window_t *);
+static int EmOpen (vout_window_t *, const vout_window_cfg_t *);
+static void EmClose (vout_window_t *);
/*
* Module descriptor
set_capability ("vout window xid", 10)
set_callbacks (Open, Close)
- add_string ("x11-display", NULL, NULL,
- DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
/* Obsolete since 1.1.0: */
add_obsolete_bool ("x11-altfullscreen")
add_obsolete_bool ("xvideo-altfullscreen")
set_subcategory (SUBCAT_VIDEO_VOUT)
set_capability ("vout window xid", 70)
set_callbacks (EmOpen, EmClose)
+ add_shortcut ("embed-xid")
- add_integer ("drawable-xid", 0, NULL, XID_TEXT, XID_LONGTEXT, true)
- change_unsaveable ()
+ add_string ("x11-display", NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true)
+ add_integer ("drawable-xid", 0, XID_TEXT, XID_LONGTEXT, true)
+ change_volatile ()
vlc_module_end ()
static int Control (vout_window_t *, int, va_list ap);
static void *Thread (void *);
-#define MATCHBOX_HACK 1 /* Matchbox focus hack */
-
struct vout_window_sys_t
{
xcb_connection_t *conn;
xcb_window_t root;
xcb_atom_t wm_state;
xcb_atom_t wm_state_above;
+ xcb_atom_t wm_state_below;
xcb_atom_t wm_state_fullscreen;
-#ifdef MATCHBOX_HACK
- xcb_atom_t mb_current_app_window;
-#endif
+
+ bool embedded;
};
/** Set an X window property from a nul-terminated string */
static void CacheAtoms (vout_window_sys_t *p_sys)
{
xcb_connection_t *conn = p_sys->conn;
- xcb_intern_atom_cookie_t wm_state_ck, wm_state_above_ck, wm_state_fs_ck;
+ xcb_intern_atom_cookie_t wm_state_ck, wm_state_above_ck,
+ wm_state_below_ck, wm_state_fs_ck;
wm_state_ck = intern_string (conn, "_NET_WM_STATE");
wm_state_above_ck = intern_string (conn, "_NET_WM_STATE_ABOVE");
+ wm_state_below_ck = intern_string (conn, "_NET_WM_STATE_BELOW");
wm_state_fs_ck = intern_string (conn, "_NET_WM_STATE_FULLSCREEN");
-#ifdef MATCHBOX_HACK
- xcb_intern_atom_cookie_t mb_current_app_window;
- mb_current_app_window = xcb_intern_atom (conn, true,
- strlen ("_MB_CURRENT_APP_WINDOW"),
- "_MB_CURRENT_APP_WINDOW");
-#endif
p_sys->wm_state = get_atom (conn, wm_state_ck);
p_sys->wm_state_above = get_atom (conn, wm_state_above_ck);
+ p_sys->wm_state_below = get_atom (conn, wm_state_below_ck);
p_sys->wm_state_fullscreen = get_atom (conn, wm_state_fs_ck);
-#ifdef MATCHBOX_HACK
- p_sys->mb_current_app_window = get_atom (conn, mb_current_app_window);
-#endif
}
/**
* Create an X11 window.
*/
-static int Open (vlc_object_t *obj)
+static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
- vout_window_t *wnd = (vout_window_t *)obj;
xcb_generic_error_t *err;
xcb_void_cookie_t ck;
vout_window_sys_t *p_sys = malloc (sizeof (*p_sys));
if (p_sys == NULL)
return VLC_ENOMEM;
+ p_sys->embedded = false;
/* Connect to X */
- char *display = var_CreateGetNonEmptyString (wnd, "x11-display");
+ char *display = var_InheritString (wnd, "x11-display");
int snum;
xcb_connection_t *conn = xcb_connect (display, &snum);
- free (display);
if (xcb_connection_has_error (conn) /*== NULL*/)
goto error;
xcb_window_t window = xcb_generate_id (conn);
ck = xcb_create_window_checked (conn, scr->root_depth, window, scr->root,
- 0, 0, wnd->cfg->width, wnd->cfg->height, 0,
+ cfg->x, cfg->y, cfg->width, cfg->height, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
scr->root_visual, mask, values);
err = xcb_request_check (conn, ck);
}
wnd->handle.xid = window;
+ wnd->display.x11 = display;
wnd->control = Control;
wnd->sys = p_sys;
p_sys->conn = conn;
- if (var_CreateGetBool (obj, "keyboard-events"))
- p_sys->keys = CreateKeyHandler (obj, conn);
+ if (var_InheritBool (wnd, "keyboard-events"))
+ p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
else
p_sys->keys = NULL;
p_sys->root = scr->root;
/* ICCCM
* No cut&paste nor drag&drop, only Window Manager communication. */
- /* Plain ASCII localization of VLC for ICCCM window name */
set_ascii_prop (conn, window, XA_WM_NAME,
- vlc_pgettext ("ASCII", "VLC media player"));
+ /* xgettext: This is a plain ASCII spelling of "VLC media player"
+ for the ICCCM window name. This must be pure ASCII.
+ The limitation is partially with ICCCM and partially with VLC.
+ For Latin script languages, you may need to strip accents.
+ For other scripts, you will need to transliterate into Latin. */
+ vlc_pgettext ("ASCII", "VLC media player"));
+
set_ascii_prop (conn, window, XA_WM_ICON_NAME,
+ /* xgettext: This is a plain ASCII spelling of "VLC"
+ for the ICCCM window name. This must be pure ASCII. */
vlc_pgettext ("ASCII", "VLC"));
set_wm_hints (conn, window);
xcb_change_property (conn, XCB_PROP_MODE_REPLACE, window, XA_WM_CLASS,
xcb_atom_t utf8 = get_atom (conn, utf8_string_ck);
xcb_atom_t net_wm_name = get_atom (conn, net_wm_name_ck);
- char *title = var_CreateGetNonEmptyString (wnd, "video-title");
+ char *title = var_InheritString (wnd, "video-title");
if (title)
{
set_string (conn, window, utf8, net_wm_name, title);
/* Cache any EWMH atom we may need later */
CacheAtoms (p_sys);
-#ifdef MATCHBOX_HACK
- if (p_sys->mb_current_app_window)
- {
- uint32_t value = XCB_EVENT_MASK_PROPERTY_CHANGE;
- xcb_change_window_attributes (conn, scr->root,
- XCB_CW_EVENT_MASK, &value);
- }
-#endif
/* Make the window visible */
xcb_map_window (conn, window);
+ if (var_InheritBool (wnd, "video-wallpaper"))
+ {
+ vout_window_SetState (wnd, VOUT_WINDOW_STATE_BELOW);
+ vout_window_SetFullScreen (wnd, true);
+ }
+
/* Create the event thread. It will dequeue all events, so any checked
* 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);
-#ifdef MATCHBOX_HACK
- if (p_sys->mb_current_app_window)
- xcb_set_input_focus (p_sys->conn, XCB_INPUT_FOCUS_POINTER_ROOT,
- wnd->handle.xid, XCB_CURRENT_TIME);
-#endif
xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
return VLC_SUCCESS;
error:
xcb_disconnect (conn);
+ free (display);
free (p_sys);
return VLC_EGENERIC;
}
/**
* Destroys the X11 window.
*/
-static void Close (vlc_object_t *obj)
+static void Close (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
vout_window_sys_t *p_sys = wnd->sys;
xcb_connection_t *conn = p_sys->conn;
DestroyKeyHandler (p_sys->keys);
}
xcb_disconnect (conn);
+ free (wnd->display.x11);
free (p_sys);
}
{
if (ProcessKeyEvent (p_sys->keys, ev) == 0)
continue;
-#ifdef MATCHBOX_HACK
- if (p_sys->mb_current_app_window
- && (ev->response_type & 0x7f) == XCB_PROPERTY_NOTIFY)
- {
- const xcb_property_notify_event_t *pne =
- (xcb_property_notify_event_t *)ev;
- if (pne->atom == p_sys->mb_current_app_window
- && pne->state == XCB_PROPERTY_NEW_VALUE)
- {
- xcb_get_property_reply_t *r =
- xcb_get_property_reply (conn,
- xcb_get_property (conn, 0, pne->window, pne->atom,
- XA_WINDOW, 0, 4), NULL);
- if (r != NULL
- && !memcmp (xcb_get_property_value (r), &wnd->handle.xid,
- 4))
- {
- msg_Dbg (wnd, "asking Matchbox for input focus");
- xcb_set_input_focus (conn,
- XCB_INPUT_FOCUS_POINTER_ROOT,
- wnd->handle.xid, pne->time);
- xcb_flush (conn);
- }
- free (r);
- }
- }
- else
-#endif
- msg_Dbg (wnd, "unhandled event: %"PRIu8, ev->response_type);
+ msg_Dbg (wnd, "unhandled event: %"PRIu8, ev->response_type);
free (ev);
}
vlc_restorecancel (canc);
{
case VOUT_WINDOW_SET_SIZE:
{
+ if (p_sys->embedded)
+ return VLC_EGENERIC;
+
unsigned width = va_arg (ap, unsigned);
unsigned height = va_arg (ap, unsigned);
const uint32_t values[] = { width, height, };
break;
}
- case VOUT_WINDOW_SET_ON_TOP:
- set_wm_state (wnd, va_arg (ap, int), p_sys->wm_state_above);
+ case VOUT_WINDOW_SET_STATE:
+ {
+ unsigned state = va_arg (ap, unsigned);
+ bool above = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
+ bool below = (state & VOUT_WINDOW_STATE_BELOW) != 0;
+
+ set_wm_state (wnd, above, p_sys->wm_state_above);
+ set_wm_state (wnd, below, p_sys->wm_state_below);
break;
+ }
case VOUT_WINDOW_SET_FULLSCREEN:
- set_wm_state (wnd, va_arg (ap, int), p_sys->wm_state_fullscreen);
+ {
+ bool fs = va_arg (ap, int);
+ if (!fs && var_GetBool (wnd, "video-wallpaper"))
+ return VLC_EGENERIC;
+ set_wm_state (wnd, fs, p_sys->wm_state_fullscreen);
break;
+ }
default:
msg_Err (wnd, "request %d not implemented", cmd);
/**
* Wrap an existing X11 window to embed the video.
*/
-static int EmOpen (vlc_object_t *obj)
+static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg)
{
- vout_window_t *wnd = (vout_window_t *)obj;
-
- xcb_window_t window = var_CreateGetInteger (obj, "drawable-xid");
+ xcb_window_t window = var_InheritInteger (wnd, "drawable-xid");
if (window == 0)
return VLC_EGENERIC;
- var_Destroy (obj, "drawable-xid");
- if (AcquireDrawable (obj, window))
+ if (AcquireDrawable (VLC_OBJECT(wnd), window))
return VLC_EGENERIC;
vout_window_sys_t *p_sys = malloc (sizeof (*p_sys));
if (p_sys == NULL || xcb_connection_has_error (conn))
goto error;
+ p_sys->embedded = true;
+ p_sys->keys = NULL;
wnd->handle.xid = window;
wnd->control = Control;
wnd->sys = p_sys;
xcb_get_geometry_reply (conn, xcb_get_geometry (conn, window), NULL);
if (geo == NULL)
{
- msg_Err (obj, "bad X11 window 0x%08"PRIx8, window);
+ msg_Err (wnd, "bad X11 window 0x%08"PRIx8, window);
goto error;
}
p_sys->root = geo->root;
free (geo);
- if (var_CreateGetBool (obj, "keyboard-events"))
+ if (var_InheritBool (wnd, "keyboard-events"))
{
- p_sys->keys = CreateKeyHandler (obj, conn);
+ p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn);
if (p_sys->keys != NULL)
{
const uint32_t mask = XCB_CW_EVENT_MASK;
DestroyKeyHandler (p_sys->keys);
xcb_flush (conn);
-
+ (void) cfg;
return VLC_SUCCESS;
error:
xcb_disconnect (conn);
free (p_sys);
- ReleaseDrawable (obj, window);
+ ReleaseDrawable (VLC_OBJECT(wnd), window);
return VLC_EGENERIC;
}
-static void EmClose (vlc_object_t *obj)
+static void EmClose (vout_window_t *wnd)
{
- vout_window_t *wnd = (vout_window_t *)obj;
xcb_window_t window = wnd->handle.xid;
- Close (obj);
- ReleaseDrawable (obj, window);
+ Close (wnd);
+ ReleaseDrawable (VLC_OBJECT(wnd), window);
}