|
Packit |
971217 |
/*
|
|
Packit |
971217 |
* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
|
Packit |
971217 |
* Copyright (C) 2015 Collabora ltd.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <stdint.h>
|
|
Packit |
971217 |
#include <stdlib.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include "win32_message_source.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
typedef struct _Win32MessageSource
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GSource source;
|
|
Packit |
971217 |
GPollFD pfd;
|
|
Packit |
971217 |
GstGLWindowWin32 *window;
|
|
Packit |
971217 |
} Win32MessageSource;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static gboolean
|
|
Packit |
971217 |
win32_message_source_check (GSource * base)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
MSG msg;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static gboolean
|
|
Packit |
971217 |
win32_message_source_dispatch (GSource * base, GSourceFunc callback,
|
|
Packit |
971217 |
gpointer user_data)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
Win32MessageSource *source = (Win32MessageSource *) base;
|
|
Packit |
971217 |
Win32MessageSourceFunc func = (Win32MessageSourceFunc) callback;
|
|
Packit |
971217 |
MSG msg;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
|
|
Packit |
971217 |
return G_SOURCE_CONTINUE;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (func)
|
|
Packit |
971217 |
func (source->window, &msg, user_data);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return G_SOURCE_CONTINUE;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static GSourceFuncs win32_message_source_funcs = {
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
win32_message_source_check,
|
|
Packit |
971217 |
win32_message_source_dispatch,
|
|
Packit |
971217 |
NULL
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GSource *
|
|
Packit |
971217 |
win32_message_source_new (GstGLWindowWin32 * window_win32)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
Win32MessageSource *source;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
source = (Win32MessageSource *)
|
|
Packit |
971217 |
g_source_new (&win32_message_source_funcs, sizeof (Win32MessageSource));
|
|
Packit |
971217 |
source->window = window_win32;
|
|
Packit |
971217 |
source->pfd.fd = G_WIN32_MSG_HANDLE;
|
|
Packit |
971217 |
source->pfd.events = G_IO_IN;
|
|
Packit |
971217 |
g_source_add_poll (&source->source, &source->pfd);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return &source->source;
|
|
Packit |
971217 |
}
|