Commit fcfe7370 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Move main thread lock back to GDK - we need it there for locking when

Wed Dec 16 13:06:17 1998  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
	thread lock back to GDK - we need it there for locking
	when translating events. Rename things appropriately.

Wed Dec 16 11:44:21 1998  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.

CVS:
parent 0dcdac58
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
Wed Dec 16 13:06:17 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.[ch] gtk/gtkmain.[ch] gtk/gtkprivate.h: Move main
thread lock back to GDK - we need it there for locking
when translating events. Rename things appropriately.
Wed Dec 16 11:44:21 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrange.c (gtk_range_expose): Fix a x/y typo.
Wed Dec 16 10:20:27 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GTK+ 1.1.8
......
......@@ -149,6 +149,9 @@ gdk_init (int *argc,
if (gdk_initialized)
return;
if (g_thread_supported ())
gdk_threads_mutex = g_mutex_new ();
if (argc && argv)
{
argc_orig = *argc;
......@@ -1265,3 +1268,16 @@ gdk_keyval_is_lower (guint keyval)
}
return TRUE;
}
void
gdk_threads_enter ()
{
GDK_THREADS_ENTER ();
}
void
gdk_threads_leave ()
{
GDK_THREADS_LEAVE ();
}
......@@ -959,6 +959,27 @@ guint gdk_keyval_to_lower (guint keyval);
gboolean gdk_keyval_is_upper (guint keyval);
gboolean gdk_keyval_is_lower (guint keyval);
/* Threading
*/
extern GMutex *gdk_threads_mutex;
void gdk_threads_enter (void);
void gdk_threads_leave (void);
#ifdef G_THREADS_ENABLED
# define GDK_THREADS_ENTER() G_STMT_START { \
if (gdk_threads_mutex) \
g_mutex_lock (gdk_threads_mutex); \
} G_STMT_END
# define GDK_THREADS_LEAVE() G_STMT_START { \
if (gdk_threads_mutex) \
g_mutex_unlock (gdk_threads_mutex); \
} G_STMT_END
#else /* !G_THREADS_ENABLED */
# define GDK_THREADS_ENTER()
# define GDK_THREADS_LEAVE()
#endif /* !G_THREADS_ENABLED */
#include <gdk/gdkrgb.h>
......
......@@ -1891,20 +1891,36 @@ gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
gint *timeout)
{
gboolean retval;
GDK_THREADS_ENTER ();
*timeout = -1;
gdk_events_queue ();
return (queued_events || putback_events);
retval = (queued_events || putback_events);
GDK_THREADS_LEAVE ();
return retval;
}
static gboolean
gdk_event_check (gpointer source_data,
GTimeVal *current_time)
{
gboolean retval;
GDK_THREADS_ENTER ();
if (event_poll_fd.revents & G_IO_IN)
gdk_events_queue ();
return (queued_events || putback_events);
retval = (queued_events || putback_events);
GDK_THREADS_LEAVE ();
return retval;
}
static GdkEvent *
......@@ -1942,7 +1958,11 @@ gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
gpointer user_data)
{
GdkEvent *event = gdk_event_unqueue();
GdkEvent *event;
GDK_THREADS_ENTER ();
event = gdk_event_unqueue();
if (event)
{
......@@ -1952,6 +1972,8 @@ gdk_event_dispatch (gpointer source_data,
gdk_event_free (event);
}
GDK_THREADS_LEAVE ();
return TRUE;
}
......
......@@ -64,6 +64,8 @@ GdkWindowPrivate *gdk_xgrab_window = NULL; /* Window that currently holds the
* x pointer grab
*/
GMutex *gdk_threads_mutex = NULL; /* Global GDK lock */
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
......
......@@ -1891,20 +1891,36 @@ gdk_event_prepare (gpointer source_data,
GTimeVal *current_time,
gint *timeout)
{
gboolean retval;
GDK_THREADS_ENTER ();
*timeout = -1;
gdk_events_queue ();
return (queued_events || putback_events);
retval = (queued_events || putback_events);
GDK_THREADS_LEAVE ();
return retval;
}
static gboolean
gdk_event_check (gpointer source_data,
GTimeVal *current_time)
{
gboolean retval;
GDK_THREADS_ENTER ();
if (event_poll_fd.revents & G_IO_IN)
gdk_events_queue ();
return (queued_events || putback_events);
retval = (queued_events || putback_events);
GDK_THREADS_LEAVE ();
return retval;
}
static GdkEvent *
......@@ -1942,7 +1958,11 @@ gdk_event_dispatch (gpointer source_data,
GTimeVal *current_time,
gpointer user_data)
{
GdkEvent *event = gdk_event_unqueue();
GdkEvent *event;
GDK_THREADS_ENTER ();
event = gdk_event_unqueue();
if (event)
{
......@@ -1952,6 +1972,8 @@ gdk_event_dispatch (gpointer source_data,
gdk_event_free (event);
}
GDK_THREADS_LEAVE ();
return TRUE;
}
......
......@@ -64,6 +64,8 @@ GdkWindowPrivate *gdk_xgrab_window = NULL; /* Window that currently holds the
* x pointer grab
*/
GMutex *gdk_threads_mutex = NULL; /* Global GDK lock */
#ifdef USE_XIM
GdkICPrivate *gdk_xim_ic; /* currently using IC */
GdkWindow *gdk_xim_window; /* currently using Window */
......
......@@ -149,6 +149,9 @@ gdk_init (int *argc,
if (gdk_initialized)
return;
if (g_thread_supported ())
gdk_threads_mutex = g_mutex_new ();
if (argc && argv)
{
argc_orig = *argc;
......@@ -1265,3 +1268,16 @@ gdk_keyval_is_lower (guint keyval)
}
return TRUE;
}
void
gdk_threads_enter ()
{
GDK_THREADS_ENTER ();
}
void
gdk_threads_leave ()
{
GDK_THREADS_LEAVE ();
}
......@@ -24,7 +24,6 @@
#include "gtkmain.h"
#include "gtksignal.h"
#include "gtkaccellabel.h"
#include "gtkprivate.h"
enum {
......@@ -354,9 +353,9 @@ gtk_accel_label_refetch_idle (GtkAccelLabel *accel_label)
{
gboolean retval;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
retval = gtk_accel_label_refetch (accel_label);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return retval;
}
......
......@@ -24,7 +24,6 @@
#include "gtkclist.h"
#include "gtkbindings.h"
#include "gtkdnd.h"
#include "gtkprivate.h"
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
......@@ -7014,7 +7013,7 @@ horizontal_timeout (GtkCList *clist)
GdkEventMotion event;
GdkModifierType mask;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
clist->htimer = 0;
gdk_window_get_pointer (clist->clist_window, &x, &y, &mask);
......@@ -7026,7 +7025,7 @@ horizontal_timeout (GtkCList *clist)
gtk_clist_motion (GTK_WIDGET (clist), &event);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -7038,7 +7037,7 @@ vertical_timeout (GtkCList *clist)
GdkEventMotion event;
GdkModifierType mask;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
clist->vtimer = 0;
gdk_window_get_pointer (clist->clist_window, &x, &y, &mask);
......@@ -7050,7 +7049,7 @@ vertical_timeout (GtkCList *clist)
gtk_clist_motion (GTK_WIDGET (clist), &event);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -24,7 +24,6 @@
#include "gtkwindow.h"
#include "gtkhbbox.h"
#include "gtkdnd.h"
#include "gtkprivate.h"
#include "gtkselection.h"
/*
......@@ -1028,13 +1027,13 @@ gtk_color_selection_value_timeout (GtkColorSelection *colorsel)
{
gint x, y;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
gdk_window_get_pointer (colorsel->value_area->window, &x, &y, NULL);
gtk_color_selection_update_value (colorsel, y);
gtk_color_selection_color_changed (colorsel);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return (TRUE);
}
......
......@@ -28,7 +28,6 @@
#include "gtklistitem.h"
#include "gtkscrolledwindow.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtksignal.h"
#include "gtkwindow.h"
#include "gdk/gdkkeysyms.h"
......@@ -237,9 +236,9 @@ gtk_combo_focus_idle (GtkCombo * combo)
{
if (combo)
{
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
gtk_widget_grab_focus (combo->entry);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
}
return FALSE;
}
......
......@@ -811,7 +811,7 @@ gtk_container_get_resize_container (GtkContainer *container)
static gboolean
gtk_container_idle_sizer (gpointer data)
{
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
/* we may be invoked with a container_resize_queue of NULL, because
* queue_resize could have been adding an extra idle function while
......@@ -833,7 +833,7 @@ gtk_container_idle_sizer (gpointer data)
gtk_container_check_resize (GTK_CONTAINER (widget));
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -22,7 +22,6 @@
#include "gtkdnd.h"
#include "gtkinvisible.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtksignal.h"
#include "gtkwindow.h"
......@@ -2272,7 +2271,7 @@ gtk_drag_anim_timeout (gpointer data)
gint x, y;
gboolean retval;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
if (anim->step == anim->n_steps)
{
......@@ -2295,7 +2294,7 @@ gtk_drag_anim_timeout (gpointer data)
retval = TRUE;
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return retval;
}
......
......@@ -22,7 +22,6 @@
#include "gdk/gdki18n.h"
#include "gtkentry.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkselection.h"
#include "gtksignal.h"
#include "gtkstyle.h"
......@@ -1481,13 +1480,13 @@ gtk_entry_timer (gpointer data)
{
GtkEntry *entry;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
entry = GTK_ENTRY (data);
entry->timer = 0;
gtk_entry_draw_text (entry);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -508,6 +508,9 @@ gtk_layout_unrealize (GtkWidget *widget)
tmp_list = tmp_list->next;
}
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
static void
......
......@@ -19,7 +19,6 @@
#include "gtklist.h"
#include "gtklistitem.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtksignal.h"
#include "gtklabel.h"
......@@ -2309,7 +2308,7 @@ gtk_list_horizontal_timeout (GtkWidget *list)
GdkEventMotion event;
GdkModifierType mask;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
GTK_LIST (list)->htimer = 0;
gdk_window_get_pointer (list->window, &x, &y, &mask);
......@@ -2321,7 +2320,7 @@ gtk_list_horizontal_timeout (GtkWidget *list)
gtk_list_motion_notify (list, &event);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......@@ -2334,7 +2333,7 @@ gtk_list_vertical_timeout (GtkWidget *list)
GdkEventMotion event;
GdkModifierType mask;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
GTK_LIST (list)->vtimer = 0;
gdk_window_get_pointer (list->window, &x, &y, &mask);
......@@ -2346,7 +2345,7 @@ gtk_list_vertical_timeout (GtkWidget *list)
gtk_list_motion_notify (list, &event);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -133,8 +133,6 @@ static GdkColormap *gtk_colormap; /* The colormap to be used in creating new
guint gtk_debug_flags = 0; /* Global GTK debug flag */
GMutex *gtk_threads_mutex = NULL; /* Global GTK lock */
#ifdef G_ENABLE_DEBUG
static const GDebugKey gtk_debug_keys[] = {
{"objects", GTK_DEBUG_OBJECTS},
......@@ -185,9 +183,6 @@ gtk_init (int *argc,
* single threaded until gtk_init().
*/
if (g_thread_supported ())
gtk_threads_mutex = g_mutex_new ();
#if 0
g_set_error_handler (gtk_error);
g_set_warning_handler (gtk_warning);
......@@ -459,9 +454,9 @@ gtk_main (void)
loop = g_main_new ();
main_loops = g_slist_prepend (main_loops, loop);
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
g_main_run (loop);
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
g_main_destroy (loop);
......@@ -1248,18 +1243,6 @@ gtk_propagate_event (GtkWidget *widget,
}
}
void
gtk_threads_enter ()
{
GTK_THREADS_ENTER ();
}
void
gtk_threads_leave ()
{
GTK_THREADS_LEAVE ();
}
#if 0
static void
gtk_error (gchar *str)
......
......@@ -131,9 +131,6 @@ void gtk_key_snooper_remove (guint snooper_handler_id);
GdkEvent* gtk_get_current_event (void);
GtkWidget* gtk_get_event_widget (GdkEvent *event);
void gtk_threads_enter (void);
void gtk_threads_leave (void);
/* deprecated */
guint gtk_idle_add_interp (GtkCallbackMarshal marshal,
gpointer data,
......
......@@ -19,7 +19,6 @@
#include <string.h>
#include "gtkaccellabel.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkmenu.h"
#include "gtkmenubar.h"
#include "gtkmenuitem.h"
......@@ -621,7 +620,7 @@ gtk_menu_item_select_timeout (gpointer data)
{
GtkMenuItem *menu_item;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
menu_item = GTK_MENU_ITEM (data);
menu_item->timer = 0;
......@@ -644,7 +643,7 @@ gtk_menu_item_select_timeout (gpointer data)
gtk_menu_shell_select_item (submenu, submenu->children->data);
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
......
......@@ -19,7 +19,6 @@
#include "gtknotebook.h"
#include "gtksignal.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtklabel.h"
......@@ -1837,7 +1836,7 @@ gtk_notebook_timer (GtkNotebook *notebook)
{
gboolean retval = FALSE;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
if (notebook->timer)
{
......@@ -1866,7 +1865,7 @@ gtk_notebook_timer (GtkNotebook *notebook)
retval = TRUE;
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return retval;
}
......
......@@ -60,25 +60,6 @@ typedef enum
#define GTK_PRIVATE_SET_FLAG(wid,flag) G_STMT_START{ (GTK_PRIVATE_FLAGS (wid) |= (PRIVATE_ ## flag)); }G_STMT_END
#define GTK_PRIVATE_UNSET_FLAG(wid,flag) G_STMT_START{ (GTK_PRIVATE_FLAGS (wid) &= ~(PRIVATE_ ## flag)); }G_STMT_END
/* Threading functions */
extern GMutex *gtk_threads_mutex;
#ifdef G_THREADS_ENABLED
# define GTK_THREADS_ENTER() G_STMT_START { \
if (gtk_threads_mutex) \
g_mutex_lock (gtk_threads_mutex); \
} G_STMT_END
# define GTK_THREADS_LEAVE() G_STMT_START { \
if (gtk_threads_mutex) \
g_mutex_unlock (gtk_threads_mutex); \
} G_STMT_END
#else /* !G_THREADS_ENABLED */
# define GTK_THREADS_ENTER()
# define GTK_THREADS_LEAVE()
#endif /* !G_THREADS_ENABLED */
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
......@@ -19,7 +19,6 @@
#include <stdio.h>
#include "gtkmain.h"
#include "gtkrange.h"
#include "gtkprivate.h"
#include "gtksignal.h"
......@@ -815,12 +814,12 @@ gtk_range_expose (GtkWidget *widget,
(event->area.x + event->area.width <=
widget->allocation.width - xt) &&
(event->area.y + event->area.height <=
widget->allocation.height - xt)))
widget->allocation.height - yt)))
gtk_range_draw_trough (range);
}
else if (event->window == widget->window)
{
gtk_range_draw_background (range);
gtk_range_draw_background (range);
}
else if (event->window == range->slider)
{
......@@ -1237,7 +1236,7 @@ gtk_real_range_timer (GtkRange *range)
{
gint return_val;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
return_val = TRUE;
if (range->click_child == RANGE_CLASS (range)->slider)
......@@ -1259,7 +1258,7 @@ gtk_real_range_timer (GtkRange *range)
(gpointer) range);
else
{
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return FALSE;
}
range->need_timer = FALSE;
......@@ -1287,7 +1286,7 @@ gtk_real_range_timer (GtkRange *range)
return_val = gtk_range_scroll (range, -1);
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return return_val;
}
......
......@@ -49,7 +49,6 @@
#include <gdk/gdkx.h>
/* we need this for gdk_window_lookup() */
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkselection.h"
#include "gtksignal.h"
......@@ -1092,7 +1091,7 @@ gtk_selection_incr_timeout (GtkIncrInfo *info)
GList *tmp_list;
gboolean retval;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
/* Determine if retrieval has finished by checking if it still in
list of pending retrievals */
......@@ -1129,7 +1128,7 @@ gtk_selection_incr_timeout (GtkIncrInfo *info)
retval = TRUE; /* timeout will happen again */
}
GTK_THREADS_LEAVE ();
GDK_THREADS_LEAVE ();
return retval;
}
......@@ -1334,7 +1333,7 @@ gtk_selection_retrieval_timeout (GtkRetrievalInfo *info)
GList *tmp_list;
gboolean retval;
GTK_THREADS_ENTER ();
GDK_THREADS_ENTER ();
/* Determine if retrieval has finished by checking if it still in
list of pending retrievals */
......@@ -1369,7 +1368,7 @@ gtk_selection_retrieval_timeout (GtkRetrievalInfo *info)