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

XCB/GLX: resize

parent 267a4bdb
......@@ -66,6 +66,8 @@ struct vout_display_sys_t
xcb_cursor_t cursor; /* blank cursor */
xcb_window_t window; /* drawable X window */
xcb_window_t glwin; /* GLX window */
uint16_t width; /* render pixel width */
uint16_t height; /* render pixel height */
bool visible; /* whether to draw */
bool v1_3; /* whether GLX >= 1.3 is available */
......@@ -100,7 +102,8 @@ static vout_window_t *MakeWindow (vout_display_t *vd)
static const xcb_screen_t *
FindWindow (vout_display_t *vd, xcb_connection_t *conn,
unsigned *restrict pnum, uint8_t *restrict pdepth)
unsigned *restrict pnum, uint8_t *restrict pdepth,
uint16_t *restrict pwidth, uint16_t *restrict pheight)
{
vout_display_sys_t *sys = vd->sys;
......@@ -115,6 +118,8 @@ FindWindow (vout_display_t *vd, xcb_connection_t *conn,
xcb_window_t root = geo->root;
*pdepth = geo->depth;
*pwidth = geo->width;
*pheight = geo->height;
free (geo);
/* Find the selected screen */
......@@ -170,11 +175,6 @@ static int CreateWindow (vout_display_t *vd, xcb_connection_t *conn,
uint_fast8_t depth, xcb_visualid_t vid)
{
vout_display_sys_t *sys = vd->sys;
unsigned width, height;
if (GetWindowSize (sys->embed, conn, &width, &height))
return VLC_EGENERIC;
const uint32_t mask = XCB_CW_EVENT_MASK;
const uint32_t values[] = {
/* XCB_CW_EVENT_MASK */
......@@ -183,7 +183,8 @@ static int CreateWindow (vout_display_t *vd, xcb_connection_t *conn,
xcb_void_cookie_t cc, cm;
cc = xcb_create_window_checked (conn, depth, sys->window,
sys->embed->xid, 0, 0, width, height, 0,
sys->embed->xid, 0, 0,
sys->width, sys->height, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
vid, mask, values);
cm = xcb_map_window_checked (conn, sys->window);
......@@ -240,7 +241,8 @@ static int Open (vlc_object_t *obj)
/* Find window parameters */
unsigned snum;
uint8_t depth;
const xcb_screen_t *scr = FindWindow (vd, conn, &snum, &depth);
const xcb_screen_t *scr = FindWindow (vd, conn, &snum, &depth,
&sys->width, &sys->height);
if (scr == NULL)
goto error;
......@@ -353,7 +355,7 @@ static int Open (vlc_object_t *obj)
/* */
vout_display_SendEventFullscreen (vd, false);
//vout_display_SendEventDisplaySize (vd, width, height, false);
vout_display_SendEventDisplaySize (vd, sys->width, sys->height, false);
return VLC_SUCCESS;
......@@ -395,6 +397,7 @@ static void SwapBuffers (vout_opengl_t *gl)
{
vout_display_sys_t *sys = gl->sys;
glViewport (0, 0, sys->width, sys->height);
glXSwapBuffers (sys->display, sys->glwin);
}
......@@ -452,8 +455,50 @@ static int Control (vout_display_t *vd, int query, va_list ap)
case VOUT_DISPLAY_CHANGE_ZOOM:
case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
msg_Err (vd, "unimplemented control request");
return VLC_EGENERIC;
{
xcb_connection_t *conn = XGetXCBConnection (sys->display);
const vout_display_cfg_t *cfg;
const video_format_t *source;
bool is_forced = false;
if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
|| query == VOUT_DISPLAY_CHANGE_SOURCE_CROP)
{
source = (const video_format_t *)va_arg (ap, const video_format_t *);
cfg = vd->cfg;
}
else
{
source = &vd->source;
cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE)
is_forced = (bool)va_arg (ap, int);
}
/* */
if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE
&& is_forced
&& (cfg->display.width != vd->cfg->display.width
||cfg->display.height != vd->cfg->display.height)
&& vout_window_SetSize (sys->embed,
cfg->display.width, cfg->display.height))
return VLC_EGENERIC;
vout_display_place_t place;
vout_display_PlacePicture (&place, source, cfg, false);
sys->width = place.width;
sys->height = place.height;
/* Move the picture within the window */
const uint32_t values[] = { place.x, place.y,
place.width, place.height, };
xcb_configure_window (conn, sys->window,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
| XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
values);
xcb_flush (conn);
return VLC_SUCCESS;
}
/* Hide the mouse. It will be send when
* vout_display_t::info.b_hide_mouse is false */
......
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