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

vout: expand stacking mode from boolean to unsigned

This enables passing a below state in addition to currently supported
always-on-top (above) and normal. (However, none of the window provider
support it just yet).
parent e21af726
......@@ -61,6 +61,16 @@ typedef enum
VOUT_DISPLAY_ALIGN_BOTTOM,
} vout_display_align_t;
/**
* Window management state.
*/
enum {
VOUT_WINDOW_STATE_NORMAL=0,
VOUT_WINDOW_STATE_ABOVE=1,
VOUT_WINDOW_STATE_BELOW=2,
VOUT_WINDOW_STACK_MASK=3,
};
/**
* Initial/Current configuration for a vout_display_t
*/
......@@ -133,9 +143,9 @@ enum {
* being requested (externally or by VOUT_DISPLAY_EVENT_FULLSCREEN */
VOUT_DISPLAY_CHANGE_FULLSCREEN, /* const vout_display_cfg_t *p_cfg */
/* Ask the module to acknowledge/refuse the "always on top" state change
* after being requested externally or by VOUT_DISPLAY_EVENT_ON_TOP */
VOUT_DISPLAY_CHANGE_ON_TOP, /* int b_on_top */
/* Ask the module to acknowledge/refuse the window management state change
* after being requested externally or by VOUT_DISPLAY_WINDOW_STATE */
VOUT_DISPLAY_CHANGE_WINDOW_STATE, /* unsigned state */
/* Ask the module to acknowledge/refuse the display size change requested
* (externally or by VOUT_DISPLAY_EVENT_DISPLAY_SIZE) */
......@@ -177,7 +187,7 @@ enum {
VOUT_DISPLAY_EVENT_PICTURES_INVALID, /* The buffer are now invalid and need to be changed */
VOUT_DISPLAY_EVENT_FULLSCREEN,
VOUT_DISPLAY_EVENT_ON_TOP,
VOUT_DISPLAY_EVENT_WINDOW_STATE,
VOUT_DISPLAY_EVENT_DISPLAY_SIZE, /* The display size need to change : int i_width, int i_height, bool is_fullscreen */
......@@ -344,9 +354,9 @@ static inline void vout_display_SendEventFullscreen(vout_display_t *vd, bool is_
{
vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_FULLSCREEN, is_fullscreen);
}
static inline void vout_display_SendEventOnTop(vout_display_t *vd, bool is_on_top)
static inline void vout_display_SendWindowState(vout_display_t *vd, unsigned state)
{
vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_ON_TOP, is_on_top);
vout_display_SendEvent(vd, VOUT_DISPLAY_EVENT_WINDOW_STATE, state);
}
/* The mouse position (State and Moved event) must be expressed against vout_display_t::source unit */
static inline void vout_display_SendEventMouseState(vout_display_t *vd, int x, int y, int button_mask)
......
......@@ -85,7 +85,7 @@ VLC_EXPORT(void, vout_ManageDisplay, (vout_display_t *, bool allow_reset_picture
VLC_EXPORT(void, vout_SetDisplayFullscreen, (vout_display_t *, bool is_fullscreen));
VLC_EXPORT(void, vout_SetDisplayFilled, (vout_display_t *, bool is_filled));
VLC_EXPORT(void, vout_SetDisplayZoom, (vout_display_t *, int num, int den));
VLC_EXPORT(void, vout_SetDisplayOnTop, (vout_display_t *, bool is_on_top));
VLC_EXPORT(void, vout_SetWindowState, (vout_display_t *, unsigned state));
VLC_EXPORT(void, vout_SetDisplayAspect, (vout_display_t *, unsigned sar_num, unsigned sar_den));
VLC_EXPORT(void, vout_SetDisplayCrop, (vout_display_t *, unsigned crop_num, unsigned crop_den, unsigned x, unsigned y, unsigned width, unsigned height));
VLC_EXPORT(vout_opengl_t *, vout_GetDisplayOpengl, (vout_display_t *));
......
......@@ -242,7 +242,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
switch (query)
{
case VOUT_DISPLAY_CHANGE_FULLSCREEN:
case VOUT_DISPLAY_CHANGE_ON_TOP:
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
case VOUT_DISPLAY_CHANGE_ZOOM:
......
......@@ -606,8 +606,9 @@ int CommonControl(vout_display_t *vd, int query, va_list args)
UpdateRects(vd, cfg, source, is_forced);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_ON_TOP: { /* int b_on_top */
const bool is_on_top = va_arg(args, int);
case VOUT_DISPLAY_CHANGE_WINDOW_STATE: { /* unsigned state */
const unsigned state = va_arg(args, unsigned);
const bool is_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
#ifdef MODULE_NAME_IS_direct3d
if (sys->use_desktop && is_on_top)
return VLC_EGENERIC;
......
......@@ -556,7 +556,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
}
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
case VOUT_DISPLAY_CHANGE_ON_TOP:
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
/* I don't think it is possible to support with SDL:
* - crop
* - on top
......
......@@ -279,7 +279,7 @@ static int Init(vout_thread_t *vout)
}
#endif
if (vout->b_on_top)
vout_SetDisplayOnTop(vd, true);
vout_SetWindowState(vd, VOUT_WINDOW_STATE_ABOVE);
/* XXX For non dr case, the current vout implementation force us to
* create at most 1 direct picture (otherwise the buffers will be kept
......@@ -415,7 +415,9 @@ static int Manage(vout_thread_t *vout)
vout->i_changes &= ~VOUT_SCALE_CHANGE;
}
if (vout->i_changes & VOUT_ON_TOP_CHANGE) {
vout_SetDisplayOnTop(vd, vout->b_on_top);
vout_SetWindowState(vd, vout->b_on_top
? VOUT_WINDOW_STATE_ABOVE
: VOUT_WINDOW_STATE_NORMAL);
vout->i_changes &= ~VOUT_ON_TOP_CHANGE;
}
......
......@@ -468,9 +468,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
return vout_window_SetFullScreen (sys->embed, c->is_fullscreen);
}
case VOUT_DISPLAY_CHANGE_ON_TOP:
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
{
int b_on_top = (int)va_arg (ap, int);
unsigned state = va_arg (ap, unsigned);
bool b_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
return vout_window_SetState (sys->embed, b_on_top);
}
......
......@@ -466,9 +466,10 @@ static int Control (vout_display_t *vd, int query, va_list ap)
values);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_ON_TOP:
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
{
int b_on_top = (int)va_arg (ap, int);
unsigned state = va_arg (ap, unsigned);
bool b_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
return vout_window_SetState (p_sys->embed, b_on_top);
}
......
......@@ -736,10 +736,11 @@ static int Control (vout_display_t *vd, int query, va_list ap)
xcb_flush (p_sys->conn);
return VLC_SUCCESS;
}
case VOUT_DISPLAY_CHANGE_ON_TOP:
case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
{
int on_top = (int)va_arg (ap, int);
return vout_window_SetState (p_sys->embed, on_top);
unsigned state = va_arg (ap, unsigned);
bool b_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0;
return vout_window_SetState (p_sys->embed, b_on_top);
}
/* Hide the mouse. It will be send when
......
......@@ -603,7 +603,7 @@ vout_GetDisplayOpengl
vout_SetDisplayFullscreen
vout_SetDisplayFilled
vout_SetDisplayZoom
vout_SetDisplayOnTop
vout_SetWindowState
vout_SetDisplayAspect
vout_SetDisplayCrop
vout_display_GetDefaultDisplaySize
......
......@@ -284,7 +284,7 @@ struct vout_display_owner_sys_t {
/* */
vout_display_cfg_t cfg;
bool is_on_top_initial;
unsigned wm_state_initial;
struct {
unsigned num;
unsigned den;
......@@ -309,8 +309,8 @@ struct vout_display_owner_sys_t {
int den;
} zoom;
bool ch_on_top;
bool is_on_top;
bool ch_wm_state;
unsigned wm_state;
bool ch_sar;
struct {
......@@ -582,15 +582,15 @@ static void VoutDisplayEvent(vout_display_t *vd, int event, va_list args)
break;
}
case VOUT_DISPLAY_EVENT_ON_TOP: {
const int is_on_top = (int)va_arg(args, int);
case VOUT_DISPLAY_EVENT_WINDOW_STATE: {
const unsigned state = va_arg(args, unsigned);
msg_Dbg(vd, "VoutDisplayEvent 'on top' %d", is_on_top);
msg_Dbg(vd, "VoutDisplayEvent 'window state' %u", state);
vlc_mutex_lock(&osys->lock);
if (!is_on_top != !osys->is_on_top) {
osys->ch_on_top = true;
osys->is_on_top = is_on_top;
if (state != osys->wm_state) {
osys->ch_wm_state = true;
osys->wm_state = state;
}
vlc_mutex_unlock(&osys->lock);
break;
......@@ -685,9 +685,9 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
bool is_fullscreen = osys->is_fullscreen;
osys->ch_fullscreen = false;
bool ch_on_top = osys->ch_on_top;
bool is_on_top = osys->is_on_top;
osys->ch_on_top = false;
bool ch_wm_state = osys->ch_wm_state;
unsigned wm_state = osys->wm_state;
osys->ch_wm_state = false;
bool ch_display_size = osys->ch_display_size;
int display_width = osys->display_width;
......@@ -711,7 +711,7 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
!reset_pictures &&
!osys->ch_display_filled &&
!osys->ch_zoom &&
!ch_on_top &&
!ch_wm_state &&
!osys->ch_sar &&
!osys->ch_crop)
break;
......@@ -813,15 +813,15 @@ void vout_ManageDisplay(vout_display_t *vd, bool allow_reset_pictures)
vout_SendEventZoom(osys->vout, osys->cfg.zoom.num, osys->cfg.zoom.den);
}
/* */
if (ch_on_top) {
if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_ON_TOP, is_on_top)) {
if (ch_wm_state) {
if (vout_display_Control(vd, VOUT_DISPLAY_CHANGE_WINDOW_STATE, wm_state)) {
msg_Err(vd, "Failed to set on top");
is_on_top = osys->is_on_top_initial;
wm_state = osys->wm_state;
}
osys->is_on_top_initial = is_on_top;
osys->wm_state_initial = wm_state;
/* */
vout_SendEventOnTop(osys->vout, osys->is_on_top_initial);
vout_SendEventOnTop(osys->vout, osys->wm_state_initial);
}
/* */
if (osys->ch_sar) {
......@@ -986,17 +986,19 @@ void vout_SetDisplayZoom(vout_display_t *vd, int num, int den)
osys->zoom.den = den;
}
}
void vout_SetDisplayOnTop(vout_display_t *vd, bool is_on_top)
void vout_SetWindowState(vout_display_t *vd, unsigned state)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
vlc_mutex_lock(&osys->lock);
if (!osys->is_on_top != !is_on_top) {
osys->ch_on_top = true;
osys->is_on_top = is_on_top;
if (osys->wm_state != state) {
osys->ch_wm_state = true;
osys->wm_state = state;
}
vlc_mutex_unlock(&osys->lock);
}
void vout_SetDisplayAspect(vout_display_t *vd, unsigned sar_num, unsigned sar_den)
{
vout_display_owner_sys_t *osys = vd->owner.sys;
......@@ -1048,7 +1050,8 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
vout_display_cfg_t *cfg = &osys->cfg;
*cfg = state->cfg;
osys->is_on_top_initial = state->is_on_top;;
osys->wm_state_initial = state->is_on_top
? VOUT_WINDOW_STATE_ABOVE : VOUT_WINDOW_STATE_NORMAL;
osys->sar_initial.num = state->sar.num;
osys->sar_initial.den = state->sar.den;
vout_display_GetDefaultDisplaySize(&cfg->display.width, &cfg->display.height,
......@@ -1121,8 +1124,8 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
if (osys->sar.num != source_org->i_sar_num ||
osys->sar.den != source_org->i_sar_den)
osys->ch_sar = true;
if (osys->is_on_top)
osys->ch_on_top = true;
if (osys->wm_state != VOUT_WINDOW_STATE_NORMAL)
osys->ch_wm_state = true;
if (osys->crop.x != source_org->i_x_offset ||
osys->crop.y != source_org->i_y_offset ||
osys->crop.width != source_org->i_visible_width ||
......@@ -1139,7 +1142,7 @@ void vout_DeleteDisplay(vout_display_t *vd, vout_display_state_t *state)
if (state) {
if (!osys->is_wrapper )
state->cfg = osys->cfg;
state->is_on_top = osys->is_on_top_initial;
state->is_on_top = (osys->wm_state & VOUT_WINDOW_STATE_ABOVE) != 0;
state->sar.num = osys->sar_initial.num;
state->sar.den = osys->sar_initial.den;
}
......
......@@ -101,7 +101,7 @@ void vout_ManageDisplay(vout_display_t *, bool allow_reset_pictures);
void vout_SetDisplayFullscreen(vout_display_t *, bool is_fullscreen);
void vout_SetDisplayFilled(vout_display_t *, bool is_filled);
void vout_SetDisplayZoom(vout_display_t *, int num, int den);
void vout_SetDisplayOnTop(vout_display_t *, bool is_on_top);
void vout_SetWindowState(vout_display_t *, unsigned state);
void vout_SetDisplayAspect(vout_display_t *, unsigned sar_num, unsigned sar_den);
void vout_SetDisplayCrop(vout_display_t *,
unsigned crop_num, unsigned crop_den,
......
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