It's all in the changelog. Well, almost all.

-owt
This commit is contained in:
Owen Taylor 1997-12-18 02:17:14 +00:00
parent 65e63db01e
commit d5d01a5af9
74 changed files with 3953 additions and 1465 deletions

View File

@ -3,7 +3,7 @@
SRC_SUBDIRS = glib gdk gtk
SUBDIRS = $(SRC_SUBDIRS) docs
EXTRA_DIST = gtk+.prj makecopyright TODO
EXTRA_DIST = gtk+.prj makecopyright TODO REFCOUNTING
.PHONY: files populate checkin release

View File

@ -75,7 +75,7 @@ xinput_progs = @xinput_progs@
SRC_SUBDIRS = glib gdk gtk
SUBDIRS = $(SRC_SUBDIRS) docs
EXTRA_DIST = gtk+.prj makecopyright TODO
EXTRA_DIST = gtk+.prj makecopyright TODO REFCOUNTING
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
@ -88,7 +88,7 @@ ltmain.sh missing mkinstalldirs stamp-h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
TAR = tar
GZIP = --best
default: all

338
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(gdk/gdktypes.h)
# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}
GTK_MAJOR_VERSION=0
GTK_MINOR_VERSION=99
GTK_MICRO_VERSION=0
@ -13,6 +16,9 @@ PACKAGE=gtk+
# Configure glib
AC_CONFIG_SUBDIRS(glib)
# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}
dnl Initialize automake stuff
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
@ -42,7 +48,7 @@ AC_ARG_WITH(locale, [ --with-locale=LOCALE locale name you want to use ])
AC_ARG_WITH(xinput, [ --with-xinput[=no/gxi/xfree] support XInput ])
if test -n "$DEBUGFLAG"; then
test "${CFLAGS+set}" = set || CFLAGS="$DEBUGFLAG"
test "$cflags_set" = set || CFLAGS="$DEBUGFLAG"
else
CFLAGS="$CFLAGS -DNDEBUG"
fi
@ -104,7 +110,7 @@ x_ldflags="$X_LDFLAGS $X_LIBS"
# set up things for XInput
if test "x$with_xinput" = "xgxi -o x$with_xinput" = "xyes"; then
if test "x$with_xinput" = "xgxi" -o "x$with_xinput" = "xyes"; then
AC_DEFINE(XINPUT_GXI)
xinput_progs=gxid
x_libs="-lXi $x_libs"
@ -199,38 +205,23 @@ gtk_cv_display_resource_base="private3")])
AC_MSG_RESULT($gtk_cv_display_resource_base)
AC_DEFINE_UNQUOTED(RESOURCE_BASE, gdk_display->$gtk_cv_display_resource_base)
# Look for wide string functions in wchar.h or wcstr.h
AC_MSG_CHECKING(for <wchar.h> or <wcstr.h>)
AC_TRY_CPP([#include <wchar.h>], gtk_ok=yes, gtk_ok=no)
if test $gtk_ok = no; then
AC_TRY_CPP([#include <wcstr.h>], gtk_ok=yes, gtk_ok=no)
if test $gtk_ok = no; then
need_x_locale=yes
fi
fi
AC_MSG_RESULT($gtk_ok)
# Check if X_LOCALE definition is necessary
AC_MSG_CHECKING(need -DX_LOCALE)
if test x$need_x_locale = xyes; then
AC_MSG_RESULT([yes (C library doesn't include wide string functions)])
else
AC_TRY_RUN([
#include <stdio.h>
#include <locale.h>
int
main ()
{
return setlocale (LC_ALL, "${with_locale}") == NULL;
}],
need_x_locale=no,
need_x_locale=yes)
AC_MSG_RESULT($need_x_locale)
fi
AC_TRY_RUN([
#include <stdio.h>
#include <locale.h>
int
main ()
{
return setlocale (LC_ALL, "${with_locale}") == NULL;
}],
need_x_locale=no,
need_x_locale=yes)
AC_MSG_RESULT($need_x_locale)
if test $need_x_locale = yes; then
CFLAGS="$CFLAGS -DX_LOCALE"
fi

421
gdk/gdk.c
View File

@ -88,6 +88,7 @@ struct _GdkInput
GdkInputCondition condition;
GdkInputFunction function;
gpointer data;
GdkDestroyNotify destroy;
};
struct _GdkPredicate
@ -99,12 +100,19 @@ struct _GdkPredicate
/*
* Private function declarations
*/
static GdkEvent *gdk_event_new (void);
static gint gdk_event_wait (void);
static gint gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters);
static gint gdk_event_translate (GdkEvent *event,
XEvent *xevent);
#if 0
static Bool gdk_event_get_type (Display *display,
XEvent *xevent,
XPointer arg);
#endif
static void gdk_synthesize_click (GdkEvent *event,
gint nclicks);
@ -157,15 +165,6 @@ static int connection_number = 0; /* The file descriptor numbe
* the "select" system call.
*/
static gint received_destroy_notify = FALSE; /* Did we just receive a destroy notify
* event? If so, we need to actually
* destroy the window which received
* it now.
*/
static GdkWindow *window_to_destroy = NULL; /* If we previously received a destroy
* notify event then this is the window
* which received that event.
*/
static struct timeval start; /* The time at which the library was
* last initialized.
@ -601,6 +600,58 @@ gdk_events_pending ()
return XPending (gdk_display);
}
/*
*--------------------------------------------------------------
* gdk_event_get_graphics_expose
*
* Waits for a GraphicsExpose or NoExpose event
*
* Arguments:
*
* Results:
* For GraphicsExpose events, returns a pointer to the event
* converted into a GdkEvent Otherwise, returns NULL.
*
* Side effects:
*
*-------------------------------------------------------------- */
static Bool
graphics_expose_predicate (Display *display,
XEvent *xevent,
XPointer arg)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)arg;
if ((xevent->xany.window == private->xwindow) &&
((xevent->xany.type == GraphicsExpose) ||
(xevent->xany.type == NoExpose)))
return True;
else
return False;
}
GdkEvent *
gdk_event_get_graphics_expose (GdkWindow *window)
{
XEvent xevent;
GdkEvent *event;
XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer)window);
if (xevent.xany.type == GraphicsExpose)
{
event = gdk_event_new ();
if (gdk_event_translate (event, &xevent))
return event;
else
gdk_event_free (event);
}
return NULL;
}
/*
*--------------------------------------------------------------
* gdk_event_get
@ -608,14 +659,11 @@ gdk_events_pending ()
* Gets the next event.
*
* Arguments:
* "event" is used to hold the received event.
* If "event" is NULL an event is received as normal
* however it is not placed in "event" (and thus no
* error occurs).
*
* Results:
* Returns TRUE if an event was received that we care about
* and FALSE otherwise. This function will also return
* If an event was received that we care about, returns
* a pointer to that event, to be freed with gdk_event_free.
* Otherwise, returns NULL. This function will also return
* before an event is received if the timeout interval
* runs out.
*
@ -624,45 +672,14 @@ gdk_events_pending ()
*--------------------------------------------------------------
*/
gint
gdk_event_get (GdkEvent *event,
GdkEventFunc pred,
gpointer data)
GdkEvent *
gdk_event_get (void)
{
GdkEvent *temp_event;
GdkPredicate event_pred;
GdkEvent *event;
GList *temp_list;
XEvent xevent;
/* If the last event we received was a destroy notify
* event then we will actually destroy the "gdk" data
* structures now. We don't want to destroy them at the
* time of receiving the event since the main program
* may try to access them and may need to destroy user
* data that has been attached to the window
*/
if (received_destroy_notify)
{
if (gdk_show_events)
g_print ("destroying window:\twindow: %ld\n",
((GdkWindowPrivate*) window_to_destroy)->xwindow - base_id);
gdk_window_real_destroy (window_to_destroy);
received_destroy_notify = FALSE;
window_to_destroy = NULL;
}
/* Initially we haven't received an event and want to
* return FALSE. If "event" is non-NULL, then initialize
* it to the nothing event.
*/
if (event)
{
event->any.type = GDK_NOTHING;
event->any.window = NULL;
event->any.send_event = FALSE;
}
#if 0
if (pred)
{
temp_list = putback_events;
@ -685,65 +702,61 @@ gdk_event_get (GdkEvent *event,
event_pred.func = pred;
event_pred.data = data;
if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) &event_pred))
if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) & event_pred))
if (event)
return gdk_event_translate (event, &xevent);
}
else
{
if (putback_events)
{
temp_event = putback_events->data;
*event = *temp_event;
temp_list = putback_events;
putback_events = putback_events->next;
if (putback_events)
putback_events->prev = NULL;
temp_list->next = NULL;
temp_list->prev = NULL;
g_list_free (temp_list);
g_free (temp_event);
return TRUE;
}
/* Wait for an event to occur or the timeout to elapse.
* If an event occurs "gdk_event_wait" will return TRUE.
* If the timeout elapses "gdk_event_wait" will return
* FALSE.
*/
if (gdk_event_wait ())
{
/* If we get here we can rest assurred that an event
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* dont dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
#else
XNextEvent (gdk_display, &xevent);
#endif
if (putback_events)
{
event = putback_events->data;
temp_list = putback_events;
putback_events = g_list_remove_link (putback_events, temp_list);
g_list_free_1 (temp_list);
return event;
}
/* Wait for an event to occur or the timeout to elapse.
* If an event occurs "gdk_event_wait" will return TRUE.
* If the timeout elapses "gdk_event_wait" will return
* FALSE.
*/
if (gdk_event_wait ())
{
/* If we get here we can rest assurred that an event
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* don't dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
#else
XNextEvent (gdk_display, &xevent);
#endif
event = gdk_event_new ();
event->any.send_event = xevent.xany.send_event;
/* If "event" non-NULL.
*/
if (event)
return gdk_event_translate (event, &xevent);
}
event->any.type = GDK_NOTHING;
event->any.window = NULL;
event->any.send_event = FALSE;
event->any.send_event = xevent.xany.send_event;
if (gdk_event_translate (event, &xevent))
return event;
else
gdk_event_free (event);
}
return FALSE;
return NULL;
}
void
@ -753,8 +766,7 @@ gdk_event_put (GdkEvent *event)
g_return_if_fail (event != NULL);
new_event = g_new (GdkEvent, 1);
*new_event = *event;
new_event = gdk_event_copy (event);
putback_events = g_list_prepend (putback_events, new_event);
}
@ -779,13 +791,11 @@ gdk_event_put (GdkEvent *event)
static GMemChunk *event_chunk;
GdkEvent*
gdk_event_copy (GdkEvent *event)
static GdkEvent*
gdk_event_new (void)
{
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
if (event_chunk == NULL)
event_chunk = g_mem_chunk_new ("events",
sizeof (GdkEvent),
@ -793,8 +803,31 @@ gdk_event_copy (GdkEvent *event)
G_ALLOC_AND_FREE);
new_event = g_chunk_new (GdkEvent, event_chunk);
return new_event;
}
GdkEvent*
gdk_event_copy (GdkEvent *event)
{
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
new_event = gdk_event_new ();
*new_event = *event;
gdk_window_ref (new_event->any.window);
if ((event->any.type == GDK_KEY_PRESS) ||
(event->any.type == GDK_KEY_RELEASE))
new_event->key.string = g_strdup (event->key.string);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_ref (event->crossing.subwindow);
return new_event;
}
@ -822,7 +855,18 @@ gdk_event_free (GdkEvent *event)
g_assert (event_chunk != NULL);
g_return_if_fail (event != NULL);
gdk_window_unref (event->any.window);
if ((event->any.type == GDK_KEY_PRESS) ||
(event->any.type == GDK_KEY_RELEASE))
g_free (event->key.string);
if (event->any.window)
gdk_window_unref (event->any.window);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_unref (event->crossing.subwindow);
g_mem_chunk_free (event_chunk, event);
}
@ -1008,10 +1052,11 @@ gdk_timer_disable ()
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
gdk_input_add_interp (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data,
GdkDestroyNotify destroy)
{
static gint next_tag = 1;
GList *list;
@ -1028,8 +1073,11 @@ gdk_input_add (gint source,
if ((input->source == source) && (input->condition == condition))
{
if (input->destroy)
(input->destroy) (input->data);
input->function = function;
input->data = data;
input->destroy = destroy;
tag = input->tag;
}
}
@ -1042,6 +1090,7 @@ gdk_input_add (gint source,
input->condition = condition;
input->function = function;
input->data = data;
input->destroy = destroy;
tag = input->tag;
inputs = g_list_prepend (inputs, input);
@ -1050,6 +1099,15 @@ gdk_input_add (gint source,
return tag;
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
{
return gdk_input_add_interp (source, condition, function, data, NULL);
}
void
gdk_input_remove (gint tag)
{
@ -1064,6 +1122,9 @@ gdk_input_remove (gint tag)
if (input->tag == tag)
{
if (input->destroy)
(input->destroy) (input->data);
temp_list = list;
if (list->next)
@ -1470,6 +1531,31 @@ gdk_event_wait ()
return FALSE;
}
static gint
gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters)
{
GdkEventFilter *filter;
GList *tmp_list;
GdkFilterReturn result;
tmp_list = filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
result = (*filter->function)(xevent, event, filter->data);
if (result != GDK_FILTER_CONTINUE)
return result;
tmp_list = tmp_list->next;
}
return GDK_FILTER_CONTINUE;
}
static gint
gdk_event_translate (GdkEvent *event,
XEvent *xevent)
@ -1520,6 +1606,25 @@ gdk_event_translate (GdkEvent *event,
window = gdk_window_lookup (xevent->xany.window);
window_private = (GdkWindowPrivate *) window;
if (window == NULL)
g_warning ("%#lx -> NULL\n", xevent->xany.window);
else
gdk_window_ref (window);
/* Check for filters for this window */
if (window_private)
{
GdkFilterReturn result;
result = gdk_event_apply_filters (xevent, event, window_private->filters);
if (result != GDK_FILTER_CONTINUE)
{
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
}
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@ -1555,7 +1660,7 @@ gdk_event_translate (GdkEvent *event,
{ /* retry */
/* alloc adequate size of buffer */
if (gdk_debug_level >= 1)
g_print("XIM: overflow(required %i)\n", charcount);
g_print("XIM: overflow (required %i)\n", charcount);
while (buf_len <= charcount)
buf_len *= 2;
@ -1603,10 +1708,14 @@ gdk_event_translate (GdkEvent *event,
event->key.window = window;
event->key.time = xevent->xkey.time;
event->key.state = (GdkModifierType) xevent->xkey.state;
event->key.string = buf;
event->key.string = g_strdup (buf);
event->key.length = charcount;
return_val = window_private && !window_private->destroyed;
if (!return_val)
g_free (event->key.string);
break;
case KeyRelease:
@ -2012,6 +2121,14 @@ gdk_event_translate (GdkEvent *event,
event->crossing.type = GDK_LEAVE_NOTIFY;
event->crossing.window = window;
/* If the subwindow field of the XEvent is non-NULL, then
* lookup the corresponding GdkWindow.
*/
if (xevent->xcrossing.subwindow != None)
event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
else
event->crossing.subwindow = NULL;
/* Translate the crossing detail into Gdk terms.
*/
switch (xevent->xcrossing.detail)
@ -2073,31 +2190,30 @@ gdk_event_translate (GdkEvent *event,
break;
case FocusIn:
/* Print debugging info.
*/
if (gdk_show_events)
g_print ("focus in:\t\twindow: %ld\n",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = TRUE;
return_val = window_private && !window_private->destroyed;
break;
case FocusOut:
/* Print debugging info.
/* We only care about focus events that indicate that _this_
* window (not a ancestor or child) got or lost the focus
*/
if (gdk_show_events)
g_print ("focus out:\t\twindow: %ld\n",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = FALSE;
return_val = window_private && !window_private->destroyed;
switch (xevent->xfocus.detail)
{
case NotifyAncestor:
case NotifyInferior:
case NotifyNonlinear:
/* Print debugging info.
*/
if (gdk_show_events)
g_print ("focus %s:\t\twindow: %ld\n",
(xevent->xany.type == FocusIn) ? "in" : "out",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = (xevent->xany.type == FocusIn);
return_val = window_private && !window_private->destroyed;
break;
default:
}
break;
case KeymapNotify:
@ -2194,15 +2310,9 @@ gdk_event_translate (GdkEvent *event,
event->any.type = GDK_DESTROY;
event->any.window = window;
/* Remeber which window received the destroy notify
* event so that we can destroy our associated
* data structures the next time the user asks
* us for an event.
*/
received_destroy_notify = TRUE;
window_to_destroy = window;
return_val = window_private && !window_private->destroyed;
gdk_window_destroy_notify (window);
break;
case UnmapNotify:
@ -2618,9 +2728,29 @@ gdk_event_translate (GdkEvent *event,
break;
}
if (return_val)
{
if (event->any.window)
gdk_window_ref (event->any.window);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_ref (event->crossing.subwindow);
}
else
{
/* Mark this event as having no resources to be freed */
event->any.window = NULL;
event->any.type = GDK_NOTHING;
}
if (window)
gdk_window_unref (window);
return return_val;
}
#if 0
static Bool
gdk_event_get_type (Display *display,
XEvent *xevent,
@ -2637,6 +2767,7 @@ gdk_event_get_type (Display *display,
return FALSE;
}
#endif
static void
gdk_synthesize_click (GdkEvent *event,

View File

@ -35,9 +35,8 @@ void gdk_exit (int error_code);
gchar* gdk_set_locale (void);
gint gdk_events_pending (void);
gint gdk_event_get (GdkEvent *event,
GdkEventFunc pred,
gpointer data);
GdkEvent *gdk_event_get (void);
GdkEvent *gdk_event_get_graphics_expose (GdkWindow *window);
void gdk_event_put (GdkEvent *event);
GdkEvent *gdk_event_copy (GdkEvent *event);
@ -58,11 +57,16 @@ void gdk_timer_set (guint32 milliseconds);
void gdk_timer_enable (void);
void gdk_timer_disable (void);
gint gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data);
void gdk_input_remove (gint tag);
gint gdk_input_add_interp (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data,
GdkDestroyNotify destroy);
gint gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data);
void gdk_input_remove (gint tag);
gint gdk_pointer_grab (GdkWindow * window,
gint owner_events,
@ -166,6 +170,12 @@ void gdk_window_set_user_data (GdkWindow *window,
void gdk_window_set_override_redirect(GdkWindow *window,
gboolean override_redirect);
void gdk_window_add_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data);
void gdk_window_remove_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data);
/*
* This allows for making shaped (partially transparent) windows
@ -350,8 +360,11 @@ GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkWindow *window,
GdkBitmap **mask,
GdkColor *transparent_color,
gchar **data);
void gdk_pixmap_destroy (GdkPixmap *pixmap);
GdkPixmap *gdk_pixmap_ref (GdkPixmap *pixmap);
void gdk_pixmap_unref (GdkPixmap *pixmap);
GdkBitmap *gdk_bitmap_ref (GdkBitmap *pixmap);
void gdk_bitmap_unref (GdkBitmap *pixmap);
/* Images
@ -383,10 +396,8 @@ void gdk_image_destroy (GdkImage *image);
*/
GdkColormap* gdk_colormap_new (GdkVisual *visual,
gint allocate);
void gdk_colormap_destroy (GdkColormap *colormap);
GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
void gdk_colormap_unref (GdkColormap *cmap);
GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
void gdk_colormap_unref (GdkColormap *cmap);
GdkColormap* gdk_colormap_get_system (void);
gint gdk_colormap_get_system_size (void);
@ -424,9 +435,8 @@ gint gdk_color_equal (GdkColor *colora,
*/
GdkFont* gdk_font_load (const gchar *font_name);
GdkFont* gdk_fontset_load (gchar *fontset_name);
void gdk_font_free (GdkFont *font);
void gdk_fontset_free (GdkFont *font);
GdkFont* gdk_font_ref (GdkFont *font);
void gdk_font_unref (GdkFont *font);
gint gdk_font_id (GdkFont *font);
gint gdk_font_equal (GdkFont *fonta,
GdkFont *fontb);

View File

@ -28,6 +28,7 @@ static void gdk_colormap_remove (GdkColormap *cmap);
static guint gdk_colormap_hash (Colormap *cmap);
static gint gdk_colormap_cmp (Colormap *a,
Colormap *b);
static void gdk_colormap_real_destroy (GdkColormap *colormap);
static GHashTable *colormap_hash = NULL;
@ -117,7 +118,7 @@ gdk_colormap_new (GdkVisual *visual,
return colormap;
}
void
static void
gdk_colormap_real_destroy (GdkColormap *colormap)
{
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
@ -132,12 +133,6 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
g_free (colormap);
}
void
gdk_colormap_destroy (GdkColormap *colormap)
{
gdk_colormap_unref (colormap);
}
GdkColormap*
gdk_colormap_ref (GdkColormap *cmap)
{

View File

@ -51,7 +51,7 @@ gdk_font_load (const gchar *font_name)
}
GdkFont*
gdk_fontset_load(gchar *fontset_name)
gdk_fontset_load (gchar *fontset_name)
{
GdkFont *font;
GdkFontPrivate *private;
@ -93,40 +93,6 @@ gdk_fontset_load(gchar *fontset_name)
}
return font;
}
void
gdk_font_free (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
g_free (font);
}
}
void
gdk_fontset_free (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
g_free (font);
}
}
GdkFont*
gdk_font_ref (GdkFont *font)
@ -140,6 +106,35 @@ gdk_font_ref (GdkFont *font)
return font;
}
void
gdk_font_unref (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
switch (font->type)
{
case GDK_FONT_FONT:
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
break;
case GDK_FONT_FONTSET:
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
break;
default:
g_error ("unknown font type.");
break;
}
g_free (font);
}
}
gint
gdk_font_id (GdkFont *font)
{

View File

@ -141,11 +141,13 @@ gdk_gc_new_with_values (GdkWindow *window,
xvalues.clip_y_origin = values->clip_y_origin;
xvalues_mask |= GCClipYOrigin;
}
if (values_mask & GDK_GC_EXPOSURES)
{
xvalues.graphics_exposures = values->graphics_exposures;
xvalues_mask |= GCGraphicsExposures;
}
xvalues.graphics_exposures = values->graphics_exposures;
else
xvalues.graphics_exposures = False;
xvalues_mask |= GCGraphicsExposures;
if (values_mask & GDK_GC_LINE_WIDTH)
{
xvalues.line_width = values->line_width;

View File

@ -27,23 +27,8 @@
#include <stdlib.h>
#if defined(HAVE_WCTYPE_H) && !defined(X_LOCALE)
# include <wctype.h>
#else
# define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
#endif /* HAVE_WCTYPE_H || !X_LOCALE */
#ifdef X_LOCALE
#ifndef X_LOCALE
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#else
# ifdef HAVE_WCSTR_H
# include <wcstr.h>
# endif
#endif
#else /* X_LOCALE */
#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>
@ -160,4 +145,16 @@ extern int _g_mbtowc (wchar_t *wstr, const char *str, size_t len);
#endif /* X_LOCALE */
#if (defined(HAVE_WCTYPE_H) || defined(HAVE_WCHAR_H)) && !defined(X_LOCALE)
# ifdef HAVE_WCTYPE_H
# include <wctype.h>
# else
# ifdef HAVE_WCHAR_H
# include <wchar.h>
# endif
# endif
#else
# define iswalnum(c) ((wchar_t)(c) <= 0xFF && isalnum(c))
#endif
#endif /* __GDK_I18N_H__ */

View File

@ -102,6 +102,15 @@ gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
gdk_input_vtable.set_axes (deviceid, axes);
}
void gdk_input_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
}
GdkTimeCoord *
gdk_input_motion_events (GdkWindow *window,
guint32 deviceid,
@ -258,7 +267,7 @@ gdk_input_window_destroy (GdkWindow *window)
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
gdk_input_windows = g_list_remove(gdk_input_windows,input_window);
gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
g_free(input_window);
}
@ -280,6 +289,7 @@ gdk_input_exit (void)
g_free(gdkdev->axes);
#endif
g_free(gdkdev->info.axes);
g_free(gdkdev->info.keys);
g_free(gdkdev);
}
}

View File

@ -31,6 +31,11 @@ typedef struct _GdkInputWindow GdkInputWindow;
struct _GdkInputVTable {
gint (*set_mode) (guint32 deviceid, GdkInputMode mode);
void (*set_axes) (guint32 deviceid, GdkAxisUse *axes);
void (*set_key) (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers);
GdkTimeCoord* (*motion_events) (GdkWindow *window,
guint32 deviceid,
guint32 start,
@ -93,8 +98,12 @@ struct _GdkDevicePrivate {
/* Information about XInput device */
XDevice *xdevice;
int buttonpress_type, buttonrelease_type, motionnotify_type,
proximityin_type, proximityout_type, changenotify_type;
/* minimum key code for device */
gint min_keycode;
int buttonpress_type, buttonrelease_type, keypress_type,
keyrelease_type, motionnotify_type, proximityin_type,
proximityout_type, changenotify_type;
/* true if we need to select a different set of events, but
can't because this is the core pointer */

View File

@ -59,6 +59,8 @@ static void gdk_input_common_get_pointer (GdkWindow *window,
gdouble *ytilt,
GdkModifierType *mask);
#define GDK_MAX_DEVICE_CLASSES 13
/* Global variables */
static gint gdk_input_root_width;
@ -156,6 +158,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
/* step through the classes */
gdkdev->info.num_axes = 0;
gdkdev->info.num_keys = 0;
gdkdev->info.keys = NULL;
gdkdev->axes = 0;
gdkdev->info.has_cursor = 0;
gdkdev->needs_update = FALSE;
@ -168,6 +172,21 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
switch (class->class) {
case ButtonClass:
{
break;
}
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
for (j=0; j<gdkdev->info.num_keys; j++)
{
gdkdev->info.keys[j].keyval = 0;
gdkdev->info.keys[j].modifiers = 0;
}
break;
}
case ValuatorClass:
@ -218,6 +237,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
g_free(gdkdev->info.name);
if (gdkdev->axes)
g_free(gdkdev->axes);
if (gdkdev->info.keys)
g_free(gdkdev->info.keys);
g_free(gdkdev);
return NULL;
}
@ -225,6 +246,15 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
if (device->use != IsXPointer)
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdkdev->buttonpress_type = 0;
gdkdev->buttonrelease_type = 0;
gdkdev->keypress_type = 0;
gdkdev->keyrelease_type = 0;
gdkdev->motionnotify_type = 0;
gdkdev->proximityin_type = 0;
gdkdev->proximityout_type = 0;
gdkdev->changenotify_type = 0;
return gdkdev;
}
@ -240,11 +270,15 @@ gdk_input_common_find_events(GdkWindow *window,
i = 0;
/* We have to track press and release events in pairs to keep
track of button state correctly and implement grabbing */
track of button state correctly and implement grabbing for
the gxi support */
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
{
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
class);
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
class);
if (class != 0)
classes[i++] = class;
DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
@ -258,6 +292,38 @@ gdk_input_common_find_events(GdkWindow *window,
if (class != 0)
classes[i++] = class;
}
else
if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK))
{
/* Make sure gdkdev->motionnotify_type is set */
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
}
if (mask & GDK_BUTTON1_MOTION_MASK)
{
DeviceButton1Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON2_MOTION_MASK)
{
DeviceButton2Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON3_MOTION_MASK)
{
DeviceButton3Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON_MOTION_MASK)
{
DeviceButtonMotion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_POINTER_MOTION_HINT_MASK)
{
/* We'll get into trouble if the macros change, but at least we'll
@ -266,6 +332,18 @@ gdk_input_common_find_events(GdkWindow *window,
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_PRESS_MASK)
{
DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_RELEASE_MASK)
{
DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_PROXIMITY_IN_MASK)
{
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
@ -286,7 +364,7 @@ static void
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
XEventClass classes[6];
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
if (gdkdev->info.mode == GDK_MODE_DISABLED)
@ -492,9 +570,55 @@ gdk_input_common_other_event (GdkEvent *event,
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
event->button.button = xdbe->button;
if (gdk_show_events)
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
xdbe->window,
xdbe->deviceid,
event->button.x, event->button.y,
xdbe->button);
return TRUE;
}
if ((xevent->type == gdkdev->keypress_type) ||
(xevent->type == gdkdev->keyrelease_type))
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
if (gdk_show_events)
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
xdke->window,
xdke->deviceid,
xdke->keycode);
if (event->key.keyval == 0)
{
if (gdk_show_events)
g_print ("\t\ttranslation - NONE\n");
return FALSE;
}
event->key.type = (xdke->type == gdkdev->keypress_type) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE;
event->key.window = input_window->window;
event->key.time = xdke->time;
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
if (gdk_show_events)
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval,
event->key.state);
return TRUE;
}
if (xevent->type == gdkdev->motionnotify_type)
{
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
@ -511,15 +635,17 @@ gdk_input_common_other_event (GdkEvent *event,
event->motion.deviceid = xdme->deviceid;
event->motion.state = gdk_input_translate_state(xdme->state,
xdme->device_state);
event->motion.is_hint = xdme->is_hint;
event->motion.source = gdkdev->info.source;
event->motion.deviceid = xdme->deviceid;
if (gdk_show_events)
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f hint: %s\n",
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
xdme->window,
xdme->deviceid,
event->motion.x, event->motion.y,
(xevent->xmotion.is_hint) ? "true" : "false");
event->motion.state,
(xdme->is_hint) ? "true" : "false");
return TRUE;
@ -562,6 +688,21 @@ gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
}
}
void gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (index < gdkdev->info.num_keys);
gdkdev->info.keys[index].keyval = keyval;
gdkdev->info.keys[index].modifiers = modifiers;
}
static GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
@ -658,24 +799,21 @@ gdk_input_common_get_pointer (GdkWindow *window,
switch (input_class->class)
{
case ValuatorClass:
gdk_input_translate_coordinates(gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
gdk_input_translate_coordinates (gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
break;
case ButtonClass:
if (mask)
{
*mask &= ~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK | GDK_BUTTON4_MASK |
GDK_BUTTON5_MASK);
for (i=0; i < ((XButtonState *)input_class)->num_buttons; i++)
{
if (((XButtonState *)input_class)->buttons[i])
*mask |= GDK_BUTTON1_MASK << i;
}
*mask &= 0xFF;
if (((XButtonState *)input_class)->num_buttons > 0)
*mask |= ((XButtonState *)input_class)->buttons[0] << 7;
/* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
* in bit 1<<(n%8) in byte n/8. n = 1,2,... */
}
break;
}

View File

@ -75,7 +75,8 @@ gdk_input_init(void)
GList *tmp_list;
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;

View File

@ -32,6 +32,7 @@ gdk_input_init ()
{
gdk_input_vtable.set_mode = NULL;
gdk_input_vtable.set_axes = NULL;
gdk_input_vtable.set_key = NULL;
gdk_input_vtable.motion_events = NULL;
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
gdk_input_vtable.grab_pointer = NULL;

View File

@ -44,7 +44,8 @@ void
gdk_input_init(void)
{
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
@ -229,33 +230,6 @@ gdk_input_xfree_other_event (GdkEvent *event,
gdk_input_ignore_core)
gdk_input_check_proximity();
/* Do a passive button grab. We have to be careful not to release
an explicit grab, if any. Doubling the grab should be harmless,
but we check anyways. */
/* FIXME, finding the proper events here is going to be SLOW - but
we might have different sets for each window/device combination */
if (return_val> 0 && !input_window->grabbed)
{
if (event->type == GDK_BUTTON_PRESS)
{
XEventClass event_classes[6];
gint num_classes;
gdk_input_common_find_events (window, gdkdev,
((GdkWindowPrivate *)window)->extension_events,
event_classes, &num_classes);
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
TRUE, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, event->button.time);
}
else if (event->type == GDK_BUTTON_RELEASE)
XUngrabDevice( GDK_DISPLAY(), gdkdev->xdevice, event->button.time);
}
return return_val;
}
@ -284,8 +258,9 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
GdkInputWindow *input_window, *new_window;
GdkDevicePrivate *gdkdev;
GList *tmp_list;
XEventClass event_classes[6];
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
gint result;
tmp_list = gdk_input_windows;
new_window = NULL;
@ -296,15 +271,12 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
return AlreadyGrabbed;
if (input_window->window == window)
{
new_window = input_window;
break;
}
new_window = input_window;
tmp_list = tmp_list->next;
}
g_return_if_fail (new_window == NULL);
g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
new_window->grabbed = TRUE;
@ -313,17 +285,21 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice && !gdkdev->button_state)
gdkdev->xdevice)
{
gdk_input_common_find_events (window, gdkdev,
((GdkWindowPrivate *)window)->extension_events,
gdk_input_common_find_events (window, gdkdev,
event_mask,
event_classes, &num_classes);
/* FIXME: we should do something on failure */
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
TRUE, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, time);
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
owner_events, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, time);
/* FIXME: if failure occurs on something other than the first
device, things will be badly inconsistent */
if (result != Success)
return result;
}
tmp_list = tmp_list->next;
}
@ -355,11 +331,9 @@ gdk_input_xfree_ungrab_pointer (guint32 time)
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice && !gdkdev->button_state)
{
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
}
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
tmp_list = tmp_list->next;
}
}

View File

@ -650,22 +650,39 @@ gdk_pixmap_create_from_xpm_d (GdkWindow *window,
return pixmap;
}
void
gdk_pixmap_destroy (GdkPixmap *pixmap)
GdkPixmap*
gdk_pixmap_ref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private;
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
g_return_val_if_fail (pixmap != NULL, NULL);
g_return_if_fail (pixmap != NULL);
private->ref_count += 1;
return pixmap;
}
private = (GdkPixmapPrivate*) pixmap;
if (private->ref_count <= 0)
void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
g_return_if_fail(pixmap != NULL);
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreePixmap (private->xdisplay, private->xwindow);
gdk_xid_table_remove (private->xwindow);
g_free (pixmap);
}
else
{
private->ref_count -= 1;
g_free (private);
}
}
GdkBitmap *
gdk_bitmap_ref (GdkBitmap *bitmap)
{
return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
}
void
gdk_bitmap_unref (GdkBitmap *bitmap)
{
gdk_pixmap_unref ((GdkPixmap *)bitmap);
}

View File

@ -43,6 +43,7 @@ typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkColorContextPrivate GdkColorContextPrivate;
@ -76,6 +77,8 @@ struct _GdkWindowPrivate
/* need to allow custom drag/drop cursors */
gint extension_events;
GList *filters;
};
struct _GdkImagePrivate
@ -149,6 +152,10 @@ struct _GdkDndGlobals {
};
typedef struct _GdkDndGlobals GdkDndGlobals;
struct _GdkEventFilter {
GdkFilterFunc function;
gpointer data;
};
#ifdef USE_XIM
@ -157,6 +164,7 @@ struct _GdkICPrivate
XIC xic;
GdkIMStyle style;
};
typedef struct _GdkICPrivate GdkICPrivate;
#endif /* USE_XIM */
@ -179,8 +187,8 @@ void gdk_image_exit (void);
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
GdkVisual* gdk_visual_lookup (Visual *xvisual);
void gdk_window_real_destroy (GdkWindow *window);
void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_xid_table_insert (XID *xid,
gpointer data);

View File

@ -79,6 +79,7 @@ typedef struct _GdkEventDropDataAvailable GdkEventDropDataAvailable;
typedef struct _GdkEventDropLeave GdkEventDropLeave;
typedef struct _GdkEventClient GdkEventClient;
typedef union _GdkEvent GdkEvent;
typedef struct _GdkDeviceKey GdkDeviceKey;
typedef struct _GdkDeviceInfo GdkDeviceInfo;
typedef struct _GdkTimeCoord GdkTimeCoord;
typedef gint (*GdkEventFunc) (GdkEvent *event,
@ -279,6 +280,12 @@ typedef enum
GDK_CURSOR_IS_PIXMAP = -1
} GdkCursorType;
typedef enum {
GDK_FILTER_CONTINUE, /* Event not handled, continue processesing */
GDK_FILTER_TRANSLATE, /* Translated event stored */
GDK_FILTER_REMOVE /* Terminate processing, removing event */
} GdkFilterReturn;
/* Event types.
* Nothing: No event occurred.
* Delete: A window delete event was sent by the window manager.
@ -568,6 +575,7 @@ typedef void (*GdkInputFunction) (gpointer data,
gint source,
GdkInputCondition condition);
typedef void (*GdkDestroyNotify) (gpointer data);
/* Color Context modes.
*
@ -589,7 +597,6 @@ typedef enum
GDK_CC_MODE_PALETTE
} GdkColorContextMode;
/* The color type.
* A color consists of red, green and blue values in the
* range 0-65535 and a pixel value. The pixel value is highly
@ -801,6 +808,12 @@ struct _GdkColorContext
/* Types for XInput support */
struct _GdkDeviceKey
{
guint keyval;
GdkModifierType modifiers;
};
struct _GdkDeviceInfo
{
guint32 deviceid;
@ -810,6 +823,8 @@ struct _GdkDeviceInfo
gint has_cursor; /* TRUE if the X pointer follows device motion */
gint num_axes;
GdkAxisUse *axes; /* Specifies use for each axis */
gint num_keys;
GdkDeviceKey *keys;
};
struct _GdkTimeCoord
@ -822,6 +837,14 @@ struct _GdkTimeCoord
gdouble ytilt;
};
/* Event filtering */
typedef void GdkXEvent; /* Can be cast to XEvent */
typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
GdkEvent *event,
gpointer data);
struct _GdkEventAny
{
GdkEventType type;
@ -1037,8 +1060,6 @@ struct _GdkEventClient
} data;
};
typedef void GdkXEvent; /* Can be cast to XEvent */
struct _GdkEventOther
{
GdkEventType type;

View File

@ -25,6 +25,7 @@
#include "gdkinput.h"
#include "gdkprivate.h"
#include <stdlib.h>
#include <stdio.h>
int nevent_masks = 16;
int event_mask_table[18] =
@ -137,6 +138,8 @@ gdk_window_new (GdkWindow *parent,
private->dnd_drag_data_numtypesavail = 0;
private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0;
private->filters = NULL;
window->user_data = NULL;
if (attributes_mask & GDK_WA_VISUAL)
@ -227,6 +230,7 @@ gdk_window_new (GdkWindow *parent,
x, y, private->width, private->height,
0, depth, class, xvisual,
xattributes_mask, &xattributes);
gdk_window_ref (window);
gdk_xid_table_insert (&private->xwindow, window);
switch (private->window_type)
@ -320,16 +324,24 @@ gdk_window_foreign_new (guint32 anid)
private->destroyed = FALSE;
private->extension_events = 0;
private->filters = NULL;
window->user_data = NULL;
gdk_window_ref (window);
gdk_xid_table_insert (&private->xwindow, window);
return window;
}
void
gdk_window_destroy (GdkWindow *window)
/* Call this function when you want a window and all its children to
disappear. When xdestroy is true, a request to destroy the XWindow
is sent out. When it is false, it is assumed that the XWindow has
been or will be destroyed by destroying some ancestor of this
window. */
static void
gdk_window_internal_destroy (GdkWindow *window, int xdestroy)
{
GdkWindowPrivate *private;
GdkWindowPrivate *temp_private;
@ -340,27 +352,14 @@ gdk_window_destroy (GdkWindow *window)
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
if(private->dnd_drag_data_numtypesavail > 0)
{
free(private->dnd_drag_data_typesavail);
private->dnd_drag_data_typesavail = NULL;
}
if(private->dnd_drop_data_numtypesavail > 0)
{
free(private->dnd_drop_data_typesavail);
private->dnd_drop_data_typesavail = NULL;
}
switch (private->window_type)
{
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_CHILD:
case GDK_WINDOW_DIALOG:
case GDK_WINDOW_TEMP:
if (private->ref_count >= 1)
private->ref_count -= 1;
if (!private->destroyed || (private->destroyed == 2))
if (!private->destroyed)
{
children = gdk_window_get_children (window);
tmp = children;
@ -371,18 +370,24 @@ gdk_window_destroy (GdkWindow *window)
tmp = tmp->next;
temp_private = (GdkWindowPrivate*) temp_window;
if (temp_private && !temp_private->destroyed)
/* Removes some nice coredumps... /David */
{
temp_private->destroyed = 2;
temp_private->ref_count += 1;
gdk_window_destroy (temp_window);
}
if (temp_private)
gdk_window_internal_destroy (temp_window, FALSE);
}
g_list_free (children);
if (!private->destroyed)
if(private->dnd_drag_data_numtypesavail > 0)
{
g_free (private->dnd_drag_data_typesavail);
private->dnd_drag_data_typesavail = NULL;
}
if(private->dnd_drop_data_numtypesavail > 0)
{
g_free (private->dnd_drop_data_typesavail);
private->dnd_drop_data_typesavail = NULL;
}
if (xdestroy)
XDestroyWindow (private->xdisplay, private->xwindow);
private->destroyed = TRUE;
}
@ -393,14 +398,25 @@ gdk_window_destroy (GdkWindow *window)
break;
case GDK_WINDOW_PIXMAP:
g_warning ("called gdk_window_destroy on a pixmap (use gdk_pixmap_destroy)");
gdk_pixmap_destroy (window);
g_error ("called gdk_window_destroy on a pixmap (use gdk_pixmap_unref)");
break;
}
}
/* Like internal_destroy, but also destroys the reference created by
gdk_window_new. */
void
gdk_window_real_destroy (GdkWindow *window)
gdk_window_destroy (GdkWindow *window)
{
gdk_window_internal_destroy (window, TRUE);
gdk_window_unref (window);
}
/* This function is called when the XWindow is really gone. */
void
gdk_window_destroy_notify (GdkWindow *window)
{
GdkWindowPrivate *private;
@ -411,11 +427,8 @@ gdk_window_real_destroy (GdkWindow *window)
if (private->extension_events != 0)
gdk_input_window_destroy (window);
if (private->ref_count == 0)
{
gdk_xid_table_remove (private->xwindow);
g_free (window);
}
gdk_xid_table_remove (private->xwindow);
gdk_window_unref (window);
}
GdkWindow*
@ -436,7 +449,11 @@ gdk_window_unref (GdkWindow *window)
private->ref_count -= 1;
if (private->ref_count == 0)
gdk_window_real_destroy (window);
{
if (!private->destroyed)
g_warning ("losing last reference to undestroyed window\n");
g_free (window);
}
}
void
@ -1364,6 +1381,60 @@ gdk_window_dnd_data_set (GdkWindow *window,
NoEventMask, &sev);
}
void
gdk_window_add_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list;
GdkEventFilter *filter;
private = (GdkWindowPrivate *)window;
tmp_list = private->filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
if ((filter->function == function) && (filter->data == data))
return;
tmp_list = tmp_list->next;
}
filter = g_new (GdkEventFilter, 1);
filter->function = function;
filter->data = data;
private->filters = g_list_append (private->filters, filter);
}
void
gdk_window_remove_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list;
GdkEventFilter *filter;
private = (GdkWindowPrivate *)window;
tmp_list = private->filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
tmp_list = tmp_list->next;
if ((filter->function == function) && (filter->data == data))
{
private->filters = g_list_remove_link (private->filters, tmp_list);
g_list_free_1 (tmp_list);
return;
}
}
}
void
gdk_window_set_override_redirect(GdkWindow *window,
gboolean override_redirect)

View File

@ -16,7 +16,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "gdkprivate.h"
#include <stdio.h>
static guint gdk_xid_hash (XID *xid);
static gint gdk_xid_compare (XID *a,

View File

@ -5,6 +5,7 @@
*/
#include "../config.h"
#include "gxid_lib.h"
#ifdef XINPUT_GXI
@ -16,8 +17,6 @@
#include <netinet/in.h>
#include <netdb.h>
#include "gxid_lib.h"
/* handles mechanics of communicating with a client */
static int
gxid_send_message(char *host, int port, GxidMessage *msg)
@ -112,5 +111,15 @@ gxid_release_device(char *host, int port, GxidU32 device, GxidU32 window)
return gxid_send_message(host,port,(GxidMessage *)&msg);
}
#else /* !XINPUT_GXI */
/* Some compilers don't like empty source files */
int
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
int exclusive)
{
return 0;
}
#endif /* XINPUT_GXI */

View File

@ -28,6 +28,7 @@ static void gdk_colormap_remove (GdkColormap *cmap);
static guint gdk_colormap_hash (Colormap *cmap);
static gint gdk_colormap_cmp (Colormap *a,
Colormap *b);
static void gdk_colormap_real_destroy (GdkColormap *colormap);
static GHashTable *colormap_hash = NULL;
@ -117,7 +118,7 @@ gdk_colormap_new (GdkVisual *visual,
return colormap;
}
void
static void
gdk_colormap_real_destroy (GdkColormap *colormap)
{
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
@ -132,12 +133,6 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
g_free (colormap);
}
void
gdk_colormap_destroy (GdkColormap *colormap)
{
gdk_colormap_unref (colormap);
}
GdkColormap*
gdk_colormap_ref (GdkColormap *cmap)
{

View File

@ -51,7 +51,7 @@ gdk_font_load (const gchar *font_name)
}
GdkFont*
gdk_fontset_load(gchar *fontset_name)
gdk_fontset_load (gchar *fontset_name)
{
GdkFont *font;
GdkFontPrivate *private;
@ -93,40 +93,6 @@ gdk_fontset_load(gchar *fontset_name)
}
return font;
}
void
gdk_font_free (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
g_free (font);
}
}
void
gdk_fontset_free (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
g_free (font);
}
}
GdkFont*
gdk_font_ref (GdkFont *font)
@ -140,6 +106,35 @@ gdk_font_ref (GdkFont *font)
return font;
}
void
gdk_font_unref (GdkFont *font)
{
GdkFontPrivate *private;
g_return_if_fail (font != NULL);
private = (GdkFontPrivate*) font;
private->ref_count -= 1;
if (private->ref_count == 0)
{
switch (font->type)
{
case GDK_FONT_FONT:
gdk_xid_table_remove (((XFontStruct *) private->xfont)->fid);
XFreeFont (private->xdisplay, (XFontStruct *) private->xfont);
break;
case GDK_FONT_FONTSET:
XFreeFontSet (private->xdisplay, (XFontSet) private->xfont);
break;
default:
g_error ("unknown font type.");
break;
}
g_free (font);
}
}
gint
gdk_font_id (GdkFont *font)
{

View File

@ -75,7 +75,8 @@ gdk_input_init(void)
GList *tmp_list;
gdk_input_vtable.set_mode = gdk_input_gxi_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_gxi_motion_events;
gdk_input_vtable.get_pointer = gdk_input_gxi_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_gxi_grab_pointer;

View File

@ -32,6 +32,7 @@ gdk_input_init ()
{
gdk_input_vtable.set_mode = NULL;
gdk_input_vtable.set_axes = NULL;
gdk_input_vtable.set_key = NULL;
gdk_input_vtable.motion_events = NULL;
gdk_input_vtable.get_pointer = gdk_input_none_get_pointer;
gdk_input_vtable.grab_pointer = NULL;

View File

@ -59,6 +59,8 @@ static void gdk_input_common_get_pointer (GdkWindow *window,
gdouble *ytilt,
GdkModifierType *mask);
#define GDK_MAX_DEVICE_CLASSES 13
/* Global variables */
static gint gdk_input_root_width;
@ -156,6 +158,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
/* step through the classes */
gdkdev->info.num_axes = 0;
gdkdev->info.num_keys = 0;
gdkdev->info.keys = NULL;
gdkdev->axes = 0;
gdkdev->info.has_cursor = 0;
gdkdev->needs_update = FALSE;
@ -168,6 +172,21 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
switch (class->class) {
case ButtonClass:
{
break;
}
case KeyClass:
{
XKeyInfo *xki = (XKeyInfo *)class;
gdkdev->info.num_keys = xki->max_keycode - xki->min_keycode + 1;
gdkdev->min_keycode = xki->min_keycode;
gdkdev->info.keys = g_new (GdkDeviceKey, gdkdev->info.num_keys);
for (j=0; j<gdkdev->info.num_keys; j++)
{
gdkdev->info.keys[j].keyval = 0;
gdkdev->info.keys[j].modifiers = 0;
}
break;
}
case ValuatorClass:
@ -218,6 +237,8 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
g_free(gdkdev->info.name);
if (gdkdev->axes)
g_free(gdkdev->axes);
if (gdkdev->info.keys)
g_free(gdkdev->info.keys);
g_free(gdkdev);
return NULL;
}
@ -225,6 +246,15 @@ gdk_input_device_new(XDeviceInfo *device, gint include_core)
if (device->use != IsXPointer)
gdkdev->xdevice = XOpenDevice(gdk_display, gdkdev->info.deviceid);
gdkdev->buttonpress_type = 0;
gdkdev->buttonrelease_type = 0;
gdkdev->keypress_type = 0;
gdkdev->keyrelease_type = 0;
gdkdev->motionnotify_type = 0;
gdkdev->proximityin_type = 0;
gdkdev->proximityout_type = 0;
gdkdev->changenotify_type = 0;
return gdkdev;
}
@ -240,11 +270,15 @@ gdk_input_common_find_events(GdkWindow *window,
i = 0;
/* We have to track press and release events in pairs to keep
track of button state correctly and implement grabbing */
track of button state correctly and implement grabbing for
the gxi support */
if (mask & GDK_BUTTON_PRESS_MASK || mask & GDK_BUTTON_RELEASE_MASK)
{
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
class);
DeviceButtonPress (gdkdev->xdevice, gdkdev->buttonpress_type,
class);
if (class != 0)
classes[i++] = class;
DeviceButtonPressGrab (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
DeviceButtonRelease (gdkdev->xdevice, gdkdev->buttonrelease_type,
@ -258,6 +292,38 @@ gdk_input_common_find_events(GdkWindow *window,
if (class != 0)
classes[i++] = class;
}
else
if (mask & (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK))
{
/* Make sure gdkdev->motionnotify_type is set */
DeviceMotionNotify (gdkdev->xdevice, gdkdev->motionnotify_type, class);
}
if (mask & GDK_BUTTON1_MOTION_MASK)
{
DeviceButton1Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON2_MOTION_MASK)
{
DeviceButton2Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON3_MOTION_MASK)
{
DeviceButton3Motion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_BUTTON_MOTION_MASK)
{
DeviceButtonMotion (gdkdev->xdevice, 0, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_POINTER_MOTION_HINT_MASK)
{
/* We'll get into trouble if the macros change, but at least we'll
@ -266,6 +332,18 @@ gdk_input_common_find_events(GdkWindow *window,
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_PRESS_MASK)
{
DeviceKeyPress (gdkdev->xdevice, gdkdev->keypress_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_KEY_RELEASE_MASK)
{
DeviceKeyRelease (gdkdev->xdevice, gdkdev->keyrelease_type, class);
if (class != 0)
classes[i++] = class;
}
if (mask & GDK_PROXIMITY_IN_MASK)
{
ProximityIn (gdkdev->xdevice, gdkdev->proximityin_type, class);
@ -286,7 +364,7 @@ static void
gdk_input_common_select_events(GdkWindow *window,
GdkDevicePrivate *gdkdev)
{
XEventClass classes[6];
XEventClass classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
if (gdkdev->info.mode == GDK_MODE_DISABLED)
@ -492,9 +570,55 @@ gdk_input_common_other_event (GdkEvent *event,
event->button.state = gdk_input_translate_state(xdbe->state,xdbe->device_state);
event->button.button = xdbe->button;
if (gdk_show_events)
g_print ("button %s:\t\twindow: %ld device: %ld x,y: %f %f button: %d\n",
(event->button.type == GDK_BUTTON_PRESS) ? "press" : "release",
xdbe->window,
xdbe->deviceid,
event->button.x, event->button.y,
xdbe->button);
return TRUE;
}
if ((xevent->type == gdkdev->keypress_type) ||
(xevent->type == gdkdev->keyrelease_type))
{
XDeviceKeyEvent *xdke = (XDeviceKeyEvent *)(xevent);
event->key.keyval = gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].keyval;
if (gdk_show_events)
g_print ("device key %s:\twindow: %ld device: %ld keycode: %d\n",
(event->key.type == GDK_KEY_PRESS) ? "press" : "release",
xdke->window,
xdke->deviceid,
xdke->keycode);
if (event->key.keyval == 0)
{
if (gdk_show_events)
g_print ("\t\ttranslation - NONE\n");
return FALSE;
}
event->key.type = (xdke->type == gdkdev->keypress_type) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE;
event->key.window = input_window->window;
event->key.time = xdke->time;
event->key.state = gdk_input_translate_state(xdke->state, xdke->device_state)
| gdkdev->info.keys[xdke->keycode - gdkdev->min_keycode].modifiers;
if (gdk_show_events)
g_print ("\t\ttranslation - keyval: %d modifiers: %#x\n",
event->key.keyval,
event->key.state);
return TRUE;
}
if (xevent->type == gdkdev->motionnotify_type)
{
XDeviceMotionEvent *xdme = (XDeviceMotionEvent *)(xevent);
@ -511,15 +635,17 @@ gdk_input_common_other_event (GdkEvent *event,
event->motion.deviceid = xdme->deviceid;
event->motion.state = gdk_input_translate_state(xdme->state,
xdme->device_state);
event->motion.is_hint = xdme->is_hint;
event->motion.source = gdkdev->info.source;
event->motion.deviceid = xdme->deviceid;
if (gdk_show_events)
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f hint: %s\n",
g_print ("motion notify:\t\twindow: %ld device: %ld x,y: %f %f state %#4x hint: %s\n",
xdme->window,
xdme->deviceid,
event->motion.x, event->motion.y,
(xevent->xmotion.is_hint) ? "true" : "false");
event->motion.state,
(xdme->is_hint) ? "true" : "false");
return TRUE;
@ -562,6 +688,21 @@ gdk_input_common_set_axes (guint32 deviceid, GdkAxisUse *axes)
}
}
void gdk_input_common_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
GdkDevicePrivate *gdkdev = gdk_input_find_device(deviceid);
gdkdev = gdk_input_find_device (deviceid);
g_return_if_fail (gdkdev != NULL);
g_return_if_fail (index < gdkdev->info.num_keys);
gdkdev->info.keys[index].keyval = keyval;
gdkdev->info.keys[index].modifiers = modifiers;
}
static GdkTimeCoord *
gdk_input_common_motion_events (GdkWindow *window,
guint32 deviceid,
@ -658,24 +799,21 @@ gdk_input_common_get_pointer (GdkWindow *window,
switch (input_class->class)
{
case ValuatorClass:
gdk_input_translate_coordinates(gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
gdk_input_translate_coordinates (gdkdev, input_window,
((XValuatorState *)input_class)->valuators,
x, y, pressure,
xtilt, ytilt);
break;
case ButtonClass:
if (mask)
{
*mask &= ~(GDK_BUTTON1_MASK | GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK | GDK_BUTTON4_MASK |
GDK_BUTTON5_MASK);
for (i=0; i < ((XButtonState *)input_class)->num_buttons; i++)
{
if (((XButtonState *)input_class)->buttons[i])
*mask |= GDK_BUTTON1_MASK << i;
}
*mask &= 0xFF;
if (((XButtonState *)input_class)->num_buttons > 0)
*mask |= ((XButtonState *)input_class)->buttons[0] << 7;
/* GDK_BUTTON1_MASK = 1 << 8, and button n is stored
* in bit 1<<(n%8) in byte n/8. n = 1,2,... */
}
break;
}

View File

@ -44,7 +44,8 @@ void
gdk_input_init(void)
{
gdk_input_vtable.set_mode = gdk_input_xfree_set_mode;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_axes = gdk_input_common_set_axes;
gdk_input_vtable.set_key = gdk_input_common_set_key;
gdk_input_vtable.motion_events = gdk_input_common_motion_events;
gdk_input_vtable.get_pointer = gdk_input_common_get_pointer;
gdk_input_vtable.grab_pointer = gdk_input_xfree_grab_pointer;
@ -229,33 +230,6 @@ gdk_input_xfree_other_event (GdkEvent *event,
gdk_input_ignore_core)
gdk_input_check_proximity();
/* Do a passive button grab. We have to be careful not to release
an explicit grab, if any. Doubling the grab should be harmless,
but we check anyways. */
/* FIXME, finding the proper events here is going to be SLOW - but
we might have different sets for each window/device combination */
if (return_val> 0 && !input_window->grabbed)
{
if (event->type == GDK_BUTTON_PRESS)
{
XEventClass event_classes[6];
gint num_classes;
gdk_input_common_find_events (window, gdkdev,
((GdkWindowPrivate *)window)->extension_events,
event_classes, &num_classes);
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
TRUE, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, event->button.time);
}
else if (event->type == GDK_BUTTON_RELEASE)
XUngrabDevice( GDK_DISPLAY(), gdkdev->xdevice, event->button.time);
}
return return_val;
}
@ -284,8 +258,9 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
GdkInputWindow *input_window, *new_window;
GdkDevicePrivate *gdkdev;
GList *tmp_list;
XEventClass event_classes[6];
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
gint num_classes;
gint result;
tmp_list = gdk_input_windows;
new_window = NULL;
@ -296,15 +271,12 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
return AlreadyGrabbed;
if (input_window->window == window)
{
new_window = input_window;
break;
}
new_window = input_window;
tmp_list = tmp_list->next;
}
g_return_if_fail (new_window == NULL);
g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
new_window->grabbed = TRUE;
@ -313,17 +285,21 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice && !gdkdev->button_state)
gdkdev->xdevice)
{
gdk_input_common_find_events (window, gdkdev,
((GdkWindowPrivate *)window)->extension_events,
gdk_input_common_find_events (window, gdkdev,
event_mask,
event_classes, &num_classes);
/* FIXME: we should do something on failure */
XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
TRUE, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, time);
result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
GDK_WINDOW_XWINDOW (window),
owner_events, num_classes, event_classes,
GrabModeAsync, GrabModeAsync, time);
/* FIXME: if failure occurs on something other than the first
device, things will be badly inconsistent */
if (result != Success)
return result;
}
tmp_list = tmp_list->next;
}
@ -355,11 +331,9 @@ gdk_input_xfree_ungrab_pointer (guint32 time)
while (tmp_list)
{
gdkdev = (GdkDevicePrivate *)tmp_list->data;
if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
gdkdev->xdevice && !gdkdev->button_state)
{
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
}
if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice)
XUngrabDevice( gdk_display, gdkdev->xdevice, time);
tmp_list = tmp_list->next;
}
}

View File

@ -102,6 +102,15 @@ gdk_input_set_axes (guint32 deviceid, GdkAxisUse *axes)
gdk_input_vtable.set_axes (deviceid, axes);
}
void gdk_input_set_key (guint32 deviceid,
guint index,
guint keyval,
GdkModifierType modifiers)
{
if (deviceid != GDK_CORE_POINTER && gdk_input_vtable.set_key)
gdk_input_vtable.set_key (deviceid, index, keyval, modifiers);
}
GdkTimeCoord *
gdk_input_motion_events (GdkWindow *window,
guint32 deviceid,
@ -258,7 +267,7 @@ gdk_input_window_destroy (GdkWindow *window)
input_window = gdk_input_window_find (window);
g_return_if_fail (input_window != NULL);
gdk_input_windows = g_list_remove(gdk_input_windows,input_window);
gdk_input_windows = g_list_remove (gdk_input_windows,input_window);
g_free(input_window);
}
@ -280,6 +289,7 @@ gdk_input_exit (void)
g_free(gdkdev->axes);
#endif
g_free(gdkdev->info.axes);
g_free(gdkdev->info.keys);
g_free(gdkdev);
}
}

View File

@ -88,6 +88,7 @@ struct _GdkInput
GdkInputCondition condition;
GdkInputFunction function;
gpointer data;
GdkDestroyNotify destroy;
};
struct _GdkPredicate
@ -99,12 +100,19 @@ struct _GdkPredicate
/*
* Private function declarations
*/
static GdkEvent *gdk_event_new (void);
static gint gdk_event_wait (void);
static gint gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters);
static gint gdk_event_translate (GdkEvent *event,
XEvent *xevent);
#if 0
static Bool gdk_event_get_type (Display *display,
XEvent *xevent,
XPointer arg);
#endif
static void gdk_synthesize_click (GdkEvent *event,
gint nclicks);
@ -157,15 +165,6 @@ static int connection_number = 0; /* The file descriptor numbe
* the "select" system call.
*/
static gint received_destroy_notify = FALSE; /* Did we just receive a destroy notify
* event? If so, we need to actually
* destroy the window which received
* it now.
*/
static GdkWindow *window_to_destroy = NULL; /* If we previously received a destroy
* notify event then this is the window
* which received that event.
*/
static struct timeval start; /* The time at which the library was
* last initialized.
@ -601,6 +600,58 @@ gdk_events_pending ()
return XPending (gdk_display);
}
/*
*--------------------------------------------------------------
* gdk_event_get_graphics_expose
*
* Waits for a GraphicsExpose or NoExpose event
*
* Arguments:
*
* Results:
* For GraphicsExpose events, returns a pointer to the event
* converted into a GdkEvent Otherwise, returns NULL.
*
* Side effects:
*
*-------------------------------------------------------------- */
static Bool
graphics_expose_predicate (Display *display,
XEvent *xevent,
XPointer arg)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)arg;
if ((xevent->xany.window == private->xwindow) &&
((xevent->xany.type == GraphicsExpose) ||
(xevent->xany.type == NoExpose)))
return True;
else
return False;
}
GdkEvent *
gdk_event_get_graphics_expose (GdkWindow *window)
{
XEvent xevent;
GdkEvent *event;
XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer)window);
if (xevent.xany.type == GraphicsExpose)
{
event = gdk_event_new ();
if (gdk_event_translate (event, &xevent))
return event;
else
gdk_event_free (event);
}
return NULL;
}
/*
*--------------------------------------------------------------
* gdk_event_get
@ -608,14 +659,11 @@ gdk_events_pending ()
* Gets the next event.
*
* Arguments:
* "event" is used to hold the received event.
* If "event" is NULL an event is received as normal
* however it is not placed in "event" (and thus no
* error occurs).
*
* Results:
* Returns TRUE if an event was received that we care about
* and FALSE otherwise. This function will also return
* If an event was received that we care about, returns
* a pointer to that event, to be freed with gdk_event_free.
* Otherwise, returns NULL. This function will also return
* before an event is received if the timeout interval
* runs out.
*
@ -624,45 +672,14 @@ gdk_events_pending ()
*--------------------------------------------------------------
*/
gint
gdk_event_get (GdkEvent *event,
GdkEventFunc pred,
gpointer data)
GdkEvent *
gdk_event_get (void)
{
GdkEvent *temp_event;
GdkPredicate event_pred;
GdkEvent *event;
GList *temp_list;
XEvent xevent;
/* If the last event we received was a destroy notify
* event then we will actually destroy the "gdk" data
* structures now. We don't want to destroy them at the
* time of receiving the event since the main program
* may try to access them and may need to destroy user
* data that has been attached to the window
*/
if (received_destroy_notify)
{
if (gdk_show_events)
g_print ("destroying window:\twindow: %ld\n",
((GdkWindowPrivate*) window_to_destroy)->xwindow - base_id);
gdk_window_real_destroy (window_to_destroy);
received_destroy_notify = FALSE;
window_to_destroy = NULL;
}
/* Initially we haven't received an event and want to
* return FALSE. If "event" is non-NULL, then initialize
* it to the nothing event.
*/
if (event)
{
event->any.type = GDK_NOTHING;
event->any.window = NULL;
event->any.send_event = FALSE;
}
#if 0
if (pred)
{
temp_list = putback_events;
@ -685,65 +702,61 @@ gdk_event_get (GdkEvent *event,
event_pred.func = pred;
event_pred.data = data;
if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) &event_pred))
if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) & event_pred))
if (event)
return gdk_event_translate (event, &xevent);
}
else
{
if (putback_events)
{
temp_event = putback_events->data;
*event = *temp_event;
temp_list = putback_events;
putback_events = putback_events->next;
if (putback_events)
putback_events->prev = NULL;
temp_list->next = NULL;
temp_list->prev = NULL;
g_list_free (temp_list);
g_free (temp_event);
return TRUE;
}
/* Wait for an event to occur or the timeout to elapse.
* If an event occurs "gdk_event_wait" will return TRUE.
* If the timeout elapses "gdk_event_wait" will return
* FALSE.
*/
if (gdk_event_wait ())
{
/* If we get here we can rest assurred that an event
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* dont dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
#else
XNextEvent (gdk_display, &xevent);
#endif
if (putback_events)
{
event = putback_events->data;
temp_list = putback_events;
putback_events = g_list_remove_link (putback_events, temp_list);
g_list_free_1 (temp_list);
return event;
}
/* Wait for an event to occur or the timeout to elapse.
* If an event occurs "gdk_event_wait" will return TRUE.
* If the timeout elapses "gdk_event_wait" will return
* FALSE.
*/
if (gdk_event_wait ())
{
/* If we get here we can rest assurred that an event
* has occurred. Read it.
*/
#ifdef USE_XIM
gint filter_status;
if (xim_using && xim_window)
do
{ /* don't dispatch events used by IM */
XNextEvent (gdk_display, &xevent);
filter_status = XFilterEvent (&xevent,
GDK_WINDOW_XWINDOW (xim_window));
} while (filter_status == True);
else
XNextEvent (gdk_display, &xevent);
#else
XNextEvent (gdk_display, &xevent);
#endif
event = gdk_event_new ();
event->any.send_event = xevent.xany.send_event;
/* If "event" non-NULL.
*/
if (event)
return gdk_event_translate (event, &xevent);
}
event->any.type = GDK_NOTHING;
event->any.window = NULL;
event->any.send_event = FALSE;
event->any.send_event = xevent.xany.send_event;
if (gdk_event_translate (event, &xevent))
return event;
else
gdk_event_free (event);
}
return FALSE;
return NULL;
}
void
@ -753,8 +766,7 @@ gdk_event_put (GdkEvent *event)
g_return_if_fail (event != NULL);
new_event = g_new (GdkEvent, 1);
*new_event = *event;
new_event = gdk_event_copy (event);
putback_events = g_list_prepend (putback_events, new_event);
}
@ -779,13 +791,11 @@ gdk_event_put (GdkEvent *event)
static GMemChunk *event_chunk;
GdkEvent*
gdk_event_copy (GdkEvent *event)
static GdkEvent*
gdk_event_new (void)
{
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
if (event_chunk == NULL)
event_chunk = g_mem_chunk_new ("events",
sizeof (GdkEvent),
@ -793,8 +803,31 @@ gdk_event_copy (GdkEvent *event)
G_ALLOC_AND_FREE);
new_event = g_chunk_new (GdkEvent, event_chunk);
return new_event;
}
GdkEvent*
gdk_event_copy (GdkEvent *event)
{
GdkEvent *new_event;
g_return_val_if_fail (event != NULL, NULL);
new_event = gdk_event_new ();
*new_event = *event;
gdk_window_ref (new_event->any.window);
if ((event->any.type == GDK_KEY_PRESS) ||
(event->any.type == GDK_KEY_RELEASE))
new_event->key.string = g_strdup (event->key.string);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_ref (event->crossing.subwindow);
return new_event;
}
@ -822,7 +855,18 @@ gdk_event_free (GdkEvent *event)
g_assert (event_chunk != NULL);
g_return_if_fail (event != NULL);
gdk_window_unref (event->any.window);
if ((event->any.type == GDK_KEY_PRESS) ||
(event->any.type == GDK_KEY_RELEASE))
g_free (event->key.string);
if (event->any.window)
gdk_window_unref (event->any.window);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_unref (event->crossing.subwindow);
g_mem_chunk_free (event_chunk, event);
}
@ -1008,10 +1052,11 @@ gdk_timer_disable ()
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
gdk_input_add_interp (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data,
GdkDestroyNotify destroy)
{
static gint next_tag = 1;
GList *list;
@ -1028,8 +1073,11 @@ gdk_input_add (gint source,
if ((input->source == source) && (input->condition == condition))
{
if (input->destroy)
(input->destroy) (input->data);
input->function = function;
input->data = data;
input->destroy = destroy;
tag = input->tag;
}
}
@ -1042,6 +1090,7 @@ gdk_input_add (gint source,
input->condition = condition;
input->function = function;
input->data = data;
input->destroy = destroy;
tag = input->tag;
inputs = g_list_prepend (inputs, input);
@ -1050,6 +1099,15 @@ gdk_input_add (gint source,
return tag;
}
gint
gdk_input_add (gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data)
{
return gdk_input_add_interp (source, condition, function, data, NULL);
}
void
gdk_input_remove (gint tag)
{
@ -1064,6 +1122,9 @@ gdk_input_remove (gint tag)
if (input->tag == tag)
{
if (input->destroy)
(input->destroy) (input->data);
temp_list = list;
if (list->next)
@ -1470,6 +1531,31 @@ gdk_event_wait ()
return FALSE;
}
static gint
gdk_event_apply_filters (XEvent *xevent,
GdkEvent *event,
GList *filters)
{
GdkEventFilter *filter;
GList *tmp_list;
GdkFilterReturn result;
tmp_list = filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
result = (*filter->function)(xevent, event, filter->data);
if (result != GDK_FILTER_CONTINUE)
return result;
tmp_list = tmp_list->next;
}
return GDK_FILTER_CONTINUE;
}
static gint
gdk_event_translate (GdkEvent *event,
XEvent *xevent)
@ -1520,6 +1606,25 @@ gdk_event_translate (GdkEvent *event,
window = gdk_window_lookup (xevent->xany.window);
window_private = (GdkWindowPrivate *) window;
if (window == NULL)
g_warning ("%#lx -> NULL\n", xevent->xany.window);
else
gdk_window_ref (window);
/* Check for filters for this window */
if (window_private)
{
GdkFilterReturn result;
result = gdk_event_apply_filters (xevent, event, window_private->filters);
if (result != GDK_FILTER_CONTINUE)
{
return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
}
}
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
* the conversion is fairly straightforward. We also
@ -1555,7 +1660,7 @@ gdk_event_translate (GdkEvent *event,
{ /* retry */
/* alloc adequate size of buffer */
if (gdk_debug_level >= 1)
g_print("XIM: overflow(required %i)\n", charcount);
g_print("XIM: overflow (required %i)\n", charcount);
while (buf_len <= charcount)
buf_len *= 2;
@ -1603,10 +1708,14 @@ gdk_event_translate (GdkEvent *event,
event->key.window = window;
event->key.time = xevent->xkey.time;
event->key.state = (GdkModifierType) xevent->xkey.state;
event->key.string = buf;
event->key.string = g_strdup (buf);
event->key.length = charcount;
return_val = window_private && !window_private->destroyed;
if (!return_val)
g_free (event->key.string);
break;
case KeyRelease:
@ -2012,6 +2121,14 @@ gdk_event_translate (GdkEvent *event,
event->crossing.type = GDK_LEAVE_NOTIFY;
event->crossing.window = window;
/* If the subwindow field of the XEvent is non-NULL, then
* lookup the corresponding GdkWindow.
*/
if (xevent->xcrossing.subwindow != None)
event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow);
else
event->crossing.subwindow = NULL;
/* Translate the crossing detail into Gdk terms.
*/
switch (xevent->xcrossing.detail)
@ -2073,31 +2190,30 @@ gdk_event_translate (GdkEvent *event,
break;
case FocusIn:
/* Print debugging info.
*/
if (gdk_show_events)
g_print ("focus in:\t\twindow: %ld\n",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = TRUE;
return_val = window_private && !window_private->destroyed;
break;
case FocusOut:
/* Print debugging info.
/* We only care about focus events that indicate that _this_
* window (not a ancestor or child) got or lost the focus
*/
if (gdk_show_events)
g_print ("focus out:\t\twindow: %ld\n",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = FALSE;
return_val = window_private && !window_private->destroyed;
switch (xevent->xfocus.detail)
{
case NotifyAncestor:
case NotifyInferior:
case NotifyNonlinear:
/* Print debugging info.
*/
if (gdk_show_events)
g_print ("focus %s:\t\twindow: %ld\n",
(xevent->xany.type == FocusIn) ? "in" : "out",
xevent->xfocus.window - base_id);
event->focus_change.type = GDK_FOCUS_CHANGE;
event->focus_change.window = window;
event->focus_change.in = (xevent->xany.type == FocusIn);
return_val = window_private && !window_private->destroyed;
break;
default:
}
break;
case KeymapNotify:
@ -2194,15 +2310,9 @@ gdk_event_translate (GdkEvent *event,
event->any.type = GDK_DESTROY;
event->any.window = window;
/* Remeber which window received the destroy notify
* event so that we can destroy our associated
* data structures the next time the user asks
* us for an event.
*/
received_destroy_notify = TRUE;
window_to_destroy = window;
return_val = window_private && !window_private->destroyed;
gdk_window_destroy_notify (window);
break;
case UnmapNotify:
@ -2618,9 +2728,29 @@ gdk_event_translate (GdkEvent *event,
break;
}
if (return_val)
{
if (event->any.window)
gdk_window_ref (event->any.window);
if (((event->any.type == GDK_ENTER_NOTIFY) ||
(event->any.type == GDK_LEAVE_NOTIFY)) &&
(event->crossing.subwindow != NULL))
gdk_window_ref (event->crossing.subwindow);
}
else
{
/* Mark this event as having no resources to be freed */
event->any.window = NULL;
event->any.type = GDK_NOTHING;
}
if (window)
gdk_window_unref (window);
return return_val;
}
#if 0
static Bool
gdk_event_get_type (Display *display,
XEvent *xevent,
@ -2637,6 +2767,7 @@ gdk_event_get_type (Display *display,
return FALSE;
}
#endif
static void
gdk_synthesize_click (GdkEvent *event,

View File

@ -650,22 +650,39 @@ gdk_pixmap_create_from_xpm_d (GdkWindow *window,
return pixmap;
}
void
gdk_pixmap_destroy (GdkPixmap *pixmap)
GdkPixmap*
gdk_pixmap_ref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private;
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
g_return_val_if_fail (pixmap != NULL, NULL);
g_return_if_fail (pixmap != NULL);
private->ref_count += 1;
return pixmap;
}
private = (GdkPixmapPrivate*) pixmap;
if (private->ref_count <= 0)
void
gdk_pixmap_unref (GdkPixmap *pixmap)
{
GdkWindowPrivate *private = (GdkWindowPrivate *)pixmap;
g_return_if_fail(pixmap != NULL);
private->ref_count -= 1;
if (private->ref_count == 0)
{
XFreePixmap (private->xdisplay, private->xwindow);
gdk_xid_table_remove (private->xwindow);
g_free (pixmap);
}
else
{
private->ref_count -= 1;
g_free (private);
}
}
GdkBitmap *
gdk_bitmap_ref (GdkBitmap *bitmap)
{
return (GdkBitmap *)gdk_pixmap_ref ((GdkPixmap *)bitmap);
}
void
gdk_bitmap_unref (GdkBitmap *bitmap)
{
gdk_pixmap_unref ((GdkPixmap *)bitmap);
}

View File

@ -25,6 +25,7 @@
#include "gdkinput.h"
#include "gdkprivate.h"
#include <stdlib.h>
#include <stdio.h>
int nevent_masks = 16;
int event_mask_table[18] =
@ -137,6 +138,8 @@ gdk_window_new (GdkWindow *parent,
private->dnd_drag_data_numtypesavail = 0;
private->dnd_drag_eventmask = private->dnd_drag_savedeventmask = 0;
private->filters = NULL;
window->user_data = NULL;
if (attributes_mask & GDK_WA_VISUAL)
@ -227,6 +230,7 @@ gdk_window_new (GdkWindow *parent,
x, y, private->width, private->height,
0, depth, class, xvisual,
xattributes_mask, &xattributes);
gdk_window_ref (window);
gdk_xid_table_insert (&private->xwindow, window);
switch (private->window_type)
@ -320,16 +324,24 @@ gdk_window_foreign_new (guint32 anid)
private->destroyed = FALSE;
private->extension_events = 0;
private->filters = NULL;
window->user_data = NULL;
gdk_window_ref (window);
gdk_xid_table_insert (&private->xwindow, window);
return window;
}
void
gdk_window_destroy (GdkWindow *window)
/* Call this function when you want a window and all its children to
disappear. When xdestroy is true, a request to destroy the XWindow
is sent out. When it is false, it is assumed that the XWindow has
been or will be destroyed by destroying some ancestor of this
window. */
static void
gdk_window_internal_destroy (GdkWindow *window, int xdestroy)
{
GdkWindowPrivate *private;
GdkWindowPrivate *temp_private;
@ -340,27 +352,14 @@ gdk_window_destroy (GdkWindow *window)
g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
if(private->dnd_drag_data_numtypesavail > 0)
{
free(private->dnd_drag_data_typesavail);
private->dnd_drag_data_typesavail = NULL;
}
if(private->dnd_drop_data_numtypesavail > 0)
{
free(private->dnd_drop_data_typesavail);
private->dnd_drop_data_typesavail = NULL;
}
switch (private->window_type)
{
case GDK_WINDOW_TOPLEVEL:
case GDK_WINDOW_CHILD:
case GDK_WINDOW_DIALOG:
case GDK_WINDOW_TEMP:
if (private->ref_count >= 1)
private->ref_count -= 1;
if (!private->destroyed || (private->destroyed == 2))
if (!private->destroyed)
{
children = gdk_window_get_children (window);
tmp = children;
@ -371,18 +370,24 @@ gdk_window_destroy (GdkWindow *window)
tmp = tmp->next;
temp_private = (GdkWindowPrivate*) temp_window;
if (temp_private && !temp_private->destroyed)
/* Removes some nice coredumps... /David */
{
temp_private->destroyed = 2;
temp_private->ref_count += 1;
gdk_window_destroy (temp_window);
}
if (temp_private)
gdk_window_internal_destroy (temp_window, FALSE);
}
g_list_free (children);
if (!private->destroyed)
if(private->dnd_drag_data_numtypesavail > 0)
{
g_free (private->dnd_drag_data_typesavail);
private->dnd_drag_data_typesavail = NULL;
}
if(private->dnd_drop_data_numtypesavail > 0)
{
g_free (private->dnd_drop_data_typesavail);
private->dnd_drop_data_typesavail = NULL;
}
if (xdestroy)
XDestroyWindow (private->xdisplay, private->xwindow);
private->destroyed = TRUE;
}
@ -393,14 +398,25 @@ gdk_window_destroy (GdkWindow *window)
break;
case GDK_WINDOW_PIXMAP:
g_warning ("called gdk_window_destroy on a pixmap (use gdk_pixmap_destroy)");
gdk_pixmap_destroy (window);
g_error ("called gdk_window_destroy on a pixmap (use gdk_pixmap_unref)");
break;
}
}
/* Like internal_destroy, but also destroys the reference created by
gdk_window_new. */
void
gdk_window_real_destroy (GdkWindow *window)
gdk_window_destroy (GdkWindow *window)
{
gdk_window_internal_destroy (window, TRUE);
gdk_window_unref (window);
}
/* This function is called when the XWindow is really gone. */
void
gdk_window_destroy_notify (GdkWindow *window)
{
GdkWindowPrivate *private;
@ -411,11 +427,8 @@ gdk_window_real_destroy (GdkWindow *window)
if (private->extension_events != 0)
gdk_input_window_destroy (window);
if (private->ref_count == 0)
{
gdk_xid_table_remove (private->xwindow);
g_free (window);
}
gdk_xid_table_remove (private->xwindow);
gdk_window_unref (window);
}
GdkWindow*
@ -436,7 +449,11 @@ gdk_window_unref (GdkWindow *window)
private->ref_count -= 1;
if (private->ref_count == 0)
gdk_window_real_destroy (window);
{
if (!private->destroyed)
g_warning ("losing last reference to undestroyed window\n");
g_free (window);
}
}
void
@ -1364,6 +1381,60 @@ gdk_window_dnd_data_set (GdkWindow *window,
NoEventMask, &sev);
}
void
gdk_window_add_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list;
GdkEventFilter *filter;
private = (GdkWindowPrivate *)window;
tmp_list = private->filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
if ((filter->function == function) && (filter->data == data))
return;
tmp_list = tmp_list->next;
}
filter = g_new (GdkEventFilter, 1);
filter->function = function;
filter->data = data;
private->filters = g_list_append (private->filters, filter);
}
void
gdk_window_remove_filter (GdkWindow *window,
GdkFilterFunc function,
gpointer data)
{
GdkWindowPrivate *private;
GList *tmp_list;
GdkEventFilter *filter;
private = (GdkWindowPrivate *)window;
tmp_list = private->filters;
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
tmp_list = tmp_list->next;
if ((filter->function == function) && (filter->data == data))
{
private->filters = g_list_remove_link (private->filters, tmp_list);
g_list_free_1 (tmp_list);
return;
}
}
}
void
gdk_window_set_override_redirect(GdkWindow *window,
gboolean override_redirect)

View File

@ -16,7 +16,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "gdkprivate.h"
#include <stdio.h>
static guint gdk_xid_hash (XID *xid);
static gint gdk_xid_compare (XID *a,

View File

@ -5,6 +5,7 @@
*/
#include "../config.h"
#include "gxid_lib.h"
#ifdef XINPUT_GXI
@ -16,8 +17,6 @@
#include <netinet/in.h>
#include <netdb.h>
#include "gxid_lib.h"
/* handles mechanics of communicating with a client */
static int
gxid_send_message(char *host, int port, GxidMessage *msg)
@ -112,5 +111,15 @@ gxid_release_device(char *host, int port, GxidU32 device, GxidU32 window)
return gxid_send_message(host,port,(GxidMessage *)&msg);
}
#else /* !XINPUT_GXI */
/* Some compilers don't like empty source files */
int
gxid_claim_device(char *host, int port, GxidU32 device, GxidU32 window,
int exclusive)
{
return 0;
}
#endif /* XINPUT_GXI */

44
glib/configure vendored
View File

@ -1227,7 +1227,7 @@ fi
if test -n "$DEBUGFLAG"; then
test "${CFLAGS+set}" = set || CFLAGS="$DEBUGFLAG"
test "$cflags_set" = set || CFLAGS="$DEBUGFLAG"
fi
# Checks for programs.
@ -2453,10 +2453,10 @@ fi
# (under some other name?) then the definitions would
# belong there. (They are only used in GDK)
# Look for wide string functions in wchar.h or wcstr.h
# Check for wchar.h
echo $ac_n "checking for <wchar.h> or <wcstr.h>""... $ac_c" 1>&6
echo "configure:2460: checking for <wchar.h> or <wcstr.h>" >&5
echo $ac_n "checking for wchar.h""... $ac_c" 1>&6
echo "configure:2460: checking for wchar.h" >&5
cat > conftest.$ac_ext <<EOF
#line 2462 "configure"
#include "confdefs.h"
@ -2481,44 +2481,20 @@ if test $gtk_ok = yes; then
#define HAVE_WCHAR_H 1
EOF
else
cat > conftest.$ac_ext <<EOF
#line 2487 "configure"
#include "confdefs.h"
#include <wcstr.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2492: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
gtk_ok=yes
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
gtk_ok=no
fi
rm -f conftest*
if test $gtk_ok = yes; then
cat >> confdefs.h <<\EOF
#define HAVE_WCSTR_H 1
EOF
fi
fi
echo "$ac_t""$gtk_ok" 1>&6
# Check for wctype.h (for iswalnum)
echo $ac_n "checking for <wctype.h>""... $ac_c" 1>&6
echo "configure:2515: checking for <wctype.h>" >&5
echo $ac_n "checking for wctype.h""... $ac_c" 1>&6
echo "configure:2491: checking for wctype.h" >&5
cat > conftest.$ac_ext <<EOF
#line 2517 "configure"
#line 2493 "configure"
#include "confdefs.h"
#include <wctype.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*

View File

@ -24,7 +24,7 @@ AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]]
, enable_ansi=no)
if test -n "$DEBUGFLAG"; then
test "${CFLAGS+set}" = set || CFLAGS="$DEBUGFLAG"
test "$cflags_set" = set || CFLAGS="$DEBUGFLAG"
fi
# Checks for programs.
@ -116,21 +116,18 @@ fi
# (under some other name?) then the definitions would
# belong there. (They are only used in GDK)
# Look for wide string functions in wchar.h or wcstr.h
# Check for wchar.h
AC_MSG_CHECKING(for <wchar.h> or <wcstr.h>)
AC_MSG_CHECKING(for wchar.h)
AC_TRY_CPP([#include <wchar.h>], gtk_ok=yes, gtk_ok=no)
if test $gtk_ok = yes; then
AC_DEFINE(HAVE_WCHAR_H)
else
AC_TRY_CPP([#include <wcstr.h>], gtk_ok=yes, gtk_ok=no)
if test $gtk_ok = yes; then
AC_DEFINE(HAVE_WCSTR_H)
fi
fi
AC_MSG_RESULT($gtk_ok)
# Check for wctype.h (for iswalnum)
AC_MSG_CHECKING(for <wctype.h>)
AC_MSG_CHECKING(for wctype.h)
AC_TRY_CPP([#include <wctype.h>], gtk_ok=yes, gtk_ok=no)
if test $gtk_ok = yes; then
AC_DEFINE(HAVE_WCTYPE_H)

View File

@ -31,7 +31,6 @@
#undef NO_SYS_SIGLIST
#undef HAVE_WCHAR_H
#undef HAVE_WCSTR_H
#undef HAVE_WCTYPE_H
/* #undef PACKAGE */

File diff suppressed because it is too large Load Diff

View File

@ -95,17 +95,6 @@ gtk_accelerator_table_find (GtkObject *object,
return NULL;
}
void
gtk_accelerator_table_destroy (GtkAcceleratorTable *table)
{
g_return_if_fail (table != NULL);
g_return_if_fail (table->ref_count <= 0);
tables = g_slist_remove (tables, table);
gtk_accelerator_table_clean (table);
g_free (table);
}
GtkAcceleratorTable*
gtk_accelerator_table_ref (GtkAcceleratorTable *table)
{
@ -122,7 +111,11 @@ gtk_accelerator_table_unref (GtkAcceleratorTable *table)
table->ref_count -= 1;
if (table->ref_count <= 0)
gtk_accelerator_table_destroy (table);
{
tables = g_slist_remove (tables, table);
gtk_accelerator_table_clean (table);
g_free (table);
}
}
void
@ -322,7 +315,7 @@ gtk_accelerator_table_init (GtkAcceleratorTable *table)
for (i = 0; i < 256; i++)
table->entries[i] = NULL;
table->ref_count = 0;
table->ref_count = 1;
table->modifier_mask = gtk_accelerator_table_default_mod_mask;
}

View File

@ -46,7 +46,6 @@ GtkAcceleratorTable* gtk_accelerator_table_find (GtkObject *object,
guchar accelerator_key,
guint8 accelerator_mods);
void gtk_accelerator_table_destroy (GtkAcceleratorTable *table);
GtkAcceleratorTable *gtk_accelerator_table_ref (GtkAcceleratorTable *table);
void gtk_accelerator_table_unref (GtkAcceleratorTable *table);
void gtk_accelerator_table_install (GtkAcceleratorTable *table,

View File

@ -296,7 +296,7 @@ gtk_curve_graph_events (GtkWidget *widget, GdkEvent *event, GtkCurve *c)
{
case GDK_CONFIGURE:
if (c->pixmap)
gdk_pixmap_destroy (c->pixmap);
gdk_pixmap_unref (c->pixmap);
c->pixmap = 0;
/* fall through */
case GDK_EXPOSE:
@ -849,7 +849,7 @@ gtk_curve_destroy (GtkObject *object)
curve = GTK_CURVE (object);
if (curve->pixmap)
gdk_pixmap_destroy (curve->pixmap);
gdk_pixmap_unref (curve->pixmap);
if (curve->point)
g_free (curve->point);
if (curve->ctlpoint)

View File

@ -252,8 +252,8 @@ button_realize_callback (GtkWidget *w)
gtk_container_add (GTK_CONTAINER (w), pixmap);
gtk_widget_show (pixmap);
gdk_pixmap_destroy (pm);
gdk_pixmap_destroy (mask); /* a bitmap is really just a special pixmap */
gdk_pixmap_unref (pm);
gdk_bitmap_unref (mask); /* a bitmap is really just a special pixmap */
}
static void

View File

@ -147,7 +147,9 @@ gtk_hscrollbar_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
range->trough = widget->window;
gdk_window_ref (range->trough);
attributes.x = widget->style->klass->xthickness;
attributes.y = widget->style->klass->ythickness;

View File

@ -28,6 +28,7 @@
#include <ctype.h>
#include "gdk/gdkkeysyms.h"
#include "gtkbutton.h"
#include "gtkentry.h"
#include "gtkhbox.h"
#include "gtkhseparator.h"
#include "gtkinputdialog.h"
@ -36,15 +37,23 @@
#include "gtkmain.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtknotebook.h"
#include "gtkoptionmenu.h"
#include "gtkscrolledwindow.h"
#include "gtksignal.h"
#include "gtktable.h"
#include "gtkvbox.h"
typedef void (*GtkInputDialogSignal1) (GtkObject *object,
int arg1,
gpointer data);
typedef struct {
gint index;
GtkWidget *entry;
GtkInputDialog *inputd;
} GtkInputKeyInfo;
enum
{
ENABLE_DEVICE,
@ -56,6 +65,9 @@ enum
#define AXIS_LIST_WIDTH 160
#define AXIS_LIST_HEIGHT 175
#define KEYS_LIST_WIDTH 200
#define KEYS_LIST_HEIGHT 175
/* Forward declarations */
static void gtk_input_dialog_marshal_signal1 (GtkObject *object,
@ -72,6 +84,18 @@ static void gtk_input_dialog_set_mapping_mode(GtkWidget *w,
static void gtk_input_dialog_set_axis(GtkWidget *widget, gpointer data);
static void gtk_input_dialog_fill_axes (GtkInputDialog *inputd,
GdkDeviceInfo *info);
static void gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval,
GdkModifierType modifiers);
static gint gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key);
static void gtk_input_dialog_clear_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_destroy_key (GtkWidget *widget,
GtkInputKeyInfo *key);
static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd,
GdkDeviceInfo *info);
static GtkObjectClass *parent_class = NULL;
static gint input_dialog_signals[LAST_SIGNAL] = { 0 };
@ -171,6 +195,7 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
GtkWidget *menuitem;
GtkWidget *optionmenu;
GtkWidget *separator;
GtkWidget *notebook;
GList *tmp_list;
GList *device_info;
@ -225,17 +250,9 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), device_menu);
gtk_widget_show (label);
gtk_widget_show (util_box);
/* Device options */
separator = gtk_hseparator_new();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), util_box, FALSE, FALSE, 0);
/* mapping mode option menu */
mapping_menu = gtk_menu_new ();
@ -282,34 +299,65 @@ gtk_input_dialog_init (GtkInputDialog *inputd)
gtk_widget_show (label);
gtk_widget_show (util_box);
separator = gtk_hseparator_new();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);
/* Notebook */
notebook = gtk_notebook_new ();
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
gtk_widget_show (notebook);
/* The axis listbox */
label = gtk_label_new ("Axes");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
inputd->axis_listbox = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->axis_listbox),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize (inputd->axis_listbox, AXIS_LIST_WIDTH, AXIS_LIST_HEIGHT);
gtk_box_pack_start (GTK_BOX (vbox), inputd->axis_listbox, TRUE, TRUE, 0);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
inputd->axis_listbox, label);
gtk_widget_show (inputd->axis_listbox);
inputd->axis_list = 0;
gtk_widget_show(label);
/* Keys listbox */
label = gtk_label_new ("Keys");
inputd->keys_listbox = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_usize (inputd->keys_listbox, KEYS_LIST_WIDTH, KEYS_LIST_HEIGHT);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(inputd->keys_listbox),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
inputd->keys_listbox, label);
gtk_widget_show (inputd->keys_listbox);
inputd->keys_list = 0;
/* ...set_device expects to get input dialog from widget user data */
gtk_object_set_user_data (GTK_OBJECT (inputd), inputd);
gtk_input_dialog_set_device(GTK_WIDGET(inputd), (gpointer)((long)
((GdkDeviceInfo *)device_info->data)->deviceid));
}
/* buttons */
/* We create the save button in any case, so that clients can
connect to it, without paying attention to whether it exits */
inputd->save_button = gtk_button_new_with_label ("Save");
GTK_WIDGET_SET_FLAGS (inputd->save_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area),
inputd->save_button, TRUE, TRUE, 0);
gtk_widget_show (inputd->save_button);
if (g_list_length(device_info) <= 1) /* only core device */
gtk_widget_set_sensitive(inputd->save_button, FALSE);
inputd->close_button = gtk_button_new_with_label ("Close");
GTK_WIDGET_SET_FLAGS (inputd->close_button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(inputd)->action_area),
@ -345,6 +393,7 @@ gtk_input_dialog_set_device(GtkWidget *widget, gpointer data)
info = gtk_input_dialog_get_device_info((guint32)data);
gtk_input_dialog_fill_axes(inputd, info);
gtk_input_dialog_fill_keys(inputd, info);
gtk_option_menu_set_history(GTK_OPTION_MENU(inputd->mode_optionmenu),
info->mode);
@ -464,11 +513,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
};
int i,j;
GtkWidget *list_item;
GtkWidget *menu;
GtkWidget *option_menu;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
/* remove all the old items */
@ -477,7 +523,7 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
gtk_widget_hide (inputd->axis_list); /* suppress resizes (or get warnings) */
gtk_widget_destroy (inputd->axis_list);
}
inputd->axis_list = gtk_vbox_new (FALSE, 0);
inputd->axis_list = gtk_table_new (GDK_AXIS_LAST, 2, 0);
gtk_container_add (GTK_CONTAINER (inputd->axis_listbox), inputd->axis_list);
gtk_widget_show (inputd->axis_list);
@ -487,21 +533,11 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
for (i=GDK_AXIS_X;i<GDK_AXIS_LAST;i++)
{
list_item = gtk_list_item_new();
gtk_box_pack_start(GTK_BOX(inputd->axis_list),list_item,FALSE,FALSE,0);
gtk_widget_show (list_item);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER (list_item), vbox);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 1);
/* create the label */
label = gtk_label_new(axis_use_strings[i]);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 2);
gtk_table_attach (GTK_TABLE (inputd->axis_list), label, 0, 1, i, i+1,
0, 0, 2, 2);
/* and the use option menu */
menu = gtk_menu_new();
@ -527,7 +563,8 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
}
inputd->axis_items[i] = option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 2);
gtk_table_attach (GTK_TABLE (inputd->axis_list), option_menu,
1, 2, i, i+1, 0, 0, 2, 2);
gtk_widget_show (option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
@ -539,8 +576,134 @@ gtk_input_dialog_fill_axes(GtkInputDialog *inputd, GdkDeviceInfo *info)
}
gtk_widget_show (label);
gtk_widget_show (hbox);
gtk_widget_show (vbox);
}
}
static void
gtk_input_dialog_clear_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
gtk_entry_set_text (GTK_ENTRY(key->entry), "(disabled)");
gdk_input_set_key (key->inputd->current_device, key->index, 0, 0);
}
static void
gtk_input_dialog_set_key (GtkInputKeyInfo *key,
guint keyval, GdkModifierType modifiers)
{
GString *str;
gchar chars[2];
if (keyval)
{
str = g_string_new("");
if (modifiers & GDK_SHIFT_MASK)
g_string_append (str, "Shft+");
if (modifiers & GDK_CONTROL_MASK)
g_string_append (str, "Ctl+");
if (modifiers & GDK_MOD1_MASK)
g_string_append (str, "Alt+");
if ((keyval >= 0x20) && (keyval <= 0xFF))
{
chars[0] = keyval;
chars[1] = 0;
g_string_append (str, chars);
}
else
g_string_append (str, "(unknown)");
gtk_entry_set_text (GTK_ENTRY(key->entry), str->str);
g_string_free (str, TRUE);
}
else
{
gtk_entry_set_text (GTK_ENTRY(key->entry), "(disabled)");
}
}
static gint
gtk_input_dialog_key_press (GtkWidget *widget,
GdkEventKey *event,
GtkInputKeyInfo *key)
{
gtk_input_dialog_set_key (key, event->keyval, event->state & 0xFF);
gdk_input_set_key (key->inputd->current_device, key->index,
event->keyval, event->state & 0xFF);
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
return TRUE;
}
static void
gtk_input_dialog_destroy_key (GtkWidget *widget, GtkInputKeyInfo *key)
{
g_free (key);
}
static void
gtk_input_dialog_fill_keys(GtkInputDialog *inputd, GdkDeviceInfo *info)
{
int i;
GtkWidget *label;
GtkWidget *button;
char buffer[16];
/* remove all the old items */
if (inputd->keys_list)
{
gtk_widget_hide (inputd->keys_list); /* suppress resizes (or get warnings) */
gtk_widget_destroy (inputd->keys_list);
}
inputd->keys_list = gtk_table_new (info->num_keys, 3, FALSE);
gtk_container_add (GTK_CONTAINER (inputd->keys_listbox), inputd->keys_list);
gtk_widget_show (inputd->keys_list);
gtk_widget_realize (inputd->keys_list);
gdk_window_set_background (inputd->keys_list->window,
&inputd->keys_list->style->white);
for (i=0;i<info->num_keys;i++)
{
GtkInputKeyInfo *key = g_new (GtkInputKeyInfo, 1);
key->index = i;
key->inputd = inputd;
/* create the label */
sprintf(buffer, "%d", i+1);
label = gtk_label_new(buffer);
gtk_table_attach (GTK_TABLE (inputd->keys_list), label, 0, 1, i, i+1,
0, 0, 2, 2);
gtk_widget_show (label);
/* the entry */
key->entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (inputd->keys_list), key->entry, 1, 2, i, i+1,
GTK_EXPAND | GTK_FILL , 0, 2, 2);
gtk_widget_show (key->entry);
gtk_signal_connect (GTK_OBJECT(key->entry), "key_press_event",
GTK_SIGNAL_FUNC (gtk_input_dialog_key_press), key);
gtk_signal_connect (GTK_OBJECT(key->entry), "destroy",
GTK_SIGNAL_FUNC (gtk_input_dialog_destroy_key),
key);
/* and clear button */
button = gtk_button_new_with_label ("clear");
gtk_table_attach (GTK_TABLE (inputd->keys_list), button, 2, 3, i, i+1,
0, 0, 2, 2);
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC (gtk_input_dialog_clear_key), key);
gtk_input_dialog_set_key (key, info->keys[i].keyval,
info->keys[i].modifiers);
}
}

View File

@ -49,6 +49,9 @@ struct _GtkInputDialog
GtkWidget *axis_items[GDK_AXIS_LAST];
guint32 current_device;
GtkWidget *keys_list;
GtkWidget *keys_listbox;
};
struct _GtkInputDialogClass

View File

@ -38,6 +38,7 @@
typedef struct _GtkInitFunction GtkInitFunction;
typedef struct _GtkTimeoutFunction GtkTimeoutFunction;
typedef struct _GtkIdleFunction GtkIdleFunction;
typedef struct _GtkInputFunction GtkInputFunction;
struct _GtkInitFunction
{
@ -66,6 +67,12 @@ struct _GtkIdleFunction
GtkDestroyNotify destroy;
};
struct _GtkInputFunction
{
GtkCallbackMarshal callback;
gpointer data;
GtkDestroyNotify destroy;
};
static void gtk_exit_func (void);
static void gtk_timeout_insert (GtkTimeoutFunction *timeoutf);
@ -85,10 +92,9 @@ static void gtk_print (gchar *str);
static gint done;
static guint main_level = 0;
static gint initialized = FALSE;
static GdkEvent next_event;
static GdkEvent current_event;
static gint have_event = FALSE;
static gint have_next_event = FALSE;
static GdkEvent *next_event = NULL;
static GdkEvent *current_event = NULL;
static GList *current_events = NULL;
static GList *grabs = NULL; /* A list of grabs. The grabbing widget
* is the first one on the list.
@ -219,9 +225,10 @@ gtk_main_quit ()
gint
gtk_main_iteration ()
{
GdkEvent event_copy;
GtkWidget *event_widget;
GtkWidget *grab_widget;
GdkEvent *event = NULL;
GList *tmp_list;
done = FALSE;
@ -240,19 +247,17 @@ gtk_main_iteration ()
return done;
}
/* If there is a valid event in 'next_event' then copy
* it to 'event' and unset the flag.
/* If there is a valid event in 'next_event' then move it to 'event'
*/
if (have_next_event)
if (next_event)
{
have_next_event = FALSE;
have_event = TRUE;
current_event = next_event;
event = next_event;
next_event = NULL;
}
/* If we don't have an event then get one.
*/
if (!have_event)
if (!event)
{
/* Handle setting of the "gdk" timer. If there are no
* timeout functions, then the timer is turned off.
@ -262,21 +267,19 @@ gtk_main_iteration ()
*/
gtk_handle_timer ();
have_event = gdk_event_get (&current_event, NULL, NULL);
event = gdk_event_get ();
}
/* "gdk_event_get" can return FALSE if the timer goes off
* and no events are pending. Therefore, we should make
* sure that we got an event before continuing.
*/
if (have_event)
if (event)
{
have_event = FALSE;
/* If there are any events pending then get the next one.
*/
if (gdk_events_pending () > 0)
have_next_event = gdk_event_get (&next_event, NULL, NULL);
next_event = gdk_event_get ();
/* Try to compress enter/leave notify events. These event
* pairs occur when the mouse is dragged quickly across
@ -286,19 +289,32 @@ gtk_main_iteration ()
* which contained the mouse initially and highlight the
* widget which ends up containing the mouse.
*/
if (have_next_event)
if (((current_event.type == GDK_ENTER_NOTIFY) ||
(current_event.type == GDK_LEAVE_NOTIFY)) &&
((next_event.type == GDK_ENTER_NOTIFY) ||
(next_event.type == GDK_LEAVE_NOTIFY)) &&
(next_event.type != current_event.type) &&
(next_event.any.window == current_event.any.window))
return done;
if (next_event)
if (((event->type == GDK_ENTER_NOTIFY) ||
(event->type == GDK_LEAVE_NOTIFY)) &&
((next_event->type == GDK_ENTER_NOTIFY) ||
(next_event->type == GDK_LEAVE_NOTIFY)) &&
(next_event->type != event->type) &&
(next_event->any.window == event->any.window))
{
tmp_list = current_events;
current_events = g_list_remove_link (current_events, tmp_list);
g_list_free_1 (tmp_list);
gdk_event_free (event);
return done;
}
/* Push the event onto a stack of current events for
* gdk_current_event_get */
current_events = g_list_prepend (current_events, event);
/* Find the widget which got the event. We store the widget
* in the user_data field of GdkWindow's.
*/
event_widget = gtk_get_event_widget (&current_event);
event_widget = gtk_get_event_widget (event);
/* If there is a grab in effect...
*/
@ -325,20 +341,23 @@ gtk_main_iteration ()
* and 2) redirecting these events to the grabbing widget
* could cause the display to be messed up.
*/
event_copy = current_event;
switch (event_copy.type)
switch (event->type)
{
case GDK_NOTHING:
break;
case GDK_DELETE:
if (gtk_widget_event (event_widget, &event_copy))
gtk_object_ref (GTK_OBJECT (event_widget));
if (gtk_widget_event (event_widget, event))
gtk_widget_destroy (event_widget);
gtk_object_unref (GTK_OBJECT (event_widget));
break;
case GDK_DESTROY:
gtk_widget_event (event_widget, &event_copy);
gtk_object_ref (GTK_OBJECT (event_widget));
gtk_widget_event (event_widget, event);
gtk_widget_destroy (event_widget);
gtk_object_unref (GTK_OBJECT (event_widget));
break;
case GDK_PROPERTY_NOTIFY:
@ -351,8 +370,8 @@ gtk_main_iteration ()
if (event_widget == NULL)
{
gtk_selection_incr_event (event_copy.any.window,
&event_copy.property);
gtk_selection_incr_event (event->any.window,
&event->property);
break;
}
/* otherwise fall through */
@ -371,7 +390,7 @@ gtk_main_iteration ()
case GDK_DROP_ENTER:
case GDK_DROP_LEAVE:
case GDK_DROP_DATA_AVAIL:
gtk_widget_event (event_widget, &event_copy);
gtk_widget_event (event_widget, event);
break;
case GDK_MOTION_NOTIFY:
@ -384,15 +403,23 @@ gtk_main_iteration ()
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
case GDK_OTHER_EVENT:
gtk_propagate_event (grab_widget, &event_copy);
gtk_propagate_event (grab_widget, event);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
if (grab_widget && GTK_WIDGET_IS_SENSITIVE (grab_widget))
gtk_widget_event (grab_widget, &event_copy);
gtk_widget_event (grab_widget, event);
break;
}
tmp_list = current_events;
current_events = g_list_remove_link (current_events, tmp_list);
g_list_free_1 (tmp_list);
gdk_event_free (event);
current_event = NULL;
}
else
{
@ -686,12 +713,63 @@ gtk_idle_remove_by_data (gpointer data)
}
}
void
gtk_get_current_event (GdkEvent *event)
static void
gtk_invoke_input_function (GtkInputFunction *input,
gint source,
GdkInputCondition condition)
{
g_assert (event != NULL);
*event = current_event;
GtkArg args[3];
args[0].type = GTK_TYPE_INT;
args[0].name = NULL;
GTK_VALUE_INT(args[0]) = source;
args[1].type = GTK_TYPE_GDK_INPUT_CONDITION;
args[1].name = NULL;
GTK_VALUE_FLAGS(args[1]) = condition;
args[2].type = GTK_TYPE_NONE;
args[2].name = NULL;
input->callback (NULL, input->data, 2, args);
}
static void
gtk_destroy_input_function (GtkInputFunction *input)
{
if (input->destroy)
(input->destroy) (input->data);
g_free (input);
}
gint
gtk_input_add_interp (gint source,
GdkInputCondition condition,
GtkCallbackMarshal callback,
gpointer data,
GtkDestroyNotify destroy)
{
GtkInputFunction *input = g_new (GtkInputFunction, 1);
input->callback = callback;
input->data = data;
input->destroy = destroy;
return gdk_input_add_interp (source,
condition,
(GdkInputFunction) gtk_invoke_input_function,
input,
(GdkDestroyNotify) gtk_destroy_input_function);
}
void
gtk_input_remove (gint tag)
{
gdk_input_remove (tag);
}
GdkEvent *
gtk_get_current_event ()
{
if (current_events)
return gdk_event_copy ((GdkEvent *)current_events->data);
else
return NULL;
}
GtkWidget*

View File

@ -65,7 +65,7 @@ gint gtk_idle_add_interp (GtkCallbackMarshal function,
void gtk_idle_remove (gint tag);
void gtk_idle_remove_by_data (gpointer data);
void gtk_get_current_event (GdkEvent *event);
GdkEvent* gtk_get_current_event (void);
GtkWidget* gtk_get_event_widget (GdkEvent *event);

View File

@ -247,12 +247,14 @@ gtk_menu_set_accelerator_table (GtkMenu *menu,
g_return_if_fail (menu != NULL);
g_return_if_fail (GTK_IS_MENU (menu));
if (menu->accelerator_table)
gtk_accelerator_table_unref (menu->accelerator_table);
menu->accelerator_table = table;
if (menu->accelerator_table)
gtk_accelerator_table_ref (menu->accelerator_table);
if (menu->accelerator_table != table)
{
if (menu->accelerator_table)
gtk_accelerator_table_unref (menu->accelerator_table);
menu->accelerator_table = table;
if (menu->accelerator_table)
gtk_accelerator_table_ref (menu->accelerator_table);
}
}

View File

@ -85,6 +85,9 @@ gtk_menu_factory_destroy (GtkMenuFactory *factory)
gtk_menu_factory_destroy (subfactory);
}
if (factory->table)
gtk_accelerator_table_unref (factory->table);
}
void
@ -237,11 +240,8 @@ gtk_menu_factory_create (GtkMenuFactory *factory,
&accelerator_key,
&accelerator_mods);
if (!factory->table)
{
factory->table = gtk_accelerator_table_new ();
gtk_accelerator_table_ref (factory->table);
}
factory->table = gtk_accelerator_table_new ();
gtk_widget_install_accelerator (menu_path->widget,
factory->table,
"activate",
@ -291,10 +291,7 @@ gtk_menu_factory_create (GtkMenuFactory *factory,
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_path->widget), menu);
if (!factory->table)
{
factory->table = gtk_accelerator_table_new ();
gtk_accelerator_table_ref (factory->table);
}
factory->table = gtk_accelerator_table_new ();
gtk_menu_set_accelerator_table (GTK_MENU (menu), factory->table);
}
@ -369,10 +366,7 @@ gtk_menu_factory_make_widget (GtkMenuFactory *factory)
widget = gtk_menu_new ();
if (!factory->table)
{
factory->table = gtk_accelerator_table_new ();
gtk_accelerator_table_ref (factory->table);
}
factory->table = gtk_accelerator_table_new ();
gtk_menu_set_accelerator_table (GTK_MENU (widget), factory->table);
return widget;
case GTK_MENU_FACTORY_MENU_BAR:

View File

@ -207,19 +207,20 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
g_return_if_fail (menu_item != NULL);
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
if (menu_item->submenu)
if (menu_item->submenu != submenu)
{
g_return_if_fail (!GTK_WIDGET_VISIBLE (menu_item->submenu));
gtk_object_unref (GTK_OBJECT (menu_item->submenu));
if (menu_item->submenu)
{
g_return_if_fail (!GTK_WIDGET_VISIBLE (menu_item->submenu));
gtk_object_unref (GTK_OBJECT (menu_item->submenu));
}
menu_item->submenu = submenu;
if (menu_item->submenu)
gtk_object_ref (GTK_OBJECT (menu_item->submenu));
if (GTK_WIDGET (menu_item)->parent)
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
}
menu_item->submenu = submenu;
if (menu_item->submenu)
gtk_object_ref (GTK_OBJECT (menu_item->submenu));
if (GTK_WIDGET (menu_item)->parent)
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
}
void

View File

@ -230,7 +230,7 @@ gtk_object_ref (GtkObject *object)
}
/*****************************************
* gtk_object_new:
* gtk_object_unref:
*
* arguments:
*

View File

@ -23,7 +23,9 @@ static void gtk_pixmap_class_init (GtkPixmapClass *klass);
static void gtk_pixmap_init (GtkPixmap *pixmap);
static gint gtk_pixmap_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pixmap_destroy (GtkObject *object);
static GtkWidgetClass *parent_class;
guint
gtk_pixmap_get_type ()
@ -51,10 +53,14 @@ gtk_pixmap_get_type ()
static void
gtk_pixmap_class_init (GtkPixmapClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_widget_get_type ());
object_class->destroy = gtk_pixmap_destroy;
widget_class->expose_event = gtk_pixmap_expose;
}
@ -82,6 +88,14 @@ gtk_pixmap_new (GdkPixmap *val,
return GTK_WIDGET (pixmap);
}
static void
gtk_pixmap_destroy (GtkObject *object)
{
gtk_pixmap_set (GTK_PIXMAP (object), NULL, NULL);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
void
gtk_pixmap_set (GtkPixmap *pixmap,
GdkPixmap *val,
@ -92,25 +106,38 @@ gtk_pixmap_set (GtkPixmap *pixmap,
g_return_if_fail (pixmap != NULL);
g_return_if_fail (GTK_IS_PIXMAP (pixmap));
g_return_if_fail (val != NULL);
pixmap->pixmap = val;
pixmap->mask = mask;
if (pixmap->pixmap)
if (pixmap->pixmap != val)
{
gdk_window_get_size (pixmap->pixmap, &width, &height);
GTK_WIDGET (pixmap)->requisition.width = width + GTK_MISC (pixmap)->xpad * 2;
GTK_WIDGET (pixmap)->requisition.height = height + GTK_MISC (pixmap)->ypad * 2;
}
else
{
GTK_WIDGET (pixmap)->requisition.width = 0;
GTK_WIDGET (pixmap)->requisition.height = 0;
if (pixmap->pixmap)
gdk_pixmap_unref (pixmap->pixmap);
pixmap->pixmap = val;
if (pixmap->pixmap)
{
gdk_pixmap_ref (pixmap->pixmap);
gdk_window_get_size (pixmap->pixmap, &width, &height);
GTK_WIDGET (pixmap)->requisition.width =
width + GTK_MISC (pixmap)->xpad * 2;
GTK_WIDGET (pixmap)->requisition.height =
height + GTK_MISC (pixmap)->ypad * 2;
}
else
{
GTK_WIDGET (pixmap)->requisition.width = 0;
GTK_WIDGET (pixmap)->requisition.height = 0;
}
if (GTK_WIDGET_VISIBLE (pixmap))
gtk_widget_queue_resize (GTK_WIDGET (pixmap));
}
if (GTK_WIDGET_VISIBLE (pixmap))
gtk_widget_queue_resize (GTK_WIDGET (pixmap));
if (pixmap->mask != mask)
{
if (pixmap->mask)
gdk_bitmap_unref (pixmap->mask);
pixmap->mask = mask;
if (pixmap->mask)
gdk_bitmap_ref (pixmap->mask);
}
}
void

View File

@ -199,7 +199,7 @@ gtk_progress_bar_make_pixmap (GtkProgressBar *pbar)
widget = GTK_WIDGET (pbar);
if (pbar->offscreen_pixmap)
gdk_pixmap_destroy (pbar->offscreen_pixmap);
gdk_pixmap_unref (pbar->offscreen_pixmap);
pbar->offscreen_pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width,

View File

@ -195,28 +195,33 @@ gtk_range_set_adjustment (GtkRange *range,
g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
if (range->adjustment)
if (range->adjustment != adjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment), (gpointer) range);
gtk_object_unref (GTK_OBJECT (range->adjustment));
if (range->adjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (range->adjustment),
(gpointer) range);
gtk_object_unref (GTK_OBJECT (range->adjustment));
}
range->adjustment = adjustment;
if (adjustment)
{
gtk_object_ref (GTK_OBJECT (adjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_range_adjustment_changed,
(gpointer) range);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc) gtk_range_adjustment_value_changed,
(gpointer) range);
range->old_value = adjustment->value;
range->old_lower = adjustment->lower;
range->old_upper = adjustment->upper;
range->old_page_size = adjustment->page_size;
gtk_range_adjustment_changed (adjustment, (gpointer) range);
}
}
range->adjustment = adjustment;
gtk_object_ref (GTK_OBJECT (range->adjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_range_adjustment_changed,
(gpointer) range);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc) gtk_range_adjustment_value_changed,
(gpointer) range);
range->old_value = adjustment->value;
range->old_lower = adjustment->lower;
range->old_upper = adjustment->upper;
range->old_page_size = adjustment->page_size;
gtk_range_adjustment_changed (range->adjustment, (gpointer) range);
}
void

View File

@ -441,7 +441,7 @@ gtk_rc_style_init (GtkRcStyle *rc_style)
old_font = rc_style->style->font;
rc_style->style->font = gdk_fontset_load (rc_style->fontset_name);
if (rc_style->style->font)
gdk_fontset_free (old_font);
gdk_font_unref (old_font);
else
rc_style->style->font = old_font;
}
@ -450,7 +450,7 @@ gtk_rc_style_init (GtkRcStyle *rc_style)
old_font = rc_style->style->font;
rc_style->style->font = gdk_font_load (rc_style->font_name);
if (rc_style->style->font)
gdk_font_free (old_font);
gdk_font_unref (old_font);
else
rc_style->style->font = old_font;
}

View File

@ -200,7 +200,7 @@ gtk_ruler_unrealize (GtkWidget *widget)
widget->window = NULL;
if (ruler->backing_store)
gdk_pixmap_destroy (ruler->backing_store);
gdk_pixmap_unref (ruler->backing_store);
if (ruler->non_gr_exp_gc)
gdk_gc_destroy (ruler->non_gr_exp_gc);
@ -286,7 +286,7 @@ gtk_ruler_make_pixmap (GtkRuler *ruler)
(height == widget->allocation.height))
return;
gdk_pixmap_destroy (ruler->backing_store);
gdk_pixmap_unref (ruler->backing_store);
}
ruler->backing_store = gdk_pixmap_new (widget->window,

View File

@ -1173,11 +1173,8 @@ gtk_params_get (GtkArg *params,
for (i = 0; i < nparams; i++)
{
if (param_types[i] != GTK_TYPE_NONE)
{
params[i].type = param_types[i];
params[i].name = NULL;
}
params[i].type = param_types[i];
params[i].name = NULL;
switch (GTK_FUNDAMENTAL_TYPE (param_types[i]))
{
@ -1258,11 +1255,8 @@ gtk_params_get (GtkArg *params,
}
}
if (return_val != GTK_TYPE_NONE)
{
params[i].type = return_val;
params[i].name = NULL;
}
params[i].type = return_val;
params[i].name = NULL;
switch (GTK_FUNDAMENTAL_TYPE (return_val))
{

View File

@ -168,12 +168,13 @@ gtk_style_new ()
style = g_new (GtkStyle, 1);
if (!default_font)
default_font = gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
default_font =
gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
style->font = default_font;
gdk_font_ref (style->font);
style->ref_count = 0;
style->ref_count = 1;
style->attach_count = 0;
style->colormap = NULL;
style->depth = -1;
@ -587,7 +588,7 @@ gtk_styles_init ()
initialize = FALSE;
style_cache = g_cache_new ((GCacheNewFunc) gtk_style_new_from_key,
(GCacheDestroyFunc) gtk_style_destroy,
(GCacheDestroyFunc) gtk_style_unref,
(GCacheDupFunc) gtk_style_key_dup,
(GCacheDestroyFunc) gtk_style_key_destroy,
(GHashFunc) gtk_style_key_hash,
@ -712,14 +713,17 @@ gtk_style_new_from_key (GtkStyleKey *key)
}
if (style)
break;
{
gtk_style_ref (style);
break;
}
}
if (!style)
{
style = g_new (GtkStyle, 1);
style->ref_count = 0;
style->ref_count = 1;
style->attach_count = 0;
style->font = key->font;
@ -794,9 +798,6 @@ gtk_style_destroy (GtkStyle *style)
{
gint i;
if (style->ref_count != 0)
return;
if (style->attach_count > 0)
{
gtk_gc_release (style->black_gc);
@ -816,13 +817,7 @@ gtk_style_destroy (GtkStyle *style)
unattached_styles = g_slist_remove (unattached_styles, style);
if (style->font->type == GDK_FONT_FONT)
gdk_font_free (style->font);
else if (style->font->type == GDK_FONT_FONTSET)
gdk_fontset_free (style->font);
else
g_error("undefined font type\n");
gdk_font_unref (style->font);
g_free (style);
}

View File

@ -244,6 +244,8 @@ static void scroll_up (GtkText* text, gint diff);
static void scroll_down (GtkText* text, gint diff);
static void scroll_int (GtkText* text, gint diff);
static void process_exposes (GtkText *text);
/* Cache Management. */
static GList* remove_cache_line (GtkText* text, GList* list);
@ -1548,6 +1550,9 @@ delete_char_line_expose (GtkText* text, gchar key, guint old_pixels)
draw_cursor (text, FALSE);
if (old_pixels != new_pixels)
process_exposes (text);
TEXT_ASSERT (text);
TEXT_SHOW(text);
}
@ -1650,6 +1655,9 @@ insert_char_line_expose (GtkText* text, gchar key, guint old_pixels)
draw_cursor (text, FALSE);
if (old_pixels != new_pixels)
process_exposes (text);
TEXT_SHOW_ADJ (text, text->vadj, "vadj");
TEXT_ASSERT (text);
TEXT_SHOW(text);
@ -2564,6 +2572,26 @@ scroll_int (GtkText* text, gint diff)
gtk_signal_emit_by_name (GTK_OBJECT (text->vadj), "value_changed");
}
static void
process_exposes (GtkText *text)
{
GdkEvent *event;
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (text->text_area)) != NULL)
{
gtk_widget_event (GTK_WIDGET (text), event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
}
static gint last_visible_line_height (GtkText* text)
{
GList *cache = text->line_start_cache;
@ -2660,6 +2688,9 @@ scroll_down (GtkText* text, gint diff0)
mouse_click_1 (text, &button);
}
}
if (height > real_diff)
process_exposes (text);
}
static void
@ -2734,6 +2765,9 @@ scroll_up (GtkText* text, gint diff0)
mouse_click_1 (text, &button);
}
}
if (height > real_diff)
process_exposes (text);
}
/**********************************************************************/

View File

@ -17,6 +17,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gtkmain.h"
#include "gtkwidget.h"
@ -41,7 +42,7 @@ static gint gtk_tooltips_widget_visible (GtkWidget *widget);
static gint gtk_tooltips_timeout (gpointer data);
static void gtk_tooltips_create_window (GtkTooltips *tooltips);
static void gtk_tooltips_draw_tips (GtkTooltips *tooltips);
static void gtk_tooltips_real_destroy (GtkTooltips *tooltips);
GtkTooltips *
gtk_tooltips_new ()
@ -52,8 +53,7 @@ gtk_tooltips_new ()
if (tooltips != NULL)
{
tooltips->ref_count = 0;
tooltips->pending_destroy = 0;
tooltips->ref_count = 1;
tooltips->enabled = TRUE;
tooltips->numwidgets = 0;
@ -81,8 +81,8 @@ gtk_tooltips_unref (GtkTooltips *tooltips)
{
g_return_if_fail (tooltips != NULL);
tooltips->ref_count -= 1;
if (tooltips->ref_count == 0 && tooltips->pending_destroy)
gtk_tooltips_destroy (tooltips);
if (tooltips->ref_count == 0)
gtk_tooltips_real_destroy (tooltips);
}
void
@ -105,20 +105,14 @@ gtk_tooltips_destroy_data (GtkTooltips *tooltips,
g_free (tooltipsdata);
}
void
gtk_tooltips_destroy (GtkTooltips *tooltips)
static void
gtk_tooltips_real_destroy (GtkTooltips *tooltips)
{
GList *current;
GtkTooltipsData *tooltipsdata;
g_return_if_fail (tooltips != NULL);
if (tooltips->ref_count > 0)
{
tooltips->pending_destroy = 1;
return;
}
if (tooltips->timer_active == TRUE)
{
tooltips->timer_active = FALSE;
@ -627,14 +621,9 @@ gtk_tooltips_widget_remove (GtkWidget *widget,
if (list)
{
tooltipsdata = (GtkTooltipsData*) list->data;
g_free (tooltipsdata->tips_text);
g_list_foreach (tooltipsdata->row, gtk_tooltips_free_string, 0);
g_list_free (tooltipsdata->row);
gtk_signal_disconnect_by_data (GTK_OBJECT (tooltipsdata->widget), (gpointer) tooltips);
g_free (tooltipsdata);
tooltips->widget_list = g_list_remove (tooltips->widget_list, tooltipsdata);
tooltips->widget_list = g_list_remove (tooltips->widget_list,
tooltipsdata);
gtk_tooltips_destroy_data (tooltips, tooltipsdata);
}
gtk_object_set_data (GTK_OBJECT (widget), "_GtkTooltips", NULL);

View File

@ -53,13 +53,10 @@ typedef struct
gint timer_active;
gint ref_count;
gint pending_destroy;
} GtkTooltips;
GtkTooltips* gtk_tooltips_new (void);
void gtk_tooltips_destroy (GtkTooltips *tooltips);
GtkTooltips* gtk_tooltips_ref (GtkTooltips *tooltips);
void gtk_tooltips_unref (GtkTooltips *tooltips);

View File

@ -20,6 +20,10 @@
{ "GtkPositionType", GTK_TYPE_ENUM },
{ "GtkPreviewType", GTK_TYPE_ENUM },
{ "GtkWidgetFlags", GTK_TYPE_FLAGS },
{ "GtkSelectionMode", GTK_TYPE_ENUM },
{ "GtkCurveType", GTK_TYPE_ENUM },
{ "GtkFundamentalType", GTK_TYPE_ENUM },
{ "GtkJustification", GTK_TYPE_ENUM },
{ "GdkWindowType", GTK_TYPE_ENUM },
{ "GdkWindowClass", GTK_TYPE_ENUM },
{ "GdkImageType", GTK_TYPE_ENUM },
@ -51,3 +55,5 @@
{ "GdkFont", GTK_TYPE_BOXED },
{ "GdkWindow", GTK_TYPE_BOXED },
{ "GdkEvent", GTK_TYPE_BOXED },
{ "GdkColor", GTK_TYPE_BOXED },
{ "GtkTooltips", GTK_TYPE_BOXED },

View File

@ -20,35 +20,41 @@
#define GTK_TYPE_POSITION_TYPE (gtk_type_builtins[17])
#define GTK_TYPE_PREVIEW_TYPE (gtk_type_builtins[18])
#define GTK_TYPE_WIDGET_FLAGS (gtk_type_builtins[19])
#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[20])
#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[21])
#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[22])
#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[23])
#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[24])
#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[25])
#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[26])
#define GTK_TYPE_GDK_FILL (gtk_type_builtins[27])
#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[28])
#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[29])
#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[30])
#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[31])
#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[32])
#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[33])
#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[34])
#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[35])
#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[36])
#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[37])
#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[38])
#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[39])
#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[40])
#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[41])
#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[42])
#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[43])
#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[44])
#define GTK_TYPE_STYLE (gtk_type_builtins[45])
#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[46])
#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[47])
#define GTK_TYPE_GDK_FONT (gtk_type_builtins[48])
#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[49])
#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[50])
#define GTK_TYPE_NUM_BUILTINS 51
#define GTK_TYPE_SELECTION_MODE (gtk_type_builtins[20])
#define GTK_TYPE_CURVE_TYPE (gtk_type_builtins[21])
#define GTK_TYPE_FUNDAMENTAL_TYPE (gtk_type_builtins[22])
#define GTK_TYPE_JUSTIFICATION (gtk_type_builtins[23])
#define GTK_TYPE_GDK_WINDOW_TYPE (gtk_type_builtins[24])
#define GTK_TYPE_GDK_WINDOW_CLASS (gtk_type_builtins[25])
#define GTK_TYPE_GDK_IMAGE_TYPE (gtk_type_builtins[26])
#define GTK_TYPE_GDK_VISUAL_TYPE (gtk_type_builtins[27])
#define GTK_TYPE_GDK_WINDOW_ATTRIBUTES_TYPE (gtk_type_builtins[28])
#define GTK_TYPE_GDK_WINDOW_HINTS (gtk_type_builtins[29])
#define GTK_TYPE_GDK_FUNCTION (gtk_type_builtins[30])
#define GTK_TYPE_GDK_FILL (gtk_type_builtins[31])
#define GTK_TYPE_GDK_LINE_STYLE (gtk_type_builtins[32])
#define GTK_TYPE_GDK_CAP_STYLE (gtk_type_builtins[33])
#define GTK_TYPE_GDK_JOIN_STYLE (gtk_type_builtins[34])
#define GTK_TYPE_GDK_CURSOR_TYPE (gtk_type_builtins[35])
#define GTK_TYPE_GDK_EVENT_TYPE (gtk_type_builtins[36])
#define GTK_TYPE_GDK_EVENT_MASK (gtk_type_builtins[37])
#define GTK_TYPE_GDK_NOTIFY_TYPE (gtk_type_builtins[38])
#define GTK_TYPE_GDK_MODIFIER_TYPE (gtk_type_builtins[39])
#define GTK_TYPE_GDK_SUBWINDOW_MODE (gtk_type_builtins[40])
#define GTK_TYPE_GDK_INPUT_CONDITION (gtk_type_builtins[41])
#define GTK_TYPE_GDK_STATUS (gtk_type_builtins[42])
#define GTK_TYPE_GDK_BYTE_ORDER (gtk_type_builtins[43])
#define GTK_TYPE_GDK_GCVALUES_MASK (gtk_type_builtins[44])
#define GTK_TYPE_GDK_SELECTION (gtk_type_builtins[45])
#define GTK_TYPE_GDK_PROPERTY_STATE (gtk_type_builtins[46])
#define GTK_TYPE_GDK_PROP_MODE (gtk_type_builtins[47])
#define GTK_TYPE_ACCELERATOR_TABLE (gtk_type_builtins[48])
#define GTK_TYPE_STYLE (gtk_type_builtins[49])
#define GTK_TYPE_GDK_COLORMAP (gtk_type_builtins[50])
#define GTK_TYPE_GDK_VISUAL (gtk_type_builtins[51])
#define GTK_TYPE_GDK_FONT (gtk_type_builtins[52])
#define GTK_TYPE_GDK_WINDOW (gtk_type_builtins[53])
#define GTK_TYPE_GDK_EVENT (gtk_type_builtins[54])
#define GTK_TYPE_GDK_COLOR (gtk_type_builtins[55])
#define GTK_TYPE_TOOLTIPS (gtk_type_builtins[56])
#define GTK_TYPE_NUM_BUILTINS 57

View File

@ -145,23 +145,27 @@ gtk_viewport_set_hadjustment (GtkViewport *viewport,
g_return_if_fail (GTK_IS_VIEWPORT (viewport));
g_return_if_fail (adjustment != NULL);
if (viewport->hadjustment)
if (viewport->hadjustment != adjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment), (gpointer) viewport);
gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
if (viewport->hadjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->hadjustment),
(gpointer) viewport);
gtk_object_unref (GTK_OBJECT (viewport->hadjustment));
}
viewport->hadjustment = adjustment;
gtk_object_ref (GTK_OBJECT (viewport->hadjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_viewport_adjustment_changed,
(gpointer) viewport);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc)gtk_viewport_adjustment_value_changed,
(gpointer) viewport);
gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport);
}
viewport->hadjustment = adjustment;
gtk_object_ref (GTK_OBJECT (viewport->hadjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_viewport_adjustment_changed,
(gpointer) viewport);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc) gtk_viewport_adjustment_value_changed,
(gpointer) viewport);
gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport);
}
void
@ -172,23 +176,27 @@ gtk_viewport_set_vadjustment (GtkViewport *viewport,
g_return_if_fail (GTK_IS_VIEWPORT (viewport));
g_return_if_fail (adjustment != NULL);
if (viewport->vadjustment)
if (viewport->vadjustment != adjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment), (gpointer) viewport);
gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
if (viewport->vadjustment)
{
gtk_signal_disconnect_by_data (GTK_OBJECT (viewport->vadjustment),
(gpointer) viewport);
gtk_object_unref (GTK_OBJECT (viewport->vadjustment));
}
viewport->vadjustment = adjustment;
gtk_object_ref (GTK_OBJECT (viewport->vadjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_viewport_adjustment_changed,
(gpointer) viewport);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc)gtk_viewport_adjustment_value_changed,
(gpointer) viewport);
gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport);
}
viewport->vadjustment = adjustment;
gtk_object_ref (GTK_OBJECT (viewport->vadjustment));
gtk_signal_connect (GTK_OBJECT (adjustment), "changed",
(GtkSignalFunc) gtk_viewport_adjustment_changed,
(gpointer) viewport);
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
(GtkSignalFunc) gtk_viewport_adjustment_value_changed,
(gpointer) viewport);
gtk_viewport_adjustment_changed (adjustment, (gpointer) viewport);
}
void

View File

@ -146,7 +146,9 @@ gtk_vscrollbar_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
range->trough = widget->window;
gdk_window_ref (range->trough);
attributes.x = widget->style->klass->xthickness;
attributes.y = widget->style->klass->ythickness;

View File

@ -135,6 +135,8 @@ static GdkColormap* gtk_widget_peek_colormap (void);
static GdkVisual* gtk_widget_peek_visual (void);
static GtkStyle* gtk_widget_peek_style (void);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_set_parent_sensitive (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_propagate_restore (GtkWidget *widget,
@ -730,11 +732,19 @@ gtk_widget_init (GtkWidget *widget)
colormap = gtk_widget_peek_colormap ();
visual = gtk_widget_peek_visual ();
/* XXX - should we ref the colormap and visual, too? */
if (colormap != gtk_widget_get_default_colormap ())
gtk_object_set_data (GTK_OBJECT (widget), colormap_key, colormap);
{
/* gdk_colormap_ref (colormap); */
gtk_object_set_data (GTK_OBJECT (widget), colormap_key, colormap);
}
if (visual != gtk_widget_get_default_visual ())
gtk_object_set_data (GTK_OBJECT (widget), visual_key, visual);
{
/* gdk_visual_ref (visual); */
gtk_object_set_data (GTK_OBJECT (widget), visual_key, visual);
}
}
/*****************************************
@ -1549,6 +1559,26 @@ gtk_widget_activate (GtkWidget *widget)
* results:
*****************************************/
static void
gtk_widget_reparent_container_child(GtkWidget *widget,
gpointer client_data)
{
GtkWidget *new_parent = GTK_WIDGET (client_data);
g_return_if_fail (widget != NULL);
g_return_if_fail (client_data != NULL);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_reparent (widget->window, new_parent->window, 0, 0);
else if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget),
gtk_widget_reparent_container_child,
new_parent);
else
widget->window = new_parent->window;
}
void
gtk_widget_reparent (GtkWidget *widget,
GtkWidget *new_parent)
@ -1559,32 +1589,35 @@ gtk_widget_reparent (GtkWidget *widget,
if (widget->parent != new_parent)
{
gtk_object_ref (GTK_OBJECT (widget));
gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
gtk_object_unref (GTK_OBJECT (widget));
if (GTK_WIDGET_REALIZED (widget))
{
if (GTK_WIDGET_REALIZED (new_parent) && !GTK_WIDGET_NO_WINDOW (widget))
if (GTK_WIDGET_REALIZED (new_parent))
{
gdk_window_reparent (widget->window, widget->parent->window, 0, 0);
if (GTK_WIDGET_NO_WINDOW (widget))
{
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER(widget),
gtk_widget_reparent_container_child,
new_parent);
else
widget->window = widget->parent->window;
}
else
gdk_window_reparent (widget->window, widget->parent->window, 0, 0);
}
else
{
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED);
if (!GTK_WIDGET_NO_WINDOW (widget))
gdk_window_destroy (widget->window);
widget->window = NULL;
if (GTK_WIDGET_REALIZED (new_parent))
gtk_widget_realize (widget);
if (GTK_WIDGET_MAPPED (new_parent))
gtk_widget_map (widget);
}
gtk_widget_unrealize (widget);
}
if (!GTK_WIDGET_REALIZED (widget) && GTK_WIDGET_REALIZED (new_parent))
gtk_widget_realize (widget);
if (!GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_MAPPED (new_parent))
if (GTK_WIDGET_VISIBLE (widget) &&
!GTK_WIDGET_MAPPED (widget) && GTK_WIDGET_MAPPED (new_parent))
gtk_widget_map (widget);
gtk_widget_queue_resize (widget);
@ -2446,9 +2479,14 @@ gtk_widget_pop_style ()
void
gtk_widget_set_default_colormap (GdkColormap *colormap)
{
if (default_colormap && (default_colormap != colormap))
gdk_colormap_destroy (default_colormap);
default_colormap = colormap;
if (default_colormap != colormap)
{
if (default_colormap)
gdk_colormap_unref (default_colormap);
default_colormap = colormap;
if (default_colormap)
gdk_colormap_ref (default_colormap);
}
}
/*****************************************
@ -2476,11 +2514,14 @@ gtk_widget_set_default_visual (GdkVisual *visual)
void
gtk_widget_set_default_style (GtkStyle *style)
{
if (default_style)
gtk_style_unref (default_style);
default_style = style;
gtk_style_ref (default_style);
if (style != default_style)
{
if (default_style)
gtk_style_unref (default_style);
default_style = style;
if (default_style)
gtk_style_ref (default_style);
}
}
/* Basically, send a message to all toplevel windows telling them
@ -2854,7 +2895,7 @@ gtk_real_widget_unrealize (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED | GTK_VISIBLE);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_REALIZED | GTK_MAPPED);
gtk_style_detach (widget->style);
if (!GTK_WIDGET_NO_WINDOW (widget))
@ -3177,7 +3218,6 @@ gtk_widget_set_style_internal (GtkWidget *widget,
gtk_style_detach (widget->style);
gtk_style_unref (widget->style);
widget->style = style;
gtk_style_ref (widget->style);

View File

@ -25,6 +25,7 @@
enum {
MOVE_RESIZE,
SET_FOCUS,
LAST_SIGNAL
};
@ -35,13 +36,18 @@ typedef gint (*GtkWindowSignal1) (GtkObject *object,
gint arg3,
gint arg4,
gpointer data);
typedef void (*GtkWindowSignal2) (GtkObject *object,
gpointer arg1,
gpointer data);
static void gtk_window_marshal_signal_1 (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
static void gtk_window_marshal_signal_2 (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args);
static void gtk_window_class_init (GtkWindowClass *klass);
static void gtk_window_init (GtkWindow *window);
static void gtk_window_arg (GtkWindow *window,
@ -80,6 +86,8 @@ static gint gtk_real_window_move_resize (GtkWindow *window,
gint *y,
gint width,
gint height);
static void gtk_real_window_set_focus (GtkWindow *window,
GtkWidget *focus);
static gint gtk_window_move_resize (GtkWidget *widget);
static void gtk_window_set_hints (GtkWidget *widget,
GtkRequisition *requisition);
@ -144,6 +152,15 @@ gtk_window_class_init (GtkWindowClass *klass)
GTK_TYPE_POINTER, GTK_TYPE_POINTER,
GTK_TYPE_INT, GTK_TYPE_INT);
window_signals[SET_FOCUS] =
gtk_signal_new ("set_focus",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkWindowClass, set_focus),
gtk_window_marshal_signal_2,
GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, window_signals, LAST_SIGNAL);
object_class->destroy = gtk_window_destroy;
@ -168,6 +185,7 @@ gtk_window_class_init (GtkWindowClass *klass)
container_class->need_resize = gtk_window_need_resize;
klass->move_resize = gtk_real_window_move_resize;
klass->set_focus = gtk_real_window_set_focus;
}
static void
@ -270,36 +288,7 @@ void
gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus)
{
GdkEventFocus event;
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
if (focus && !GTK_WIDGET_CAN_FOCUS (focus))
return;
if (window->focus_widget != focus)
{
if (window->focus_widget)
{
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = FALSE;
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
window->focus_widget = focus;
if (window->focus_widget)
{
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = TRUE;
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
}
gtk_signal_emit (GTK_OBJECT (window), window_signals[SET_FOCUS], focus);
}
void
@ -350,7 +339,8 @@ gtk_window_add_accelerator_table (GtkWindow *window,
g_return_if_fail (GTK_IS_WINDOW (window));
gtk_accelerator_table_ref (table);
window->accelerator_tables = g_list_prepend (window->accelerator_tables, table);
window->accelerator_tables = g_list_prepend (window->accelerator_tables,
table);
}
void
@ -360,7 +350,8 @@ gtk_window_remove_accelerator_table (GtkWindow *window,
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
window->accelerator_tables = g_list_remove (window->accelerator_tables, table);
window->accelerator_tables = g_list_remove (window->accelerator_tables,
table);
gtk_accelerator_table_unref (table);
}
@ -394,6 +385,19 @@ gtk_window_marshal_signal_1 (GtkObject *object,
func_data);
}
static void
gtk_window_marshal_signal_2 (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
GtkWindowSignal2 rfunc;
rfunc = (GtkWindowSignal2) func;
(* rfunc) (object, GTK_VALUE_POINTER (args[0]), func_data);
}
static void
gtk_window_destroy (GtkObject *object)
{
@ -1127,6 +1131,42 @@ gtk_window_move_resize (GtkWidget *widget)
return return_val;
}
static void
gtk_real_window_set_focus (GtkWindow *window,
GtkWidget *focus)
{
GdkEventFocus event;
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
if (focus && !GTK_WIDGET_CAN_FOCUS (focus))
return;
if (window->focus_widget != focus)
{
if (window->focus_widget)
{
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = FALSE;
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
window->focus_widget = focus;
if (window->focus_widget)
{
event.type = GDK_FOCUS_CHANGE;
event.window = window->focus_widget->window;
event.in = TRUE;
gtk_widget_event (window->focus_widget, (GdkEvent*) &event);
}
}
}
static void
gtk_window_set_hints (GtkWidget *widget,
GtkRequisition *requisition)

View File

@ -66,6 +66,8 @@ struct _GtkWindowClass
gint *y,
gint width,
gint height);
void (* set_focus) (GtkWindow *window,
GtkWidget *focus);
};

View File

@ -2763,6 +2763,194 @@ create_gamma_curve ()
++count;
}
static int scroll_test_pos = 0.0;
static GdkGC *scroll_test_gc = NULL;
static gint
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
GtkAdjustment *adj)
{
gint i,j;
gint imin, imax, jmin, jmax;
imin = (event->area.x) / 10;
imax = (event->area.x + event->area.width + 9) / 10;
jmin = ((int)adj->value + event->area.y) / 10;
jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10;
gdk_window_clear_area (widget->window,
event->area.x, event->area.y,
event->area.width, event->area.height);
for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++)
if ((i+j) % 2)
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
TRUE,
10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
return TRUE;
}
static void
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj)
{
adj->page_increment = 0.9 * widget->allocation.height;
adj->page_size = widget->allocation.height;
gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed");
}
static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
gint source_min = (int)adj->value - scroll_test_pos;
gint source_max = source_min + widget->allocation.height;
gint dest_min = 0;
gint dest_max = widget->allocation.height;
GdkRectangle rect;
GdkEvent *event;
scroll_test_pos = adj->value;
if (!GTK_WIDGET_DRAWABLE (widget))
return;
if (source_min < 0)
{
rect.x = 0;
rect.y = 0;
rect.width = widget->allocation.width;
rect.height = -source_min;
if (rect.height > widget->allocation.height)
rect.height = widget->allocation.height;
source_min = 0;
dest_min = rect.height;
}
else
{
rect.x = 0;
rect.y = 2*widget->allocation.height - source_max;
if (rect.y < 0)
rect.y = 0;
rect.width = widget->allocation.width;
rect.height = widget->allocation.height - rect.y;
source_max = widget->allocation.height;
dest_max = rect.y;
}
if (source_min != source_max)
{
if (scroll_test_gc == NULL)
{
scroll_test_gc = gdk_gc_new (widget->window);
gdk_gc_set_exposures (scroll_test_gc, TRUE);
}
gdk_draw_pixmap (widget->window,
scroll_test_gc,
widget->window,
0, source_min,
0, dest_min,
widget->allocation.width,
source_max - source_min);
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (widget->window)) != NULL)
{
gtk_widget_event (widget, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
}
if (rect.height != 0)
gtk_widget_draw (widget, &rect);
}
void
create_scroll_test ()
{
static GtkWidget *window = NULL;
GtkWidget *hbox;
GtkWidget *drawing_area;
GtkWidget *scrollbar;
GtkWidget *button;
GtkAdjustment *adj;
if (!window)
{
window = gtk_dialog_new ();
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_window_set_title (GTK_WINDOW (window), "Scroll Test");
gtk_container_border_width (GTK_CONTAINER (window), 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), hbox,
TRUE, TRUE, 0);
gtk_widget_show (hbox);
drawing_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200);
gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
gtk_widget_show (drawing_area);
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK);
adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0));
scroll_test_pos = 0.0;
scrollbar = gtk_vscrollbar_new (adj);
gtk_box_pack_start (GTK_BOX (hbox), scrollbar, FALSE, FALSE, 0);
gtk_widget_show (scrollbar);
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
GTK_SIGNAL_FUNC (scroll_test_expose), adj);
gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
GTK_SIGNAL_FUNC (scroll_test_configure), adj);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (scroll_test_adjustment_changed),
drawing_area);
/* .. And create some buttons */
button = gtk_button_new_with_label ("Quit");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
button, TRUE, TRUE, 0);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
/*
* Timeout Test
@ -3069,6 +3257,7 @@ create_main_window ()
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },
{ "gamma curve", create_gamma_curve },
{ "test scrolling", create_scroll_test },
{ "test selection", create_selection_test },
{ "test timeout", create_timeout_test },
{ "test idle", create_idle_test },

View File

@ -96,9 +96,7 @@ static gint
configure_event (GtkWidget *widget, GdkEventConfigure *event)
{
if (pixmap)
{
gdk_pixmap_destroy(pixmap);
}
gdk_pixmap_unref (pixmap);
pixmap = gdk_pixmap_new(widget->window,
widget->allocation.width,
widget->allocation.height,
@ -186,6 +184,17 @@ button_press_event (GtkWidget *widget, GdkEventButton *event)
return TRUE;
}
static gint
key_press_event (GtkWidget *widget, GdkEventKey *event)
{
if ((event->keyval >= 0x20) && (event->keyval <= 0xFF))
printf("I got a %c\n", event->keyval);
else
printf("I got some other key\n");
return TRUE;
}
static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
@ -338,6 +347,8 @@ main (int argc, char *argv[])
(GtkSignalFunc) motion_notify_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event",
(GtkSignalFunc) button_press_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "key_press_event",
(GtkSignalFunc) key_press_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "leave_notify_event",
(GtkSignalFunc) leave_notify_event, NULL);
@ -347,6 +358,7 @@ main (int argc, char *argv[])
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_KEY_PRESS_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK
| GDK_PROXIMITY_OUT_MASK);
@ -355,6 +367,8 @@ main (int argc, char *argv[])
events for the drawing area */
gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_ALL);
gtk_widget_grab_focus (drawing_area);
/* .. And create some buttons */
button = gtk_button_new_with_label ("Input Dialog");
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

View File

@ -319,6 +319,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
name?name:"<unknown>",
data->type);
position = data->length;
continue;
}
}
gtk_text_insert (GTK_TEXT (selection_text), NULL,

View File

@ -2763,6 +2763,194 @@ create_gamma_curve ()
++count;
}
static int scroll_test_pos = 0.0;
static GdkGC *scroll_test_gc = NULL;
static gint
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
GtkAdjustment *adj)
{
gint i,j;
gint imin, imax, jmin, jmax;
imin = (event->area.x) / 10;
imax = (event->area.x + event->area.width + 9) / 10;
jmin = ((int)adj->value + event->area.y) / 10;
jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10;
gdk_window_clear_area (widget->window,
event->area.x, event->area.y,
event->area.width, event->area.height);
for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++)
if ((i+j) % 2)
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
TRUE,
10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
return TRUE;
}
static void
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj)
{
adj->page_increment = 0.9 * widget->allocation.height;
adj->page_size = widget->allocation.height;
gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed");
}
static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
gint source_min = (int)adj->value - scroll_test_pos;
gint source_max = source_min + widget->allocation.height;
gint dest_min = 0;
gint dest_max = widget->allocation.height;
GdkRectangle rect;
GdkEvent *event;
scroll_test_pos = adj->value;
if (!GTK_WIDGET_DRAWABLE (widget))
return;
if (source_min < 0)
{
rect.x = 0;
rect.y = 0;
rect.width = widget->allocation.width;
rect.height = -source_min;
if (rect.height > widget->allocation.height)
rect.height = widget->allocation.height;
source_min = 0;
dest_min = rect.height;
}
else
{
rect.x = 0;
rect.y = 2*widget->allocation.height - source_max;
if (rect.y < 0)
rect.y = 0;
rect.width = widget->allocation.width;
rect.height = widget->allocation.height - rect.y;
source_max = widget->allocation.height;
dest_max = rect.y;
}
if (source_min != source_max)
{
if (scroll_test_gc == NULL)
{
scroll_test_gc = gdk_gc_new (widget->window);
gdk_gc_set_exposures (scroll_test_gc, TRUE);
}
gdk_draw_pixmap (widget->window,
scroll_test_gc,
widget->window,
0, source_min,
0, dest_min,
widget->allocation.width,
source_max - source_min);
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (widget->window)) != NULL)
{
gtk_widget_event (widget, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
}
if (rect.height != 0)
gtk_widget_draw (widget, &rect);
}
void
create_scroll_test ()
{
static GtkWidget *window = NULL;
GtkWidget *hbox;
GtkWidget *drawing_area;
GtkWidget *scrollbar;
GtkWidget *button;
GtkAdjustment *adj;
if (!window)
{
window = gtk_dialog_new ();
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC(destroy_window),
&window);
gtk_window_set_title (GTK_WINDOW (window), "Scroll Test");
gtk_container_border_width (GTK_CONTAINER (window), 0);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), hbox,
TRUE, TRUE, 0);
gtk_widget_show (hbox);
drawing_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (drawing_area), 200, 200);
gtk_box_pack_start (GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
gtk_widget_show (drawing_area);
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK);
adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 1000.0, 1.0, 180.0, 200.0));
scroll_test_pos = 0.0;
scrollbar = gtk_vscrollbar_new (adj);
gtk_box_pack_start (GTK_BOX (hbox), scrollbar, FALSE, FALSE, 0);
gtk_widget_show (scrollbar);
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
GTK_SIGNAL_FUNC (scroll_test_expose), adj);
gtk_signal_connect (GTK_OBJECT (drawing_area), "configure_event",
GTK_SIGNAL_FUNC (scroll_test_configure), adj);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (scroll_test_adjustment_changed),
drawing_area);
/* .. And create some buttons */
button = gtk_button_new_with_label ("Quit");
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
button, TRUE, TRUE, 0);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
gtk_widget_show (button);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
/*
* Timeout Test
@ -3069,6 +3257,7 @@ create_main_window ()
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },
{ "gamma curve", create_gamma_curve },
{ "test scrolling", create_scroll_test },
{ "test selection", create_selection_test },
{ "test timeout", create_timeout_test },
{ "test idle", create_idle_test },

View File

@ -96,9 +96,7 @@ static gint
configure_event (GtkWidget *widget, GdkEventConfigure *event)
{
if (pixmap)
{
gdk_pixmap_destroy(pixmap);
}
gdk_pixmap_unref (pixmap);
pixmap = gdk_pixmap_new(widget->window,
widget->allocation.width,
widget->allocation.height,
@ -186,6 +184,17 @@ button_press_event (GtkWidget *widget, GdkEventButton *event)
return TRUE;
}
static gint
key_press_event (GtkWidget *widget, GdkEventKey *event)
{
if ((event->keyval >= 0x20) && (event->keyval <= 0xFF))
printf("I got a %c\n", event->keyval);
else
printf("I got some other key\n");
return TRUE;
}
static gint
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
@ -338,6 +347,8 @@ main (int argc, char *argv[])
(GtkSignalFunc) motion_notify_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event",
(GtkSignalFunc) button_press_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "key_press_event",
(GtkSignalFunc) key_press_event, NULL);
gtk_signal_connect (GTK_OBJECT (drawing_area), "leave_notify_event",
(GtkSignalFunc) leave_notify_event, NULL);
@ -347,6 +358,7 @@ main (int argc, char *argv[])
gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_KEY_PRESS_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK
| GDK_PROXIMITY_OUT_MASK);
@ -355,6 +367,8 @@ main (int argc, char *argv[])
events for the drawing area */
gtk_widget_set_extension_events (drawing_area, GDK_EXTENSION_EVENTS_ALL);
gtk_widget_grab_focus (drawing_area);
/* .. And create some buttons */
button = gtk_button_new_with_label ("Input Dialog");
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

View File

@ -319,6 +319,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
name?name:"<unknown>",
data->type);
position = data->length;
continue;
}
}
gtk_text_insert (GTK_TEXT (selection_text), NULL,