win32: Fix clutter_win32_disable_event_retrieval

There was previously a flag that gets set when this function was
called but nothing checked it so the function effectively did
nothing. Also the flag was a member of the backend struct but this
can't be used because the function should be called before
clutter_init so the backend is not ready yet. This patch makes the
event disabling work more like the X11 backend and set a global
variable instead.
This commit is contained in:
Neil Roberts 2010-10-21 17:20:44 +01:00
parent e6099cdd4b
commit 6da18b6e4f
3 changed files with 28 additions and 23 deletions

View File

@ -51,6 +51,9 @@ static gchar *clutter_vblank_name = NULL;
static HINSTANCE clutter_hinst = NULL; static HINSTANCE clutter_hinst = NULL;
/* various flags corresponding to pre init setup calls */
static gboolean _no_event_retrieval = FALSE;
gboolean gboolean
clutter_backend_win32_pre_parse (ClutterBackend *backend, clutter_backend_win32_pre_parse (ClutterBackend *backend,
GError **error) GError **error)
@ -75,6 +78,7 @@ clutter_backend_win32_init_events (ClutterBackend *backend)
"backend", backend_win32, "backend", backend_win32,
NULL); NULL);
if (!_no_event_retrieval)
_clutter_backend_win32_events_init (backend); _clutter_backend_win32_events_init (backend);
} }
@ -539,6 +543,29 @@ clutter_backend_win32_get_device_manager (ClutterBackend *backend)
return backend_win32->device_manager; return backend_win32->device_manager;
} }
/**
* clutter_win32_disable_event_retrieval
*
* Disables retrieval of Windows messages in the main loop. Use to
* create event-less canvas.
*
* This function can only be called before calling clutter_init().
*
* Since: 0.8
*/
void
clutter_win32_disable_event_retrieval (void)
{
if (_clutter_context_is_initialized ())
{
g_warning ("clutter_win32_disable_event_retrieval() can only be "
"called before clutter_init()");
return;
}
_no_event_retrieval = TRUE;
}
static void static void
clutter_backend_win32_class_init (ClutterBackendWin32Class *klass) clutter_backend_win32_class_init (ClutterBackendWin32Class *klass)
{ {
@ -566,7 +593,6 @@ clutter_backend_win32_init (ClutterBackendWin32 *backend_win32)
ClutterBackend *backend = CLUTTER_BACKEND (backend_win32); ClutterBackend *backend = CLUTTER_BACKEND (backend_win32);
backend_win32->gl_context = NULL; backend_win32->gl_context = NULL;
backend_win32->no_event_retrieval = FALSE;
backend_win32->invisible_cursor = NULL; backend_win32->invisible_cursor = NULL;
/* FIXME: get from GetSystemMetric? /* FIXME: get from GetSystemMetric?

View File

@ -48,7 +48,6 @@ struct _ClutterBackendWin32
HGLRC gl_context; HGLRC gl_context;
HWND dummy_hwnd; HWND dummy_hwnd;
HDC dummy_dc; HDC dummy_dc;
gboolean no_event_retrieval;
HCURSOR invisible_cursor; HCURSOR invisible_cursor;

View File

@ -237,26 +237,6 @@ make_button_event (const MSG *msg,
take_and_queue_event (event); take_and_queue_event (event);
} }
/**
* clutter_win32_disable_event_retrieval
*
* Disables retrieval of Windows messages in the main loop. Use to
* create event-less canvas.
*
* This function can only be called before calling clutter_init().
*
* Since: 0.8
*/
void
clutter_win32_disable_event_retrieval (void)
{
ClutterBackendWin32 *backend;
backend = CLUTTER_BACKEND_WIN32 (clutter_get_default_backend ());
backend->no_event_retrieval = TRUE;
}
static gboolean static gboolean
clutter_event_prepare (GSource *source, clutter_event_prepare (GSource *source,
gint *timeout) gint *timeout)