mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-29 02:27:53 +00:00
win32: use a struct for the event source
This removes the event_poll_fd global variable and the (ab)use of get_default_display. It is also more consistent with other backends. Also store display
This commit is contained in:
parent
58a49c1a4b
commit
8f25481406
@ -232,7 +232,7 @@ _gdk_win32_display_open (const gchar *display_name)
|
|||||||
|
|
||||||
win32_display->screen = g_object_new (GDK_TYPE_WIN32_SCREEN, NULL);
|
win32_display->screen = g_object_new (GDK_TYPE_WIN32_SCREEN, NULL);
|
||||||
|
|
||||||
_gdk_events_init ();
|
_gdk_events_init (_gdk_display);
|
||||||
|
|
||||||
_gdk_input_ignore_core = FALSE;
|
_gdk_input_ignore_core = FALSE;
|
||||||
|
|
||||||
|
@ -108,6 +108,14 @@ extern gint _gdk_input_ignore_core;
|
|||||||
|
|
||||||
GdkCursor *_gdk_win32_grab_cursor;
|
GdkCursor *_gdk_win32_grab_cursor;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GSource source;
|
||||||
|
|
||||||
|
GdkDisplay *display;
|
||||||
|
GPollFD event_poll_fd;
|
||||||
|
} GdkWin32EventSource;
|
||||||
|
|
||||||
static GSourceFuncs event_funcs = {
|
static GSourceFuncs event_funcs = {
|
||||||
gdk_event_prepare,
|
gdk_event_prepare,
|
||||||
gdk_event_check,
|
gdk_event_check,
|
||||||
@ -115,8 +123,6 @@ static GSourceFuncs event_funcs = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
GPollFD event_poll_fd;
|
|
||||||
|
|
||||||
static GdkWindow *mouse_window = NULL;
|
static GdkWindow *mouse_window = NULL;
|
||||||
static GdkWindow *mouse_window_ignored_leave = NULL;
|
static GdkWindow *mouse_window_ignored_leave = NULL;
|
||||||
static gint current_x, current_y;
|
static gint current_x, current_y;
|
||||||
@ -286,9 +292,10 @@ _gdk_win32_window_procedure (HWND hwnd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_gdk_events_init (void)
|
_gdk_events_init (GdkDisplay *display)
|
||||||
{
|
{
|
||||||
GSource *source;
|
GSource *source;
|
||||||
|
GdkWin32EventSource *event_source;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
@ -376,20 +383,22 @@ _gdk_events_init (void)
|
|||||||
GDK_NOTE (EVENTS, g_print ("latin_locale = %08x\n", (guint) latin_locale));
|
GDK_NOTE (EVENTS, g_print ("latin_locale = %08x\n", (guint) latin_locale));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
source = g_source_new (&event_funcs, sizeof (GSource));
|
source = g_source_new (&event_funcs, sizeof (GdkWin32EventSource));
|
||||||
g_source_set_name (source, "GDK Win32 event source");
|
g_source_set_name (source, "GDK Win32 event source");
|
||||||
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
|
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
|
||||||
|
|
||||||
|
event_source = (GdkWin32EventSource *)source;
|
||||||
|
event_source->display = display;
|
||||||
#ifdef G_WITH_CYGWIN
|
#ifdef G_WITH_CYGWIN
|
||||||
event_poll_fd.fd = open ("/dev/windows", O_RDONLY);
|
event_source->event_poll_fd.fd = open ("/dev/windows", O_RDONLY);
|
||||||
if (event_poll_fd.fd == -1)
|
if (event_source->event_poll_fd.fd == -1)
|
||||||
g_error ("can't open \"/dev/windows\": %s", g_strerror (errno));
|
g_error ("can't open \"/dev/windows\": %s", g_strerror (errno));
|
||||||
#else
|
#else
|
||||||
event_poll_fd.fd = G_WIN32_MSG_HANDLE;
|
event_source->event_poll_fd.fd = G_WIN32_MSG_HANDLE;
|
||||||
#endif
|
#endif
|
||||||
event_poll_fd.events = G_IO_IN;
|
event_source->event_poll_fd.events = G_IO_IN;
|
||||||
|
|
||||||
g_source_add_poll (source, &event_poll_fd);
|
g_source_add_poll (source, &event_source->event_poll_fd);
|
||||||
g_source_set_can_recurse (source, TRUE);
|
g_source_set_can_recurse (source, TRUE);
|
||||||
g_source_attach (source, NULL);
|
g_source_attach (source, NULL);
|
||||||
}
|
}
|
||||||
@ -3501,19 +3510,17 @@ static gboolean
|
|||||||
gdk_event_prepare (GSource *source,
|
gdk_event_prepare (GSource *source,
|
||||||
gint *timeout)
|
gint *timeout)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkWin32EventSource *event_source = (GdkWin32EventSource *)source;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
display = gdk_display_get_default ();
|
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
|
|
||||||
*timeout = -1;
|
*timeout = -1;
|
||||||
|
|
||||||
if (display->event_pause_count > 0)
|
if (event_source->display->event_pause_count > 0)
|
||||||
retval =_gdk_event_queue_find_first (display) != NULL;
|
retval =_gdk_event_queue_find_first (event_source->display) != NULL;
|
||||||
else
|
else
|
||||||
retval = (_gdk_event_queue_find_first (display) != NULL ||
|
retval = (_gdk_event_queue_find_first (event_source->display) != NULL ||
|
||||||
(modal_win32_dialog == NULL &&
|
(modal_win32_dialog == NULL &&
|
||||||
GetQueueStatus (QS_ALLINPUT) != 0));
|
GetQueueStatus (QS_ALLINPUT) != 0));
|
||||||
|
|
||||||
@ -3525,17 +3532,15 @@ gdk_event_prepare (GSource *source,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gdk_event_check (GSource *source)
|
gdk_event_check (GSource *source)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkWin32EventSource *event_source = (GdkWin32EventSource *)source;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
display = gdk_display_get_default ();
|
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
|
|
||||||
if (display->event_pause_count > 0)
|
if (event_source->display->event_pause_count > 0)
|
||||||
retval = _gdk_event_queue_find_first (display) != NULL;
|
retval = _gdk_event_queue_find_first (event_source->display) != NULL;
|
||||||
else if (event_poll_fd.revents & G_IO_IN)
|
else if (event_source->event_poll_fd.revents & G_IO_IN)
|
||||||
retval = (_gdk_event_queue_find_first (display) != NULL ||
|
retval = (_gdk_event_queue_find_first (event_source->display) != NULL ||
|
||||||
(modal_win32_dialog == NULL &&
|
(modal_win32_dialog == NULL &&
|
||||||
GetQueueStatus (QS_ALLINPUT) != 0));
|
GetQueueStatus (QS_ALLINPUT) != 0));
|
||||||
else
|
else
|
||||||
@ -3551,15 +3556,13 @@ gdk_event_dispatch (GSource *source,
|
|||||||
GSourceFunc callback,
|
GSourceFunc callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GdkDisplay *display;
|
GdkWin32EventSource *event_source = (GdkWin32EventSource *)source;
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
|
|
||||||
display = gdk_display_get_default ();
|
|
||||||
|
|
||||||
gdk_threads_enter ();
|
gdk_threads_enter ();
|
||||||
|
|
||||||
_gdk_win32_display_queue_events (display);
|
_gdk_win32_display_queue_events (event_source->display);
|
||||||
event = _gdk_event_unqueue (display);
|
event = _gdk_event_unqueue (event_source->display);
|
||||||
|
|
||||||
if (event)
|
if (event)
|
||||||
{
|
{
|
||||||
|
@ -540,6 +540,6 @@ gboolean _gdk_win32_window_lacks_wm_decorations (GdkWindow *window);
|
|||||||
/* Initialization */
|
/* Initialization */
|
||||||
void _gdk_win32_windowing_init (void);
|
void _gdk_win32_windowing_init (void);
|
||||||
void _gdk_dnd_init (void);
|
void _gdk_dnd_init (void);
|
||||||
void _gdk_events_init (void);
|
void _gdk_events_init (GdkDisplay *display);
|
||||||
|
|
||||||
#endif /* __GDK_PRIVATE_WIN32_H__ */
|
#endif /* __GDK_PRIVATE_WIN32_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user