mir: add renderer event listener support
This commit is contained in:
parent
2872695fa7
commit
bc83282f4f
@ -80,6 +80,66 @@ cogl_mir_renderer_set_foreign_connection (CoglRenderer *renderer,
|
|||||||
MirConnection *
|
MirConnection *
|
||||||
cogl_mir_renderer_get_connection (CoglRenderer *renderer);
|
cogl_mir_renderer_get_connection (CoglRenderer *renderer);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CoglMirEvent:
|
||||||
|
* @onscreen: pointer to a #CoglOnscreen structure
|
||||||
|
* @surface: pointer to a #MirSurface structure
|
||||||
|
* @event: pointer to a #MirEvent structure
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
CoglOnscreen *onscreen;
|
||||||
|
MirSurface *surface;
|
||||||
|
MirEvent *event;
|
||||||
|
} CoglMirEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CoglMirEventCallback:
|
||||||
|
* @event: pointer to a CoglMirEvent structure
|
||||||
|
* @data: (closure): the data that was given when the filter was added
|
||||||
|
*
|
||||||
|
* A callback function that can be registered with
|
||||||
|
* cogl_mir_renderer_add_event_listener().
|
||||||
|
*
|
||||||
|
* Since: 1.8
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
typedef void (* CoglMirEventCallback) (CoglMirEvent *event,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cogl_mir_renderer_add_event_listener:
|
||||||
|
* @renderer: a #CoglRenderer
|
||||||
|
* @func: the callback function
|
||||||
|
* @data: user data passed to @func when called
|
||||||
|
*
|
||||||
|
* Adds a callback function that will receive all native events.
|
||||||
|
*
|
||||||
|
* Since: 1.8
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_mir_renderer_add_event_listener (CoglRenderer *renderer,
|
||||||
|
CoglMirEventCallback func,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* cogl_mir_renderer_remove_event_listener:
|
||||||
|
* @renderer: a #CoglRenderer
|
||||||
|
* @func: the callback function
|
||||||
|
* @data: user data given when the callback was installed
|
||||||
|
*
|
||||||
|
* Removes a callback that was previously added with
|
||||||
|
* cogl_mir_renderer_add_filter().
|
||||||
|
*
|
||||||
|
* Since: 1.8
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cogl_mir_renderer_remove_event_listener (CoglRenderer *renderer,
|
||||||
|
CoglMirEventCallback func,
|
||||||
|
void *data);
|
||||||
|
|
||||||
COGL_END_DECLS
|
COGL_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_MIR_RENDERER_H__ */
|
#endif /* __COGL_MIR_RENDERER_H__ */
|
||||||
|
@ -328,6 +328,7 @@ make_dummy_surface (CoglDisplay *display,
|
|||||||
|
|
||||||
mir_display->dummy_mir_surface =
|
mir_display->dummy_mir_surface =
|
||||||
mir_connection_create_surface_sync (mir_renderer->mir_connection, &surfaceparm);
|
mir_connection_create_surface_sync (mir_renderer->mir_connection, &surfaceparm);
|
||||||
|
|
||||||
if (!mir_surface_is_valid (mir_display->dummy_mir_surface))
|
if (!mir_surface_is_valid (mir_display->dummy_mir_surface))
|
||||||
{
|
{
|
||||||
error_message = "Failed to create a dummy mir surface";
|
error_message = "Failed to create a dummy mir surface";
|
||||||
@ -475,15 +476,18 @@ flush_pending_resize_notifications_idle (void *user_data)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _mir_surface_event_cb(MirSurface* surface, MirEvent const* event, void* data)
|
static void _mir_surface_event_cb (MirSurface *surface,
|
||||||
|
MirEvent const *event,
|
||||||
|
void *data)
|
||||||
{
|
{
|
||||||
CoglOnscreen *onscreen = data;
|
CoglOnscreen *onscreen = data;
|
||||||
|
|
||||||
if (event->type == mir_event_type_resize)
|
|
||||||
{
|
|
||||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||||
CoglContext *context = framebuffer->context;
|
CoglContext *context = framebuffer->context;
|
||||||
CoglRenderer *renderer = context->display->renderer;
|
CoglRenderer *renderer = context->display->renderer;
|
||||||
|
CoglMirEvent mir_event = { onscreen, surface, (MirEvent *) event };
|
||||||
|
|
||||||
|
if (event->type == mir_event_type_resize)
|
||||||
|
{
|
||||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||||
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
||||||
CoglOnscreenMir *mir_onscreen = egl_onscreen->platform;
|
CoglOnscreenMir *mir_onscreen = egl_onscreen->platform;
|
||||||
@ -505,6 +509,8 @@ static void _mir_surface_event_cb(MirSurface* surface, MirEvent const* event, vo
|
|||||||
|
|
||||||
g_mutex_unlock (&mir_onscreen->mir_event_lock);
|
g_mutex_unlock (&mir_onscreen->mir_event_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cogl_renderer_handle_native_event (renderer, &mir_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
@ -717,6 +723,28 @@ cogl_mir_renderer_get_connection (CoglRenderer *renderer)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_mir_renderer_add_event_listener (CoglRenderer *renderer,
|
||||||
|
CoglMirEventCallback func,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
||||||
|
|
||||||
|
_cogl_renderer_add_native_filter (renderer,
|
||||||
|
(CoglNativeFilterFunc)func, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_mir_renderer_remove_event_listener (CoglRenderer *renderer,
|
||||||
|
CoglMirEventCallback func,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
||||||
|
|
||||||
|
_cogl_renderer_remove_native_filter (renderer,
|
||||||
|
(CoglNativeFilterFunc)func, data);
|
||||||
|
}
|
||||||
|
|
||||||
CoglBool
|
CoglBool
|
||||||
cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen,
|
cogl_mir_onscreen_set_foreign_surface (CoglOnscreen *onscreen,
|
||||||
MirSurface *surface)
|
MirSurface *surface)
|
||||||
|
Loading…
Reference in New Issue
Block a user