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

window: use separate constant callback structure

parent fa02a890
......@@ -116,11 +116,16 @@ typedef struct vout_window_cfg_t {
} vout_window_cfg_t;
typedef struct vout_window_owner {
void *sys;
struct vout_window_callbacks {
void (*resized)(vout_window_t *, unsigned width, unsigned height);
void (*closed)(vout_window_t *);
void (*mouse_event)(vout_window_t *, const vout_window_mouse_event_t *mouse);
void (*mouse_event)(vout_window_t *,
const vout_window_mouse_event_t *mouse);
};
typedef struct vout_window_owner {
const struct vout_window_callbacks *cbs;
void *sys;
} vout_window_owner_t;
/**
......@@ -296,20 +301,20 @@ static inline int vout_window_HideMouse(vout_window_t *window, bool hide)
static inline void vout_window_ReportSize(vout_window_t *window,
unsigned width, unsigned height)
{
window->owner.resized(window, width, height);
window->owner.cbs->resized(window, width, height);
}
static inline void vout_window_ReportClose(vout_window_t *window)
{
if (window->owner.closed != NULL)
window->owner.closed(window);
if (window->owner.cbs->closed != NULL)
window->owner.cbs->closed(window);
}
static inline void vout_window_SendMouseEvent(vout_window_t *window,
const vout_window_mouse_event_t *mouse)
{
if (window->owner.mouse_event != NULL)
window->owner.mouse_event(window, mouse);
if (window->owner.cbs->mouse_event != NULL)
window->owner.cbs->mouse_event(window, mouse);
}
/**
......
......@@ -131,9 +131,12 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
sys->height = cfg->height;
vlc_mutex_init(&sys->lock);
static const struct vout_window_callbacks cbs = {
.resized = vlc_gl_surface_ResizeNotify,
};
vout_window_owner_t owner = {
.cbs = &cbs,
.sys = sys,
.resized = vlc_gl_surface_ResizeNotify,
};
char *modlist = var_InheritString(obj, "window");
......
......@@ -163,6 +163,12 @@ static void vout_display_window_MouseEvent(vout_window_t *window,
vout_WindowMouseEvent(vout, mouse);
}
static const struct vout_window_callbacks vout_display_window_cbs = {
.resized = vout_display_window_ResizeNotify,
.closed = vout_display_window_CloseNotify,
.mouse_event = vout_display_window_MouseEvent,
};
/**
* Creates a video window, initially without any attached display.
*/
......@@ -180,10 +186,8 @@ vout_window_t *vout_display_window_New(vout_thread_t *vout,
char *modlist = var_InheritString(vout, "window");
vout_window_owner_t owner = {
.cbs = &vout_display_window_cbs,
.sys = state,
.resized = vout_display_window_ResizeNotify,
.closed = vout_display_window_CloseNotify,
.mouse_event = vout_display_window_MouseEvent,
};
vout_window_t *window;
......
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