diff options
author | Owen Taylor <otaylor@gtk.org> | 1998-05-03 22:41:32 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-05-03 22:41:32 +0000 |
commit | 4851efe29604e1d950dc9711d9d7ced69771f2e9 (patch) | |
tree | ce3b07c7f78836ae33f34479193041f19e9548d6 /gdk | |
parent | c0b92323516fef167517dc9ab645dcfd4075227e (diff) | |
download | gtk+-4851efe29604e1d950dc9711d9d7ced69771f2e9.tar.gz |
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on
Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org>
* configure.in acheader.h gdk/gdkwindow.c
Check for Shape extension both on the client and server
side. (And, more importantly, check for the shape extension
so we may include -lXext even when compiling with --disable-xshm)
Don't set override_redirect on all shaped windows. It isn't
necessary.
* gdk/gdkwindow.c: Set ->colormap to NULL for root
and foreign windows. Use this to check if we
need to get the colormap from X.
Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkbutton.c (gtk_button_paint): Draw the areas
between the default and the button always in GTK_STATE_NORMAL.
* gtk/gtkrange.c (gtk_range_style_set): Added a style_set
callback.
Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]):
Fix a buffer overflow on pixmaps that claim to have
more than 31 characters per pixel.
(gdk_pixmap_read_string): Don't wrap around strings longer
than half of address space ;-)
* gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers
that were used for printing integers.
* */* (almost):
Style: All
int foo () { ... }
changed to
int foo (void) { ... }
^^^^^^^ This is why some many files changed
Even where there were proper prototypes elsewhere.
* gdk/gxid.c (handle_claim_device): Some extra checks.
It isn't safe against being fed bad X id's, but at
least it should be safe against deleting all your
files.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdk.c | 32 | ||||
-rw-r--r-- | gdk/gdkimage.c | 4 | ||||
-rw-r--r-- | gdk/gdkinput.c | 2 | ||||
-rw-r--r-- | gdk/gdkinputnone.h | 2 | ||||
-rw-r--r-- | gdk/gdkinputxfree.h | 4 | ||||
-rw-r--r-- | gdk/gdkpixmap.c | 20 | ||||
-rw-r--r-- | gdk/gdkvisual.c | 10 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 79 | ||||
-rw-r--r-- | gdk/gxid.c | 47 | ||||
-rw-r--r-- | gdk/x11/gdkimage-x11.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkinput-none.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkinput-xfree.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkinput.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 32 | ||||
-rw-r--r-- | gdk/x11/gdkpixmap-x11.c | 20 | ||||
-rw-r--r-- | gdk/x11/gdkvisual-x11.c | 10 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 79 | ||||
-rw-r--r-- | gdk/x11/gxid.c | 47 |
18 files changed, 252 insertions, 148 deletions
@@ -625,7 +625,7 @@ gdk_exit (int errorcode) */ gchar* -gdk_set_locale () +gdk_set_locale (void) { if (!setlocale (LC_ALL,"")) g_print ("locale not supported by C library\n"); @@ -663,7 +663,7 @@ gdk_set_locale () */ gint -gdk_events_pending () +gdk_events_pending (void) { gint result; GList *tmp_list; @@ -1023,13 +1023,13 @@ gdk_set_use_xshm (gint use_xshm) } gint -gdk_get_show_events () +gdk_get_show_events (void) { return gdk_debug_flags & GDK_DEBUG_EVENTS; } gint -gdk_get_use_xshm () +gdk_get_use_xshm (void) { return gdk_use_xshm; } @@ -1055,7 +1055,7 @@ gdk_get_use_xshm () */ guint32 -gdk_time_get () +gdk_time_get (void) { struct timeval end; struct timeval elapsed; @@ -1094,7 +1094,7 @@ gdk_time_get () */ guint32 -gdk_timer_get () +gdk_timer_get (void) { return timer_val; } @@ -1129,13 +1129,13 @@ gdk_timer_set (guint32 milliseconds) } void -gdk_timer_enable () +gdk_timer_enable (void) { timerp = &timer; } void -gdk_timer_disable () +gdk_timer_disable (void) { timerp = NULL; } @@ -1463,7 +1463,7 @@ gdk_keyboard_ungrab (guint32 time) */ gint -gdk_screen_width () +gdk_screen_width (void) { gint return_val; @@ -1488,7 +1488,7 @@ gdk_screen_width () */ gint -gdk_screen_height () +gdk_screen_height (void) { gint return_val; @@ -1498,13 +1498,13 @@ gdk_screen_height () } void -gdk_key_repeat_disable () +gdk_key_repeat_disable (void) { XAutoRepeatOff (gdk_display); } void -gdk_key_repeat_restore () +gdk_key_repeat_restore (void) { if (autorepeat) XAutoRepeatOn (gdk_display); @@ -1531,14 +1531,14 @@ gdk_key_repeat_restore () *-------------------------------------------------------------- */ -void gdk_flush () +void gdk_flush (void) { XSync (gdk_display, False); } void -gdk_beep () +gdk_beep (void) { XBell(gdk_display, 100); } @@ -1562,7 +1562,7 @@ gdk_beep () */ static gint -gdk_event_wait () +gdk_event_wait (void) { GList *list; GdkInput *input; @@ -3028,7 +3028,7 @@ gdk_synthesize_click (GdkEvent *event, */ static void -gdk_exit_func () +gdk_exit_func (void) { static gboolean in_gdk_exit_func = FALSE; diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c index 82c5421227..c31ab4e5be 100644 --- a/gdk/gdkimage.c +++ b/gdk/gdkimage.c @@ -64,7 +64,7 @@ static GList *image_list = NULL; void -gdk_image_exit () +gdk_image_exit (void) { GdkImage *image; @@ -131,7 +131,7 @@ gdk_image_check_xshm(Display *display) } void -gdk_image_init () +gdk_image_init (void) { if (gdk_use_xshm) { diff --git a/gdk/gdkinput.c b/gdk/gdkinput.c index e47f2205ff..491131ca27 100644 --- a/gdk/gdkinput.c +++ b/gdk/gdkinput.c @@ -70,7 +70,7 @@ static GList *gdk_input_windows; #include "gdkinputgxi.h" GList * -gdk_input_list_devices () +gdk_input_list_devices (void) { return gdk_input_devices; } diff --git a/gdk/gdkinputnone.h b/gdk/gdkinputnone.h index 44bd8d0378..aa0cc0b0bc 100644 --- a/gdk/gdkinputnone.h +++ b/gdk/gdkinputnone.h @@ -29,7 +29,7 @@ static void gdk_input_none_get_pointer (GdkWindow *window, GdkModifierType *mask); void -gdk_input_init () +gdk_input_init (void) { gdk_input_vtable.set_mode = NULL; gdk_input_vtable.set_axes = NULL; diff --git a/gdk/gdkinputxfree.h b/gdk/gdkinputxfree.h index efc728cb0b..c0411a4fea 100644 --- a/gdk/gdkinputxfree.h +++ b/gdk/gdkinputxfree.h @@ -22,7 +22,7 @@ /* forward declarations */ static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode); -static void gdk_input_check_proximity(); +static void gdk_input_check_proximity (void); static void gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window); static void gdk_input_xfree_enter_event (XCrossingEvent *xevent, @@ -115,7 +115,7 @@ gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode) } static void -gdk_input_check_proximity() +gdk_input_check_proximity (void) { gint new_proximity = 0; GList *tmp_list = gdk_input_devices; diff --git a/gdk/gdkpixmap.c b/gdk/gdkpixmap.c index a1af21542e..2f2cdea4c0 100644 --- a/gdk/gdkpixmap.c +++ b/gdk/gdkpixmap.c @@ -256,8 +256,14 @@ gdk_pixmap_read_string (FILE *infile, { if (cnt == (*buffer_size)) { - (*buffer_size) *= 2; - (*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); } + guint new_size = (*buffer_size) * 2; + if (new_size > (*buffer_size)) + *buffer_size = new_size; + else + return FALSE; + + (*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); + } if (c != '"') (*buffer)[cnt++] = c; @@ -399,6 +405,11 @@ gdk_pixmap_colormap_create_from_xpm (GdkWindow *window, gdk_pixmap_read_string (infile, &buffer, &buffer_size); sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp); + if (cpp >= 32) + { + g_warning ("Pixmap has more than 31 characters per color\n"); + return NULL; + } colors = g_new(_GdkPixmapColor, num_cols); @@ -574,6 +585,11 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window, i = 0; buffer = data[i++]; sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp); + if (cpp >= 32) + { + g_warning ("Pixmap has more than 31 characters per color\n"); + return NULL; + } colors = g_new(_GdkPixmapColor, num_cols); diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c index 90ca5cfe78..a6a8b2b134 100644 --- a/gdk/gdkvisual.c +++ b/gdk/gdkvisual.c @@ -58,7 +58,7 @@ static gchar* visual_names[] = static GHashTable *visual_hash = NULL; void -gdk_visual_init () +gdk_visual_init (void) { static gint possible_depths[6] = { 32, 24, 16, 15, 8, 1 }; static GdkVisualType possible_types[6] = @@ -263,25 +263,25 @@ gdk_visual_unref (GdkVisual *visual) } gint -gdk_visual_get_best_depth () +gdk_visual_get_best_depth (void) { return available_depths[0]; } GdkVisualType -gdk_visual_get_best_type () +gdk_visual_get_best_type (void) { return available_types[0]; } GdkVisual* -gdk_visual_get_system () +gdk_visual_get_system (void) { return ((GdkVisual*) system_visual); } GdkVisual* -gdk_visual_get_best () +gdk_visual_get_best (void) { return ((GdkVisual*) &(visuals[0])); } diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 6df4e07b36..7836f27077 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -20,7 +20,6 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> -#include <X11/extensions/shape.h> #include <netinet/in.h> #include "gdk.h" #include "../config.h" @@ -30,6 +29,10 @@ #include <stdlib.h> #include <stdio.h> +#ifdef HAVE_SHAPE_EXT +#include <X11/extensions/shape.h> +#endif + int nevent_masks = 17; int event_mask_table[19] = { @@ -172,7 +175,7 @@ gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child) } void -gdk_window_init () +gdk_window_init (void) { XWindowAttributes xattributes; unsigned int width; @@ -192,6 +195,7 @@ gdk_window_init () gdk_root_parent.width = width; gdk_root_parent.height = height; gdk_root_parent.children = NULL; + gdk_root_parent.colormap = NULL; } GdkWindow* @@ -472,6 +476,7 @@ gdk_window_foreign_new (guint32 anid) private->destroyed = FALSE; private->extension_events = 0; + private->colormap = NULL; private->dnd_drag_data_type = None; private->dnd_drag_data_typesavail = @@ -1195,8 +1200,7 @@ gdk_window_get_visual (GdkWindow *window) if (window_private && !window_private->destroyed) { - if ((window_private->window_type == GDK_WINDOW_FOREIGN)|| - (window_private->xwindow==DefaultRootWindow(window_private->xdisplay))) + if (window_private->colormap == NULL) { XGetWindowAttributes (window_private->xdisplay, window_private->xwindow, @@ -1222,8 +1226,7 @@ gdk_window_get_colormap (GdkWindow *window) g_return_val_if_fail (window_private->window_type != GDK_WINDOW_PIXMAP, NULL); if (!window_private->destroyed) { - if ((window_private->window_type == GDK_WINDOW_FOREIGN)|| - (window_private->xwindow==DefaultRootWindow(window_private->xdisplay))) + if (window_private->colormap == NULL) { XGetWindowAttributes (window_private->xdisplay, window_private->xwindow, @@ -1479,8 +1482,7 @@ gdk_window_add_colormap_windows (GdkWindow *window) /* * This needs the X11 shape extension. - * If not available, simply remove the call to - * XShapeCombineMask. Shaped windows will look + * If not available, shaped windows will look * ugly, but programs still work. Stefan Wille */ void @@ -1488,38 +1490,53 @@ gdk_window_shape_combine_mask (GdkWindow *window, GdkBitmap *mask, gint x, gint y) { + enum { UNKNOWN, NO, YES }; + + static gint have_shape = UNKNOWN; + GdkWindowPrivate *window_private; Pixmap pixmap; g_return_if_fail (window != NULL); - /* This is needed, according to raster */ - gdk_window_set_override_redirect(window, TRUE); - - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) - return; - - if (mask) +#ifdef HAVE_SHAPE_EXT + if (have_shape == UNKNOWN) { - GdkWindowPrivate *pixmap_private; - - pixmap_private = (GdkWindowPrivate*) mask; - pixmap = (Pixmap) pixmap_private->xwindow; + int ignore; + if (XQueryExtension(gdk_display, "SHAPE", &ignore, &ignore, &ignore)) + have_shape = YES; + else + have_shape = NO; } - else + + if (have_shape == YES) { - x = 0; - y = 0; - pixmap = None; + window_private = (GdkWindowPrivate*) window; + if (window_private->destroyed) + return; + + if (mask) + { + GdkWindowPrivate *pixmap_private; + + pixmap_private = (GdkWindowPrivate*) mask; + pixmap = (Pixmap) pixmap_private->xwindow; + } + else + { + x = 0; + y = 0; + pixmap = None; + } + + XShapeCombineMask (window_private->xdisplay, + window_private->xwindow, + ShapeBounding, + x, y, + pixmap, + ShapeSet); } - - XShapeCombineMask (window_private->xdisplay, - window_private->xwindow, - ShapeBounding, - x, y, - pixmap, - ShapeSet); +#endif /* HAVE_SHAPE_EXT */ } void diff --git a/gdk/gxid.c b/gdk/gxid.c index 219c08bfe0..40b48fa31c 100644 --- a/gdk/gxid.c +++ b/gdk/gxid.c @@ -61,7 +61,7 @@ handler(int signal) } void -init_socket() +init_socket(void) { struct sockaddr_in sin; @@ -130,7 +130,7 @@ enable_device(GxidDevice *dev) /* switch the core pointer from whatever it is now to something else, return true on success, false otherwise */ static int -switch_core_pointer() +switch_core_pointer(void) { GxidDevice *old_pointer = 0; GxidDevice *new_pointer = 0; @@ -222,7 +222,7 @@ init_device(XDeviceInfo *xdevice) } void -init_xinput() +init_xinput(void) { char **extensions; XDeviceInfo *xdevices; @@ -279,12 +279,22 @@ int handle_claim_device(GxidClaimDevice *msg) { int i,j; - XID devid = ntohl(msg->device); - XID winid = ntohl(msg->window); - int exclusive = ntohl(msg->exclusive); + XID devid; + XID winid; + int exclusive; GxidDevice *device = NULL; GxidWindow *window = NULL; + if (msg->length != sizeof(GxidClaimDevice)) + { + fprintf(stderr,"Bad length for ClaimDevice message\n"); + return GXID_RETURN_ERROR; + } + + devid = ntohl(msg->device); + winid = ntohl(msg->window); + exclusive = ntohl(msg->exclusive); + #ifdef DEBUG_CLIENTS fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid); #endif @@ -397,11 +407,20 @@ int handle_release_device(GxidReleaseDevice *msg) { int i,j; - XID devid = ntohl(msg->device); - XID winid = ntohl(msg->window); + XID devid; + XID winid; GxidDevice *device = NULL; + if (msg->length != sizeof(GxidReleaseDevice)) + { + fprintf(stderr,"Bad length for ReleaseDevice message\n"); + return GXID_RETURN_ERROR; + } + + devid = ntohl(msg->device); + winid = ntohl(msg->window); + #ifdef DEBUG_CLIENTS fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid); #endif @@ -460,11 +479,11 @@ handle_release_device(GxidReleaseDevice *msg) } void -handle_connection() +handle_connection (void) { GxidMessage msg; GxidU32 type; - int length; + GxidU32 length; GxidI32 retval; int conn_fd; @@ -496,7 +515,7 @@ handle_connection() /* read rest of message */ - if (length > sizeof(GxidMessage)) + if ((length > sizeof(GxidMessage)) || (length < 2*sizeof(GxidU32))) { fprintf(stderr,"%s: Bad message length\n", program_name); @@ -689,7 +708,7 @@ handle_destroy_notify(XDestroyWindowEvent *event) } void -handle_xevent() +handle_xevent(void) { int i; XEvent event; @@ -743,7 +762,7 @@ handle_xevent() } void -usage() +usage(void) { fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n", program_name); @@ -833,7 +852,7 @@ main(int argc, char **argv) } if (FD_ISSET(socket_fd,&readfds)) - handle_connection(socket_fd); + handle_connection(); while (XPending(dpy)) handle_xevent(); diff --git a/gdk/x11/gdkimage-x11.c b/gdk/x11/gdkimage-x11.c index 82c5421227..c31ab4e5be 100644 --- a/gdk/x11/gdkimage-x11.c +++ b/gdk/x11/gdkimage-x11.c @@ -64,7 +64,7 @@ static GList *image_list = NULL; void -gdk_image_exit () +gdk_image_exit (void) { GdkImage *image; @@ -131,7 +131,7 @@ gdk_image_check_xshm(Display *display) } void -gdk_image_init () +gdk_image_init (void) { if (gdk_use_xshm) { diff --git a/gdk/x11/gdkinput-none.c b/gdk/x11/gdkinput-none.c index 44bd8d0378..aa0cc0b0bc 100644 --- a/gdk/x11/gdkinput-none.c +++ b/gdk/x11/gdkinput-none.c @@ -29,7 +29,7 @@ static void gdk_input_none_get_pointer (GdkWindow *window, GdkModifierType *mask); void -gdk_input_init () +gdk_input_init (void) { gdk_input_vtable.set_mode = NULL; gdk_input_vtable.set_axes = NULL; diff --git a/gdk/x11/gdkinput-xfree.c b/gdk/x11/gdkinput-xfree.c index efc728cb0b..c0411a4fea 100644 --- a/gdk/x11/gdkinput-xfree.c +++ b/gdk/x11/gdkinput-xfree.c @@ -22,7 +22,7 @@ /* forward declarations */ static gint gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode); -static void gdk_input_check_proximity(); +static void gdk_input_check_proximity (void); static void gdk_input_xfree_configure_event (XConfigureEvent *xevent, GdkWindow *window); static void gdk_input_xfree_enter_event (XCrossingEvent *xevent, @@ -115,7 +115,7 @@ gdk_input_xfree_set_mode (guint32 deviceid, GdkInputMode mode) } static void -gdk_input_check_proximity() +gdk_input_check_proximity (void) { gint new_proximity = 0; GList *tmp_list = gdk_input_devices; diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c index e47f2205ff..491131ca27 100644 --- a/gdk/x11/gdkinput.c +++ b/gdk/x11/gdkinput.c @@ -70,7 +70,7 @@ static GList *gdk_input_windows; #include "gdkinputgxi.h" GList * -gdk_input_list_devices () +gdk_input_list_devices (void) { return gdk_input_devices; } diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 30b11087b0..68e9b98a21 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -625,7 +625,7 @@ gdk_exit (int errorcode) */ gchar* -gdk_set_locale () +gdk_set_locale (void) { if (!setlocale (LC_ALL,"")) g_print ("locale not supported by C library\n"); @@ -663,7 +663,7 @@ gdk_set_locale () */ gint -gdk_events_pending () +gdk_events_pending (void) { gint result; GList *tmp_list; @@ -1023,13 +1023,13 @@ gdk_set_use_xshm (gint use_xshm) } gint -gdk_get_show_events () +gdk_get_show_events (void) { return gdk_debug_flags & GDK_DEBUG_EVENTS; } gint -gdk_get_use_xshm () +gdk_get_use_xshm (void) { return gdk_use_xshm; } @@ -1055,7 +1055,7 @@ gdk_get_use_xshm () */ guint32 -gdk_time_get () +gdk_time_get (void) { struct timeval end; struct timeval elapsed; @@ -1094,7 +1094,7 @@ gdk_time_get () */ guint32 -gdk_timer_get () +gdk_timer_get (void) { return timer_val; } @@ -1129,13 +1129,13 @@ gdk_timer_set (guint32 milliseconds) } void -gdk_timer_enable () +gdk_timer_enable (void) { timerp = &timer; } void -gdk_timer_disable () +gdk_timer_disable (void) { timerp = NULL; } @@ -1463,7 +1463,7 @@ gdk_keyboard_ungrab (guint32 time) */ gint -gdk_screen_width () +gdk_screen_width (void) { gint return_val; @@ -1488,7 +1488,7 @@ gdk_screen_width () */ gint -gdk_screen_height () +gdk_screen_height (void) { gint return_val; @@ -1498,13 +1498,13 @@ gdk_screen_height () } void -gdk_key_repeat_disable () +gdk_key_repeat_disable (void) { XAutoRepeatOff (gdk_display); } void -gdk_key_repeat_restore () +gdk_key_repeat_restore (void) { if (autorepeat) XAutoRepeatOn (gdk_display); @@ -1531,14 +1531,14 @@ gdk_key_repeat_restore () *-------------------------------------------------------------- */ -void gdk_flush () +void gdk_flush (void) { XSync (gdk_display, False); } void -gdk_beep () +gdk_beep (void) { XBell(gdk_display, 100); } @@ -1562,7 +1562,7 @@ gdk_beep () */ static gint -gdk_event_wait () +gdk_event_wait (void) { GList *list; GdkInput *input; @@ -3028,7 +3028,7 @@ gdk_synthesize_click (GdkEvent *event, */ static void -gdk_exit_func () +gdk_exit_func (void) { static gboolean in_gdk_exit_func = FALSE; diff --git a/gdk/x11/gdkpixmap-x11.c b/gdk/x11/gdkpixmap-x11.c index a1af21542e..2f2cdea4c0 100644 --- a/gdk/x11/gdkpixmap-x11.c +++ b/gdk/x11/gdkpixmap-x11.c @@ -256,8 +256,14 @@ gdk_pixmap_read_string (FILE *infile, { if (cnt == (*buffer_size)) { - (*buffer_size) *= 2; - (*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); } + guint new_size = (*buffer_size) * 2; + if (new_size > (*buffer_size)) + *buffer_size = new_size; + else + return FALSE; + + (*buffer) = (gchar *) g_realloc ((*buffer), *buffer_size); + } if (c != '"') (*buffer)[cnt++] = c; @@ -399,6 +405,11 @@ gdk_pixmap_colormap_create_from_xpm (GdkWindow *window, gdk_pixmap_read_string (infile, &buffer, &buffer_size); sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp); + if (cpp >= 32) + { + g_warning ("Pixmap has more than 31 characters per color\n"); + return NULL; + } colors = g_new(_GdkPixmapColor, num_cols); @@ -574,6 +585,11 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window, i = 0; buffer = data[i++]; sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp); + if (cpp >= 32) + { + g_warning ("Pixmap has more than 31 characters per color\n"); + return NULL; + } colors = g_new(_GdkPixmapColor, num_cols); diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index 90ca5cfe78..a6a8b2b134 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -58,7 +58,7 @@ static gchar* visual_names[] = static GHashTable *visual_hash = NULL; void -gdk_visual_init () +gdk_visual_init (void) { static gint possible_depths[6] = { 32, 24, 16, 15, 8, 1 }; static GdkVisualType possible_types[6] = @@ -263,25 +263,25 @@ gdk_visual_unref (GdkVisual *visual) } gint -gdk_visual_get_best_depth () +gdk_visual_get_best_depth (void) { return available_depths[0]; } GdkVisualType -gdk_visual_get_best_type () +gdk_visual_get_best_type (void) { return available_types[0]; } GdkVisual* -gdk_visual_get_system () +gdk_visual_get_system (void) { return ((GdkVisual*) system_visual); } GdkVisual* -gdk_visual_get_best () +gdk_visual_get_best (void) { return ((GdkVisual*) &(visuals[0])); } diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 6df4e07b36..7836f27077 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -20,7 +20,6 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> -#include <X11/extensions/shape.h> #include <netinet/in.h> #include "gdk.h" #include "../config.h" @@ -30,6 +29,10 @@ #include <stdlib.h> #include <stdio.h> +#ifdef HAVE_SHAPE_EXT +#include <X11/extensions/shape.h> +#endif + int nevent_masks = 17; int event_mask_table[19] = { @@ -172,7 +175,7 @@ gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child) } void -gdk_window_init () +gdk_window_init (void) { XWindowAttributes xattributes; unsigned int width; @@ -192,6 +195,7 @@ gdk_window_init () gdk_root_parent.width = width; gdk_root_parent.height = height; gdk_root_parent.children = NULL; + gdk_root_parent.colormap = NULL; } GdkWindow* @@ -472,6 +476,7 @@ gdk_window_foreign_new (guint32 anid) private->destroyed = FALSE; private->extension_events = 0; + private->colormap = NULL; private->dnd_drag_data_type = None; private->dnd_drag_data_typesavail = @@ -1195,8 +1200,7 @@ gdk_window_get_visual (GdkWindow *window) if (window_private && !window_private->destroyed) { - if ((window_private->window_type == GDK_WINDOW_FOREIGN)|| - (window_private->xwindow==DefaultRootWindow(window_private->xdisplay))) + if (window_private->colormap == NULL) { XGetWindowAttributes (window_private->xdisplay, window_private->xwindow, @@ -1222,8 +1226,7 @@ gdk_window_get_colormap (GdkWindow *window) g_return_val_if_fail (window_private->window_type != GDK_WINDOW_PIXMAP, NULL); if (!window_private->destroyed) { - if ((window_private->window_type == GDK_WINDOW_FOREIGN)|| - (window_private->xwindow==DefaultRootWindow(window_private->xdisplay))) + if (window_private->colormap == NULL) { XGetWindowAttributes (window_private->xdisplay, window_private->xwindow, @@ -1479,8 +1482,7 @@ gdk_window_add_colormap_windows (GdkWindow *window) /* * This needs the X11 shape extension. - * If not available, simply remove the call to - * XShapeCombineMask. Shaped windows will look + * If not available, shaped windows will look * ugly, but programs still work. Stefan Wille */ void @@ -1488,38 +1490,53 @@ gdk_window_shape_combine_mask (GdkWindow *window, GdkBitmap *mask, gint x, gint y) { + enum { UNKNOWN, NO, YES }; + + static gint have_shape = UNKNOWN; + GdkWindowPrivate *window_private; Pixmap pixmap; g_return_if_fail (window != NULL); - /* This is needed, according to raster */ - gdk_window_set_override_redirect(window, TRUE); - - window_private = (GdkWindowPrivate*) window; - if (window_private->destroyed) - return; - - if (mask) +#ifdef HAVE_SHAPE_EXT + if (have_shape == UNKNOWN) { - GdkWindowPrivate *pixmap_private; - - pixmap_private = (GdkWindowPrivate*) mask; - pixmap = (Pixmap) pixmap_private->xwindow; + int ignore; + if (XQueryExtension(gdk_display, "SHAPE", &ignore, &ignore, &ignore)) + have_shape = YES; + else + have_shape = NO; } - else + + if (have_shape == YES) { - x = 0; - y = 0; - pixmap = None; + window_private = (GdkWindowPrivate*) window; + if (window_private->destroyed) + return; + + if (mask) + { + GdkWindowPrivate *pixmap_private; + + pixmap_private = (GdkWindowPrivate*) mask; + pixmap = (Pixmap) pixmap_private->xwindow; + } + else + { + x = 0; + y = 0; + pixmap = None; + } + + XShapeCombineMask (window_private->xdisplay, + window_private->xwindow, + ShapeBounding, + x, y, + pixmap, + ShapeSet); } - - XShapeCombineMask (window_private->xdisplay, - window_private->xwindow, - ShapeBounding, - x, y, - pixmap, - ShapeSet); +#endif /* HAVE_SHAPE_EXT */ } void diff --git a/gdk/x11/gxid.c b/gdk/x11/gxid.c index 219c08bfe0..40b48fa31c 100644 --- a/gdk/x11/gxid.c +++ b/gdk/x11/gxid.c @@ -61,7 +61,7 @@ handler(int signal) } void -init_socket() +init_socket(void) { struct sockaddr_in sin; @@ -130,7 +130,7 @@ enable_device(GxidDevice *dev) /* switch the core pointer from whatever it is now to something else, return true on success, false otherwise */ static int -switch_core_pointer() +switch_core_pointer(void) { GxidDevice *old_pointer = 0; GxidDevice *new_pointer = 0; @@ -222,7 +222,7 @@ init_device(XDeviceInfo *xdevice) } void -init_xinput() +init_xinput(void) { char **extensions; XDeviceInfo *xdevices; @@ -279,12 +279,22 @@ int handle_claim_device(GxidClaimDevice *msg) { int i,j; - XID devid = ntohl(msg->device); - XID winid = ntohl(msg->window); - int exclusive = ntohl(msg->exclusive); + XID devid; + XID winid; + int exclusive; GxidDevice *device = NULL; GxidWindow *window = NULL; + if (msg->length != sizeof(GxidClaimDevice)) + { + fprintf(stderr,"Bad length for ClaimDevice message\n"); + return GXID_RETURN_ERROR; + } + + devid = ntohl(msg->device); + winid = ntohl(msg->window); + exclusive = ntohl(msg->exclusive); + #ifdef DEBUG_CLIENTS fprintf(stderr,"device %ld claimed (window 0x%lx)\n",devid,winid); #endif @@ -397,11 +407,20 @@ int handle_release_device(GxidReleaseDevice *msg) { int i,j; - XID devid = ntohl(msg->device); - XID winid = ntohl(msg->window); + XID devid; + XID winid; GxidDevice *device = NULL; + if (msg->length != sizeof(GxidReleaseDevice)) + { + fprintf(stderr,"Bad length for ReleaseDevice message\n"); + return GXID_RETURN_ERROR; + } + + devid = ntohl(msg->device); + winid = ntohl(msg->window); + #ifdef DEBUG_CLIENTS fprintf(stderr,"device %ld released (window 0x%lx)\n",devid,winid); #endif @@ -460,11 +479,11 @@ handle_release_device(GxidReleaseDevice *msg) } void -handle_connection() +handle_connection (void) { GxidMessage msg; GxidU32 type; - int length; + GxidU32 length; GxidI32 retval; int conn_fd; @@ -496,7 +515,7 @@ handle_connection() /* read rest of message */ - if (length > sizeof(GxidMessage)) + if ((length > sizeof(GxidMessage)) || (length < 2*sizeof(GxidU32))) { fprintf(stderr,"%s: Bad message length\n", program_name); @@ -689,7 +708,7 @@ handle_destroy_notify(XDestroyWindowEvent *event) } void -handle_xevent() +handle_xevent(void) { int i; XEvent event; @@ -743,7 +762,7 @@ handle_xevent() } void -usage() +usage(void) { fprintf(stderr,"Usage: %s [-d display] [-p --gxid-port port]\n", program_name); @@ -833,7 +852,7 @@ main(int argc, char **argv) } if (FD_ISSET(socket_fd,&readfds)) - handle_connection(socket_fd); + handle_connection(); while (XPending(dpy)) handle_xevent(); |