From 6da18b6e4f93bb1430698959d6280cb53f9e2ff2 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 21 Oct 2010 17:20:44 +0100 Subject: [PATCH] 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. --- clutter/win32/clutter-backend-win32.c | 30 +++++++++++++++++++++++++-- clutter/win32/clutter-backend-win32.h | 1 - clutter/win32/clutter-event-win32.c | 20 ------------------ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/clutter/win32/clutter-backend-win32.c b/clutter/win32/clutter-backend-win32.c index 6613468ea..18a15b775 100644 --- a/clutter/win32/clutter-backend-win32.c +++ b/clutter/win32/clutter-backend-win32.c @@ -51,6 +51,9 @@ static gchar *clutter_vblank_name = NULL; static HINSTANCE clutter_hinst = NULL; +/* various flags corresponding to pre init setup calls */ +static gboolean _no_event_retrieval = FALSE; + gboolean clutter_backend_win32_pre_parse (ClutterBackend *backend, GError **error) @@ -75,7 +78,8 @@ clutter_backend_win32_init_events (ClutterBackend *backend) "backend", backend_win32, NULL); - _clutter_backend_win32_events_init (backend); + if (!_no_event_retrieval) + _clutter_backend_win32_events_init (backend); } HCURSOR @@ -539,6 +543,29 @@ clutter_backend_win32_get_device_manager (ClutterBackend *backend) 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 clutter_backend_win32_class_init (ClutterBackendWin32Class *klass) { @@ -566,7 +593,6 @@ clutter_backend_win32_init (ClutterBackendWin32 *backend_win32) ClutterBackend *backend = CLUTTER_BACKEND (backend_win32); backend_win32->gl_context = NULL; - backend_win32->no_event_retrieval = FALSE; backend_win32->invisible_cursor = NULL; /* FIXME: get from GetSystemMetric? diff --git a/clutter/win32/clutter-backend-win32.h b/clutter/win32/clutter-backend-win32.h index 5a6c40dbc..4da5c8a90 100644 --- a/clutter/win32/clutter-backend-win32.h +++ b/clutter/win32/clutter-backend-win32.h @@ -48,7 +48,6 @@ struct _ClutterBackendWin32 HGLRC gl_context; HWND dummy_hwnd; HDC dummy_dc; - gboolean no_event_retrieval; HCURSOR invisible_cursor; diff --git a/clutter/win32/clutter-event-win32.c b/clutter/win32/clutter-event-win32.c index 17717c6ce..152a4a1e1 100644 --- a/clutter/win32/clutter-event-win32.c +++ b/clutter/win32/clutter-event-win32.c @@ -237,26 +237,6 @@ make_button_event (const MSG *msg, 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 clutter_event_prepare (GSource *source, gint *timeout)