Commit ec468212 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vout_window_t: simplify via anynomous union

parent d5618a75
...@@ -90,7 +90,7 @@ struct vout_window_t { ...@@ -90,7 +90,7 @@ struct vout_window_t {
union { union {
void *hwnd; /* Win32 window handle */ void *hwnd; /* Win32 window handle */
uint32_t xid; /* X11 windows ID */ uint32_t xid; /* X11 windows ID */
} handle; };
/* Control on the module (mandatory) /* Control on the module (mandatory)
* *
......
...@@ -288,15 +288,15 @@ static int OpenWindow (vlc_object_t *obj) ...@@ -288,15 +288,15 @@ static int OpenWindow (vlc_object_t *obj)
while ((intf = wnd_req.intf) == NULL) while ((intf = wnd_req.intf) == NULL)
vlc_cond_wait (&wnd_req.wait, &wnd_req.lock); vlc_cond_wait (&wnd_req.wait, &wnd_req.lock);
wnd->handle.xid = request_video( intf, vout ); wnd->xid = request_video( intf, vout );
vlc_mutex_unlock (&wnd_req.lock); vlc_mutex_unlock (&wnd_req.lock);
vlc_object_release( vout ); vlc_object_release( vout );
if (!wnd->handle.xid) if (!wnd->xid)
return VLC_EGENERIC; return VLC_EGENERIC;
msg_Dbg( intf, "Using handle %"PRIu32, wnd->handle.xid ); msg_Dbg( intf, "Using handle %"PRIu32, wnd->xid );
wnd->control = ControlWindow; wnd->control = ControlWindow;
wnd->sys = (vout_window_sys_t*)intf; wnd->sys = (vout_window_sys_t*)intf;
......
...@@ -528,13 +528,13 @@ static int WindowOpen( vlc_object_t *p_obj ) ...@@ -528,13 +528,13 @@ static int WindowOpen( vlc_object_t *p_obj )
unsigned i_height = p_wnd->cfg->height; unsigned i_height = p_wnd->cfg->height;
#if defined (Q_WS_X11) #if defined (Q_WS_X11)
p_wnd->handle.xid = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height ); p_wnd->xid = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
if( !p_wnd->handle.xid ) if( !p_wnd->xid )
return VLC_EGENERIC; return VLC_EGENERIC;
#elif defined (WIN32) #elif defined (WIN32)
p_wnd->handle.hwnd = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height ); p_wnd->hwnd = p_mi->getVideo( &i_x, &i_y, &i_width, &i_height );
if( !p_wnd->handle.hwnd ) if( !p_wnd->hwnd )
return VLC_EGENERIC; return VLC_EGENERIC;
#endif #endif
......
...@@ -385,9 +385,9 @@ static int WindowOpen( vlc_object_t *p_this ) ...@@ -385,9 +385,9 @@ static int WindowOpen( vlc_object_t *p_this )
vlc_mutex_lock( &serializer ); vlc_mutex_lock( &serializer );
pWnd->handle.hwnd = VoutManager::getWindow( pIntf, pWnd ); pWnd->hwnd = VoutManager::getWindow( pIntf, pWnd );
if( pWnd->handle.hwnd ) if( pWnd->hwnd )
{ {
pWnd->control = &VoutManager::controlWindow; pWnd->control = &VoutManager::controlWindow;
pWnd->sys = (vout_window_sys_t*)pIntf; pWnd->sys = (vout_window_sys_t*)pIntf;
......
...@@ -101,7 +101,7 @@ skip: ...@@ -101,7 +101,7 @@ skip:
if (val == NULL) if (val == NULL)
return VLC_EGENERIC; return VLC_EGENERIC;
wnd->handle.hwnd = val; wnd->hwnd = val;
wnd->control = Control; wnd->control = Control;
wnd->sys = val; wnd->sys = val;
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -420,7 +420,7 @@ static int DirectXCreateWindow( event_thread_t *p_event ) ...@@ -420,7 +420,7 @@ static int DirectXCreateWindow( event_thread_t *p_event )
/* If an external window was specified, we'll draw in it. */ /* If an external window was specified, we'll draw in it. */
p_event->parent_window = vout_display_NewWindow(vd, &p_event->wnd_cfg ); p_event->parent_window = vout_display_NewWindow(vd, &p_event->wnd_cfg );
if( p_event->parent_window ) if( p_event->parent_window )
p_event->hparent = p_event->parent_window->handle.hwnd; p_event->hparent = p_event->parent_window->hwnd;
else else
p_event->hparent = NULL; p_event->hparent = NULL;
#ifdef MODULE_NAME_IS_direct3d #ifdef MODULE_NAME_IS_direct3d
......
...@@ -449,7 +449,7 @@ static int DirectXCreateWindow( event_thread_t *p_event ) ...@@ -449,7 +449,7 @@ static int DirectXCreateWindow( event_thread_t *p_event )
/* If an external window was specified, we'll draw in it. */ /* If an external window was specified, we'll draw in it. */
p_event->parent_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &p_event->wnd_cfg ); p_event->parent_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &p_event->wnd_cfg );
if( p_event->parent_window ) if( p_event->parent_window )
p_event->hparent = p_event->parent_window->handle.hwnd; p_event->hparent = p_event->parent_window->hwnd;
else else
p_event->hparent = NULL; p_event->hparent = NULL;
#ifdef MODULE_NAME_IS_direct3d #ifdef MODULE_NAME_IS_direct3d
......
...@@ -610,7 +610,7 @@ static void CreateWindow( vout_sys_t *p_sys ) ...@@ -610,7 +610,7 @@ static void CreateWindow( vout_sys_t *p_sys )
xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask
| VisibilityChangeMask; | VisibilityChangeMask;
p_sys->window = XCreateWindow( p_sys->p_display, p_sys->window = XCreateWindow( p_sys->p_display,
p_sys->owner_window->handle.xid, p_sys->owner_window->xid,
0, 0, 0, 0,
p_sys->main_window.i_width, p_sys->main_window.i_width,
p_sys->main_window.i_height, p_sys->main_window.i_height,
...@@ -620,7 +620,7 @@ static void CreateWindow( vout_sys_t *p_sys ) ...@@ -620,7 +620,7 @@ static void CreateWindow( vout_sys_t *p_sys )
&xwindow_attributes ); &xwindow_attributes );
XMapWindow( p_sys->p_display, p_sys->window ); XMapWindow( p_sys->p_display, p_sys->window );
XSelectInput( p_sys->p_display, p_sys->owner_window->handle.xid, XSelectInput( p_sys->p_display, p_sys->owner_window->xid,
StructureNotifyMask ); StructureNotifyMask );
} }
...@@ -242,7 +242,7 @@ static int ManageVideo( vout_thread_t *p_vout ) ...@@ -242,7 +242,7 @@ static int ManageVideo( vout_thread_t *p_vout )
/* Handle events from the owner window */ /* Handle events from the owner window */
while( XCheckWindowEvent( p_vout->p_sys->p_display, while( XCheckWindowEvent( p_vout->p_sys->p_display,
p_vout->p_sys->window.owner_window->handle.xid, p_vout->p_sys->window.owner_window->xid,
StructureNotifyMask, &xevent ) == True ) StructureNotifyMask, &xevent ) == True )
{ {
/* ConfigureNotify event: prepare */ /* ConfigureNotify event: prepare */
...@@ -602,11 +602,11 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win ) ...@@ -602,11 +602,11 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win )
/* Select events we are interested in. */ /* Select events we are interested in. */
XSelectInput( p_vout->p_sys->p_display, XSelectInput( p_vout->p_sys->p_display,
p_win->owner_window->handle.xid, StructureNotifyMask ); p_win->owner_window->xid, StructureNotifyMask );
/* Get the parent window's geometry information */ /* Get the parent window's geometry information */
XGetGeometry( p_vout->p_sys->p_display, XGetGeometry( p_vout->p_sys->p_display,
p_win->owner_window->handle.xid, p_win->owner_window->xid,
&(Window){ 0 }, &(int){ 0 }, &(int){ 0 }, &(Window){ 0 }, &(int){ 0 }, &(int){ 0 },
&p_win->i_width, &p_win->i_width,
&p_win->i_height, &p_win->i_height,
...@@ -616,7 +616,7 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win ) ...@@ -616,7 +616,7 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win )
* ButtonPress event, so we need to open a new window anyway. */ * ButtonPress event, so we need to open a new window anyway. */
p_win->base_window = p_win->base_window =
XCreateWindow( p_vout->p_sys->p_display, XCreateWindow( p_vout->p_sys->p_display,
p_win->owner_window->handle.xid, p_win->owner_window->xid,
0, 0, 0, 0,
p_win->i_width, p_win->i_height, p_win->i_width, p_win->i_height,
0, 0,
......
...@@ -116,7 +116,7 @@ vout_window_t *GetWindow (vout_display_t *vd, ...@@ -116,7 +116,7 @@ vout_window_t *GetWindow (vout_display_t *vd,
xcb_get_geometry_reply_t *geo; xcb_get_geometry_reply_t *geo;
xcb_get_geometry_cookie_t ck; xcb_get_geometry_cookie_t ck;
ck = xcb_get_geometry (conn, wnd->handle.xid); ck = xcb_get_geometry (conn, wnd->xid);
geo = xcb_get_geometry_reply (conn, ck, NULL); geo = xcb_get_geometry_reply (conn, ck, NULL);
if (geo == NULL) if (geo == NULL)
{ {
...@@ -130,7 +130,7 @@ vout_window_t *GetWindow (vout_display_t *vd, ...@@ -130,7 +130,7 @@ vout_window_t *GetWindow (vout_display_t *vd,
/* Subscribe to parent window resize events */ /* Subscribe to parent window resize events */
uint32_t value = XCB_EVENT_MASK_POINTER_MOTION uint32_t value = XCB_EVENT_MASK_POINTER_MOTION
| XCB_EVENT_MASK_STRUCTURE_NOTIFY; | XCB_EVENT_MASK_STRUCTURE_NOTIFY;
xcb_change_window_attributes (conn, wnd->handle.xid, xcb_change_window_attributes (conn, wnd->xid,
XCB_CW_EVENT_MASK, &value); XCB_CW_EVENT_MASK, &value);
/* Try to subscribe to click events */ /* Try to subscribe to click events */
/* (only one X11 client can get them, so might not work) */ /* (only one X11 client can get them, so might not work) */
...@@ -138,7 +138,7 @@ vout_window_t *GetWindow (vout_display_t *vd, ...@@ -138,7 +138,7 @@ vout_window_t *GetWindow (vout_display_t *vd,
{ {
value |= XCB_EVENT_MASK_BUTTON_PRESS value |= XCB_EVENT_MASK_BUTTON_PRESS
| XCB_EVENT_MASK_BUTTON_RELEASE; | XCB_EVENT_MASK_BUTTON_RELEASE;
xcb_change_window_attributes (conn, wnd->handle.xid, xcb_change_window_attributes (conn, wnd->xid,
XCB_CW_EVENT_MASK, &value); XCB_CW_EVENT_MASK, &value);
} }
} }
...@@ -193,7 +193,7 @@ error: ...@@ -193,7 +193,7 @@ error:
int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn, int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
unsigned *restrict width, unsigned *restrict height) unsigned *restrict width, unsigned *restrict height)
{ {
xcb_get_geometry_cookie_t ck = xcb_get_geometry (conn, wnd->handle.xid); xcb_get_geometry_cookie_t ck = xcb_get_geometry (conn, wnd->xid);
xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply (conn, ck, NULL); xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply (conn, ck, NULL);
if (!geo) if (!geo)
......
...@@ -261,7 +261,7 @@ static int Open (vlc_object_t *obj) ...@@ -261,7 +261,7 @@ static int Open (vlc_object_t *obj)
goto error; goto error;
} }
wnd->handle.xid = window; wnd->xid = window;
wnd->control = Control; wnd->control = Control;
wnd->sys = p_sys; wnd->sys = p_sys;
...@@ -335,7 +335,7 @@ static int Open (vlc_object_t *obj) ...@@ -335,7 +335,7 @@ static int Open (vlc_object_t *obj)
#ifdef MATCHBOX_HACK #ifdef MATCHBOX_HACK
if (p_sys->mb_current_app_window) if (p_sys->mb_current_app_window)
xcb_set_input_focus (p_sys->conn, XCB_INPUT_FOCUS_POINTER_ROOT, xcb_set_input_focus (p_sys->conn, XCB_INPUT_FOCUS_POINTER_ROOT,
wnd->handle.xid, XCB_CURRENT_TIME); wnd->xid, XCB_CURRENT_TIME);
#endif #endif
xcb_flush (conn); /* Make sure map_window is sent (should be useless) */ xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -404,13 +404,13 @@ static void *Thread (void *data) ...@@ -404,13 +404,13 @@ static void *Thread (void *data)
xcb_get_property (conn, 0, pne->window, pne->atom, xcb_get_property (conn, 0, pne->window, pne->atom,
XA_WINDOW, 0, 4), NULL); XA_WINDOW, 0, 4), NULL);
if (r != NULL if (r != NULL
&& !memcmp (xcb_get_property_value (r), &wnd->handle.xid, && !memcmp (xcb_get_property_value (r), &wnd->xid,
4)) 4))
{ {
msg_Dbg (wnd, "asking Matchbox for input focus"); msg_Dbg (wnd, "asking Matchbox for input focus");
xcb_set_input_focus (conn, xcb_set_input_focus (conn,
XCB_INPUT_FOCUS_POINTER_ROOT, XCB_INPUT_FOCUS_POINTER_ROOT,
wnd->handle.xid, pne->time); wnd->xid, pne->time);
xcb_flush (conn); xcb_flush (conn);
} }
free (r); free (r);
...@@ -440,7 +440,7 @@ static void set_wm_state (vout_window_t *wnd, bool on, xcb_atom_t state) ...@@ -440,7 +440,7 @@ static void set_wm_state (vout_window_t *wnd, bool on, xcb_atom_t state)
xcb_client_message_event_t ev = { xcb_client_message_event_t ev = {
.response_type = XCB_CLIENT_MESSAGE, .response_type = XCB_CLIENT_MESSAGE,
.format = 32, .format = 32,
.window = wnd->handle.xid, .window = wnd->xid,
.type = sys->wm_state, .type = sys->wm_state,
}; };
...@@ -470,7 +470,7 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap) ...@@ -470,7 +470,7 @@ static int Control (vout_window_t *wnd, int cmd, va_list ap)
unsigned height = va_arg (ap, unsigned); unsigned height = va_arg (ap, unsigned);
const uint32_t values[] = { width, height, }; const uint32_t values[] = { width, height, };
xcb_configure_window (conn, wnd->handle.xid, xcb_configure_window (conn, wnd->xid,
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_WIDTH |
XCB_CONFIG_WINDOW_HEIGHT, values); XCB_CONFIG_WINDOW_HEIGHT, values);
break; break;
...@@ -585,7 +585,7 @@ static int EmOpen (vlc_object_t *obj) ...@@ -585,7 +585,7 @@ static int EmOpen (vlc_object_t *obj)
if (p_sys == NULL || xcb_connection_has_error (conn)) if (p_sys == NULL || xcb_connection_has_error (conn))
goto error; goto error;
wnd->handle.xid = window; wnd->xid = window;
wnd->control = Control; wnd->control = Control;
wnd->sys = p_sys; wnd->sys = p_sys;
...@@ -633,7 +633,7 @@ error: ...@@ -633,7 +633,7 @@ error:
static void EmClose (vlc_object_t *obj) static void EmClose (vlc_object_t *obj)
{ {
vout_window_t *wnd = (vout_window_t *)obj; vout_window_t *wnd = (vout_window_t *)obj;
xcb_window_t window = wnd->handle.xid; xcb_window_t window = wnd->xid;
Close (obj); Close (obj);
ReleaseDrawable (obj, window); ReleaseDrawable (obj, window);
......
...@@ -271,7 +271,7 @@ static int Open (vlc_object_t *obj) ...@@ -271,7 +271,7 @@ static int Open (vlc_object_t *obj)
c = xcb_create_window_checked (p_sys->conn, p_sys->depth, c = xcb_create_window_checked (p_sys->conn, p_sys->depth,
p_sys->window, p_sys->window,
p_sys->embed->handle.xid, 0, 0, p_sys->embed->xid, 0, 0,
width, height, 0, width, height, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_WINDOW_CLASS_INPUT_OUTPUT,
vid, mask, values); vid, mask, values);
...@@ -519,7 +519,7 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -519,7 +519,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
/* Hide the mouse. It will be send when /* Hide the mouse. It will be send when
* vout_display_t::info.b_hide_mouse is false */ * vout_display_t::info.b_hide_mouse is false */
case VOUT_DISPLAY_HIDE_MOUSE: case VOUT_DISPLAY_HIDE_MOUSE:
xcb_change_window_attributes (p_sys->conn, p_sys->embed->handle.xid, xcb_change_window_attributes (p_sys->conn, p_sys->embed->xid,
XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor }); XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor });
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -340,7 +340,7 @@ static int Open (vlc_object_t *obj) ...@@ -340,7 +340,7 @@ static int Open (vlc_object_t *obj)
/* Cache adaptors infos */ /* Cache adaptors infos */
xcb_xv_query_adaptors_reply_t *adaptors = xcb_xv_query_adaptors_reply_t *adaptors =
xcb_xv_query_adaptors_reply (conn, xcb_xv_query_adaptors_reply (conn,
xcb_xv_query_adaptors (conn, p_sys->embed->handle.xid), NULL); xcb_xv_query_adaptors (conn, p_sys->embed->xid), NULL);
if (adaptors == NULL) if (adaptors == NULL)
goto error; goto error;
...@@ -464,7 +464,7 @@ static int Open (vlc_object_t *obj) ...@@ -464,7 +464,7 @@ static int Open (vlc_object_t *obj)
xcb_void_cookie_t c; xcb_void_cookie_t c;
c = xcb_create_window_checked (conn, f->depth, p_sys->window, c = xcb_create_window_checked (conn, f->depth, p_sys->window,
p_sys->embed->handle.xid, 0, 0, 1, 1, 0, p_sys->embed->xid, 0, 0, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual, XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual,
XCB_CW_EVENT_MASK, &mask); XCB_CW_EVENT_MASK, &mask);
...@@ -762,7 +762,7 @@ static int Control (vout_display_t *vd, int query, va_list ap) ...@@ -762,7 +762,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
/* Hide the mouse. It will be send when /* Hide the mouse. It will be send when
* vout_display_t::info.b_hide_mouse is false */ * vout_display_t::info.b_hide_mouse is false */
case VOUT_DISPLAY_HIDE_MOUSE: case VOUT_DISPLAY_HIDE_MOUSE:
xcb_change_window_attributes (p_sys->conn, p_sys->embed->handle.xid, xcb_change_window_attributes (p_sys->conn, p_sys->embed->xid,
XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor }); XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor });
return VLC_SUCCESS; return VLC_SUCCESS;
case VOUT_DISPLAY_RESET_PICTURES: case VOUT_DISPLAY_RESET_PICTURES:
......
...@@ -50,7 +50,6 @@ vout_window_t *vout_window_New(vlc_object_t *obj, ...@@ -50,7 +50,6 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
vout_window_t *window = &w->wnd; vout_window_t *window = &w->wnd;
window->cfg = cfg; window->cfg = cfg;
memset(&window->handle, 0, sizeof(window->handle));
window->control = NULL; window->control = NULL;
window->sys = NULL; window->sys = NULL;
...@@ -60,9 +59,11 @@ vout_window_t *vout_window_New(vlc_object_t *obj, ...@@ -60,9 +59,11 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
switch (cfg->type) { switch (cfg->type) {
case VOUT_WINDOW_TYPE_HWND: case VOUT_WINDOW_TYPE_HWND:
type = "vout window hwnd"; type = "vout window hwnd";
window->hwnd = NULL;
break; break;
case VOUT_WINDOW_TYPE_XID: case VOUT_WINDOW_TYPE_XID:
type = "vout window xid"; type = "vout window xid";
window->xid = 0;
break; break;
default: default:
assert(0); assert(0);
...@@ -78,7 +79,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj, ...@@ -78,7 +79,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
/* Hook for screensaver inhibition */ /* Hook for screensaver inhibition */
if (cfg->type == VOUT_WINDOW_TYPE_XID) { if (cfg->type == VOUT_WINDOW_TYPE_XID) {
w->inhibit = vlc_inhibit_Create (VLC_OBJECT (window), w->inhibit = vlc_inhibit_Create (VLC_OBJECT (window),
window->handle.xid); window->xid);
if (w->inhibit != NULL) if (w->inhibit != NULL)
vlc_inhibit_Set (w->inhibit, true); vlc_inhibit_Set (w->inhibit, true);
/* FIXME: ^ wait for vout activation, pause */ /* FIXME: ^ wait for vout activation, pause */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment