From be698675c7c043e3161362b99b9dc656531c91b4 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 13 Nov 2000 17:40:23 +0000 Subject: [PATCH] Cleanup and reindent of GtkFB. Added some serial mouse support. Updates to latest Gtk+/pango --- ChangeLog | 52 ++ ChangeLog.pre-2-0 | 52 ++ ChangeLog.pre-2-10 | 52 ++ ChangeLog.pre-2-2 | 52 ++ ChangeLog.pre-2-4 | 52 ++ ChangeLog.pre-2-6 | 52 ++ ChangeLog.pre-2-8 | 52 ++ gdk/linux-fb/gdkcc-fb.c | 14 +- gdk/linux-fb/gdkcolor-fb.c | 171 +++--- gdk/linux-fb/gdkcursor-fb.c | 51 +- gdk/linux-fb/gdkdnd-fb.c | 29 +- gdk/linux-fb/gdkdrawable-fb2.c | 1014 +++++++++++++++++--------------- gdk/linux-fb/gdkevents-fb.c | 87 +-- gdk/linux-fb/gdkfont-fb.c | 21 +- gdk/linux-fb/gdkgc-fb.c | 268 +++++---- gdk/linux-fb/gdkgeometry-fb.c | 41 +- gdk/linux-fb/gdkimage-fb.c | 67 ++- gdk/linux-fb/gdkinput-ps2.c | 813 ++++++++++++++----------- gdk/linux-fb/gdkinput.c | 37 +- gdk/linux-fb/gdkmain-fb.c | 271 ++++----- gdk/linux-fb/gdkpango-fb.c | 332 +++++------ gdk/linux-fb/gdkpixmap-fb.c | 25 +- gdk/linux-fb/gdkprivate-fb.h | 19 +- gdk/linux-fb/gdkproperty-fb.c | 78 +-- gdk/linux-fb/gdkvisual-fb.c | 36 +- gdk/linux-fb/gdkwindow-fb.c | 697 +++++++++++----------- gdk/linux-fb/mitypes.h | 442 -------------- modules/linux-fb/basic.c | 6 +- 28 files changed, 2539 insertions(+), 2344 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d4b2a4f709..4ea80557cc 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,55 @@ +2000-11-13 Alexander Larsson + + * gdk/linux-fb/*.[ch]: + Massive reindent to gtk+ standard. My hands hurt. + + * gdk/linux-fb/gdkcolor-fb.c: + Move GdkColorPrivateFB from inherited to windowing_data + + * gdk/linux-fb/gdkcursor-fb.c: + _gdk_cursor_new_from_pixmap made static + + * gdk/linux-fb/gdkdnd-fb.c: + GdkDragContextPrivate moved to windowing_data + + * gdk/linux-fb/gdkdrawable-fb2.c: + Removed endian.h, use glib endianness macros instead + Some cleanups in the usage of GDK_DRAWABLE_FBDATA + and GDK_DRAWABLE_IMPL_FBDATA + + * gdk/linux-fb/gdkfont-fb.c: + Add empty gdk_font_load(). Needed for linking of Gtk+. + + * gdk/linux-fb/gdkimage-fb.c: + Removed endian.h, use glib endianness macros instead + Moved GdkImagePrivateFB to windowing_data + gdk_image_new_bitmap didn't always allocate enough + memory. + + * gdk/linux-fb/gdkinput-ps2.c: + Added semi-working support for MS serial mice. + + * gdk/linux-fb/gdkprivate-fb.h: + s/GdkWindowPrivate/GdkWindowObject/ + Removed GdkWindowPrivate typedef + s/GDK_DRAWABLE_P/GDK_DRAWABLE_FBDATA/ + Removed GDK_DRAWABLE_P + Move GdkColorPrivateFB from inherited to windowing_data + Moved GdkImagePrivateFB to windowing_data + + * gdk/linux-fb/gdkvisual-fb.c: + Removed some unused debug code. + + * gdk/linux-fb/gdkwindow-fb.c: + Use stock cursors instead of including X headers. + s/GdkWindowPrivate/GdkWindowObject/ + + * gdk/linux-fb/mitypes.h: + Removed unused types. + + * modules/linux-fb/basic.c: + Use the pango fribidi wrappers. + 2000-11-13 Sebastian Wilhelmi * gdk/linux-fb/gdkcolor-fb.c, gdk/nanox/gdkmain-nanox.c, diff --git a/gdk/linux-fb/gdkcc-fb.c b/gdk/linux-fb/gdkcc-fb.c index 234614a6e3..e8a98644b0 100644 --- a/gdk/linux-fb/gdkcc-fb.c +++ b/gdk/linux-fb/gdkcc-fb.c @@ -127,7 +127,7 @@ my_x_query_colors (GdkColormap *colormap, for (i = 0; i < ncolors; i++) { pixel = colors[i].pixel; - switch(colormap->visual->depth) + switch (colormap->visual->depth) { case 8: colors[i] = colormap->colors[pixel]; @@ -143,7 +143,7 @@ my_x_query_colors (GdkColormap *colormap, << (16 - colormap->visual->blue_prec - colormap->visual->blue_shift); break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } } @@ -243,10 +243,10 @@ init_gray (GdkColorContext *cc) { GdkColor colr; - gdk_color_white(cc->colormap, &colr); + gdk_color_white (cc->colormap, &colr); cc->white_pixel = colr.pixel; - gdk_color_black(cc->colormap, &colr); + gdk_color_black (cc->colormap, &colr); cc->black_pixel = colr.pixel; } @@ -277,9 +277,9 @@ init_color (GdkColorContext *cc) ccp->blue_mult = 1; ccp->base_pixel = 0; - gdk_color_white(cc->colormap, &colr); + gdk_color_white (cc->colormap, &colr); cc->white_pixel = colr.pixel; - gdk_color_black(cc->colormap, &colr); + gdk_color_black (cc->colormap, &colr); cc->black_pixel = colr.pixel; cc->num_colors = cc->visual->colormap_size; @@ -1503,7 +1503,7 @@ gdk_color_context_add_palette (GdkColorContext *cc, /* copy incoming palette */ - cc->palette = g_new0(GdkColor, num_palette); + cc->palette = g_new0 (GdkColor, num_palette); j = 0; diff --git a/gdk/linux-fb/gdkcolor-fb.c b/gdk/linux-fb/gdkcolor-fb.c index 3dadfc010a..310e0c708d 100644 --- a/gdk/linux-fb/gdkcolor-fb.c +++ b/gdk/linux-fb/gdkcolor-fb.c @@ -32,6 +32,8 @@ #include "gdkcolor.h" #include "gdkprivate-fb.h" +#define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateFB *) GDK_COLORMAP (cmap)->windowing_data) + static gint gdk_colormap_match_color (GdkColormap *cmap, GdkColor *color, const gchar *available); @@ -41,8 +43,8 @@ static gpointer parent_class; static void gdk_colormap_finalize (GObject *object) { - GdkColormap *colormap = GDK_COLORMAP(object); - GdkColormapPrivateFB *private = (GdkColormapPrivateFB*) colormap; + GdkColormap *colormap = GDK_COLORMAP (object); + GdkColormapPrivateFB *private = GDK_COLORMAP_PRIVATE_DATA (colormap); if (private->hash) g_hash_table_destroy (private->hash); @@ -50,13 +52,17 @@ gdk_colormap_finalize (GObject *object) g_free (private->info); g_free (colormap->colors); - G_OBJECT_CLASS(parent_class)->finalize(object); + G_OBJECT_CLASS (parent_class)->finalize (object); } static void gdk_colormap_init (GdkColormap *colormap) { - colormap->windowing_data = NULL; + GdkColormapPrivateFB *private; + + private = g_new (GdkColormapPrivateFB, 1); + + colormap->windowing_data = private; colormap->size = 0; colormap->colors = NULL; @@ -81,13 +87,13 @@ gdk_colormap_get_type (void) { static const GTypeInfo object_info = { - sizeof (GdkColormapFBClass), + sizeof (GdkColormapClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gdk_colormap_class_init, NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (GdkColormapPrivateFB), + sizeof (GdkColormap), 0, /* n_preallocs */ (GInstanceInitFunc) gdk_colormap_init, }; @@ -101,7 +107,7 @@ gdk_colormap_get_type (void) return object_type; } -GdkColormap* +GdkColormap * gdk_colormap_new (GdkVisual *visual, gint private_cmap) { @@ -112,10 +118,10 @@ gdk_colormap_new (GdkVisual *visual, g_return_val_if_fail (visual != NULL, NULL); - private = (GdkColormapPrivateFB *)g_object_new(gdk_colormap_get_type(), NULL); - colormap = (GdkColormap*) private; + colormap = g_object_new (gdk_colormap_get_type (), NULL); + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - private->base.visual = visual; + colormap->visual = visual; fbd = gdk_display; private->hash = NULL; @@ -144,7 +150,7 @@ gdk_colormap_new (GdkVisual *visual, fbc.green = green; fbc.blue = blue; - if(ioctl(fbd->fd, FBIOGETCMAP, &fbc)) + if (ioctl (fbd->fd, FBIOGETCMAP, &fbc)) g_error("ioctl(FBIOGETCMAP) failed"); for (i = 0; i < colormap->size; i++) @@ -181,7 +187,7 @@ gdk_colormap_new (GdkVisual *visual, break; default: - g_assert_not_reached(); + g_assert_not_reached (); case GDK_VISUAL_TRUE_COLOR: break; @@ -209,9 +215,9 @@ gdk_colormap_get_system (void) guint16 red[256], green[256], blue[256]; struct fb_cmap fbc = {0, 256}; int i, r, g, b; - GdkVisual *visual = gdk_visual_get_system(); + GdkVisual *visual = gdk_visual_get_system (); - if(visual->type == GDK_VISUAL_GRAYSCALE + if (visual->type == GDK_VISUAL_GRAYSCALE || visual->type == GDK_VISUAL_PSEUDO_COLOR) { fbc.red = red; @@ -236,7 +242,7 @@ gdk_colormap_get_system (void) blue[i] = b * 65535 / 5; i++; } - g_assert(i == 216); + g_assert (i == 216); /* Fill in remaining space with grays */ for(i = 216; i < 256; i++) @@ -251,10 +257,10 @@ gdk_colormap_get_system (void) break; } - ioctl(gdk_display->fd, FBIOPUTCMAP, &fbc); + ioctl (gdk_display->fd, FBIOPUTCMAP, &fbc); } - colormap = gdk_colormap_new(visual, TRUE); + colormap = gdk_colormap_new (visual, TRUE); } return colormap; @@ -281,8 +287,8 @@ gdk_colormap_change (GdkColormap *colormap, fbc.green = green; fbc.blue = blue; - private = (GdkColormapPrivateFB*) colormap; - switch (private->base.visual->type) + private = GDK_COLORMAP_PRIVATE_DATA (colormap); + switch (colormap->visual->type) { case GDK_VISUAL_GRAYSCALE: for(i = 0; i < ncolors; i++) @@ -292,7 +298,7 @@ gdk_colormap_change (GdkColormap *colormap, colormap->colors[i].green + colormap->colors[i].blue)/3; } - ioctl(gdk_display->fd, FBIOPUTCMAP, &fbc); + ioctl (gdk_display->fd, FBIOPUTCMAP, &fbc); break; case GDK_VISUAL_PSEUDO_COLOR: @@ -302,7 +308,7 @@ gdk_colormap_change (GdkColormap *colormap, green[i] = colormap->colors[i].green; blue[i] = colormap->colors[i].blue; } - ioctl(gdk_display->fd, FBIOPUTCMAP, &fbc); + ioctl (gdk_display->fd, FBIOPUTCMAP, &fbc); break; default: @@ -320,34 +326,34 @@ gdk_color_parse (const gchar *spec, g_return_val_if_fail(spec, FALSE); g_return_val_if_fail(color, FALSE); - if(spec[0] == '#') + if (spec[0] == '#') { - if(strlen(spec) == 7) + if (strlen(spec) == 7) { guint num; - sscanf(spec + 1, "%x", &num); + sscanf (spec + 1, "%x", &num); color->red = (num & 0xFF0000) >> 8; color->green = (num & 0xFF00); color->blue = (num & 0xFF) << 8; } - else if(strlen(spec) == 13) + else if (strlen(spec) == 13) { char s1[5], s2[5], s3[5]; - g_snprintf(s1, sizeof(s1), spec + 1); - g_snprintf(s2, sizeof(s2), spec + 5); - g_snprintf(s3, sizeof(s3), spec + 9); + g_snprintf (s1, sizeof(s1), spec + 1); + g_snprintf (s2, sizeof(s2), spec + 5); + g_snprintf (s3, sizeof(s3), spec + 9); - if(!sscanf(s1, "%hx", &color->red)) - g_error("sscanf failed"); - if(!sscanf(s2, "%hx", &color->green)) - g_error("sscanf failed"); - if(!sscanf(s3, "%hx", &color->blue)) - g_error("sscanf failed"); + if (!sscanf(s1, "%hx", &color->red)) + g_error ("sscanf failed"); + if (!sscanf(s2, "%hx", &color->green)) + g_error ("sscanf failed"); + if (!sscanf (s3, "%hx", &color->blue)) + g_error ("sscanf failed"); } else { - g_warning("Couldn't parse color specifier `%s'", spec); + g_warning ("Couldn't parse color specifier `%s'", spec); return FALSE; } @@ -355,36 +361,36 @@ gdk_color_parse (const gchar *spec, } else { - fh = fopen("/usr/lib/X11/rgb.txt", "r"); - if(!fh) + fh = fopen ("/usr/lib/X11/rgb.txt", "r"); + if (!fh) return FALSE; - while(fgets(aline, sizeof(aline), fh)) + while(fgets (aline, sizeof(aline), fh)) { int red, green, blue; char *ctmp; - g_strstrip(aline); - if(!aline[0] || aline[0] == '#' || aline[0] == '!') + g_strstrip (aline); + if (!aline[0] || aline[0] == '#' || aline[0] == '!') continue; - ctmp = strtok(aline, " \t"); - if(!ctmp) + ctmp = strtok (aline, " \t"); + if (!ctmp) continue; - red = atoi(ctmp); + red = atoi (ctmp); - ctmp = strtok(NULL, " \t"); - if(!ctmp) + ctmp = strtok (NULL, " \t"); + if (!ctmp) continue; - green = atoi(ctmp); + green = atoi (ctmp); - ctmp = strtok(NULL, " \t"); - if(!ctmp) + ctmp = strtok (NULL, " \t"); + if (!ctmp) continue; - blue = atoi(ctmp); + blue = atoi (ctmp); - ctmp = strtok(NULL, " \t"); - if(!ctmp || strcmp(ctmp, spec)) + ctmp = strtok (NULL, " \t"); + if (!ctmp || strcmp (ctmp, spec)) continue; color->red = red << 8; @@ -392,7 +398,7 @@ gdk_color_parse (const gchar *spec, color->blue = blue << 8; return TRUE; } - fclose(fh); + fclose (fh); } return FALSE; @@ -409,10 +415,10 @@ gdk_colormap_free_colors (GdkColormap *colormap, g_return_if_fail (colormap != NULL); g_return_if_fail (colors != NULL); - private = (GdkColormapPrivateFB*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) && - (private->base.visual->type != GDK_VISUAL_GRAYSCALE)) + if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) && + (colormap->visual->type != GDK_VISUAL_GRAYSCALE)) return; for (i=0; ibase.visual->type != GDK_VISUAL_GRAYSCALE - && private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) + if (colormap->visual->type != GDK_VISUAL_GRAYSCALE + && colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) return FALSE; *ret = *color; - if(!color->red && !color->green && !color->blue) /* black */ + if (!color->red && !color->green && !color->blue) /* black */ { ret->pixel = 0; private->info[ret->pixel].ref_count++; return TRUE; } - if(color->red == 65535 && color->green == 65535 && color->blue == 65535) /* white */ + if (color->red == 65535 && color->green == 65535 && color->blue == 65535) /* white */ { ret->pixel = 255; private->info[ret->pixel].ref_count++; return TRUE; } - for(i = 1; i < (colormap->size - 1); i++) + for (i = 1; i < (colormap->size - 1); i++) { - if(!private->info[i].ref_count) + if (!private->info[i].ref_count) { guint16 red = color->red, green = color->green, blue = color->blue; struct fb_cmap fbc; + fbc.len = 1; fbc.start = i; fbc.red = &red; fbc.green = &green; fbc.blue = &blue; - ioctl(gdk_display->fd, FBIOPUTCMAP, &fbc); + ioctl (gdk_display->fd, FBIOPUTCMAP, &fbc); ret->pixel = i; colormap->colors[ret->pixel] = *ret; @@ -509,7 +516,7 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap, gint nremaining = 0; gint nfailed = 0; - private = (GdkColormapPrivateFB*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); index = -1; for (i=0; ibase.visual->type) + visual = colormap->visual; + switch (visual->type) { case GDK_VISUAL_PSEUDO_COLOR: case GDK_VISUAL_GRAYSCALE: @@ -663,8 +671,6 @@ gdk_colormap_alloc_colors (GdkColormap *colormap, case GDK_VISUAL_DIRECT_COLOR: case GDK_VISUAL_TRUE_COLOR: - visual = private->base.visual; - for (i=0; i> (16 - visual->red_prec)) << visual->red_shift) + @@ -687,9 +693,9 @@ gdk_color_change (GdkColormap *colormap, g_return_val_if_fail (colormap != NULL, FALSE); g_return_val_if_fail (color != NULL, FALSE); - private = (GdkColormapPrivateFB*) colormap; + private = GDK_COLORMAP_PRIVATE_DATA (colormap); - switch(private->base.visual->type) + switch(colormap->visual->type) { case GDK_VISUAL_GRAYSCALE: color->red = color->green = color->blue = (color->red + color->green + color->blue)/3; @@ -699,7 +705,7 @@ gdk_color_change (GdkColormap *colormap, fbc.red = &color->red; fbc.green = &color->green; fbc.blue = &color->blue; - ioctl(gdk_display->fd, FBIOPUTCMAP, &fbc); + ioctl (gdk_display->fd, FBIOPUTCMAP, &fbc); break; default: @@ -747,20 +753,21 @@ gdk_colormap_match_color (GdkColormap *cmap, return index; } -gint gdk_colors_alloc (GdkColormap *colormap, - gboolean contiguous, - gulong *planes, - gint nplanes, - gulong *pixels, - gint npixels) +gint +gdk_colors_alloc (GdkColormap *colormap, + gboolean contiguous, + gulong *planes, + gint nplanes, + gulong *pixels, + gint npixels) { return 0; } void -gdk_colors_free (GdkColormap *colormap, - gulong *pixels, - gint npixels, - gulong planes) +gdk_colors_free (GdkColormap *colormap, + gulong *pixels, + gint npixels, + gulong planes) { } diff --git a/gdk/linux-fb/gdkcursor-fb.c b/gdk/linux-fb/gdkcursor-fb.c index 4a0acff4e9..3b38a562d0 100644 --- a/gdk/linux-fb/gdkcursor-fb.c +++ b/gdk/linux-fb/gdkcursor-fb.c @@ -191,17 +191,15 @@ static struct { {xterm_mask_bits, xterm_mask_width, xterm_mask_height, xterm_mask_x_hot, xterm_mask_y_hot} }; - - -GdkCursor* +static GdkCursor * _gdk_cursor_new_from_pixmap (GdkPixmap *source, GdkPixmap *mask, GdkColor *fg, GdkColor *bg, gint x, gint y, - gint mask_off_x, - gint mask_off_y) + gint mask_off_x, + gint mask_off_y) { GdkCursorPrivateFB *private; GdkCursor *cursor; @@ -212,8 +210,8 @@ _gdk_cursor_new_from_pixmap (GdkPixmap *source, cursor = (GdkCursor *) private; cursor->type = GDK_CURSOR_IS_PIXMAP; cursor->ref_count = 1; - private->cursor = gdk_pixmap_ref(source); - private->mask = gdk_pixmap_ref(mask); + private->cursor = gdk_pixmap_ref (source); + private->mask = gdk_pixmap_ref (mask); private->hot_x = x; private->hot_y = y; private->mask_off_x = mask_off_x; @@ -227,33 +225,34 @@ gdk_cursor_new (GdkCursorType cursor_type) { GdkPixmap *pm, *mask; - if(cursor_type >= sizeof(stock_cursors)/sizeof(stock_cursors[0])) + if (cursor_type >= sizeof(stock_cursors)/sizeof(stock_cursors[0])) return NULL; pm = stock_cursors[cursor_type].pm; - if(!pm) + if (!pm) { - pm = stock_cursors[cursor_type].pm = gdk_bitmap_create_from_data(gdk_parent_root, - stock_cursors[cursor_type].bits, - stock_cursors[cursor_type].width, - stock_cursors[cursor_type].height); - gdk_pixmap_ref(pm); + pm = stock_cursors[cursor_type].pm = gdk_bitmap_create_from_data (gdk_parent_root, + stock_cursors[cursor_type].bits, + stock_cursors[cursor_type].width, + stock_cursors[cursor_type].height); + gdk_pixmap_ref (pm); } + mask = stock_cursors[cursor_type+1].pm; - if(!mask) + if (!mask) { - mask = stock_cursors[cursor_type+1].pm = gdk_bitmap_create_from_data(gdk_parent_root, - stock_cursors[cursor_type+1].bits, - stock_cursors[cursor_type+1].width, - stock_cursors[cursor_type+1].height); - gdk_pixmap_ref(mask); + mask = stock_cursors[cursor_type+1].pm = gdk_bitmap_create_from_data (gdk_parent_root, + stock_cursors[cursor_type+1].bits, + stock_cursors[cursor_type+1].width, + stock_cursors[cursor_type+1].height); + gdk_pixmap_ref (mask); } - return _gdk_cursor_new_from_pixmap(pm, mask, NULL, NULL, - stock_cursors[cursor_type].hotx, - stock_cursors[cursor_type].hoty, - (stock_cursors[cursor_type].hotx - stock_cursors[cursor_type+1].hotx) * 1, - (stock_cursors[cursor_type].hoty - stock_cursors[cursor_type+1].hoty) * 1); + return _gdk_cursor_new_from_pixmap (pm, mask, NULL, NULL, + stock_cursors[cursor_type].hotx, + stock_cursors[cursor_type].hoty, + (stock_cursors[cursor_type].hotx - stock_cursors[cursor_type+1].hotx) * 1, + (stock_cursors[cursor_type].hoty - stock_cursors[cursor_type+1].hoty) * 1); } GdkCursor* @@ -264,7 +263,7 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source, gint x, gint y) { - return _gdk_cursor_new_from_pixmap(source, mask, fg, bg, x, y, 0, 0); + return _gdk_cursor_new_from_pixmap (source, mask, fg, bg, x, y, 0, 0); } void diff --git a/gdk/linux-fb/gdkdnd-fb.c b/gdk/linux-fb/gdkdnd-fb.c index 4a66837716..d4d131cc5d 100644 --- a/gdk/linux-fb/gdkdnd-fb.c +++ b/gdk/linux-fb/gdkdnd-fb.c @@ -45,8 +45,6 @@ typedef enum { * this is used on both source and destination sides. */ struct _GdkDragContextPrivate { - GdkDragContext context; - guint ref_count; }; @@ -55,11 +53,12 @@ struct _GdkDragContextPrivate { static GList *contexts; static gpointer parent_class = NULL; +#define GDK_DRAG_CONTEXT_PRIVATE_DATA(ctx) ((GdkDragContextPrivate *) GDK_DRAG_CONTEXT (ctx)->windowing_data) static void gdk_drag_context_init (GdkDragContext *dragcontext) { - dragcontext->windowing_data = NULL; + dragcontext->windowing_data = g_new (GdkDragContextPrivate, 1); contexts = g_list_prepend (contexts, dragcontext); } @@ -68,16 +67,22 @@ static void gdk_drag_context_finalize (GObject *object) { GdkDragContext *context = GDK_DRAG_CONTEXT (object); + GdkDragContextPrivate *private = GDK_DRAG_CONTEXT_PRIVATE_DATA (object); g_list_free (context->targets); if (context->source_window) - { - gdk_window_unref (context->source_window); - } + gdk_window_unref (context->source_window); if (context->dest_window) gdk_window_unref (context->dest_window); + + + if (private) + { + g_free (private); + context->windowing_data = NULL; + } contexts = g_list_remove (contexts, context); @@ -127,19 +132,19 @@ gdk_drag_context_get_type (void) GdkDragContext * gdk_drag_context_new (void) { - return (GdkDragContext *)g_object_new(gdk_drag_context_get_type (), NULL); + return (GdkDragContext *)g_object_new (gdk_drag_context_get_type (), NULL); } void gdk_drag_context_ref (GdkDragContext *context) { - g_object_ref(G_OBJECT(context)); + g_object_ref (G_OBJECT (context)); } void gdk_drag_context_unref (GdkDragContext *context) { - g_object_unref(G_OBJECT(context)); + g_object_unref (G_OBJECT (context)); } /************************************************************* @@ -207,9 +212,9 @@ gdk_drag_find_window (GdkDragContext *context, { g_return_if_fail (context != NULL); - *dest_window = gdk_window_get_pointer(NULL, &x_root, &y_root, NULL); - if(*dest_window) - gdk_window_ref(*dest_window); + *dest_window = gdk_window_get_pointer (NULL, &x_root, &y_root, NULL); + if (*dest_window) + gdk_window_ref (*dest_window); } gboolean diff --git a/gdk/linux-fb/gdkdrawable-fb2.c b/gdk/linux-fb/gdkdrawable-fb2.c index 45fa2da5d9..31550424fe 100644 --- a/gdk/linux-fb/gdkdrawable-fb2.c +++ b/gdk/linux-fb/gdkdrawable-fb2.c @@ -4,106 +4,119 @@ #include #include -#include -#ifndef __BYTE_ORDER -#error "endian.h needs to #define __BYTE_ORDER" -#endif #ifndef g_alloca #define g_alloca alloca #endif -static void gdk_fb_drawable_set_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkColor *spot, gboolean abs_coords); -typedef enum { GPR_USED_BG, GPR_AA_GRAYVAL, GPR_NONE, GPR_ERR_BOUNDS } GetPixelRet; -static GetPixelRet gdk_fb_drawable_get_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkColor *spot, - gboolean abs_coords, GdkDrawable *bg_relto, GdkDrawable *bgpm); +typedef enum { + GPR_USED_BG, + GPR_AA_GRAYVAL, + GPR_NONE, + GPR_ERR_BOUNDS +} GetPixelRet; + +static void gdk_fb_drawable_set_pixel (GdkDrawable *drawable, + GdkGC *gc, + int x, + int y, + GdkColor *spot, + gboolean abs_coords); +static GetPixelRet gdk_fb_drawable_get_pixel (GdkDrawable *drawable, + GdkGC *gc, + int x, + int y, + GdkColor *spot, + gboolean abs_coords, + GdkDrawable *bg_relto, + GdkDrawable *bgpm); +void gdk_fb_draw_rectangle (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height); +static void gdk_fb_draw_arc (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height, + gint angle1, + gint angle2); +static void gdk_fb_draw_polygon (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + GdkPoint *points, + gint npoints); +static void gdk_fb_draw_text (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const gchar *text, + gint text_length); +static void gdk_fb_draw_text_wc (GdkDrawable *drawable, + GdkFont *font, + GdkGC *gc, + gint x, + gint y, + const GdkWChar *text, + gint text_length); +static void gdk_fb_draw_glyphs (GdkDrawable *drawable, + GdkGC *gc, + PangoFont *font, + gint x, + gint y, + PangoGlyphString *glyphs); +void gdk_fb_draw_drawable (GdkDrawable *drawable, + GdkGC *gc, + GdkPixmap *src, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); +static void gdk_fb_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height); +static void gdk_fb_draw_points (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); +static void gdk_fb_draw_segments (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *segs, + gint nsegs); +static void gdk_fb_draw_lines (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints); +static GdkColormap* gdk_fb_get_colormap (GdkDrawable *drawable); +static void gdk_fb_set_colormap (GdkDrawable *drawable, + GdkColormap *colormap); +static gint gdk_fb_get_depth (GdkDrawable *drawable); +static GdkVisual* gdk_fb_get_visual (GdkDrawable *drawable); -void gdk_fb_draw_rectangle (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height); -static void gdk_fb_draw_arc (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height, - gint angle1, - gint angle2); -static void gdk_fb_draw_polygon (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - GdkPoint *points, - gint npoints); -static void gdk_fb_draw_text (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const gchar *text, - gint text_length); -static void gdk_fb_draw_text_wc (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const GdkWChar *text, - gint text_length); -static void gdk_fb_draw_glyphs (GdkDrawable *drawable, - GdkGC *gc, - PangoFont *font, - gint x, - gint y, - PangoGlyphString *glyphs); -void gdk_fb_draw_drawable (GdkDrawable *drawable, - GdkGC *gc, - GdkPixmap *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); -static void gdk_fb_draw_image (GdkDrawable *drawable, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); -static void gdk_fb_draw_points (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints); -static void gdk_fb_draw_segments (GdkDrawable *drawable, - GdkGC *gc, - GdkSegment *segs, - gint nsegs); -static void gdk_fb_draw_lines (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints); -static GdkColormap* gdk_fb_get_colormap (GdkDrawable *drawable); -static void gdk_fb_set_colormap (GdkDrawable *drawable, - GdkColormap *colormap); -static gint gdk_fb_get_depth (GdkDrawable *drawable); -static GdkVisual* gdk_fb_get_visual (GdkDrawable *drawable); static gpointer parent_class = NULL; static void -gdk_fb_get_size(GdkDrawable *d, gint *width, gint *height) +gdk_fb_get_size (GdkDrawable *d, gint *width, gint *height) { - if(width) - *width = GDK_DRAWABLE_P(d)->width; - if(height) - *height = GDK_DRAWABLE_P(d)->height; + if (width) + *width = GDK_DRAWABLE_FBDATA (d)->width; + if (height) + *height = GDK_DRAWABLE_FBDATA (d)->height; } static void @@ -173,10 +186,10 @@ gdk_drawable_impl_fb_get_type (void) static GdkColormap* gdk_fb_get_colormap (GdkDrawable *drawable) { - GdkColormap *retval = GDK_DRAWABLE_FBDATA(drawable)->colormap; + GdkColormap *retval = GDK_DRAWABLE_FBDATA (drawable)->colormap; - if(!retval) - retval = gdk_colormap_get_system(); + if (!retval) + retval = gdk_colormap_get_system (); return retval; } @@ -186,110 +199,129 @@ gdk_fb_set_colormap (GdkDrawable *drawable, GdkColormap *colormap) { GdkColormap *old_cmap; - old_cmap = GDK_DRAWABLE_FBDATA(drawable)->colormap; - GDK_DRAWABLE_FBDATA(drawable)->colormap = gdk_colormap_ref(colormap); - gdk_colormap_unref(old_cmap); + GdkDrawableFBData *private; + + private = GDK_DRAWABLE_FBDATA (drawable); + + old_cmap = private->colormap; + private->colormap = gdk_colormap_ref (colormap); + gdk_colormap_unref (old_cmap); } -/* Drawing +/* Calculates the real clipping region for a drawable, taking into account + * other windows, gc clip region and gc clip mask. */ GdkRegion * -gdk_fb_clip_region(GdkDrawable *drawable, GdkGC *gc, gboolean do_clipping, gboolean do_children) +gdk_fb_clip_region (GdkDrawable *drawable, + GdkGC *gc, + gboolean do_clipping, + gboolean do_children) { GdkRectangle draw_rect; GdkRegion *real_clip_region, *tmpreg; - gboolean watchit = FALSE, skipit = FALSE; + gboolean skipit = FALSE; + GdkDrawableFBData *private; - g_assert(!GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper) || !GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->input_only); - - draw_rect.x = GDK_DRAWABLE_FBDATA(drawable)->llim_x; - draw_rect.y = GDK_DRAWABLE_FBDATA(drawable)->llim_y; - if(!GDK_IS_WINDOW(GDK_DRAWABLE_FBDATA(drawable)) || GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->mapped) + private = GDK_DRAWABLE_FBDATA (drawable); + + g_assert(!GDK_IS_WINDOW (private->wrapper) || + !GDK_WINDOW_P (private->wrapper)->input_only); + + draw_rect.x = private->llim_x; + draw_rect.y = private->llim_y; + if (!GDK_IS_WINDOW (private) || + GDK_WINDOW_P (private->wrapper)->mapped) { - draw_rect.width = GDK_DRAWABLE_FBDATA(drawable)->lim_x - draw_rect.x; - draw_rect.height = GDK_DRAWABLE_FBDATA(drawable)->lim_y - draw_rect.y; + draw_rect.width = private->lim_x - draw_rect.x; + draw_rect.height = private->lim_y - draw_rect.y; } else { draw_rect.width = draw_rect.height = 0; skipit = TRUE; } - real_clip_region = gdk_region_rectangle(&draw_rect); - if(skipit) + real_clip_region = gdk_region_rectangle (&draw_rect); + if (skipit) return real_clip_region; - if(gc && GDK_GC_FBDATA(gc)->values.subwindow_mode == GDK_INCLUDE_INFERIORS) + if (gc && GDK_GC_FBDATA(gc)->values.subwindow_mode == GDK_INCLUDE_INFERIORS) do_children = FALSE; - if(do_clipping && GDK_IS_WINDOW(GDK_DRAWABLE_FBDATA(drawable)->wrapper) && GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->mapped && !GDK_WINDOW_P(GDK_DRAWABLE_FBDATA(drawable)->wrapper)->input_only) + if (do_clipping && + GDK_IS_WINDOW (private->wrapper) && + GDK_WINDOW_P (private->wrapper)->mapped && + !GDK_WINDOW_P (private->wrapper)->input_only) { GdkWindow *parentwin, *lastwin; + GdkDrawableFBData *impl_private; - lastwin = GDK_DRAWABLE_FBDATA(drawable)->wrapper; - if(do_children) + lastwin = private->wrapper; + if (do_children) parentwin = lastwin; else - parentwin = (GdkWindow *)GDK_WINDOW_P(lastwin)->parent; + parentwin = (GdkWindow *)GDK_WINDOW_P (lastwin)->parent; - for(; - parentwin; lastwin = parentwin, parentwin = (GdkWindow *)GDK_WINDOW_P(parentwin)->parent) + for (; parentwin; lastwin = parentwin, parentwin = (GdkWindow *)GDK_WINDOW_P (parentwin)->parent) { GList *cur; - for(cur = GDK_WINDOW_P(parentwin)->children; cur && cur->data != lastwin; cur = cur->next) + for (cur = GDK_WINDOW_P (parentwin)->children; cur && cur->data != lastwin; cur = cur->next) { - GdkRegion *reg2; - - if(!GDK_WINDOW_P(cur->data)->mapped || GDK_WINDOW_P(cur->data)->input_only) + if (!GDK_WINDOW_P (cur->data)->mapped || GDK_WINDOW_P (cur->data)->input_only) continue; + impl_private = GDK_DRAWABLE_IMPL_FBDATA(cur->data); + draw_rect.x = impl_private->llim_x; + draw_rect.y = impl_private->llim_y; + draw_rect.width = impl_private->lim_x - draw_rect.x; + draw_rect.height = impl_private->lim_y - draw_rect.y; - draw_rect.x = GDK_DRAWABLE_IMPL_FBDATA(cur->data)->llim_x; - draw_rect.y = GDK_DRAWABLE_IMPL_FBDATA(cur->data)->llim_y; - draw_rect.width = GDK_DRAWABLE_IMPL_FBDATA(cur->data)->lim_x - draw_rect.x; - draw_rect.height = GDK_DRAWABLE_IMPL_FBDATA(cur->data)->lim_y - draw_rect.y; + tmpreg = gdk_region_rectangle (&draw_rect); - tmpreg = gdk_region_rectangle(&draw_rect); - - reg2 = gdk_region_copy(real_clip_region); - gdk_region_subtract(reg2, tmpreg); - if(watchit && !gdk_region_point_in(reg2, 100, 353)) - G_BREAKPOINT(); - gdk_region_destroy(real_clip_region); real_clip_region = reg2; - gdk_region_destroy(tmpreg); + gdk_region_subtract (real_clip_region, tmpreg); + gdk_region_destroy (tmpreg); } } } - if(gc) + if (gc) { - if(GDK_GC_FBDATA(gc)->clip_region) + if (GDK_GC_FBDATA (gc)->clip_region) { - tmpreg = gdk_region_copy(GDK_GC_FBDATA(gc)->clip_region); - gdk_region_offset(tmpreg, GDK_DRAWABLE_FBDATA(drawable)->abs_x + GDK_GC_P(gc)->clip_x_origin, - GDK_DRAWABLE_FBDATA(drawable)->abs_y + GDK_GC_P(gc)->clip_y_origin); - gdk_region_intersect(real_clip_region, tmpreg); - gdk_region_destroy(tmpreg); + tmpreg = gdk_region_copy (GDK_GC_FBDATA (gc)->clip_region); + gdk_region_offset (tmpreg, private->abs_x + GDK_GC_P (gc)->clip_x_origin, + private->abs_y + GDK_GC_P (gc)->clip_y_origin); + gdk_region_intersect (real_clip_region, tmpreg); + gdk_region_destroy (tmpreg); } - if(GDK_GC_FBDATA(gc)->values.clip_mask) + if (GDK_GC_FBDATA (gc)->values.clip_mask) { - GdkDrawable *cmask = GDK_GC_FBDATA(gc)->values.clip_mask; + GdkDrawable *cmask = GDK_GC_FBDATA (gc)->values.clip_mask; + GdkDrawableFBData *cmask_private; - g_assert(GDK_DRAWABLE_IMPL_FBDATA(cmask)->depth == 1); - g_assert(GDK_DRAWABLE_IMPL_FBDATA(cmask)->abs_x == 0 - && GDK_DRAWABLE_IMPL_FBDATA(cmask)->abs_y == 0); + cmask_private = GDK_DRAWABLE_IMPL_FBDATA (cmask); - draw_rect.x = GDK_DRAWABLE_FBDATA(drawable)->abs_x + GDK_DRAWABLE_IMPL_FBDATA(cmask)->llim_x + GDK_GC_FBDATA(gc)->values.clip_x_origin; - draw_rect.y = GDK_DRAWABLE_FBDATA(drawable)->abs_y + GDK_DRAWABLE_IMPL_FBDATA(cmask)->llim_y + GDK_GC_FBDATA(gc)->values.clip_y_origin; - draw_rect.width = GDK_DRAWABLE_IMPL_FBDATA(cmask)->width; - draw_rect.height = GDK_DRAWABLE_IMPL_FBDATA(cmask)->height; + g_assert (cmask_private->depth == 1); + g_assert (cmask_private->abs_x == 0 && + cmask_private->abs_y == 0); - tmpreg = gdk_region_rectangle(&draw_rect); - gdk_region_intersect(real_clip_region, tmpreg); - gdk_region_destroy(tmpreg); - if(!real_clip_region->numRects) - g_warning("Empty clip region"); + draw_rect.x = private->abs_x + + cmask_private->llim_x + + GDK_GC_FBDATA (gc)->values.clip_x_origin; + + draw_rect.y = private->abs_y + + cmask_private->llim_y + + GDK_GC_FBDATA (gc)->values.clip_y_origin; + + draw_rect.width = cmask_private->width; + draw_rect.height = cmask_private->height; + + tmpreg = gdk_region_rectangle (&draw_rect); + gdk_region_intersect (real_clip_region, tmpreg); + gdk_region_destroy (tmpreg); + if (!real_clip_region->numRects) + g_warning ("Empty clip region"); } } @@ -297,16 +329,25 @@ gdk_fb_clip_region(GdkDrawable *drawable, GdkGC *gc, gboolean do_clipping, gbool } static void -gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *color, GdkVisual *visual) +gdk_fb_fill_span (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *cur, + GdkColor *color, + GdkVisual *visual) { int curx, cury; GdkColor spot = *color; + GdkGCFBData *gc_private; + GdkDrawableFBData *private; - if(gc - && (GDK_GC_FBDATA(gc)->values.clip_mask - || GDK_GC_FBDATA(gc)->values.tile - || GDK_GC_FBDATA(gc)->values.stipple - || GDK_GC_FBDATA(gc)->values.function == GDK_INVERT)) + private = GDK_DRAWABLE_FBDATA (drawable); + gc_private = GDK_GC_FBDATA (gc); + + if (gc && + (gc_private->values.clip_mask || + gc_private->values.tile || + gc_private->values.stipple || + gc_private->values.function == GDK_INVERT)) { int clipxoff, clipyoff; /* Amounts to add to curx & cury to get x & y in clip mask */ int tsxoff, tsyoff; @@ -314,140 +355,147 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co guchar *clipmem; guint mask_rowstride; GdkPixmap *ts = NULL; + GdkDrawableFBData *ts_private; gboolean solid_stipple; - GdkFunction func = GDK_GC_FBDATA(gc)->values.function; + GdkFunction func = gc_private->values.function; - cmask = GDK_GC_FBDATA(gc)->values.clip_mask; + ts_private = GDK_DRAWABLE_IMPL_FBDATA (ts); + + cmask = gc_private->values.clip_mask; clipxoff = clipyoff = tsxoff = tsyoff = 0; mask_rowstride = 0; solid_stipple = FALSE; clipmem = NULL; - if(cmask) + if (cmask) { - clipmem = GDK_DRAWABLE_IMPL_FBDATA(cmask)->mem; - clipxoff = GDK_DRAWABLE_IMPL_FBDATA(cmask)->abs_x - GDK_GC_FBDATA(gc)->values.clip_x_origin - GDK_DRAWABLE_FBDATA(drawable)->abs_x; - clipyoff = GDK_DRAWABLE_IMPL_FBDATA(cmask)->abs_y - GDK_GC_FBDATA(gc)->values.clip_y_origin - GDK_DRAWABLE_FBDATA(drawable)->abs_y; - mask_rowstride = GDK_DRAWABLE_IMPL_FBDATA(cmask)->rowstride; + GdkDrawableFBData *cmask_private; + + cmask_private = GDK_DRAWABLE_IMPL_FBDATA (cmask); + + clipmem = cmask_private->mem; + clipxoff = cmask_private->abs_x - gc_private->values.clip_x_origin - private->abs_x; + clipyoff = cmask_private->abs_y - gc_private->values.clip_y_origin - private->abs_y; + mask_rowstride = cmask_private->rowstride; } - if(GDK_GC_FBDATA(gc)->values.fill == GDK_TILED - && GDK_GC_FBDATA(gc)->values.tile) + if (gc_private->values.fill == GDK_TILED && + gc_private->values.tile) { gint xstep, ystep; gint relx, rely; GdkFBDrawingContext *dc, dc_data; dc = &dc_data; - gdk_fb_drawing_context_init(dc, drawable, gc, FALSE, TRUE); + gdk_fb_drawing_context_init (dc, drawable, gc, FALSE, TRUE); - ts = GDK_GC_FBDATA(gc)->values.tile; - for(cury = cur->y1; cury < cur->y2; cury += ystep) + ts = gc_private->values.tile; + for (cury = cur->y1; cury < cur->y2; cury += ystep) { int drawh; - rely = cury - GDK_DRAWABLE_FBDATA(drawable)->abs_y; - drawh = (rely + GDK_GC_FBDATA(gc)->values.ts_y_origin) % GDK_DRAWABLE_IMPL_FBDATA(ts)->height; - if(drawh < 0) - drawh += GDK_DRAWABLE_P(ts)->height; + rely = cury - private->abs_y; + drawh = (rely + gc_private->values.ts_y_origin) % ts_private->height; + if (drawh < 0) + drawh += GDK_DRAWABLE_FBDATA (ts)->height; - ystep = MIN(GDK_DRAWABLE_IMPL_FBDATA(ts)->height - drawh, cur->y2 - rely); + ystep = MIN (ts_private->height - drawh, cur->y2 - rely); - for(curx = cur->x1; curx < cur->x2; curx += xstep) + for (curx = cur->x1; curx < cur->x2; curx += xstep) { int draww; - relx = curx - GDK_DRAWABLE_FBDATA(drawable)->abs_x; + relx = curx - private->abs_x; - draww = (relx + GDK_GC_FBDATA(gc)->values.ts_x_origin) % GDK_DRAWABLE_IMPL_FBDATA(ts)->width; - if(draww < 0) - draww += GDK_DRAWABLE_IMPL_FBDATA(ts)->width; + draww = (relx + gc_private->values.ts_x_origin) % ts_private->width; + if (draww < 0) + draww += ts_private->width; - xstep = MIN(GDK_DRAWABLE_IMPL_FBDATA(ts)->width - draww, cur->x2 - relx); + xstep = MIN (ts_private->width - draww, cur->x2 - relx); - gdk_fb_draw_drawable_3(drawable, gc, GDK_DRAWABLE_IMPL(ts), - dc, - draww, drawh, - relx, rely, - xstep, ystep); + gdk_fb_draw_drawable_3 (drawable, gc, GDK_DRAWABLE_IMPL (ts), + dc, + draww, drawh, + relx, rely, + xstep, ystep); } } - gdk_fb_drawing_context_finalize(dc); + gdk_fb_drawing_context_finalize (dc); return; } - else if((GDK_GC_FBDATA(gc)->values.fill == GDK_STIPPLED - || GDK_GC_FBDATA(gc)->values.fill == GDK_OPAQUE_STIPPLED) - && GDK_GC_FBDATA(gc)->values.stipple) + else if ((gc_private->values.fill == GDK_STIPPLED || + gc_private->values.fill == GDK_OPAQUE_STIPPLED) && + gc_private->values.stipple) { - ts = GDK_GC_FBDATA(gc)->values.stipple; - tsxoff = GDK_DRAWABLE_FBDATA(ts)->abs_x - GDK_GC_FBDATA(gc)->values.ts_x_origin - GDK_DRAWABLE_FBDATA(drawable)->abs_x; - tsyoff = GDK_DRAWABLE_FBDATA(ts)->abs_y - GDK_GC_FBDATA(gc)->values.ts_y_origin - GDK_DRAWABLE_FBDATA(drawable)->abs_y; - solid_stipple = (GDK_GC_FBDATA(gc)->values.fill == GDK_OPAQUE_STIPPLED); + ts = gc_private->values.stipple; + tsxoff = GDK_DRAWABLE_FBDATA (ts)->abs_x - gc_private->values.ts_x_origin - private->abs_x; + tsyoff = GDK_DRAWABLE_FBDATA (ts)->abs_y - gc_private->values.ts_y_origin - private->abs_y; + solid_stipple = (gc_private->values.fill == GDK_OPAQUE_STIPPLED); } - for(cury = cur->y1; cury < cur->y2; cury++) + for (cury = cur->y1; cury < cur->y2; cury++) { - for(curx = cur->x1; curx < cur->x2; curx++) + for (curx = cur->x1; curx < cur->x2; curx++) { int maskx = curx+clipxoff, masky = cury + clipyoff; guchar foo; - if(cmask) + if (cmask) { foo = clipmem[masky*mask_rowstride + (maskx >> 3)]; - - if(!(foo & (1 << (maskx % 8)))) + + if (!(foo & (1 << (maskx % 8)))) continue; } - if(func == GDK_INVERT) + if (func == GDK_INVERT) { - gdk_fb_drawable_get_pixel(drawable, gc, curx, cury, &spot, TRUE, NULL, NULL); + gdk_fb_drawable_get_pixel (drawable, gc, curx, cury, &spot, TRUE, NULL, NULL); spot.pixel = ~spot.pixel; spot.red = ~spot.red; spot.green = ~spot.green; spot.blue = ~spot.blue; } - else if(ts) + else if (ts) { - int wid = GDK_DRAWABLE_IMPL_FBDATA(ts)->width, hih = GDK_DRAWABLE_IMPL_FBDATA(ts)->height; + int wid = ts_private->width, hih = ts_private->height; maskx = (curx+tsxoff)%wid; masky = (cury+tsyoff)%hih; - if(maskx < 0) + if (maskx < 0) maskx += wid; - if(masky < 0) + if (masky < 0) masky += hih; - foo = GDK_DRAWABLE_IMPL_FBDATA(ts)->mem[(maskx >> 3) + GDK_DRAWABLE_IMPL_FBDATA(ts)->rowstride*masky]; - if(foo & (1 << (maskx % 8))) + foo = ts_private->mem[(maskx >> 3) + ts_private->rowstride*masky]; + if (foo & (1 << (maskx % 8))) { - spot = GDK_GC_FBDATA(gc)->values.foreground; + spot = gc_private->values.foreground; } - else if(solid_stipple) + else if (solid_stipple) { - spot = GDK_GC_FBDATA(gc)->values.background; + spot = gc_private->values.background; } else continue; } - gdk_fb_drawable_set_pixel(drawable, gc, curx, cury, &spot, TRUE); + gdk_fb_drawable_set_pixel (drawable, gc, curx, cury, &spot, TRUE); } } } else { - guchar *mem = GDK_DRAWABLE_FBDATA(drawable)->mem, *ptr; - guint rowstride = GDK_DRAWABLE_FBDATA(drawable)->rowstride; + guchar *mem = private->mem, *ptr; + guint rowstride = private->rowstride; int n; - switch(GDK_DRAWABLE_P(drawable)->depth) + switch (private->depth) { case 1: { - int fromx = MIN((cur->x1+7)&(~7), cur->x2); + int fromx = MIN ((cur->x1+7)&(~7), cur->x2); int begn = fromx - cur->x1, begoff = cur->x1 % 8, endn; guchar begmask, endmask; int body_end = cur->x2 & ~7; @@ -458,26 +506,26 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co endn = cur->x2 - body_end; endmask = (1 << endn) - 1; - for(cury = cur->y1; cury < cur->y2; cury++) + for (cury = cur->y1; cury < cur->y2; cury++) { ptr = mem + cury*rowstride + (cur->x1 >> 3); - if(spot.pixel) + if (spot.pixel) *ptr |= begmask; else *ptr &= ~begmask; curx = fromx; - if(curx < cur->x2) + if (curx < cur->x2) { ptr = mem + cury*rowstride + (curx >> 3); - memset(ptr, spot.pixel?0xFF:0, body_len); + memset (ptr, spot.pixel?0xFF:0, body_len); - if(endn) + if (endn) { ptr = mem + cury*rowstride + (body_end >> 3); - if(spot.pixel) + if (spot.pixel) *ptr |= endmask; else *ptr &= ~endmask; @@ -487,20 +535,20 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co } break; case 8: - for(cury = cur->y1; cury < cur->y2; cury++) + for (cury = cur->y1; cury < cur->y2; cury++) { ptr = mem + cury*rowstride + cur->x1; - memset(ptr, spot.pixel, cur->x2 - cur->x1); + memset (ptr, spot.pixel, cur->x2 - cur->x1); } break; case 16: { int i; n = cur->x2 - cur->x1; - for(cury = cur->y1; cury < cur->y2; cury++) + for (cury = cur->y1; cury < cur->y2; cury++) { guint16 *p16 = (guint16 *)(mem + cury * rowstride + cur->x1*2); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) *(p16++) = spot.pixel; } } @@ -510,23 +558,23 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co guchar redval = spot.red>>8, greenval=spot.green>>8, blueval=spot.blue>>8; guchar *firstline, *ptr_end; - if((cur->y2 - cur->y1) <= 0) + if ((cur->y2 - cur->y1) <= 0) break; n = (cur->x2 - cur->x1)*3; firstline = ptr = mem + cur->y1 * rowstride + cur->x1*3; ptr_end = ptr+n; - while(ptr < ptr_end) + while (ptr < ptr_end) { ptr[gdk_display->red_byte] = redval; ptr[gdk_display->green_byte] = greenval; ptr[gdk_display->blue_byte] = blueval; ptr += 3; } - for(cury = cur->y1 + 1, ptr = mem + cury * rowstride + cur->x1*3; cury < cur->y2; cury++, ptr += rowstride) + for (cury = cur->y1 + 1, ptr = mem + cury * rowstride + cur->x1*3; cury < cur->y2; cury++, ptr += rowstride) { - memcpy(ptr, firstline, n); + memcpy (ptr, firstline, n); } } break; @@ -534,22 +582,22 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co { int i; n = cur->x2 - cur->x1; - for(cury = cur->y1; cury < cur->y2; cury++) + for (cury = cur->y1; cury < cur->y2; cury++) { guint32 *p32 = (guint32 *)(mem + cury * rowstride + cur->x1*4); - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) *(p32++) = spot.pixel; } } break; default: - g_assert_not_reached(); + g_assert_not_reached (); #if 0 for(cury = cur->y1; cury < cur->y2; cury++) { for(curx = cur->x1; curx < cur->x2; curx++) { - gdk_fb_drawable_set_pixel(drawable, gc, curx, cury, &spot, TRUE); + gdk_fb_drawable_set_pixel (drawable, gc, curx, cury, &spot, TRUE); } } #endif @@ -559,42 +607,45 @@ gdk_fb_fill_span(GdkDrawable *drawable, GdkGC *gc, GdkSegment *cur, GdkColor *co } void -gdk_fb_fill_spans(GdkDrawable *real_drawable, - GdkGC *gc, - GdkRectangle *rects, int nrects) +gdk_fb_fill_spans (GdkDrawable *real_drawable, + GdkGC *gc, + GdkRectangle *rects, + int nrects) { int i; GdkColor color; GdkRegion *real_clip_region, *tmpreg; GdkRectangle draw_rect; - GdkVisual *visual = gdk_visual_get_system(); + GdkVisual *visual = gdk_visual_get_system (); gboolean handle_cursor = FALSE; GdkDrawable *drawable; + GdkDrawableFBData *private; drawable = real_drawable; + private = GDK_DRAWABLE_FBDATA (drawable); - if(GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper) && !GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->mapped) + if (GDK_IS_WINDOW (private->wrapper) && !GDK_WINDOW_P (private->wrapper)->mapped) return; - if(GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper) && GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->input_only) - g_error("Drawing on the evil input-only!"); + if (GDK_IS_WINDOW (private->wrapper) && GDK_WINDOW_P (private->wrapper)->input_only) + g_error ("Drawing on the evil input-only!"); - if(gc && (GDK_GC_FBDATA(gc)->values_mask | GDK_GC_FOREGROUND)) - color = GDK_GC_FBDATA(gc)->values.foreground; - else if(GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper)) - color = GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->bg_color; + if (gc && (GDK_GC_FBDATA (gc)->values_mask | GDK_GC_FOREGROUND)) + color = GDK_GC_FBDATA (gc)->values.foreground; + else if (GDK_IS_WINDOW (private->wrapper)) + color = GDK_WINDOW_P (private->wrapper)->bg_color; else - gdk_color_black(GDK_DRAWABLE_P(drawable)->colormap, &color); + gdk_color_black (private->colormap, &color); - real_clip_region = gdk_fb_clip_region(drawable, gc, TRUE, (!gc || GDK_GC_FBDATA(gc)->values.function!=GDK_INVERT)); + real_clip_region = gdk_fb_clip_region (drawable, gc, TRUE, (!gc || GDK_GC_FBDATA (gc)->values.function != GDK_INVERT)); - if(GDK_DRAWABLE_FBDATA(drawable)->mem == GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->mem - && gdk_fb_cursor_region_need_hide(real_clip_region)) + if (private->mem == GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->mem && + gdk_fb_cursor_region_need_hide (real_clip_region)) { handle_cursor = TRUE; - gdk_fb_cursor_hide(); + gdk_fb_cursor_hide (); } - for(i = 0; i < nrects; i++) + for (i = 0; i < nrects; i++) { GdkSegment cur; int j; @@ -603,100 +654,107 @@ gdk_fb_fill_spans(GdkDrawable *real_drawable, cur.y1 = rects[i].y; cur.x2 = cur.x1 + rects[i].width; cur.y2 = cur.y1 + rects[i].height; - g_assert(cur.x2 >= cur.x1); - g_assert(cur.y2 >= cur.y1); + g_assert (cur.x2 >= cur.x1); + g_assert (cur.y2 >= cur.y1); - cur.x1 += GDK_DRAWABLE_FBDATA(drawable)->abs_x; - cur.x1 = MAX(cur.x1, GDK_DRAWABLE_FBDATA(drawable)->llim_x); + cur.x1 += private->abs_x; + cur.x1 = MAX (cur.x1, private->llim_x); - cur.x2 += GDK_DRAWABLE_FBDATA(drawable)->abs_x; - cur.x2 = MIN(cur.x2, GDK_DRAWABLE_FBDATA(drawable)->lim_x); - cur.x1 = MIN(cur.x1, cur.x2); + cur.x2 += private->abs_x; + cur.x2 = MIN (cur.x2, private->lim_x); + cur.x1 = MIN (cur.x1, cur.x2); - cur.y1 += GDK_DRAWABLE_FBDATA(drawable)->abs_y; - cur.y1 = MAX(cur.y1, GDK_DRAWABLE_FBDATA(drawable)->llim_y); + cur.y1 += private->abs_y; + cur.y1 = MAX (cur.y1, private->llim_y); - cur.y2 += GDK_DRAWABLE_FBDATA(drawable)->abs_y; - cur.y2 = MIN(cur.y2, GDK_DRAWABLE_FBDATA(drawable)->lim_y); - cur.y1 = MIN(cur.y1, cur.y2); + cur.y2 += private->abs_y; + cur.y2 = MIN (cur.y2, private->lim_y); + cur.y1 = MIN (cur.y1, cur.y2); draw_rect.x = cur.x1; draw_rect.y = cur.y1; draw_rect.width = cur.x2 - cur.x1; draw_rect.height = cur.y2 - cur.y1; - switch(gdk_region_rect_in(real_clip_region, &draw_rect)) + switch (gdk_region_rect_in (real_clip_region, &draw_rect)) { case GDK_OVERLAP_RECTANGLE_PART: - tmpreg = gdk_region_rectangle(&draw_rect); - gdk_region_intersect(tmpreg, real_clip_region); - for(j = 0; j < tmpreg->numRects; j++) + tmpreg = gdk_region_rectangle (&draw_rect); + gdk_region_intersect (tmpreg, real_clip_region); + for (j = 0; j < tmpreg->numRects; j++) { cur = tmpreg->rects[j]; - gdk_fb_fill_span(drawable, gc, &cur, &color, visual); + gdk_fb_fill_span (drawable, gc, &cur, &color, visual); } - gdk_region_destroy(tmpreg); + gdk_region_destroy (tmpreg); break; case GDK_OVERLAP_RECTANGLE_IN: - gdk_fb_fill_span(drawable, gc, &cur, &color, visual); + gdk_fb_fill_span (drawable, gc, &cur, &color, visual); break; default: break; } } - gdk_region_destroy(real_clip_region); - if(handle_cursor) - gdk_fb_cursor_unhide(); + gdk_region_destroy (real_clip_region); + if (handle_cursor) + gdk_fb_cursor_unhide (); } static GetPixelRet -gdk_fb_drawable_get_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkColor *spot, - gboolean abs_coords, GdkDrawable *bg_relto, GdkDrawable *bgpm) +gdk_fb_drawable_get_pixel (GdkDrawable *drawable, + GdkGC *gc, + int x, + int y, + GdkColor *spot, + gboolean abs_coords, + GdkDrawable *bg_relto, + GdkDrawable *bgpm) { GetPixelRet retval = GPR_NONE; - guchar *mem = GDK_DRAWABLE_FBDATA(drawable)->mem; - guint rowstride = GDK_DRAWABLE_FBDATA(drawable)->rowstride; + GdkDrawableFBData *private = GDK_DRAWABLE_FBDATA (drawable); + guchar *mem = private->mem; + guint rowstride = private->rowstride; - if(!abs_coords) + if (!abs_coords) { - x += GDK_DRAWABLE_FBDATA(drawable)->abs_x; - y += GDK_DRAWABLE_FBDATA(drawable)->abs_y; + x += private->abs_x; + y += private->abs_y; } - - switch(GDK_DRAWABLE_P(drawable)->depth) + + switch (private->depth) { case 1: { guchar foo = mem[(x >> 3) + y * rowstride]; - if(foo & (1 << (x % 8))) - *spot = GDK_GC_FBDATA(gc)->values.foreground; + if (foo & (1 << (x % 8))) + *spot = GDK_GC_FBDATA (gc)->values.foreground; else { retval = GPR_USED_BG; - if(bgpm) + if (bgpm) { int bgx, bgy; - bgx = (x - GDK_DRAWABLE_IMPL_FBDATA(bg_relto)->abs_x) % GDK_DRAWABLE_IMPL_FBDATA(bgpm)->width; - bgy = (y - GDK_DRAWABLE_IMPL_FBDATA(bg_relto)->abs_y) % GDK_DRAWABLE_IMPL_FBDATA(bgpm)->height; + bgx = (x - GDK_DRAWABLE_IMPL_FBDATA (bg_relto)->abs_x) % GDK_DRAWABLE_IMPL_FBDATA (bgpm)->width; + bgy = (y - GDK_DRAWABLE_IMPL_FBDATA (bg_relto)->abs_y) % GDK_DRAWABLE_IMPL_FBDATA (bgpm)->height; - gdk_fb_drawable_get_pixel(bgpm, gc, bgx, bgy, spot, FALSE, NULL, NULL); + gdk_fb_drawable_get_pixel (bgpm, gc, bgx, bgy, spot, FALSE, NULL, NULL); retval = GPR_USED_BG; } else { - *spot = GDK_GC_FBDATA(gc)->values.background; + *spot = GDK_GC_FBDATA (gc)->values.background; } } } break; case 71: - if(mem[x + y * rowstride]) - *spot = GDK_GC_FBDATA(gc)->values.foreground; + if (mem[x + y * rowstride]) + *spot = GDK_GC_FBDATA (gc)->values.foreground; else - *spot = GDK_GC_FBDATA(gc)->values.background; + *spot = GDK_GC_FBDATA (gc)->values.background; break; case 77: retval = GPR_AA_GRAYVAL; @@ -710,7 +768,7 @@ gdk_fb_drawable_get_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkCol break; case 8: spot->pixel = mem[x + y * rowstride]; - *spot = GDK_DRAWABLE_P(drawable)->colormap->colors[spot->pixel]; + *spot = private->colormap->colors[spot->pixel]; break; case 16: { @@ -729,7 +787,7 @@ gdk_fb_drawable_get_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkCol spot->red = smem[gdk_display->red_byte] << 8; spot->green = smem[gdk_display->green_byte] << 8; spot->blue = smem[gdk_display->blue_byte] << 8; -#if (__BYTE_ORDER == __BIG_ENDIAN) +#if (G_BYTE_ORDER == G_BIG_ENDIAN) spot->pixel = (smem[0]<<16)|(smem[1]<<8)|smem[2]; #else spot->pixel = smem[0]|(smem[1]<<8)|(smem[2]<<16); @@ -754,22 +812,23 @@ static void gdk_fb_drawable_set_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkColor *spot, gboolean abs_coords) { - guchar *mem = GDK_DRAWABLE_FBDATA(drawable)->mem; - guint rowstride = GDK_DRAWABLE_FBDATA(drawable)->rowstride; + GdkDrawableFBData *private = GDK_DRAWABLE_FBDATA (drawable); + guchar *mem = private->mem; + guint rowstride = private->rowstride; - if(!abs_coords) + if (!abs_coords) { - x += GDK_DRAWABLE_FBDATA(drawable)->abs_x; - y += GDK_DRAWABLE_FBDATA(drawable)->abs_y; + x += private->abs_x; + y += private->abs_y; } - switch(GDK_DRAWABLE_P(drawable)->depth) + switch (private->depth) { case 1: { guchar *foo = mem + (y*rowstride) + (x >> 3); - if(spot->pixel) + if (spot->pixel) *foo |= (1 << (x % 8)); else *foo &= ~(1 << (x % 8)); @@ -799,71 +858,72 @@ gdk_fb_drawable_set_pixel(GdkDrawable *drawable, GdkGC *gc, int x, int y, GdkCol } break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } } void -gdk_fb_drawing_context_init(GdkFBDrawingContext *dc, - GdkDrawable *drawable, - GdkGC *gc, - gboolean draw_bg, - gboolean do_clipping) +gdk_fb_drawing_context_init (GdkFBDrawingContext *dc, + GdkDrawable *drawable, + GdkGC *gc, + gboolean draw_bg, + gboolean do_clipping) { - dc->mem = GDK_DRAWABLE_FBDATA(drawable)->mem; - dc->rowstride = GDK_DRAWABLE_FBDATA(drawable)->rowstride; + GdkDrawableFBData *private = GDK_DRAWABLE_FBDATA (drawable); + dc->mem = private->mem; + dc->rowstride = private->rowstride; dc->handle_cursor = FALSE; dc->bgpm = NULL; - dc->bg_relto = GDK_DRAWABLE_P(drawable)->wrapper; + dc->bg_relto = private->wrapper; dc->draw_bg = draw_bg; - if(GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper)) + if (GDK_IS_WINDOW (private->wrapper)) { - dc->bgpm = GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->bg_pixmap; - if(dc->bgpm == GDK_PARENT_RELATIVE_BG) + dc->bgpm = GDK_WINDOW_P (private->wrapper)->bg_pixmap; + if (dc->bgpm == GDK_PARENT_RELATIVE_BG) { - for(; dc->bgpm == GDK_PARENT_RELATIVE_BG && dc->bg_relto; dc->bg_relto = (GdkWindow *)GDK_WINDOW_P(dc->bg_relto)->parent) - dc->bgpm = GDK_WINDOW_P(dc->bg_relto)->bg_pixmap; + for (; dc->bgpm == GDK_PARENT_RELATIVE_BG && dc->bg_relto; dc->bg_relto = (GdkWindow *)GDK_WINDOW_P (dc->bg_relto)->parent) + dc->bgpm = GDK_WINDOW_P (dc->bg_relto)->bg_pixmap; } - if(dc->bgpm == GDK_NO_BG) + if (dc->bgpm == GDK_NO_BG) dc->bgpm = NULL; } - dc->clipxoff = - GDK_DRAWABLE_FBDATA(drawable)->abs_x; - dc->clipyoff = - GDK_DRAWABLE_FBDATA(drawable)->abs_y; + dc->clipxoff = - private->abs_x; + dc->clipyoff = - private->abs_y; - dc->real_clip_region = gdk_fb_clip_region(drawable, gc, do_clipping, TRUE); + dc->real_clip_region = gdk_fb_clip_region (drawable, gc, do_clipping, TRUE); - if(gc) + if (gc) { - dc->clipxoff -= GDK_GC_FBDATA(gc)->values.clip_x_origin; - dc->clipyoff -= GDK_GC_FBDATA(gc)->values.clip_y_origin; + dc->clipxoff -= GDK_GC_FBDATA (gc)->values.clip_x_origin; + dc->clipyoff -= GDK_GC_FBDATA (gc)->values.clip_y_origin; - if(GDK_GC_FBDATA(gc)->values.clip_mask) + if (GDK_GC_FBDATA (gc)->values.clip_mask) { - dc->clipmem = GDK_DRAWABLE_IMPL_FBDATA(GDK_GC_FBDATA(gc)->values.clip_mask)->mem; - dc->clip_rowstride = GDK_DRAWABLE_IMPL_FBDATA(GDK_GC_FBDATA(gc)->values.clip_mask)->rowstride; + dc->clipmem = GDK_DRAWABLE_IMPL_FBDATA (GDK_GC_FBDATA (gc)->values.clip_mask)->mem; + dc->clip_rowstride = GDK_DRAWABLE_IMPL_FBDATA (GDK_GC_FBDATA (gc)->values.clip_mask)->rowstride; } } - if(do_clipping - && GDK_DRAWABLE_FBDATA(drawable)->mem == GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->mem - && gdk_fb_cursor_region_need_hide(dc->real_clip_region)) + if (do_clipping && + private->mem == GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->mem && + gdk_fb_cursor_region_need_hide (dc->real_clip_region)) { dc->handle_cursor = TRUE; - gdk_fb_cursor_hide(); + gdk_fb_cursor_hide (); } } void -gdk_fb_drawing_context_finalize(GdkFBDrawingContext *dc) +gdk_fb_drawing_context_finalize (GdkFBDrawingContext *dc) { - gdk_region_destroy(dc->real_clip_region); + gdk_region_destroy (dc->real_clip_region); - if(dc->handle_cursor) - gdk_fb_cursor_unhide(); + if (dc->handle_cursor) + gdk_fb_cursor_unhide (); } void @@ -882,9 +942,9 @@ gdk_fb_draw_drawable_2 (GdkDrawable *drawable, GdkFBDrawingContext *dc, dc_data; dc = &dc_data; - gdk_fb_drawing_context_init(dc, drawable, gc, draw_bg, do_clipping); - gdk_fb_draw_drawable_3(drawable, gc, src, dc, xsrc, ysrc, xdest, ydest, width, height); - gdk_fb_drawing_context_finalize(dc); + gdk_fb_drawing_context_init (dc, drawable, gc, draw_bg, do_clipping); + gdk_fb_draw_drawable_3 (drawable, gc, src, dc, xsrc, ysrc, xdest, ydest, width, height); + gdk_fb_drawing_context_finalize (dc); } void @@ -899,6 +959,8 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, gint width, gint height) { + GdkDrawableFBData *private = GDK_DRAWABLE_FBDATA (drawable); + GdkDrawableFBData *src_private = GDK_DRAWABLE_FBDATA (src); GdkRectangle rect; guchar *srcmem = GDK_DRAWABLE_FBDATA(src)->mem; int src_x_off, src_y_off; @@ -907,15 +969,15 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, int draw_direction = 1; gboolean do_quick_draw; - if(GDK_IS_WINDOW(GDK_DRAWABLE_P(drawable)->wrapper)) + if (GDK_IS_WINDOW (private->wrapper)) { - if(!GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->mapped) + if (!GDK_WINDOW_P (private->wrapper)->mapped) return; - if(GDK_WINDOW_P(GDK_DRAWABLE_P(drawable)->wrapper)->input_only) - g_error("Drawing on the evil input-only!"); + if (GDK_WINDOW_P (private->wrapper)->input_only) + g_error ("Drawing on the evil input-only!"); } - if(drawable == src) + if (drawable == src) { GdkRegionBox srcb, destb; srcb.x1 = xsrc; @@ -927,16 +989,15 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, destb.x2 = xdest + width; destb.y2 = xdest + height; - if(EXTENTCHECK(&srcb, &destb) - && ydest > ysrc) + if (EXTENTCHECK (&srcb, &destb) && ydest > ysrc) draw_direction = -1; #if 0 { - GdkDrawableFBData *fbd = GDK_DRAWABLE_FBDATA(src); + GdkDrawableFBData *fbd = src_private; /* One lame hack deserves another ;-) */ - srcmem = g_alloca(fbd->rowstride * (fbd->lim_y - fbd->llim_y)); - memmove(srcmem, dc->mem + (fbd->rowstride * fbd->llim_y), fbd->rowstride * (fbd->lim_y - fbd->llim_y)); + srcmem = g_alloca (fbd->rowstride * (fbd->lim_y - fbd->llim_y)); + memmove (srcmem, dc->mem + (fbd->rowstride * fbd->llim_y), fbd->rowstride * (fbd->lim_y - fbd->llim_y)); srcmem -= (fbd->rowstride * fbd->llim_y); } #endif @@ -945,37 +1006,37 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, /* Do some magic to avoid creating extra regions unnecessarily */ tmpreg = dc->real_clip_region; - rect.x = xdest + GDK_DRAWABLE_FBDATA(drawable)->abs_x; - rect.y = ydest + GDK_DRAWABLE_FBDATA(drawable)->abs_y; + rect.x = xdest + private->abs_x; + rect.y = ydest + private->abs_y; rect.width = width; rect.height = height; - real_clip_region = gdk_region_rectangle(&rect); - gdk_region_intersect(real_clip_region, tmpreg); + real_clip_region = gdk_region_rectangle (&rect); + gdk_region_intersect (real_clip_region, tmpreg); - rect.x = xdest + GDK_DRAWABLE_FBDATA(drawable)->abs_x; - rect.y = ydest + GDK_DRAWABLE_FBDATA(drawable)->abs_y; - rect.width = MAX(GDK_DRAWABLE_P(src)->width - xsrc, 0); - rect.height = MAX(GDK_DRAWABLE_P(src)->height - ysrc, 0); - if(!rect.width || !rect.height) + rect.x = xdest + private->abs_x; + rect.y = ydest + private->abs_y; + rect.width = MAX (src_private->width - xsrc, 0); + rect.height = MAX (src_private->height - ysrc, 0); + if (!rect.width || !rect.height) goto out; - tmpreg = gdk_region_rectangle(&rect); - gdk_region_intersect(real_clip_region, tmpreg); - gdk_region_destroy(tmpreg); + tmpreg = gdk_region_rectangle (&rect); + gdk_region_intersect (real_clip_region, tmpreg); + gdk_region_destroy (tmpreg); - src_x_off = (GDK_DRAWABLE_FBDATA(src)->abs_x + xsrc) - (GDK_DRAWABLE_FBDATA(drawable)->abs_x + xdest); - src_y_off = (GDK_DRAWABLE_FBDATA(src)->abs_y + ysrc) - (GDK_DRAWABLE_FBDATA(drawable)->abs_y + ydest); + src_x_off = (src_private->abs_x + xsrc) - (private->abs_x + xdest); + src_y_off = (src_private->abs_y + ysrc) - (private->abs_y + ydest); - do_quick_draw = GDK_DRAWABLE_P(src)->depth == GDK_DRAWABLE_P(drawable)->depth - && GDK_DRAWABLE_P(src)->depth >= 8 - && GDK_DRAWABLE_P(src)->depth <= 32 - && (!gc || !GDK_GC_FBDATA(gc)->values.clip_mask); + do_quick_draw = src_private->depth == private->depth && + src_private->depth >= 8 && + src_private->depth <= 32 && + (!gc || !GDK_GC_FBDATA (gc)->values.clip_mask); for(i = 0; i < real_clip_region->numRects; i++) { GdkRegionBox *cur = &real_clip_region->rects[i]; int start_y, end_y, cur_y; - if(draw_direction > 0) + if (draw_direction > 0) { start_y = cur->y1; end_y = cur->y2; @@ -986,41 +1047,41 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, end_y = cur->y1 - 1; } - if(do_quick_draw) + if (do_quick_draw) { - guint depth = GDK_DRAWABLE_P(src)->depth; - guint src_rowstride = GDK_DRAWABLE_FBDATA(src)->rowstride; + guint depth = src_private->depth; + guint src_rowstride = src_private->rowstride; int linelen = (cur->x2 - cur->x1)*(depth>>3); for(cur_y = start_y; cur_y*draw_direction < end_y*draw_direction; cur_y += draw_direction) { - memmove(dc->mem + (cur_y * dc->rowstride) + cur->x1*(depth>>3), - srcmem + ((cur_y + src_y_off)*src_rowstride) + (cur->x1 + src_x_off)*(depth>>3), - linelen); + memmove (dc->mem + (cur_y * dc->rowstride) + cur->x1*(depth>>3), + srcmem + ((cur_y + src_y_off)*src_rowstride) + (cur->x1 + src_x_off)*(depth>>3), + linelen); } } else { int cur_x; - for(cur_y = start_y; cur_y*draw_direction < end_y*draw_direction; cur_y+=draw_direction) + for (cur_y = start_y; cur_y*draw_direction < end_y*draw_direction; cur_y+=draw_direction) { - for(cur_x = cur->x1; cur_x < cur->x2; cur_x++) + for (cur_x = cur->x1; cur_x < cur->x2; cur_x++) { GdkColor spot; - if(gc && GDK_GC_FBDATA(gc)->values.clip_mask) + if (gc && GDK_GC_FBDATA(gc)->values.clip_mask) { int maskx = cur_x+dc->clipxoff, masky = cur_y + dc->clipyoff; guchar foo; foo = dc->clipmem[masky*dc->clip_rowstride + (maskx >> 3)]; - if(!(foo & (1 << (maskx % 8)))) + if (!(foo & (1 << (maskx % 8)))) continue; } - switch(gdk_fb_drawable_get_pixel(src, gc, cur_x + src_x_off, cur_y + src_y_off, &spot, TRUE, NULL, NULL)) + switch (gdk_fb_drawable_get_pixel (src, gc, cur_x + src_x_off, cur_y + src_y_off, &spot, TRUE, NULL, NULL)) { case GPR_AA_GRAYVAL: { @@ -1028,40 +1089,40 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, guint graylevel = spot.pixel; gint tmp; - if(GDK_DRAWABLE_P(drawable)->depth == 1) + if (private->depth == 1) { - if(spot.pixel > 192) - spot = GDK_GC_FBDATA(gc)->values.foreground; + if (spot.pixel > 192) + spot = GDK_GC_FBDATA (gc)->values.foreground; else - spot = GDK_GC_FBDATA(gc)->values.background; + spot = GDK_GC_FBDATA (gc)->values.background; break; } else { - if(graylevel >= 254) + if (graylevel >= 254) { - spot = GDK_GC_FBDATA(gc)->values.foreground; + spot = GDK_GC_FBDATA (gc)->values.foreground; } - else if(graylevel <= 2) + else if (graylevel <= 2) { - if(!dc->draw_bg) + if (!dc->draw_bg) continue; - spot = GDK_GC_FBDATA(gc)->values.background; + spot = GDK_GC_FBDATA (gc)->values.background; } else { - switch(gdk_fb_drawable_get_pixel(drawable, gc, cur_x, cur_y, &realspot, TRUE, dc->bg_relto, dc->bgpm)) + switch (gdk_fb_drawable_get_pixel (drawable, gc, cur_x, cur_y, &realspot, TRUE, dc->bg_relto, dc->bgpm)) { case GPR_NONE: case GPR_USED_BG: break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } - fg = GDK_GC_FBDATA(gc)->values.foreground; + fg = GDK_GC_FBDATA (gc)->values.foreground; /* Now figure out what 'spot' should actually look like */ fg.red >>= 8; fg.green >>= 8; @@ -1083,12 +1144,12 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, spot.blue <<= 8; /* Now find the pixel for this thingie */ - switch(GDK_DRAWABLE_P(drawable)->depth) + switch (private->depth) { case 8: - if(!gdk_colormap_alloc_color(GDK_DRAWABLE_P(drawable)->colormap, &spot, FALSE, TRUE)) + if (!gdk_colormap_alloc_color (private->colormap, &spot, FALSE, TRUE)) { - g_error("Can't allocate AA color!"); + g_error ("Can't allocate AA color!"); } break; case 16: @@ -1108,24 +1169,24 @@ gdk_fb_draw_drawable_3 (GdkDrawable *drawable, } break; case GPR_USED_BG: - if(!dc->draw_bg) + if (!dc->draw_bg) continue; break; case GPR_NONE: break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } - gdk_fb_drawable_set_pixel(drawable, gc, cur_x, cur_y, &spot, GDK_DRAWABLE_P(src)->depth); + gdk_fb_drawable_set_pixel (drawable, gc, cur_x, cur_y, &spot, src_private->depth); } } } } out: - gdk_region_destroy(real_clip_region); + gdk_region_destroy (real_clip_region); } void @@ -1139,7 +1200,7 @@ gdk_fb_draw_drawable (GdkDrawable *drawable, gint width, gint height) { - gdk_fb_draw_drawable_2(drawable, gc, GDK_DRAWABLE_IMPL(src), xsrc, ysrc, xdest, ydest, width, height, TRUE, TRUE); + gdk_fb_draw_drawable_2 (drawable, gc, GDK_DRAWABLE_IMPL (src), xsrc, ysrc, xdest, ydest, width, height, TRUE, TRUE); } static void @@ -1151,7 +1212,7 @@ gdk_fb_draw_text(GdkDrawable *drawable, const gchar *text, gint text_length) { - g_warning("gdk_fb_draw_text NYI"); + g_warning ("gdk_fb_draw_text NYI"); } static void @@ -1163,7 +1224,7 @@ gdk_fb_draw_text_wc (GdkDrawable *drawable, const GdkWChar *text, gint text_length) { - g_warning("gdk_fb_draw_text_wc NYI"); + g_warning ("gdk_fb_draw_text_wc NYI"); } void @@ -1177,13 +1238,13 @@ gdk_fb_draw_rectangle (GdkDrawable *drawable, { GdkRectangle rect; - if(filled) + if (filled) { rect.x = x; rect.y = y; rect.width = width; rect.height = height; - gdk_fb_fill_spans(drawable, gc, &rect, 1); + gdk_fb_fill_spans (drawable, gc, &rect, 1); } else { @@ -1196,37 +1257,39 @@ gdk_fb_draw_rectangle (GdkDrawable *drawable, pts[2].y = y + height; pts[3].x = x; pts[3].y = y + height; - gdk_fb_draw_lines(drawable, gc, pts, 5); + gdk_fb_draw_lines (drawable, gc, pts, 5); } } -static void gdk_fb_draw_points (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints) +static void +gdk_fb_draw_points (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints) { - GdkRectangle *rects = g_alloca(npoints * sizeof(GdkRectangle)); + GdkRectangle *rects = g_alloca (npoints * sizeof(GdkRectangle)); int i; - for(i = 0; i < npoints; i++) + for (i = 0; i < npoints; i++) { rects[i].x = points[i].x; rects[i].y = points[i].y; rects[i].width = rects[i].height = 1; } - gdk_fb_fill_spans(drawable, gc, rects, npoints); + gdk_fb_fill_spans (drawable, gc, rects, npoints); } -static void gdk_fb_draw_arc (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height, - gint angle1, - gint angle2) +static void +gdk_fb_draw_arc (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + gint x, + gint y, + gint width, + gint height, + gint angle1, + gint angle2) { miArc arc; @@ -1237,45 +1300,48 @@ static void gdk_fb_draw_arc (GdkDrawable *drawable, arc.angle1 = angle1; arc.angle2 = angle2; - if(filled) - miPolyFillArc(drawable, gc, 1, &arc); + if (filled) + miPolyFillArc (drawable, gc, 1, &arc); else - miPolyArc(drawable, gc, 1, &arc); + miPolyArc (drawable, gc, 1, &arc); } -static void gdk_fb_draw_polygon (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - GdkPoint *points, - gint npoints) +static void +gdk_fb_draw_polygon (GdkDrawable *drawable, + GdkGC *gc, + gint filled, + GdkPoint *points, + gint npoints) { - if(filled) - miFillPolygon(drawable, gc, 0, 0, npoints, points); + if (filled) + miFillPolygon (drawable, gc, 0, 0, npoints, points); else { - GdkPoint *realpts = g_alloca(sizeof(GdkPoint) * (npoints + 1)); + GdkPoint *realpts = g_alloca (sizeof(GdkPoint) * (npoints + 1)); - memcpy(realpts, points, sizeof(GdkPoint) * npoints); + memcpy (realpts, points, sizeof(GdkPoint) * npoints); realpts[npoints] = points[0]; - gdk_fb_draw_lines(drawable, gc, points, npoints); + gdk_fb_draw_lines (drawable, gc, points, npoints); } } -static void gdk_fb_draw_lines (GdkDrawable *drawable, - GdkGC *gc, - GdkPoint *points, - gint npoints) +static void +gdk_fb_draw_lines (GdkDrawable *drawable, + GdkGC *gc, + GdkPoint *points, + gint npoints) { - if(GDK_GC_FBDATA(gc)->values.line_width > 0) - miWideLine(drawable, gc, 0, npoints, points); + if (GDK_GC_FBDATA (gc)->values.line_width > 0) + miWideLine (drawable, gc, 0, npoints, points); else - miZeroLine(drawable, gc, 0, npoints, points); + miZeroLine (drawable, gc, 0, npoints, points); } -static void gdk_fb_draw_segments (GdkDrawable *drawable, - GdkGC *gc, - GdkSegment *segs, - gint nsegs) +static void +gdk_fb_draw_segments (GdkDrawable *drawable, + GdkGC *gc, + GdkSegment *segs, + gint nsegs) { GdkPoint pts[2]; int i; @@ -1286,13 +1352,13 @@ static void gdk_fb_draw_segments (GdkDrawable *drawable, pts[0].y = segs[i].y1; pts[1].x = segs[i].x2; pts[1].y = segs[i].y2; - - gdk_fb_draw_lines(drawable, gc, pts, 2); + + gdk_fb_draw_lines (drawable, gc, pts, 2); } } void -gdk_fb_drawable_clear(GdkDrawable *d) +gdk_fb_drawable_clear (GdkDrawable *d) { extern void _gdk_windowing_window_clear_area (GdkWindow *window, @@ -1301,64 +1367,66 @@ gdk_fb_drawable_clear(GdkDrawable *d) gint width, gint height); - _gdk_windowing_window_clear_area(d, 0, 0, GDK_DRAWABLE_IMPL_FBDATA(d)->width, GDK_DRAWABLE_IMPL_FBDATA(d)->height); + _gdk_windowing_window_clear_area (d, 0, 0, GDK_DRAWABLE_IMPL_FBDATA (d)->width, GDK_DRAWABLE_IMPL_FBDATA (d)->height); } extern FT_Library gdk_fb_ft_lib; extern void pango_fb_font_set_size(PangoFont *font); -static void gdk_fb_draw_glyphs(GdkDrawable *drawable, - GdkGC *gc, - PangoFont *font, - gint x, - gint y, - PangoGlyphString *glyphs) +static void +gdk_fb_draw_glyphs (GdkDrawable *drawable, + GdkGC *gc, + PangoFont *font, + gint x, + gint y, + PangoGlyphString *glyphs) { int i; int xpos; GdkFBDrawingContext fbdc; - g_return_if_fail(font); + g_return_if_fail (font); - gdk_fb_drawing_context_init(&fbdc, drawable, gc, FALSE, TRUE); + gdk_fb_drawing_context_init (&fbdc, drawable, gc, FALSE, TRUE); /* Fake its existence as a pixmap */ - pango_fb_font_set_size(font); - for(i = xpos = 0; i < glyphs->num_glyphs; i++) + pango_fb_font_set_size (font); + + for (i = xpos = 0; i < glyphs->num_glyphs; i++) { PangoFBGlyphInfo *pgi; int this_wid; - pgi = pango_fb_font_get_glyph_info(font, glyphs->glyphs[i].glyph); + pgi = pango_fb_font_get_glyph_info (font, glyphs->glyphs[i].glyph); this_wid = (xpos + glyphs->glyphs[i].geometry.width)/PANGO_SCALE; - gdk_fb_draw_drawable_3(drawable, gc, (GdkPixmap *)&pgi->fbd, - &fbdc, - 0, 0, - x + (xpos + glyphs->glyphs[i].geometry.x_offset)/PANGO_SCALE, - y + glyphs->glyphs[i].geometry.y_offset / PANGO_SCALE - + pgi->hbearing, - this_wid, pgi->fbd.drawable_data.height); + gdk_fb_draw_drawable_3 (drawable, gc, (GdkPixmap *)&pgi->fbd, + &fbdc, + 0, 0, + x + (xpos + glyphs->glyphs[i].geometry.x_offset)/PANGO_SCALE, + y + glyphs->glyphs[i].geometry.y_offset / PANGO_SCALE + + pgi->hbearing, + this_wid, pgi->fbd.drawable_data.height); xpos += glyphs->glyphs[i].geometry.width; } - gdk_fb_drawing_context_finalize(&fbdc); + gdk_fb_drawing_context_finalize (&fbdc); } static void -gdk_fb_draw_image(GdkDrawable *drawable, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) +gdk_fb_draw_image (GdkDrawable *drawable, + GdkGC *gc, + GdkImage *image, + gint xsrc, + gint ysrc, + gint xdest, + gint ydest, + gint width, + gint height) { GdkImagePrivateFB *image_private; GdkPixmapFBData fbd; @@ -1372,7 +1440,7 @@ gdk_fb_draw_image(GdkDrawable *drawable, g_return_if_fail (image->type == GDK_IMAGE_NORMAL); /* Fake its existence as a pixmap */ - memset(&fbd, 0, sizeof(fbd)); + memset (&fbd, 0, sizeof(fbd)); fbd.drawable_data.mem = image->mem; fbd.drawable_data.rowstride = image->bpl; fbd.drawable_data.width = fbd.drawable_data.lim_x = image->width; @@ -1380,7 +1448,7 @@ gdk_fb_draw_image(GdkDrawable *drawable, fbd.drawable_data.depth = image->depth; fbd.drawable_data.window_type = GDK_DRAWABLE_PIXMAP; - gdk_fb_draw_drawable_2(drawable, gc, (GdkPixmap *)&fbd, xsrc, ysrc, xdest, ydest, width, height, TRUE, TRUE); + gdk_fb_draw_drawable_2 (drawable, gc, (GdkPixmap *)&fbd, xsrc, ysrc, xdest, ydest, width, height, TRUE, TRUE); } static gint diff --git a/gdk/linux-fb/gdkevents-fb.c b/gdk/linux-fb/gdkevents-fb.c index 482516c4a6..36c9cfd8c1 100644 --- a/gdk/linux-fb/gdkevents-fb.c +++ b/gdk/linux-fb/gdkevents-fb.c @@ -90,16 +90,17 @@ static GSourceFuncs event_funcs = { * Functions for maintaining the event queue * *********************************************/ -static gboolean fb_events_prepare(gpointer source_data, - GTimeVal *current_time, - gint *timeout, - gpointer user_data); -static gboolean fb_events_check(gpointer source_data, - GTimeVal *current_time, - gpointer user_data); -static gboolean fb_events_dispatch(gpointer source_data, - GTimeVal *dispatch_time, - gpointer user_data); +static gboolean fb_events_prepare (gpointer source_data, + GTimeVal *current_time, + gint *timeout, + gpointer user_data); +static gboolean fb_events_check (gpointer source_data, + GTimeVal *current_time, + gpointer user_data); +static gboolean fb_events_dispatch (gpointer source_data, + GTimeVal *dispatch_time, + gpointer user_data); + void gdk_events_init (void) { @@ -110,7 +111,7 @@ gdk_events_init (void) NULL }; - g_source_add(GDK_PRIORITY_EVENTS, TRUE, &fb_events_funcs, NULL, NULL, NULL); + g_source_add (GDK_PRIORITY_EVENTS, TRUE, &fb_events_funcs, NULL, NULL, NULL); } /* @@ -132,7 +133,7 @@ gdk_events_init (void) gboolean gdk_events_pending (void) { - return gdk_event_queue_find_first()?TRUE:FALSE; + return gdk_event_queue_find_first () ? TRUE : FALSE; } GdkEvent* @@ -141,20 +142,20 @@ gdk_event_get_graphics_expose (GdkWindow *window) GList *ltmp; g_return_val_if_fail (window != NULL, NULL); - for(ltmp = gdk_queued_events; ltmp; ltmp = ltmp->next) + for (ltmp = gdk_queued_events; ltmp; ltmp = ltmp->next) { GdkEvent *event = ltmp->data; - if(event->type == GDK_EXPOSE - && event->expose.window == window) + if (event->type == GDK_EXPOSE && + event->expose.window == window) break; } - if(ltmp) + if (ltmp) { GdkEvent *retval = ltmp->data; - gdk_event_queue_remove_link(ltmp); - g_list_free_1(ltmp); + gdk_event_queue_remove_link (ltmp); + g_list_free_1 (ltmp); return retval; } @@ -168,53 +169,58 @@ gdk_events_queue (void) } static gboolean -fb_events_prepare(gpointer source_data, - GTimeVal *current_time, - gint *timeout, - gpointer user_data) +fb_events_prepare (gpointer source_data, + GTimeVal *current_time, + gint *timeout, + gpointer user_data) { *timeout = -1; - return fb_events_check(source_data, current_time, user_data); + return fb_events_check (source_data, current_time, user_data); } static gboolean -fb_events_check(gpointer source_data, - GTimeVal *current_time, - gpointer user_data) +fb_events_check (gpointer source_data, + GTimeVal *current_time, + gpointer user_data) { gboolean retval; - GDK_THREADS_ENTER(); + GDK_THREADS_ENTER (); retval = (gdk_event_queue_find_first () != NULL); - GDK_THREADS_LEAVE(); + GDK_THREADS_LEAVE (); return retval; } static gboolean -fb_events_dispatch(gpointer source_data, GTimeVal *dispatch_time, gpointer user_data) +fb_events_dispatch (gpointer source_data, + GTimeVal *dispatch_time, + gpointer user_data) { GdkEvent *event; - GDK_THREADS_ENTER(); + GDK_THREADS_ENTER (); - while((event = gdk_event_unqueue())) + while (event = gdk_event_unqueue ()) { - if(event->type == GDK_EXPOSE - && event->expose.window == gdk_parent_root) - gdk_window_clear_area(event->expose.window, event->expose.area.x, event->expose.area.y, event->expose.area.width, - event->expose.area.height); + if (event->type == GDK_EXPOSE && + event->expose.window == gdk_parent_root) + gdk_window_clear_area (event->expose.window, + event->expose.area.x, + event->expose.area.y, + event->expose.area.width, + event->expose.area.height); - else if(gdk_event_func) - (*gdk_event_func)(event, gdk_event_data); + else if (gdk_event_func) + (*gdk_event_func) (event, gdk_event_data); - gdk_event_free(event); + gdk_event_free (event); } - GDK_THREADS_LEAVE(); + GDK_THREADS_LEAVE (); return TRUE; } @@ -248,6 +254,7 @@ gdk_event_send_client_message (GdkEvent *event, guint32 xid) return FALSE; } -void gdk_event_send_clientmessage_toall (GdkEvent *sev) +void +gdk_event_send_clientmessage_toall (GdkEvent *sev) { } diff --git a/gdk/linux-fb/gdkfont-fb.c b/gdk/linux-fb/gdkfont-fb.c index e55f477905..a156234d32 100644 --- a/gdk/linux-fb/gdkfont-fb.c +++ b/gdk/linux-fb/gdkfont-fb.c @@ -44,9 +44,9 @@ gdk_font_from_description (PangoFontDescription *font_desc) GdkFont *font; GdkFontPrivateFB *private; - g_return_val_if_fail(font_desc, NULL); + g_return_val_if_fail (font_desc, NULL); - private = g_new0(GdkFontPrivateFB, 1); + private = g_new0 (GdkFontPrivateFB, 1); font = (GdkFont *)private; private->base.ref_count = 1; @@ -166,6 +166,12 @@ gdk_fontset_load (const gchar *fontset_name) } #endif +GdkFont * +gdk_font_load (const gchar *font_name) +{ + return NULL; +} + void _gdk_font_destroy (GdkFont *font) { @@ -370,10 +376,17 @@ gdk_text_extents_wc (GdkFont *font, char *realstr; int i; - realstr = alloca(text_length + 1); + realstr = alloca (text_length + 1); for(i = 0; i < text_length; i++) realstr[i] = text[i]; realstr[i] = '\0'; - return gdk_text_extents(font, realstr, text_length, lbearing, rbearing, width, ascent, descent); + return gdk_text_extents (font, + realstr, + text_length, + lbearing, + rbearing, + width, + ascent, + descent); } diff --git a/gdk/linux-fb/gdkgc-fb.c b/gdk/linux-fb/gdkgc-fb.c index 762282ee2f..62bb2b78f1 100644 --- a/gdk/linux-fb/gdkgc-fb.c +++ b/gdk/linux-fb/gdkgc-fb.c @@ -11,16 +11,16 @@ typedef enum { GDK_GC_DIRTY_TS = 1 << 1 } GdkGCDirtyValues; -static void gdk_fb_gc_finalize (GObject *obj); +static void gdk_fb_gc_finalize (GObject *obj); static void gdk_fb_gc_get_values (GdkGC *gc, - GdkGCValues *values); + GdkGCValues *values); static void gdk_fb_gc_set_values (GdkGC *gc, - GdkGCValues *values, - GdkGCValuesMask values_mask); -static void gdk_fb_gc_set_dashes (GdkGC *gc, - gint dash_offset, - gint8 dash_list[], - gint n); + GdkGCValues *values, + GdkGCValuesMask values_mask); +static void gdk_fb_gc_set_dashes (GdkGC *gc, + gint dash_offset, + gint8 dash_list[], + gint n); static gpointer parent_class = NULL; @@ -39,7 +39,8 @@ gdk_gc_fb_class_init (GdkGCFBClass *klass) gc_class->set_dashes = gdk_fb_gc_set_dashes; } -GType gdk_gc_fb_get_type (void) +GType +gdk_gc_fb_get_type (void) { static GType object_type = 0; @@ -76,14 +77,14 @@ _gdk_fb_gc_new (GdkDrawable *drawable, GdkGC *private; GdkGCFBData *data; - gc = GDK_GC(g_object_new (gdk_gc_fb_get_type (), NULL)); + gc = GDK_GC (g_object_new (gdk_gc_fb_get_type (), NULL)); private = (GdkGC *)gc; data = (GdkGCFBData *)gc; data->values.foreground.pixel = 255; data->values.foreground.red = data->values.foreground.green = data->values.foreground.blue = 65535; - gdk_fb_gc_set_values(gc, values, values_mask); + gdk_fb_gc_set_values (gc, values, values_mask); return gc; } @@ -91,16 +92,19 @@ _gdk_fb_gc_new (GdkDrawable *drawable, static void gdk_fb_gc_finalize (GObject *obj) { - GdkGC *gc = GDK_GC_P(obj); + GdkGC *gc = GDK_GC_P (obj); + GdkGCFBData *private; - if (GDK_GC_FBDATA (gc)->clip_region) - gdk_region_destroy (GDK_GC_FBDATA (gc)->clip_region); - if (GDK_GC_FBDATA (gc)->values.clip_mask) - gdk_pixmap_unref(GDK_GC_FBDATA (gc)->values.clip_mask); - if (GDK_GC_FBDATA (gc)->values.stipple) - gdk_pixmap_unref(GDK_GC_FBDATA (gc)->values.stipple); - if (GDK_GC_FBDATA (gc)->values.tile) - gdk_pixmap_unref(GDK_GC_FBDATA (gc)->values.tile); + private = GDK_GC_FBDATA (gc); + + if (private->clip_region) + gdk_region_destroy (private->clip_region); + if (private->values.clip_mask) + gdk_pixmap_unref (private->values.clip_mask); + if (private->values.stipple) + gdk_pixmap_unref (private->values.stipple); + if (private->values.tile) + gdk_pixmap_unref (private->values.tile); G_OBJECT_CLASS (parent_class)->finalize (obj); } @@ -109,7 +113,7 @@ static void gdk_fb_gc_get_values (GdkGC *gc, GdkGCValues *values) { - *values = GDK_GC_FBDATA(gc)->values; + *values = GDK_GC_FBDATA (gc)->values; } @@ -120,137 +124,140 @@ gdk_fb_gc_set_values (GdkGC *gc, { GdkPixmap *oldpm; GdkFont *oldf; + GdkGCFBData *private; - if(values_mask & GDK_GC_FOREGROUND) + private = GDK_GC_FBDATA (gc); + + if (values_mask & GDK_GC_FOREGROUND) { - GDK_GC_FBDATA(gc)->values.foreground = values->foreground; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_FOREGROUND; + private->values.foreground = values->foreground; + private->values_mask |= GDK_GC_FOREGROUND; } - if(values_mask & GDK_GC_BACKGROUND) + if (values_mask & GDK_GC_BACKGROUND) { - GDK_GC_FBDATA(gc)->values.background = values->background; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_BACKGROUND; + private->values.background = values->background; + private->values_mask |= GDK_GC_BACKGROUND; } - if(values_mask & GDK_GC_FONT) + if (values_mask & GDK_GC_FONT) { - oldf = GDK_GC_FBDATA(gc)->values.font; - GDK_GC_FBDATA(gc)->values.font = gdk_font_ref(values->font); - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_FONT; - if(oldf) + oldf = private->values.font; + private->values.font = gdk_font_ref (values->font); + private->values_mask |= GDK_GC_FONT; + if (oldf) gdk_font_unref(oldf); } - if(values_mask & GDK_GC_FUNCTION) + if (values_mask & GDK_GC_FUNCTION) { - GDK_GC_FBDATA(gc)->values.function = values->function; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_FUNCTION; + private->values.function = values->function; + private->values_mask |= GDK_GC_FUNCTION; } - if(values_mask & GDK_GC_FILL) + if (values_mask & GDK_GC_FILL) { - GDK_GC_FBDATA(gc)->values.fill = values->fill; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_FILL; + private->values.fill = values->fill; + private->values_mask |= GDK_GC_FILL; } - if(values_mask & GDK_GC_TILE) + if (values_mask & GDK_GC_TILE) { - oldpm = GDK_GC_FBDATA(gc)->values.tile; - if(values->tile) - g_assert(GDK_DRAWABLE_IMPL_FBDATA(values->tile)->depth >= 8); + oldpm = private->values.tile; + if (values->tile) + g_assert (GDK_DRAWABLE_IMPL_FBDATA (values->tile)->depth >= 8); - GDK_GC_FBDATA(gc)->values.tile = values->tile?gdk_pixmap_ref(values->tile):NULL; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_TILE; - if(oldpm) - gdk_pixmap_unref(oldpm); + private->values.tile = values->tile ? gdk_pixmap_ref (values->tile) : NULL; + private->values_mask |= GDK_GC_TILE; + if (oldpm) + gdk_pixmap_unref (oldpm); } - if(values_mask & GDK_GC_STIPPLE) + if (values_mask & GDK_GC_STIPPLE) { - oldpm = GDK_GC_FBDATA(gc)->values.stipple; - if(values->stipple) - g_assert(GDK_DRAWABLE_IMPL_FBDATA(values->stipple)->depth == 1); - GDK_GC_FBDATA(gc)->values.stipple = values->stipple?gdk_pixmap_ref(values->stipple):NULL; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_STIPPLE; - if(oldpm) - gdk_pixmap_unref(oldpm); + oldpm = private->values.stipple; + if (values->stipple) + g_assert (GDK_DRAWABLE_IMPL_FBDATA (values->stipple)->depth == 1); + private->values.stipple = values->stipple ? gdk_pixmap_ref (values->stipple) : NULL; + private->values_mask |= GDK_GC_STIPPLE; + if (oldpm) + gdk_pixmap_unref (oldpm); } - if(values_mask & GDK_GC_CLIP_MASK) + if (values_mask & GDK_GC_CLIP_MASK) { - oldpm = GDK_GC_FBDATA(gc)->values.clip_mask; + oldpm = private->values.clip_mask; - GDK_GC_FBDATA(gc)->values.clip_mask = values->clip_mask?gdk_pixmap_ref(values->clip_mask):NULL; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_CLIP_MASK; - if(oldpm) - gdk_pixmap_unref(oldpm); + private->values.clip_mask = values->clip_mask ? gdk_pixmap_ref (values->clip_mask) : NULL; + private->values_mask |= GDK_GC_CLIP_MASK; + if (oldpm) + gdk_pixmap_unref (oldpm); - if(GDK_GC_FBDATA(gc)->clip_region) + if (private->clip_region) { - gdk_region_destroy(GDK_GC_FBDATA(gc)->clip_region); - GDK_GC_FBDATA(gc)->clip_region = NULL; + gdk_region_destroy (private->clip_region); + private->clip_region = NULL; } } - if(values_mask & GDK_GC_SUBWINDOW) + if (values_mask & GDK_GC_SUBWINDOW) { - GDK_GC_FBDATA(gc)->values.subwindow_mode = values->subwindow_mode; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_SUBWINDOW; + private->values.subwindow_mode = values->subwindow_mode; + private->values_mask |= GDK_GC_SUBWINDOW; } - if(values_mask & GDK_GC_TS_X_ORIGIN) + if (values_mask & GDK_GC_TS_X_ORIGIN) { - GDK_GC_FBDATA(gc)->values.ts_x_origin = values->ts_x_origin; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_TS_X_ORIGIN; + private->values.ts_x_origin = values->ts_x_origin; + private->values_mask |= GDK_GC_TS_X_ORIGIN; } - if(values_mask & GDK_GC_TS_Y_ORIGIN) + if (values_mask & GDK_GC_TS_Y_ORIGIN) { - GDK_GC_FBDATA(gc)->values.ts_y_origin = values->ts_y_origin; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_TS_Y_ORIGIN; + private->values.ts_y_origin = values->ts_y_origin; + private->values_mask |= GDK_GC_TS_Y_ORIGIN; } - if(values_mask & GDK_GC_CLIP_X_ORIGIN) + if (values_mask & GDK_GC_CLIP_X_ORIGIN) { - GDK_GC_FBDATA(gc)->values.clip_x_origin = GDK_GC_P(gc)->clip_x_origin = values->clip_x_origin; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_CLIP_X_ORIGIN; + private->values.clip_x_origin = GDK_GC_P (gc)->clip_x_origin = values->clip_x_origin; + private->values_mask |= GDK_GC_CLIP_X_ORIGIN; } - if(values_mask & GDK_GC_CLIP_Y_ORIGIN) + if (values_mask & GDK_GC_CLIP_Y_ORIGIN) { - GDK_GC_FBDATA(gc)->values.clip_y_origin = GDK_GC_P(gc)->clip_y_origin = values->clip_y_origin; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_CLIP_Y_ORIGIN; + private->values.clip_y_origin = GDK_GC_P(gc)->clip_y_origin = values->clip_y_origin; + private->values_mask |= GDK_GC_CLIP_Y_ORIGIN; } - if(values_mask & GDK_GC_EXPOSURES) + if (values_mask & GDK_GC_EXPOSURES) { - GDK_GC_FBDATA(gc)->values.graphics_exposures = values->graphics_exposures; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_EXPOSURES; + private->values.graphics_exposures = values->graphics_exposures; + private->values_mask |= GDK_GC_EXPOSURES; } - if(values_mask & GDK_GC_LINE_WIDTH) + if (values_mask & GDK_GC_LINE_WIDTH) { - GDK_GC_FBDATA(gc)->values.line_width = values->line_width; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_LINE_WIDTH; + private->values.line_width = values->line_width; + private->values_mask |= GDK_GC_LINE_WIDTH; } - if(values_mask & GDK_GC_LINE_STYLE) + if (values_mask & GDK_GC_LINE_STYLE) { - GDK_GC_FBDATA(gc)->values.line_style = values->line_style; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_LINE_STYLE; + private->values.line_style = values->line_style; + private->values_mask |= GDK_GC_LINE_STYLE; } - if(values_mask & GDK_GC_CAP_STYLE) + if (values_mask & GDK_GC_CAP_STYLE) { - GDK_GC_FBDATA(gc)->values.cap_style = values->cap_style; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_CAP_STYLE; + private->values.cap_style = values->cap_style; + private->values_mask |= GDK_GC_CAP_STYLE; } - if(values_mask & GDK_GC_JOIN_STYLE) + if (values_mask & GDK_GC_JOIN_STYLE) { - GDK_GC_FBDATA(gc)->values.join_style = values->join_style; - GDK_GC_FBDATA(gc)->values_mask |= GDK_GC_JOIN_STYLE; + private->values.join_style = values->join_style; + private->values_mask |= GDK_GC_JOIN_STYLE; } } @@ -260,17 +267,22 @@ gdk_fb_gc_set_dashes (GdkGC *gc, gint8 dash_list[], gint n) { - GDK_GC_FBDATA(gc)->dash_offset = dash_offset; - GDK_GC_FBDATA(gc)->dash_list_len = n; - if(n) + GdkGCFBData *private; + + private = GDK_GC_FBDATA (gc); + + private->dash_offset = dash_offset; + private->dash_list_len = n; + + if (n) { - GDK_GC_FBDATA(gc)->dash_list = g_realloc(GDK_GC_FBDATA(gc)->dash_list, n); - memcpy(GDK_GC_FBDATA(gc)->dash_list, dash_list, n); + private->dash_list = g_realloc (private->dash_list, n); + memcpy (private->dash_list, dash_list, n); } else { - g_free(GDK_GC_FBDATA(gc)->dash_list); - GDK_GC_FBDATA(gc)->dash_list = NULL; + g_free (private->dash_list); + private->dash_list = NULL; } } @@ -279,13 +291,15 @@ gc_unset_cmask(GdkGC *gc) { GdkGCFBData *data; data = GDK_GC_FBDATA (gc); - if(data->values.clip_mask) + + if (data->values.clip_mask) { - gdk_pixmap_unref(data->values.clip_mask); + gdk_pixmap_unref (data->values.clip_mask); data->values.clip_mask = NULL; data->values_mask &= ~ GDK_GC_CLIP_MASK; } } + void gdk_gc_set_clip_rectangle (GdkGC *gc, GdkRectangle *rectangle) @@ -311,7 +325,7 @@ gdk_gc_set_clip_rectangle (GdkGC *gc, data->values.clip_x_origin = 0; data->values.clip_y_origin = 0; - gc_unset_cmask(gc); + gc_unset_cmask (gc); } void @@ -325,7 +339,7 @@ gdk_gc_set_clip_region (GdkGC *gc, data = GDK_GC_FBDATA (gc); - if(region == data->clip_region) + if (region == data->clip_region) return; if (data->clip_region) @@ -342,37 +356,41 @@ gdk_gc_set_clip_region (GdkGC *gc, data->values.clip_x_origin = 0; data->values.clip_y_origin = 0; - gc_unset_cmask(gc); + gc_unset_cmask (gc); } void gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc) { + GdkGCFBData *dst_private; + + dst_private = GDK_GC_FBDATA (dst_gc); + g_return_if_fail (dst_gc != NULL); g_return_if_fail (src_gc != NULL); - if(GDK_GC_FBDATA(dst_gc)->clip_region) - gdk_region_destroy(GDK_GC_FBDATA(dst_gc)->clip_region); + if (dst_private->clip_region) + gdk_region_destroy(dst_private->clip_region); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_FONT) - gdk_font_unref(GDK_GC_FBDATA(dst_gc)->values.font); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_TILE) - gdk_pixmap_unref(GDK_GC_FBDATA(dst_gc)->values.tile); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_STIPPLE) - gdk_pixmap_unref(GDK_GC_FBDATA(dst_gc)->values.stipple); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_CLIP_MASK) - gdk_pixmap_unref(GDK_GC_FBDATA(dst_gc)->values.clip_mask); + if (dst_private->values_mask & GDK_GC_FONT) + gdk_font_unref(dst_private->values.font); + if (dst_private->values_mask & GDK_GC_TILE) + gdk_pixmap_unref(dst_private->values.tile); + if (dst_private->values_mask & GDK_GC_STIPPLE) + gdk_pixmap_unref(dst_private->values.stipple); + if (dst_private->values_mask & GDK_GC_CLIP_MASK) + gdk_pixmap_unref(dst_private->values.clip_mask); *dst_gc = *src_gc; - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_FONT) - gdk_font_ref(GDK_GC_FBDATA(dst_gc)->values.font); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_TILE) - gdk_pixmap_ref(GDK_GC_FBDATA(dst_gc)->values.tile); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_STIPPLE) - gdk_pixmap_ref(GDK_GC_FBDATA(dst_gc)->values.stipple); - if(GDK_GC_FBDATA(dst_gc)->values_mask & GDK_GC_CLIP_MASK) - gdk_pixmap_ref(GDK_GC_FBDATA(dst_gc)->values.clip_mask); - if(GDK_GC_FBDATA(dst_gc)->clip_region) - GDK_GC_FBDATA(dst_gc)->clip_region = gdk_region_copy(GDK_GC_FBDATA(dst_gc)->clip_region); + if (dst_private->values_mask & GDK_GC_FONT) + gdk_font_ref(dst_private->values.font); + if (dst_private->values_mask & GDK_GC_TILE) + gdk_pixmap_ref(dst_private->values.tile); + if (dst_private->values_mask & GDK_GC_STIPPLE) + gdk_pixmap_ref(dst_private->values.stipple); + if (dst_private->values_mask & GDK_GC_CLIP_MASK) + gdk_pixmap_ref(dst_private->values.clip_mask); + if (dst_private->clip_region) + dst_private->clip_region = gdk_region_copy(dst_private->clip_region); } diff --git a/gdk/linux-fb/gdkgeometry-fb.c b/gdk/linux-fb/gdkgeometry-fb.c index 1ce3429951..3d419fd414 100644 --- a/gdk/linux-fb/gdkgeometry-fb.c +++ b/gdk/linux-fb/gdkgeometry-fb.c @@ -5,7 +5,7 @@ gdk_window_scroll (GdkWindow *window, gint dx, gint dy) { - GdkWindowObject *private = GDK_WINDOW_P(window); + GdkWindowObject *private = GDK_WINDOW_P (window); GdkRegion *invalidate_region; GdkRectangle dest_rect; GdkRectangle clip_rect; @@ -15,13 +15,13 @@ gdk_window_scroll (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - clip_rect.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - clip_rect.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - clip_rect.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - clip_rect.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - handle_cursor = gdk_fb_cursor_need_hide(&clip_rect); - clip_rect.x -= GDK_DRAWABLE_IMPL_FBDATA(window)->abs_x; - clip_rect.y -= GDK_DRAWABLE_IMPL_FBDATA(window)->abs_y; + clip_rect.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + clip_rect.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + clip_rect.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + clip_rect.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + handle_cursor = gdk_fb_cursor_need_hide (&clip_rect); + clip_rect.x -= GDK_DRAWABLE_IMPL_FBDATA (window)->abs_x; + clip_rect.y -= GDK_DRAWABLE_IMPL_FBDATA (window)->abs_y; invalidate_region = gdk_region_rectangle (&clip_rect); dest_rect = clip_rect; @@ -29,8 +29,8 @@ gdk_window_scroll (GdkWindow *window, dest_rect.y += dy; gdk_rectangle_intersect (&dest_rect, &clip_rect, &dest_rect); - if(handle_cursor) - gdk_fb_cursor_hide(); + if (handle_cursor) + gdk_fb_cursor_hide (); if (dest_rect.width > 0 && dest_rect.height > 0) { @@ -40,20 +40,27 @@ gdk_window_scroll (GdkWindow *window, gdk_region_subtract (invalidate_region, tmp_region); gdk_region_destroy (tmp_region); - gdk_fb_draw_drawable_2(GDK_DRAWABLE_IMPL(window), NULL, GDK_DRAWABLE_IMPL(window), dest_rect.x - dx, dest_rect.y - dy, dest_rect.x, dest_rect.y, - dest_rect.width, dest_rect.height, - FALSE, FALSE); + gdk_fb_draw_drawable_2 (GDK_DRAWABLE_IMPL(window), + NULL, + GDK_DRAWABLE_IMPL(window), + dest_rect.x - dx, + dest_rect.y - dy, + dest_rect.x, dest_rect.y, + dest_rect.width, dest_rect.height, + FALSE, FALSE); } + gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region); - for(tmp_list = private->children; tmp_list; tmp_list = tmp_list->next) + for (tmp_list = private->children; tmp_list; tmp_list = tmp_list->next) gdk_fb_window_move_resize (tmp_list->data, - GDK_WINDOW_OBJECT(tmp_list->data)->x + dx, GDK_WINDOW_OBJECT(tmp_list->data)->y + dy, + GDK_WINDOW_OBJECT(tmp_list->data)->x + dx, + GDK_WINDOW_OBJECT(tmp_list->data)->y + dy, GDK_DRAWABLE_IMPL_FBDATA(tmp_list->data)->width, GDK_DRAWABLE_IMPL_FBDATA(tmp_list->data)->height, FALSE); - if(handle_cursor) - gdk_fb_cursor_unhide(); + if (handle_cursor) + gdk_fb_cursor_unhide (); } diff --git a/gdk/linux-fb/gdkimage-fb.c b/gdk/linux-fb/gdkimage-fb.c index 96e518d4b3..6b728a1bf5 100644 --- a/gdk/linux-fb/gdkimage-fb.c +++ b/gdk/linux-fb/gdkimage-fb.c @@ -26,11 +26,6 @@ #include -#include -#ifndef __BYTE_ORDER -#error "endian.h needs to #define __BYTE_ORDER" -#endif - #include #include #include @@ -42,13 +37,17 @@ static gpointer parent_class = NULL; -void _gdk_windowing_image_init(void) +#define GDK_IMAGE_PRIVATE_DATA(image) ((GdkImagePrivateFB *) GDK_IMAGE (image)->windowing_data) + +void +_gdk_windowing_image_init (void) { } static void gdk_image_init (GdkImage *image) { + image->windowing_data = g_new0 (GdkImagePrivateFB, 1); } static void @@ -56,11 +55,11 @@ gdk_image_finalize (GObject *object) { GdkImage *image = GDK_IMAGE (object); - GdkImagePrivateFB *private; - - private = (GdkImagePrivateFB*) image; - - g_free(image->mem); image->mem = NULL; + g_free (image->windowing_data); + image->windowing_data = NULL; + + g_free (image->mem); + image->mem = NULL; G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -105,12 +104,17 @@ gdk_image_get_type (void) } GdkImage * -gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h) +gdk_image_new_bitmap(GdkVisual *visual, + gpointer data, + gint w, + gint h) { GdkImage *image; GdkImagePrivateFB *private; - image = (GdkImage *)private = (GdkImagePrivateFB *)g_object_new (gdk_image_get_type (), NULL); + image = g_object_new (gdk_image_get_type (), NULL); + private = GDK_IMAGE_PRIVATE_DATA (image); + image->type = GDK_IMAGE_NORMAL; image->visual = visual; image->width = w; @@ -118,9 +122,9 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h) image->depth = 1; image->byte_order = 1 /* MSBFirst */; - image->mem = g_malloc(w * h / 8); image->bpp = 1; image->bpl = (w+7)/8; + image->mem = g_malloc (image->bpl * h / 8); return image; } @@ -134,7 +138,8 @@ gdk_image_new (GdkImageType type, GdkImage *image; GdkImagePrivateFB *private; - image = (GdkImage *)private = (GdkImagePrivateFB *)g_object_new (gdk_image_get_type(), NULL); + image = g_object_new (gdk_image_get_type (), NULL); + private = GDK_IMAGE_PRIVATE_DATA (image); image->type = 0; image->visual = visual; @@ -143,9 +148,9 @@ gdk_image_new (GdkImageType type, image->depth = visual->depth; image->byte_order = 0; - image->mem = g_malloc(width * height * (image->depth >> 3)); image->bpp = image->depth/8; - image->bpl = (width * image->depth + 7)/8; + image->bpl = (width * image->depth + 7) / 8; + image->mem = g_malloc (image->bpl * height); return image; } @@ -159,12 +164,13 @@ _gdk_fb_get_image (GdkDrawable *drawable, { GdkImage *image; GdkImagePrivateFB *private; - gint bits_per_pixel = GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->depth; + gint bits_per_pixel = GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->depth; GdkPixmapFBData fbd; g_return_val_if_fail (drawable != NULL, NULL); - image = (GdkImage *)private = (GdkImagePrivateFB *)g_object_new (gdk_image_get_type(), NULL); + image = g_object_new (gdk_image_get_type (), NULL); + private = GDK_IMAGE_PRIVATE_DATA (image); image->type = GDK_IMAGE_NORMAL; image->visual = gdk_drawable_get_visual (drawable); @@ -181,11 +187,12 @@ _gdk_fb_get_image (GdkDrawable *drawable, else image->bpp = 4; image->byte_order = 1; - image->bpl = (image->width * image->depth + 7)/8; - image->mem = g_malloc(image->bpl * image->height); + + image->bpl = (image->width * image->depth + 7) / 8; /* Packed pixels */ + image->mem = g_malloc (image->bpl * image->height); /* Fake its existence as a pixmap */ - memset(&fbd, 0, sizeof(fbd)); + memset (&fbd, 0, sizeof(fbd)); fbd.drawable_data.mem = image->mem; fbd.drawable_data.rowstride = image->bpl; fbd.drawable_data.width = fbd.drawable_data.lim_x = image->width; @@ -193,7 +200,13 @@ _gdk_fb_get_image (GdkDrawable *drawable, fbd.drawable_data.depth = image->depth; fbd.drawable_data.window_type = GDK_DRAWABLE_PIXMAP; - gdk_fb_draw_drawable_2((GdkPixmap *)&fbd, NULL, drawable, x, y, 0, 0, width, height, TRUE, TRUE); + gdk_fb_draw_drawable_2 ((GdkPixmap *)&fbd, + NULL, + drawable, + x, y, + 0, 0, + width, height, + TRUE, TRUE); return image; } @@ -207,9 +220,9 @@ gdk_image_get_pixel (GdkImage *image, g_return_val_if_fail (image != NULL, 0); - private = (GdkImagePrivateFB *) image; + private = GDK_IMAGE_PRIVATE_DATA (image); - switch(image->depth) + switch (image->depth) { case 8: return ((guchar *)image->mem)[x + y * image->bpl]; @@ -239,7 +252,7 @@ gdk_image_put_pixel (GdkImage *image, g_return_if_fail (image != NULL); - switch(image->depth) + switch (image->depth) { case 8: ptr[x + y * image->bpl] = pixel; @@ -265,7 +278,7 @@ gdk_image_put_pixel (GdkImage *image, } break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } } diff --git a/gdk/linux-fb/gdkinput-ps2.c b/gdk/linux-fb/gdkinput-ps2.c index 70604045b6..8725320b14 100644 --- a/gdk/linux-fb/gdkinput-ps2.c +++ b/gdk/linux-fb/gdkinput-ps2.c @@ -30,7 +30,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -96,29 +98,29 @@ input_activity_timeout(gpointer p) /* This is all very broken :( */ static void -input_activity(void) +input_activity (void) { #if 0 - if(blanking_timer) - g_source_remove(blanking_timer); + if (blanking_timer) + g_source_remove (blanking_timer); else - gdk_fb_redraw_all(); + gdk_fb_redraw_all (); - blanking_timer = g_timeout_add(BLANKING_TIMEOUT, input_activity_timeout, NULL); + blanking_timer = g_timeout_add (BLANKING_TIMEOUT, input_activity_timeout, NULL); #endif } static gboolean -click_event_timeout(gpointer x) +click_event_timeout (gpointer x) { - switch(multiclick_event->type) + switch (multiclick_event->type) { case GDK_BUTTON_RELEASE: - gdk_event_free(multiclick_event); + gdk_event_free (multiclick_event); break; case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: - gdk_event_queue_append(multiclick_event); + gdk_event_queue_append (multiclick_event); break; default: break; @@ -131,36 +133,39 @@ click_event_timeout(gpointer x) } static void -send_button_event(MouseDevice *mouse, guint button, gboolean press_event, time_t the_time) +send_button_event (MouseDevice *mouse, + guint button, + gboolean press_event, + time_t the_time) { GdkEvent *event; gint x, y; GdkWindow *window; int nbuttons = 0; - if(_gdk_fb_pointer_grab_window_events) + if (_gdk_fb_pointer_grab_window_events) window = _gdk_fb_pointer_grab_window_events; else window = gdk_window_get_pointer(NULL, NULL, NULL, NULL); - gdk_window_get_origin(window, &x, &y); + gdk_window_get_origin (window, &x, &y); x = mouse->x - x; y = mouse->y - y; - if(!press_event - && multiclick_event - && multiclick_event->button.button == button - && multiclick_event->button.window == window - && ABS(multiclick_event->button.x - x) < 3 - && ABS(multiclick_event->button.y - y) < 3) + if (!press_event && + multiclick_event && + multiclick_event->button.button == button && + multiclick_event->button.window == window && + ABS(multiclick_event->button.x - x) < 3 && + ABS(multiclick_event->button.y - y) < 3) { multiclick_event->button.time = the_time; /* Just change multiclick_event into a different event */ - switch(multiclick_event->button.type) + switch (multiclick_event->button.type) { default: - g_assert_not_reached(); + g_assert_not_reached (); case GDK_BUTTON_RELEASE: multiclick_event->button.type = GDK_2BUTTON_PRESS; @@ -171,125 +176,136 @@ send_button_event(MouseDevice *mouse, guint button, gboolean press_event, time_t return; case GDK_3BUTTON_PRESS: - gdk_event_queue_append(multiclick_event); multiclick_event = NULL; - g_source_remove(multiclick_tag); multiclick_tag = 0; + gdk_event_queue_append (multiclick_event); multiclick_event = NULL; + g_source_remove (multiclick_tag); multiclick_tag = 0; } } - event = gdk_event_make(window, press_event?GDK_BUTTON_PRESS:GDK_BUTTON_RELEASE, FALSE); + event = gdk_event_make (window, press_event ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE, FALSE); - if(!event) + if (!event) return; event->button.x = x; event->button.y = y; event->button.button = button; - event->button.state = (mouse->button1_pressed?GDK_BUTTON1_MASK:0) - | (mouse->button2_pressed?GDK_BUTTON2_MASK:0) - | (mouse->button3_pressed?GDK_BUTTON3_MASK:0) - | (1 << (button + 8)) /* badhack */ - | keyboard->modifier_state; + event->button.state = (mouse->button1_pressed?GDK_BUTTON1_MASK:0) | + (mouse->button2_pressed ? GDK_BUTTON2_MASK : 0) | + (mouse->button3_pressed ? GDK_BUTTON3_MASK : 0) | + (1 << (button + 8)) /* badhack */ | + keyboard->modifier_state; event->button.device = gdk_core_pointer; event->button.x_root = mouse->x; event->button.y_root = mouse->y; - if(mouse->button1_pressed) + if (mouse->button1_pressed) nbuttons++; - if(mouse->button2_pressed) + if (mouse->button2_pressed) nbuttons++; - if(mouse->button3_pressed) + if (mouse->button3_pressed) nbuttons++; - if(press_event && nbuttons == 1) + if (press_event && nbuttons == 1) { - gdk_fb_pointer_grab(window, FALSE, gdk_window_get_events(window), NULL, NULL, GDK_CURRENT_TIME, TRUE); + gdk_fb_pointer_grab (window, FALSE, + gdk_window_get_events (window), + NULL, NULL, + GDK_CURRENT_TIME, TRUE); mouse->click_grab = TRUE; } - else if(!press_event && nbuttons == 0 && mouse->click_grab) + else if (!press_event && nbuttons == 0 && mouse->click_grab) { - gdk_fb_pointer_ungrab(GDK_CURRENT_TIME, TRUE); + gdk_fb_pointer_ungrab (GDK_CURRENT_TIME, TRUE); mouse->click_grab = FALSE; } #if 0 - g_message("Button #%d %s [%d, %d] in %p", button, press_event?"pressed":"released", + g_message ("Button #%d %s [%d, %d] in %p", + button, press_event?"pressed":"released", x, y, window); /* Debugging aid */ - if(window && window != gdk_parent_root) + if (window && window != gdk_parent_root) { GdkGC *tmp_gc; - tmp_gc = gdk_gc_new(window); - GDK_GC_FBDATA(tmp_gc)->values.foreground.pixel = 0; - gdk_fb_draw_rectangle(GDK_DRAWABLE_IMPL(window), tmp_gc, TRUE, 0, 0, - GDK_DRAWABLE_IMPL_FBDATA(window)->width, GDK_DRAWABLE_IMPL_FBDATA(window)->height); + tmp_gc = gdk_gc_new (window); + GDK_GC_FBDATA (tmp_gc)->values.foreground.pixel = 0; + gdk_fb_draw_rectangle (GDK_DRAWABLE_IMPL(window), tmp_gc, TRUE, 0, 0, + GDK_DRAWABLE_IMPL_FBDATA(window)->width, GDK_DRAWABLE_IMPL_FBDATA(window)->height); gdk_gc_unref(tmp_gc); } #endif - if(!press_event && !multiclick_tag) + if (!press_event && !multiclick_tag) { - multiclick_tag = g_timeout_add(250, click_event_timeout, NULL); - multiclick_event = gdk_event_copy(event); + multiclick_tag = g_timeout_add (250, click_event_timeout, NULL); + multiclick_event = gdk_event_copy (event); } - gdk_event_queue_append(event); + gdk_event_queue_append (event); } static GdkPixmap *last_contents = NULL; static GdkPoint last_location, last_contents_size; static GdkCursor *last_cursor = NULL; -GdkFBDrawingContext *gdk_fb_cursor_dc = NULL; +static GdkFBDrawingContext *gdk_fb_cursor_dc = NULL; static GdkFBDrawingContext cursor_dc_dat; static GdkGC *cursor_gc; static gint cursor_visibility_count = 1; static GdkFBDrawingContext * -gdk_fb_cursor_dc_reset(void) +gdk_fb_cursor_dc_reset (void) { - if(gdk_fb_cursor_dc) - gdk_fb_drawing_context_finalize(gdk_fb_cursor_dc); + if (gdk_fb_cursor_dc) + gdk_fb_drawing_context_finalize (gdk_fb_cursor_dc); gdk_fb_cursor_dc = &cursor_dc_dat; - gdk_fb_drawing_context_init(gdk_fb_cursor_dc, GDK_DRAWABLE_IMPL(gdk_parent_root), cursor_gc, TRUE, FALSE); + gdk_fb_drawing_context_init (gdk_fb_cursor_dc, + GDK_DRAWABLE_IMPL(gdk_parent_root), + cursor_gc, + TRUE, + FALSE); return gdk_fb_cursor_dc; } void -gdk_fb_cursor_hide(void) +gdk_fb_cursor_hide (void) { GdkFBDrawingContext *mydc = gdk_fb_cursor_dc; cursor_visibility_count--; - g_assert(cursor_visibility_count <= 0); - if(cursor_visibility_count < 0) + g_assert (cursor_visibility_count <= 0); + + if (cursor_visibility_count < 0) return; - if(!mydc) - mydc = gdk_fb_cursor_dc_reset(); + if (!mydc) + mydc = gdk_fb_cursor_dc_reset (); - if(last_contents) + if (last_contents) { - gdk_gc_set_clip_mask(cursor_gc, NULL); + gdk_gc_set_clip_mask (cursor_gc, NULL); /* Restore old picture */ - gdk_fb_draw_drawable_3(GDK_DRAWABLE_IMPL(gdk_parent_root), cursor_gc, GDK_DRAWABLE_IMPL(last_contents), - mydc, - 0, 0, - last_location.x, - last_location.y, - last_contents_size.x, - last_contents_size.y); + gdk_fb_draw_drawable_3 (GDK_DRAWABLE_IMPL(gdk_parent_root), + cursor_gc, + GDK_DRAWABLE_IMPL(last_contents), + mydc, + 0, 0, + last_location.x, + last_location.y, + last_contents_size.x, + last_contents_size.y); } } void -gdk_fb_cursor_invalidate(void) +gdk_fb_cursor_invalidate (void) { - if(last_contents) + if (last_contents) { - gdk_pixmap_unref(last_contents); + gdk_pixmap_unref (last_contents); last_contents = NULL; } } @@ -300,90 +316,100 @@ gdk_fb_cursor_unhide() GdkFBDrawingContext *mydc = gdk_fb_cursor_dc; cursor_visibility_count++; - g_assert(cursor_visibility_count <= 1); - if(cursor_visibility_count < 1) + g_assert (cursor_visibility_count <= 1); + if (cursor_visibility_count < 1) return; - if(!mydc) - mydc = gdk_fb_cursor_dc_reset(); + if (!mydc) + mydc = gdk_fb_cursor_dc_reset (); - if(last_cursor) + if (last_cursor) { - if(!last_contents - || GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width > GDK_DRAWABLE_IMPL_FBDATA(last_contents)->width - || GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height > GDK_DRAWABLE_IMPL_FBDATA(last_contents)->height) + if (!last_contents || + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width > GDK_DRAWABLE_IMPL_FBDATA (last_contents)->width || + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height > GDK_DRAWABLE_IMPL_FBDATA (last_contents)->height) { - if(last_contents) - gdk_pixmap_unref(last_contents); + if (last_contents) + gdk_pixmap_unref (last_contents); - last_contents = gdk_pixmap_new(gdk_parent_root, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height, - GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->depth); + last_contents = gdk_pixmap_new (gdk_parent_root, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height, + GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->depth); } - gdk_gc_set_clip_mask(cursor_gc, NULL); - gdk_fb_draw_drawable_2(GDK_DRAWABLE_IMPL(last_contents), cursor_gc, GDK_DRAWABLE_IMPL(gdk_parent_root), last_location.x, - last_location.y, 0, 0, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height, TRUE, FALSE); - last_contents_size.x = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width; - last_contents_size.y = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height; - gdk_gc_set_clip_mask(cursor_gc, GDK_CURSOR_FB(last_cursor)->mask); - gdk_gc_set_clip_origin(cursor_gc, last_location.x + GDK_CURSOR_FB(last_cursor)->mask_off_x, - last_location.y + GDK_CURSOR_FB(last_cursor)->mask_off_y); + gdk_gc_set_clip_mask (cursor_gc, NULL); + gdk_fb_draw_drawable_2 (GDK_DRAWABLE_IMPL (last_contents), + cursor_gc, + GDK_DRAWABLE_IMPL (gdk_parent_root), + last_location.x, + last_location.y, + 0, 0, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height, + TRUE, FALSE); + last_contents_size.x = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width; + last_contents_size.y = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height; + gdk_gc_set_clip_mask (cursor_gc, GDK_CURSOR_FB (last_cursor)->mask); + gdk_gc_set_clip_origin (cursor_gc, + last_location.x + GDK_CURSOR_FB (last_cursor)->mask_off_x, + last_location.y + GDK_CURSOR_FB (last_cursor)->mask_off_y); - gdk_fb_cursor_dc_reset(); - gdk_fb_draw_drawable_3(GDK_DRAWABLE_IMPL(gdk_parent_root), cursor_gc, GDK_DRAWABLE_IMPL(GDK_CURSOR_FB(last_cursor)->cursor), - mydc, 0, 0, last_location.x, last_location.y, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width, - GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height); + gdk_fb_cursor_dc_reset (); + gdk_fb_draw_drawable_3 (GDK_DRAWABLE_IMPL(gdk_parent_root), + cursor_gc, + GDK_DRAWABLE_IMPL (GDK_CURSOR_FB (last_cursor)->cursor), + mydc, + 0, 0, + last_location.x, last_location.y, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width, + GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height); } else - gdk_fb_cursor_invalidate(); + gdk_fb_cursor_invalidate (); } gboolean -gdk_fb_cursor_region_need_hide(GdkRegion *region) +gdk_fb_cursor_region_need_hide (GdkRegion *region) { GdkRectangle testme; - if(!last_cursor) + if (!last_cursor) return FALSE; testme.x = last_location.x; testme.y = last_location.y; - testme.width = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width; - testme.height = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height; + testme.width = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width; + testme.height = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height; - return (gdk_region_rect_in(region, &testme)!=GDK_OVERLAP_RECTANGLE_OUT); + return (gdk_region_rect_in (region, &testme) != GDK_OVERLAP_RECTANGLE_OUT); } gboolean -gdk_fb_cursor_need_hide(GdkRectangle *rect) +gdk_fb_cursor_need_hide (GdkRectangle *rect) { GdkRectangle testme; - if(!last_cursor) + if (!last_cursor) return FALSE; testme.x = last_location.x; testme.y = last_location.y; - testme.width = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width; - testme.height = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height; + testme.width = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width; + testme.height = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height; - return gdk_rectangle_intersect(rect, &testme, &testme); + return gdk_rectangle_intersect (rect, &testme, &testme); } void -gdk_fb_get_cursor_rect(GdkRectangle *rect) +gdk_fb_get_cursor_rect (GdkRectangle *rect) { - if(last_cursor) + if (last_cursor) { rect->x = last_location.x; rect->y = last_location.y; - rect->width = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->width; - rect->height = GDK_DRAWABLE_IMPL_FBDATA(GDK_CURSOR_FB(last_cursor)->cursor)->height; + rect->width = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->width; + rect->height = GDK_DRAWABLE_IMPL_FBDATA (GDK_CURSOR_FB (last_cursor)->cursor)->height; } else { @@ -393,71 +419,74 @@ gdk_fb_get_cursor_rect(GdkRectangle *rect) } static void -move_pointer(MouseDevice *mouse, GdkWindow *in_window) +move_pointer (MouseDevice *mouse, GdkWindow *in_window) { GdkCursor *the_cursor; - if(!cursor_gc) + if (!cursor_gc) { GdkColor white, black; - cursor_gc = gdk_gc_new(gdk_parent_root); - gdk_color_black(gdk_colormap_get_system(), &black); - gdk_color_white(gdk_colormap_get_system(), &white); - gdk_gc_set_foreground(cursor_gc, &black); - gdk_gc_set_background(cursor_gc, &white); + cursor_gc = gdk_gc_new (gdk_parent_root); + gdk_color_black (gdk_colormap_get_system (), &black); + gdk_color_white (gdk_colormap_get_system (), &white); + gdk_gc_set_foreground (cursor_gc, &black); + gdk_gc_set_background (cursor_gc, &white); } - gdk_fb_cursor_hide(); + gdk_fb_cursor_hide (); - if(_gdk_fb_pointer_grab_window && _gdk_fb_pointer_grab_cursor) + if (_gdk_fb_pointer_grab_window && _gdk_fb_pointer_grab_cursor) the_cursor = _gdk_fb_pointer_grab_cursor; else { - while(!GDK_WINDOW_IMPL_FBDATA(in_window)->cursor && GDK_WINDOW_P(in_window)->parent) - in_window = (GdkWindow *)GDK_WINDOW_P(in_window)->parent; - the_cursor = GDK_WINDOW_IMPL_FBDATA(in_window)->cursor; + while (!GDK_WINDOW_IMPL_FBDATA (in_window)->cursor && GDK_WINDOW_P (in_window)->parent) + in_window = (GdkWindow *)GDK_WINDOW_P (in_window)->parent; + the_cursor = GDK_WINDOW_IMPL_FBDATA (in_window)->cursor; } - last_location.x = mouse->x - GDK_CURSOR_FB(the_cursor)->hot_x; - last_location.y = mouse->y - GDK_CURSOR_FB(the_cursor)->hot_y; + last_location.x = mouse->x - GDK_CURSOR_FB (the_cursor)->hot_x; + last_location.y = mouse->y - GDK_CURSOR_FB (the_cursor)->hot_y; - if(the_cursor) - gdk_cursor_ref(the_cursor); - if(last_cursor) - gdk_cursor_unref(last_cursor); + if (the_cursor) + gdk_cursor_ref (the_cursor); + if (last_cursor) + gdk_cursor_unref (last_cursor); last_cursor = the_cursor; - gdk_fb_cursor_unhide(); + gdk_fb_cursor_unhide (); } void gdk_fb_cursor_reset(void) { - GdkWindow *win = gdk_window_get_pointer(NULL, NULL, NULL, NULL); + GdkWindow *win = gdk_window_get_pointer (NULL, NULL, NULL, NULL); - move_pointer(gdk_fb_mouse, win); + move_pointer (gdk_fb_mouse, win); } -void gdk_fb_window_visibility_crossing(GdkWindow *window, gboolean is_show, gboolean is_grab) +void +gdk_fb_window_visibility_crossing (GdkWindow *window, + gboolean is_show, + gboolean is_grab) { gint winx, winy; GdkModifierType my_mask; - gdk_input_get_mouseinfo(&winx, &winy, &my_mask); + gdk_input_get_mouseinfo (&winx, &winy, &my_mask); - if(is_grab - || (winx >= GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x - && winx < GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - && winy >= GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y - && winy < GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y) + if (is_grab || + (winx >= GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x && + winx < GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x && + winy >= GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y && + winy < GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y) ) { GdkWindow *oldwin, *newwin, *curwin; GdkEvent *event; - curwin = gdk_window_get_pointer(NULL, NULL, NULL, NULL); + curwin = gdk_window_get_pointer (NULL, NULL, NULL, NULL); - if(is_show) + if (is_show) { /* Window is about to be shown */ oldwin = curwin; @@ -470,19 +499,19 @@ void gdk_fb_window_visibility_crossing(GdkWindow *window, gboolean is_show, gboo newwin = curwin; } - event = gdk_event_make(oldwin, GDK_LEAVE_NOTIFY, TRUE); - if(event) + event = gdk_event_make (oldwin, GDK_LEAVE_NOTIFY, TRUE); + if (event) { guint x_int, y_int; - event->crossing.subwindow = gdk_window_ref(newwin); - gdk_window_get_root_origin(oldwin, &x_int, &y_int); + event->crossing.subwindow = gdk_window_ref (newwin); + gdk_window_get_root_origin (oldwin, &x_int, &y_int); event->crossing.x = winx - x_int; event->crossing.y = winy - y_int; event->crossing.x_root = winx; event->crossing.y_root = winy; - if(is_grab) + if (is_grab) { - if(is_show) + if (is_show) event->crossing.mode = GDK_CROSSING_GRAB; else event->crossing.mode = GDK_CROSSING_UNGRAB; @@ -494,12 +523,12 @@ void gdk_fb_window_visibility_crossing(GdkWindow *window, gboolean is_show, gboo event->crossing.state = my_mask; } - event = gdk_event_make(newwin, GDK_ENTER_NOTIFY, TRUE); - if(event) + event = gdk_event_make (newwin, GDK_ENTER_NOTIFY, TRUE); + if (event) { guint x_int, y_int; - event->crossing.subwindow = gdk_window_ref(oldwin); - gdk_window_get_root_origin(newwin, &x_int, &y_int); + event->crossing.subwindow = gdk_window_ref (oldwin); + gdk_window_get_root_origin (newwin, &x_int, &y_int); event->crossing.x = winx - x_int; event->crossing.y = winy - y_int; event->crossing.x_root = winx; @@ -510,14 +539,15 @@ void gdk_fb_window_visibility_crossing(GdkWindow *window, gboolean is_show, gboo event->crossing.state = my_mask; } - if(gdk_fb_mouse->prev_window) - gdk_window_unref(gdk_fb_mouse->prev_window); - gdk_fb_mouse->prev_window = gdk_window_ref(newwin); + if (gdk_fb_mouse->prev_window) + gdk_window_unref (gdk_fb_mouse->prev_window); + gdk_fb_mouse->prev_window = gdk_window_ref (newwin); } } static void -handle_mouse_input(MouseDevice *mouse, gboolean got_motion) +handle_mouse_input(MouseDevice *mouse, + gboolean got_motion) { GdkWindow *mousewin; GdkEvent *event; @@ -525,40 +555,41 @@ handle_mouse_input(MouseDevice *mouse, gboolean got_motion) GdkWindow *win; guint state; - if(_gdk_fb_pointer_grab_confine) + if (_gdk_fb_pointer_grab_confine) mousewin = _gdk_fb_pointer_grab_confine; else mousewin = gdk_parent_root; - if(mouse->x < GDK_DRAWABLE_IMPL_FBDATA(mousewin)->llim_x) - mouse->x = GDK_DRAWABLE_IMPL_FBDATA(mousewin)->llim_x; - else if(mouse->x > (GDK_DRAWABLE_IMPL_FBDATA(mousewin)->lim_x - 1)) - mouse->x = GDK_DRAWABLE_IMPL_FBDATA(mousewin)->lim_x - 1; - if(mouse->y < GDK_DRAWABLE_IMPL_FBDATA(mousewin)->llim_y) - mouse->y = GDK_DRAWABLE_IMPL_FBDATA(mousewin)->llim_y; - else if(mouse->y > (GDK_DRAWABLE_IMPL_FBDATA(mousewin)->lim_y - 1)) - mouse->y = GDK_DRAWABLE_IMPL_FBDATA(mousewin)->lim_y - 1; + if (mouse->x < GDK_DRAWABLE_IMPL_FBDATA (mousewin)->llim_x) + mouse->x = GDK_DRAWABLE_IMPL_FBDATA (mousewin)->llim_x; + else if (mouse->x > (GDK_DRAWABLE_IMPL_FBDATA (mousewin)->lim_x - 1)) + mouse->x = GDK_DRAWABLE_IMPL_FBDATA (mousewin)->lim_x - 1; - if(!got_motion) + if (mouse->y < GDK_DRAWABLE_IMPL_FBDATA (mousewin)->llim_y) + mouse->y = GDK_DRAWABLE_IMPL_FBDATA (mousewin)->llim_y; + else if (mouse->y > (GDK_DRAWABLE_IMPL_FBDATA (mousewin)->lim_y - 1)) + mouse->y = GDK_DRAWABLE_IMPL_FBDATA (mousewin)->lim_y - 1; + + if (!got_motion) return; - win = gdk_window_get_pointer(NULL, NULL, NULL, NULL); - move_pointer(mouse, win); - if(_gdk_fb_pointer_grab_window_events) + win = gdk_window_get_pointer (NULL, NULL, NULL, NULL); + move_pointer (mouse, win); + if (_gdk_fb_pointer_grab_window_events) win = _gdk_fb_pointer_grab_window_events; - gdk_window_get_origin(win, &x, &y); + gdk_window_get_origin (win, &x, &y); x = mouse->x - x; y = mouse->y - y; - state = (mouse->button1_pressed?GDK_BUTTON1_MASK:0) - | (mouse->button2_pressed?GDK_BUTTON2_MASK:0) - | (mouse->button3_pressed?GDK_BUTTON3_MASK:0) - | keyboard->modifier_state; + state = (mouse->button1_pressed?GDK_BUTTON1_MASK:0) | + (mouse->button2_pressed?GDK_BUTTON2_MASK:0) | + (mouse->button3_pressed?GDK_BUTTON3_MASK:0) | + keyboard->modifier_state; event = gdk_event_make (win, GDK_MOTION_NOTIFY, TRUE); - if(event) + if (event) { event->motion.x = x; event->motion.y = y; @@ -569,13 +600,14 @@ handle_mouse_input(MouseDevice *mouse, gboolean got_motion) event->motion.y_root = mouse->y; } - if(win != mouse->prev_window) + if (win != mouse->prev_window) { GdkEvent *evel; - if(mouse->prev_window && (evel = gdk_event_make(mouse->prev_window, GDK_LEAVE_NOTIFY, TRUE))) + if (mouse->prev_window && + (evel = gdk_event_make (mouse->prev_window, GDK_LEAVE_NOTIFY, TRUE))) { - evel->crossing.subwindow = gdk_window_ref(win); + evel->crossing.subwindow = gdk_window_ref (win); evel->crossing.x = x; evel->crossing.y = y; evel->crossing.x_root = mouse->x; @@ -586,10 +618,10 @@ handle_mouse_input(MouseDevice *mouse, gboolean got_motion) evel->crossing.state = state; } - evel = gdk_event_make(win, GDK_ENTER_NOTIFY, TRUE); - if(evel) + evel = gdk_event_make (win, GDK_ENTER_NOTIFY, TRUE); + if (evel) { - evel->crossing.subwindow = gdk_window_ref(mouse->prev_window?mouse->prev_window:gdk_parent_root); + evel->crossing.subwindow = gdk_window_ref (mouse->prev_window ? mouse->prev_window : gdk_parent_root); evel->crossing.x = x; evel->crossing.y = y; evel->crossing.x_root = mouse->x; @@ -600,58 +632,61 @@ handle_mouse_input(MouseDevice *mouse, gboolean got_motion) evel->crossing.state = state; } - if(mouse->prev_window) - gdk_window_unref(mouse->prev_window); - mouse->prev_window = gdk_window_ref(win); + if (mouse->prev_window) + gdk_window_unref (mouse->prev_window); + mouse->prev_window = gdk_window_ref (win); } - input_activity(); + input_activity (); } static gboolean -pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, gdouble *x, gdouble *y) +pull_fidmour_packet (MouseDevice *mouse, + gboolean *btn_down, + gdouble *x, + gdouble *y) { gboolean keep_reading = TRUE; - while(keep_reading) + while (keep_reading) { int n; - n = read(mouse->fd, mouse->fidmour_bytes + mouse->fidmour_nbytes, 5 - mouse->fidmour_nbytes); - if(n < 0) + n = read (mouse->fd, mouse->fidmour_bytes + mouse->fidmour_nbytes, 5 - mouse->fidmour_nbytes); + if (n < 0) return FALSE; - else if(n == 0) + else if (n == 0) { - g_error("EOF on mouse device!"); - g_source_remove(mouse->fd_tag); + g_error ("EOF on mouse device!"); + g_source_remove (mouse->fd_tag); return FALSE; } mouse->fidmour_nbytes += n; n = 0; - if(!(mouse->fidmour_bytes[0] & 0x80)) + if (!(mouse->fidmour_bytes[0] & 0x80)) { int i; /* We haven't received any of the packet yet but there is no header at the beginning */ - for(i = 1; i < mouse->fidmour_nbytes; i++) + for (i = 1; i < mouse->fidmour_nbytes; i++) { - if(mouse->fidmour_bytes[i] & 0x80) + if (mouse->fidmour_bytes[i] & 0x80) { n = i; break; } } } - else if(mouse->fidmour_nbytes > 1 - && ((mouse->fidmour_bytes[0] & 0x90) == 0x90)) + else if (mouse->fidmour_nbytes > 1 && + ((mouse->fidmour_bytes[0] & 0x90) == 0x90)) { /* eat the 0x90 and following byte, no clue what it's for */ n = 2; } - else if(mouse->fidmour_nbytes == 5) + else if (mouse->fidmour_nbytes == 5) { - switch(mouse->fidmour_bytes[0] & 0xF) + switch (mouse->fidmour_bytes[0] & 0xF) { case 2: *btn_down = 0; @@ -661,15 +696,15 @@ pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, gdouble *x, gdouble *btn_down = 1; break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } *x = mouse->fidmour_bytes[1] + (mouse->fidmour_bytes[2] << 7); - if(*x > 8192) + if (*x > 8192) *x -= 16384; *y = mouse->fidmour_bytes[3] + (mouse->fidmour_bytes[4] << 7); - if(*y > 8192) + if (*y > 8192) *y -= 16384; /* Now map touchscreen coords to screen coords */ *x *= ((double)gdk_display->modeinfo.xres)/4096.0; @@ -678,9 +713,9 @@ pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, gdouble *x, gdouble keep_reading = FALSE; } - if(n) + if (n) { - memmove(mouse->fidmour_bytes, mouse->fidmour_bytes+n, mouse->fidmour_nbytes-n); + memmove (mouse->fidmour_bytes, mouse->fidmour_bytes+n, mouse->fidmour_nbytes-n); mouse->fidmour_nbytes -= n; } } @@ -689,7 +724,9 @@ pull_fidmour_packet(MouseDevice *mouse, gboolean *btn_down, gdouble *x, gdouble } static gboolean -handle_input_fidmour(GIOChannel *gioc, GIOCondition cond, gpointer data) +handle_input_fidmour (GIOChannel *gioc, + GIOCondition cond, + gpointer data) { MouseDevice *mouse = data; gdouble x, y, oldx, oldy; @@ -698,41 +735,42 @@ handle_input_fidmour(GIOChannel *gioc, GIOCondition cond, gpointer data) time_t the_time; GTimeVal tv; - g_get_current_time(&tv); + g_get_current_time (&tv); the_time = tv.tv_sec; oldx = mouse->x; oldy = mouse->y; - while(pull_fidmour_packet(mouse, &btn_down, &x, &y)) + while (pull_fidmour_packet (mouse, &btn_down, &x, &y)) { - if(fabs(x - mouse->x) >= 1.0 - || fabs(x - mouse->y) >= 1.0) + if (fabs(x - mouse->x) >= 1.0 || fabs(x - mouse->y) >= 1.0) { got_motion = TRUE; mouse->x = x; mouse->y = y; } - if(btn_down != mouse->button1_pressed) + if (btn_down != mouse->button1_pressed) { - if(got_motion) + if (got_motion) { - handle_mouse_input(mouse, TRUE); + handle_mouse_input (mouse, TRUE); got_motion = FALSE; } mouse->button1_pressed = btn_down; - send_button_event(mouse, 1, btn_down, the_time); + send_button_event (mouse, 1, btn_down, the_time); } } - if(got_motion) - handle_mouse_input(mouse, TRUE); + if (got_motion) + handle_mouse_input (mouse, TRUE); return TRUE; } static gboolean -handle_input_ps2(GIOChannel *gioc, GIOCondition cond, gpointer data) +handle_input_ps2 (GIOChannel *gioc, + GIOCondition cond, + gpointer data) { MouseDevice *mouse = data; guchar buf[3]; @@ -742,18 +780,18 @@ handle_input_ps2(GIOChannel *gioc, GIOCondition cond, gpointer data) GTimeVal curtime; gboolean got_motion = FALSE; - g_get_current_time(&curtime); + g_get_current_time (&curtime); the_time = curtime.tv_usec; - while(1) /* Go through as many mouse events as we can */ + while (1) /* Go through as many mouse events as we can */ { - for(left = sizeof(buf); left > 0; ) + for (left = sizeof(buf); left > 0; ) { - n = read(mouse->fd, buf+sizeof(buf)-left, left); + n = read (mouse->fd, buf+sizeof(buf)-left, left); - if(n <= 0) + if (n <= 0) { - if(left != sizeof(buf)) + if (left != sizeof(buf)) continue; /* XXX FIXME - this will be slow compared to turning on blocking mode, etc. */ goto done_reading_mouse_events; @@ -766,57 +804,118 @@ handle_input_ps2(GIOChannel *gioc, GIOCondition cond, gpointer data) new_button3 = (buf[0] & 2) && 1; new_button2 = (buf[0] & 4) && 1; - if(got_motion && - (new_button1 != mouse->button1_pressed - || new_button2 != mouse->button2_pressed - || new_button3 != mouse->button3_pressed)) + if (got_motion && + (new_button1 != mouse->button1_pressed || + new_button2 != mouse->button2_pressed || + new_button3 != mouse->button3_pressed)) { /* If a mouse button state changes we need to get correct ordering with enter/leave events, so push those out via handle_mouse_input */ got_motion = FALSE; - handle_mouse_input(mouse, TRUE); + handle_mouse_input (mouse, TRUE); } - if(new_button1 != mouse->button1_pressed) + if (new_button1 != mouse->button1_pressed) { mouse->button1_pressed = new_button1; - send_button_event(mouse, 1, new_button1, the_time); + send_button_event (mouse, 1, new_button1, the_time); } - if(new_button2 != mouse->button2_pressed) + if (new_button2 != mouse->button2_pressed) { mouse->button2_pressed = new_button2; - send_button_event(mouse, 2, new_button2, the_time); + send_button_event (mouse, 2, new_button2, the_time); } - if(new_button3 != mouse->button3_pressed) + if (new_button3 != mouse->button3_pressed) { mouse->button3_pressed = new_button3; - send_button_event(mouse, 3, new_button3, the_time); + send_button_event (mouse, 3, new_button3, the_time); } - if(buf[1] != 0) + if (buf[1] != 0) dx = ((buf[0] & 0x10) ? ((gint)buf[1])-256 : buf[1]); else dx = 0; - if(buf[2] != 0) + if (buf[2] != 0) dy = -((buf[0] & 0x20) ? ((gint)buf[2])-256 : buf[2]); else dy = 0; mouse->x += dx; mouse->y += dy; - if(dx || dy) + if (dx || dy) got_motion = TRUE; } done_reading_mouse_events: - if(got_motion) - handle_mouse_input(mouse, TRUE); + if (got_motion) + handle_mouse_input (mouse, TRUE); return TRUE; } +static gboolean +handle_input_ms (GIOChannel *gioc, + GIOCondition cond, + gpointer data) +{ + MouseDevice *mouse = data; + guchar byte1, byte2, byte3; + int n, dx=0, dy=0; + gboolean new_button1, new_button2, new_button3; + time_t the_time; + GTimeVal curtime; + + g_get_current_time (&curtime); + the_time = curtime.tv_usec; + + n = read (mouse->fd, &byte1, 1); + if ( (n!=1) || (byte1 & 0x40) != 0x40) + return TRUE; + + n = read (mouse->fd, &byte2, 1); + if ( (n!=1) || (byte2 & 0x40) != 0x00) + return TRUE; + + n = read (mouse->fd, &byte3, 1); + if (n!=1) + return TRUE; + + new_button1 = (byte1 & 0x20) && 1; + new_button2 = (byte1 & 0x10) && 1; + new_button3 = 0; + + if (new_button1 != mouse->button1_pressed) + { + mouse->button1_pressed = new_button1; + send_button_event (mouse, 1, new_button1, the_time); + } + + if (new_button2 != mouse->button2_pressed) + { + mouse->button2_pressed = new_button2; + send_button_event (mouse, 2, new_button2, the_time); + } + + if (new_button3 != mouse->button3_pressed) + { + mouse->button3_pressed = new_button3; + send_button_event (mouse, 3, new_button3, the_time); + } + + dx = (signed char)(((byte1 & 0x03) << 6) | (byte2 & 0x3F)); + dy = (signed char)(((byte1 & 0x0C) << 4) | (byte3 & 0x3F)); + + mouse->x += dx; + mouse->y += dy; + + if (dx || dy) + handle_mouse_input (mouse, TRUE); + + return TRUE; +} + static MouseDevice * mouse_open(void) { @@ -826,33 +925,44 @@ mouse_open(void) GIOChannel *gioc; char *mousedev, *ctmp; int mode; - enum { PS2_MOUSE, FIDMOUR_MOUSE, UNKNOWN_MOUSE } type; - - retval = g_new0(MouseDevice, 1); + struct termios tty; + enum { PS2_MOUSE, FIDMOUR_MOUSE, MS_MOUSE, UNKNOWN_MOUSE } type; + int flags; + fd_set fds; + char c; + struct timeval tv; + + retval = g_new0 (MouseDevice, 1); retval->fd = -1; mode = O_RDWR; - ctmp = getenv("GDK_MOUSETYPE"); - if(ctmp) + ctmp = getenv ("GDK_MOUSETYPE"); + if (ctmp) { - if(!strcmp(ctmp, "fidmour")) + if (!strcmp (ctmp, "fidmour")) type = FIDMOUR_MOUSE; - else if(!strcmp(ctmp, "ps2")) + else if (!strcmp (ctmp, "ps2")) type = PS2_MOUSE; + else if (!strcmp (ctmp, "ms")) + type = MS_MOUSE; else { - g_print("Unknown mouse type %s\n", ctmp); + g_print ("Unknown mouse type %s\n", ctmp); type = UNKNOWN_MOUSE; } } else type = PS2_MOUSE; - switch(type) + switch (type) { case PS2_MOUSE: mousedev = "/dev/psaux"; mode = O_RDWR; break; + case MS_MOUSE: + mousedev = "/dev/ttyS0"; + mode = O_RDWR; + break; case FIDMOUR_MOUSE: mousedev = "/dev/fidmour"; mode = O_RDONLY; @@ -862,15 +972,19 @@ mouse_open(void) break; } - ctmp = getenv("GDK_MOUSEDEV"); - if(ctmp) + ctmp = getenv ("GDK_MOUSEDEV"); + if (ctmp) mousedev = ctmp; - retval->fd = open(mousedev, mode); - if(retval->fd < 0) + /* Use nonblocking mode to open, to not hang on device */ + retval->fd = open (mousedev, mode | O_NONBLOCK); + if (retval->fd < 0) goto error; - switch(type) + flags = fcntl (retval->fd, F_GETFL); + fcntl (retval->fd, F_SETFL, flags & ~O_NONBLOCK); + + switch (type) { case PS2_MOUSE: /* From xf86_Mouse.c */ @@ -880,27 +994,57 @@ mouse_open(void) buf[i++] = 200; buf[i++] = 232; /* device resolution */ buf[i++] = 1; - write(retval->fd, buf, i); - fcntl(retval->fd, F_SETFL, O_RDWR|O_NONBLOCK); + write (retval->fd, buf, i); + fcntl (retval->fd, F_SETFL, O_RDWR|O_NONBLOCK); - usleep(10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt + usleep (10000); /* sleep 10 ms, then read whatever junk we can get from the mouse, in a vain attempt to get synchronized with the event stream */ - while((i = read(retval->fd, buf, sizeof(buf))) > 0) - g_print("Got %d bytes of junk from psaux\n", i); + while ((i = read (retval->fd, buf, sizeof(buf))) > 0) + g_print ("Got %d bytes of junk from psaux\n", i); - gioc = g_io_channel_unix_new(retval->fd); - retval->fd_tag = g_io_add_watch(gioc, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_ps2, retval); + gioc = g_io_channel_unix_new (retval->fd); + retval->fd_tag = g_io_add_watch (gioc, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_ps2, retval); + break; + + case MS_MOUSE: + /* Read all data from fd: */ + FD_ZERO (&fds); + FD_SET (retval->fd, &fds); + tv.tv_sec = 0; + tv.tv_usec = 0; + while (select (retval->fd+1, &fds, NULL, NULL, &tv) > 0) { + FD_ZERO (&fds); + FD_SET (retval->fd, &fds); + tv.tv_sec = 0; + tv.tv_usec = 0; + read (retval->fd, &c, 1); + } + + tcgetattr (retval->fd, &tty); + tty.c_iflag = IGNBRK | IGNPAR; + tty.c_cflag = CREAD|CLOCAL|HUPCL|CS7|B1200; + tty.c_oflag = 0; + tty.c_lflag = 0; + tty.c_line = 0; + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 1; + tcsetattr (retval->fd, TCSAFLUSH, &tty); + + write (retval->fd, "*n", 2); + + gioc = g_io_channel_unix_new (retval->fd); + retval->fd_tag = g_io_add_watch (gioc, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_ms, retval); break; case FIDMOUR_MOUSE: - fcntl(retval->fd, F_SETFL, O_RDONLY|O_NONBLOCK); - gioc = g_io_channel_unix_new(retval->fd); + fcntl (retval->fd, F_SETFL, O_RDONLY|O_NONBLOCK); + gioc = g_io_channel_unix_new (retval->fd); /* We set the priority lower here because otherwise it will flood out all the other stuff */ - retval->fd_tag = g_io_add_watch_full(gioc, G_PRIORITY_DEFAULT, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, + retval->fd_tag = g_io_add_watch_full (gioc, G_PRIORITY_DEFAULT, G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, handle_input_fidmour, retval, NULL); break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } @@ -911,9 +1055,10 @@ mouse_open(void) error: /* No errors allowed once fd_tag is added */ - if(retval->fd >= 0) - close(retval->fd); - g_free(retval); + g_warning ("Failed to open mouse device\n"); + if (retval->fd >= 0) + close (retval->fd); + g_free (retval); return NULL; } @@ -924,34 +1069,36 @@ gdk_input_init (void) gdk_input_ignore_core = FALSE; - gdk_fb_mouse = mouse_open(); + gdk_fb_mouse = mouse_open (); } void -gdk_input_get_mouseinfo(gint *x, gint *y, GdkModifierType *mask) +gdk_input_get_mouseinfo (gint *x, + gint *y, + GdkModifierType *mask) { *x = gdk_fb_mouse->x; *y = gdk_fb_mouse->y; *mask = - (gdk_fb_mouse->button1_pressed?GDK_BUTTON1_MASK:0) - | (gdk_fb_mouse->button2_pressed?GDK_BUTTON2_MASK:0) - | (gdk_fb_mouse->button3_pressed?GDK_BUTTON3_MASK:0) - | keyboard->modifier_state; + (gdk_fb_mouse->button1_pressed?GDK_BUTTON1_MASK:0) | + (gdk_fb_mouse->button2_pressed?GDK_BUTTON2_MASK:0) | + (gdk_fb_mouse->button3_pressed?GDK_BUTTON3_MASK:0) | + keyboard->modifier_state; } GdkWindow * -gdk_window_find_focus(void) +gdk_window_find_focus (void) { - if(_gdk_fb_keyboard_grab_window) + if (_gdk_fb_keyboard_grab_window) return _gdk_fb_keyboard_grab_window; - else if(GDK_WINDOW_P(gdk_parent_root)->children) + else if (GDK_WINDOW_P (gdk_parent_root)->children) { GList *item; - for(item = GDK_WINDOW_P(gdk_parent_root)->children; item; item = item->next) + for (item = GDK_WINDOW_P (gdk_parent_root)->children; item; item = item->next) { - GdkWindowPrivate *priv = item->data; + GdkWindowObject *priv = item->data; - if(priv->mapped) + if (priv->mapped) return item->data; } } @@ -1253,7 +1400,9 @@ static const guint trans_table[256][3] = { #define TRANS_TABLE_SIZE (sizeof(trans_table)/sizeof(trans_table[0])) static gboolean -handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer data) +handle_mediumraw_keyboard_input (GIOChannel *gioc, + GIOCondition cond, + gpointer data) { guchar buf[128]; int i, n; @@ -1261,15 +1410,15 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d time_t now; GTimeVal curtime; - n = read(k->fd, buf, sizeof(buf)); - if(n <= 0) + n = read (k->fd, buf, sizeof(buf)); + if (n <= 0) g_error("Nothing from keyboard!"); /* Now turn this into a keyboard event */ - g_get_current_time(&curtime); + g_get_current_time (&curtime); now = curtime.tv_sec; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) { guchar keycode; gboolean key_up; @@ -1284,16 +1433,16 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d if (keycode > TRANS_TABLE_SIZE) { - g_warning("Unknown keycode\n"); + g_warning ("Unknown keycode\n"); continue; } - if((keycode == 0x1D) /* left Ctrl */ - || (keycode == 0x9D) /* right Ctrl */ - || (keycode == 0x38) /* left Alt */ - || (keycode == 0xB8) /* right Alt */ - || (keycode == 0x2A) /* left Shift */ - || (keycode == 0x36) /* right Shift */) + if ( (keycode == 0x1D) /* left Ctrl */ + || (keycode == 0x9D) /* right Ctrl */ + || (keycode == 0x38) /* left Alt */ + || (keycode == 0xB8) /* right Alt */ + || (keycode == 0x2A) /* left Shift */ + || (keycode == 0x36) /* right Shift */) { switch (keycode) { @@ -1322,27 +1471,27 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d continue; /* Don't generate events for modifiers */ } - if(keycode == 0x3A /* Caps lock */) + if (keycode == 0x3A /* Caps lock */) { - if(!key_up) + if (!key_up) k->caps_lock = !k->caps_lock; - ioctl (k->fd, KDSETLED, k->caps_lock?LED_CAP:0); + ioctl (k->fd, KDSETLED, k->caps_lock ? LED_CAP : 0); continue; } - if(trans_table[keycode][0] >= GDK_F1 - && trans_table[keycode][0] <= GDK_F35 - && (k->modifier_state & GDK_MOD1_MASK)) + if (trans_table[keycode][0] >= GDK_F1 && + trans_table[keycode][0] <= GDK_F35 && + (k->modifier_state & GDK_MOD1_MASK)) { - if(key_up) /* Only switch on release */ + if (key_up) /* Only switch on release */ { gint vtnum = trans_table[keycode][0] - GDK_F1 + 1; /* Do the whole funky VT switch thing */ - ioctl(k->consfd, VT_ACTIVATE, vtnum); - ioctl(k->consfd, VT_WAITACTIVE, k->vtnum); - gdk_fb_redraw_all(); + ioctl (k->consfd, VT_ACTIVATE, vtnum); + ioctl (k->consfd, VT_WAITACTIVE, k->vtnum); + gdk_fb_redraw_all (); } continue; @@ -1358,8 +1507,7 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d keyval = trans_table[keycode][mod--]; } while (!keyval && (mod >= 0)); - if (k->caps_lock && (keyval >= 'a') - && (keyval <= 'z')) + if (k->caps_lock && (keyval >= 'a') && (keyval <= 'z')) keyval = toupper (keyval); /* handle some magic keys */ @@ -1368,10 +1516,10 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d if (key_up) { if (keyval == GDK_BackSpace) - exit(1); + exit (1); if (keyval == GDK_Return) - gdk_fb_redraw_all(); + gdk_fb_redraw_all (); } keyval = 0; @@ -1381,27 +1529,31 @@ handle_mediumraw_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer d continue; win = gdk_window_find_focus (); - event = gdk_event_make (win, key_up?GDK_KEY_RELEASE:GDK_KEY_PRESS, TRUE); + event = gdk_event_make (win, + key_up ? GDK_KEY_RELEASE : GDK_KEY_PRESS, + TRUE); if (event) { /* Find focused window */ event->key.time = now; event->key.state = k->modifier_state; event->key.keyval = keyval; - event->key.length = isprint(event->key.keyval)?1:0; + event->key.length = isprint (event->key.keyval) ? 1 : 0; dummy[0] = event->key.keyval; dummy[1] = 0; - event->key.string = event->key.length?g_strdup(dummy):NULL; + event->key.string = event->key.length ? g_strdup(dummy) : NULL; } } - input_activity(); + input_activity (); return TRUE; } static gboolean -handle_xlate_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer data) +handle_xlate_keyboard_input (GIOChannel *gioc, + GIOCondition cond, + gpointer data) { guchar buf[128]; int i, n; @@ -1409,15 +1561,15 @@ handle_xlate_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer data) time_t now; GTimeVal curtime; - n = read(k->fd, buf, sizeof(buf)); - if(n <= 0) - g_error("Nothing from keyboard!"); + n = read (k->fd, buf, sizeof(buf)); + if (n <= 0) + g_error ("Nothing from keyboard!"); /* Now turn this into a keyboard event */ - g_get_current_time(&curtime); + g_get_current_time (&curtime); now = curtime.tv_sec; - for(i = 0; i < n; i++) + for (i = 0; i < n; i++) { GdkEvent *event; GdkWindow *win; @@ -1451,10 +1603,10 @@ handle_xlate_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer data) event->key.time = now; event->key.state = k->modifier_state; event->key.keyval = keyval; - event->key.length = isprint(event->key.keyval)?1:0; + event->key.length = isprint (event->key.keyval) ? 1 : 0; dummy[0] = event->key.keyval; dummy[1] = 0; - event->key.string = event->key.length?g_strdup(dummy):NULL; + event->key.string = event->key.length ? g_strdup(dummy) : NULL; } /* Send key up: */ @@ -1465,23 +1617,23 @@ handle_xlate_keyboard_input (GIOChannel *gioc, GIOCondition cond, gpointer data) event->key.time = now; event->key.state = k->modifier_state; event->key.keyval = keyval; - event->key.length = isprint(event->key.keyval)?1:0; + event->key.length = isprint (event->key.keyval) ? 1 : 0; dummy[0] = event->key.keyval; dummy[1] = 0; - event->key.string = event->key.length?g_strdup(dummy):NULL; + event->key.string = event->key.length ? g_strdup(dummy) : NULL; } } - input_activity(); + input_activity (); return TRUE; } static Keyboard * -tty_keyboard_open(void) +tty_keyboard_open (void) { - Keyboard *retval = g_new0(Keyboard, 1); + Keyboard *retval = g_new0 (Keyboard, 1); GIOChannel *gioc; const char cursoroff_str[] = "\033[?1;0;0c"; int n; @@ -1500,8 +1652,8 @@ tty_keyboard_open(void) g_snprintf (buf, sizeof(buf), "/dev/tty%d", retval->prev_vtnum); ioctl (retval->consfd, KDSKBMODE, K_XLATE); - n = ioctl(retval->consfd, VT_OPENQRY, &retval->vtnum); - if(n < 0 || retval->vtnum == -1) + n = ioctl (retval->consfd, VT_OPENQRY, &retval->vtnum); + if (n < 0 || retval->vtnum == -1) g_error("Cannot allocate VT"); ioctl (retval->consfd, VT_ACTIVATE, retval->vtnum); @@ -1512,6 +1664,7 @@ tty_keyboard_open(void) close (1); close (2); #endif + g_snprintf (buf, sizeof(buf), "/dev/tty%d", retval->vtnum); retval->fd = open (buf, O_RDWR|O_NONBLOCK); if (retval->fd < 0) @@ -1520,7 +1673,7 @@ tty_keyboard_open(void) if (ioctl (retval->fd, KDSKBMODE, K_MEDIUMRAW) < 0) { raw_keyboard = FALSE; - g_warning("K_MEDIUMRAW failed, using broken XLATE keyboard driver"); + g_warning ("K_MEDIUMRAW failed, using broken XLATE keyboard driver"); } /* Disable normal text on the console */ @@ -1538,7 +1691,7 @@ tty_keyboard_open(void) tcsetpgrp (retval->fd, getpgrp()); - write (retval->fd, cursoroff_str, strlen(cursoroff_str)); + write (retval->fd, cursoroff_str, strlen (cursoroff_str)); #if 0 if (retval->fd != 0) @@ -1551,8 +1704,8 @@ tty_keyboard_open(void) gioc = g_io_channel_unix_new (retval->fd); retval->fd_tag = g_io_add_watch (gioc, - G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, - (raw_keyboard)?handle_mediumraw_keyboard_input:handle_xlate_keyboard_input, + G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, + (raw_keyboard) ? handle_mediumraw_keyboard_input : handle_xlate_keyboard_input, retval); return retval; @@ -1575,13 +1728,13 @@ gdk_beep (void) } void -keyboard_init(void) +keyboard_init (void) { - keyboard = tty_keyboard_open(); + keyboard = tty_keyboard_open (); } void -keyboard_shutdown(void) +keyboard_shutdown (void) { int tmpfd; diff --git a/gdk/linux-fb/gdkinput.c b/gdk/linux-fb/gdkinput.c index c51067e64b..87791852a9 100644 --- a/gdk/linux-fb/gdkinput.c +++ b/gdk/linux-fb/gdkinput.c @@ -66,7 +66,8 @@ gdk_devices_list (void) } void -gdk_device_set_source (GdkDevice *device, GdkInputSource source) +gdk_device_set_source (GdkDevice *device, + GdkInputSource source) { device->source = source; } @@ -122,7 +123,7 @@ gdk_device_get_state (GdkDevice *device, { gint x_int, y_int; - g_assert(device == gdk_core_pointer); + g_assert (device == gdk_core_pointer); gdk_window_get_pointer (window, &x_int, &y_int, mask); @@ -205,14 +206,14 @@ void gdk_input_set_extension_events (GdkWindow *window, gint mask, GdkExtensionMode mode) { - GdkWindowPrivate *window_private; + GdkWindowObject *window_private; GList *tmp_list; GdkInputWindow *iw; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - window_private = (GdkWindowPrivate*) window; + window_private = (GdkWindowObject*) window; if (mode == GDK_EXTENSION_EVENTS_NONE) mask = 0; @@ -228,7 +229,7 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, iw->num_obscuring = 0; iw->grabbed = FALSE; - gdk_input_windows = g_list_append(gdk_input_windows,iw); + gdk_input_windows = g_list_append (gdk_input_windows,iw); window_private->extension_events = mask; /* Add enter window events to the event mask */ @@ -242,8 +243,8 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, iw = gdk_input_window_find (window); if (iw) { - gdk_input_windows = g_list_remove(gdk_input_windows,iw); - g_free(iw); + gdk_input_windows = g_list_remove (gdk_input_windows,iw); + g_free (iw); } window_private->extension_events = 0; @@ -257,9 +258,9 @@ gdk_input_set_extension_events (GdkWindow *window, gint mask, { if (mask != 0 && gdkdev->info.mode != GDK_MODE_DISABLED && (gdkdev->info.has_cursor || mode == GDK_EXTENSION_EVENTS_ALL)) - gdk_input_enable_window(window,gdkdev); + gdk_input_enable_window (window,gdkdev); else - gdk_input_disable_window(window,gdkdev); + gdk_input_disable_window (window,gdkdev); } } } @@ -273,7 +274,7 @@ gdk_input_window_destroy (GdkWindow *window) g_return_if_fail (input_window != NULL); gdk_input_windows = g_list_remove (gdk_input_windows,input_window); - g_free(input_window); + g_free (input_window); } void @@ -287,22 +288,22 @@ gdk_input_exit (void) gdkdev = (GdkDevicePrivate *)(tmp_list->data); if (gdkdev != (GdkDevicePrivate *)gdk_core_pointer) { - gdk_device_set_mode((GdkDevice *)gdkdev, GDK_MODE_DISABLED); + gdk_device_set_mode ((GdkDevice *)gdkdev, GDK_MODE_DISABLED); - g_free(gdkdev->info.name); - g_free(gdkdev->info.axes); - g_free(gdkdev->info.keys); - g_free(gdkdev); + g_free (gdkdev->info.name); + g_free (gdkdev->info.axes); + g_free (gdkdev->info.keys); + g_free (gdkdev); } } - g_list_free(gdk_input_devices); + g_list_free (gdk_input_devices); for (tmp_list = gdk_input_windows; tmp_list; tmp_list = tmp_list->next) { - g_free(tmp_list->data); + g_free (tmp_list->data); } - g_list_free(gdk_input_windows); + g_list_free (gdk_input_windows); } /** diff --git a/gdk/linux-fb/gdkmain-fb.c b/gdk/linux-fb/gdkmain-fb.c index d4d38c083a..5ffac036ef 100644 --- a/gdk/linux-fb/gdkmain-fb.c +++ b/gdk/linux-fb/gdkmain-fb.c @@ -143,35 +143,35 @@ fb_modes_parse_mode (GScanner *scanner, int found_geometry = 0; int found_timings = 0; - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_SYMBOL) return -1; - keyword = GPOINTER_TO_INT(scanner->value.v_symbol); + keyword = GPOINTER_TO_INT (scanner->value.v_symbol); if (keyword != FB_MODE) return -1; - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_STRING) return -1; - modename = g_strdup(scanner->value.v_string); + modename = g_strdup (scanner->value.v_string); - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_SYMBOL) { g_free (modename); return -1; /* Not a valid keyword */ } - keyword = GPOINTER_TO_INT(scanner->value.v_symbol); + keyword = GPOINTER_TO_INT (scanner->value.v_symbol); while ( keyword != FB_ENDMODE ) { - switch (GPOINTER_TO_INT(scanner->value.v_symbol)) + switch (GPOINTER_TO_INT (scanner->value.v_symbol)) { case FB_GEOMETRY: for (i=0;i<5;i++) { - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_INT) { g_free (modename); @@ -183,7 +183,7 @@ fb_modes_parse_mode (GScanner *scanner, break; case FB_TIMINGS: for (i=0;i<7;i++) { - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_INT) { g_free (modename); @@ -194,15 +194,15 @@ fb_modes_parse_mode (GScanner *scanner, found_timings = TRUE; break; case FB_LACED: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "true")==0) + if (g_strcasecmp (scanner->value.v_identifier, "true")==0) laced = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "false")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "false")==0) laced = 0; else { @@ -211,15 +211,15 @@ fb_modes_parse_mode (GScanner *scanner, } break; case FB_EXTSYNC: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "true")==0) + if (g_strcasecmp (scanner->value.v_identifier, "true")==0) extsync = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "false")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "false")==0) extsync = 0; else { @@ -228,15 +228,15 @@ fb_modes_parse_mode (GScanner *scanner, } break; case FB_DOUBLE: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "true")==0) + if (g_strcasecmp (scanner->value.v_identifier, "true")==0) doublescan = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "false")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "false")==0) doublescan = 0; else { @@ -245,15 +245,15 @@ fb_modes_parse_mode (GScanner *scanner, } break; case FB_VSYNC: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "high")==0) + if (g_strcasecmp (scanner->value.v_identifier, "high")==0) vsync = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "low")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "low")==0) vsync = 0; else { @@ -262,15 +262,15 @@ fb_modes_parse_mode (GScanner *scanner, } break; case FB_HSYNC: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "high")==0) + if (g_strcasecmp (scanner->value.v_identifier, "high")==0) hsync = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "low")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "low")==0) hsync = 0; else { @@ -279,15 +279,15 @@ fb_modes_parse_mode (GScanner *scanner, } break; case FB_CSYNC: - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_IDENTIFIER) { g_free (modename); return -1; } - if (g_strcasecmp(scanner->value.v_identifier, "high")==0) + if (g_strcasecmp (scanner->value.v_identifier, "high")==0) csync = 1; - else if (g_strcasecmp(scanner->value.v_identifier, "low")==0) + else if (g_strcasecmp (scanner->value.v_identifier, "low")==0) csync = 0; else { @@ -297,18 +297,18 @@ fb_modes_parse_mode (GScanner *scanner, break; } - token = g_scanner_get_next_token(scanner); + token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_SYMBOL) { g_free (modename); return -1; /* Not a valid keyword */ } - keyword = GPOINTER_TO_INT(scanner->value.v_symbol); + keyword = GPOINTER_TO_INT (scanner->value.v_symbol); } - if (strcmp(modename, specified_modename)== 0) { + if (strcmp (modename, specified_modename)== 0) { if (!found_geometry) - g_warning("Geometry not specified\n"); + g_warning ("Geometry not specified\n"); if (found_geometry) { @@ -320,7 +320,7 @@ fb_modes_parse_mode (GScanner *scanner, } if (!found_timings) - g_warning("Timing not specified\n"); + g_warning ("Timing not specified\n"); if (found_timings) { @@ -345,17 +345,18 @@ fb_modes_parse_mode (GScanner *scanner, modeinfo->sync |= FB_SYNC_VERT_HIGH_ACT; } - g_free(modename); + g_free (modename); return 1; } - g_free(modename); + g_free (modename); return 0; } static int -gdk_fb_setup_mode_from_name(struct fb_var_screeninfo *modeinfo, char *modename) +gdk_fb_setup_mode_from_name (struct fb_var_screeninfo *modeinfo, + char *modename) { GScanner *scanner; char *filename; @@ -378,18 +379,18 @@ gdk_fb_setup_mode_from_name(struct fb_var_screeninfo *modeinfo, char *modename) scanner->input_name = filename; for (i=0;iline); + g_warning ("parse error in %s at line %d\n", filename, scanner->line); break; } if (result > 0) @@ -401,14 +402,14 @@ gdk_fb_setup_mode_from_name(struct fb_var_screeninfo *modeinfo, char *modename) g_scanner_destroy (scanner); - close(fd); + close (fd); return retval; } static int -gdk_fb_set_mode(GdkFBDisplay *display) +gdk_fb_set_mode (GdkFBDisplay *display) { char *env, *end; int depth, height, width; @@ -416,25 +417,25 @@ gdk_fb_set_mode(GdkFBDisplay *display) if (ioctl (display->fd, FBIOGET_VSCREENINFO, &display->modeinfo) < 0) return -1; - env = getenv("GDK_DISPLAY_MODE"); + env = getenv ("GDK_DISPLAY_MODE"); if (env) { - if (!gdk_fb_setup_mode_from_name(&display->modeinfo, env)) - g_warning("Couldn't find mode named '%s'\n", env); + if (!gdk_fb_setup_mode_from_name (&display->modeinfo, env)) + g_warning ("Couldn't find mode named '%s'\n", env); } - env = getenv("GDK_DISPLAY_DEPTH"); + env = getenv ("GDK_DISPLAY_DEPTH"); if (env) { - depth = strtol(env, &end, 10); + depth = strtol (env, &end, 10); if (env != end) display->modeinfo.bits_per_pixel = depth; } - env = getenv("GDK_DISPLAY_WIDTH"); + env = getenv ("GDK_DISPLAY_WIDTH"); if (env) { - width = strtol(env, &end, 10); + width = strtol (env, &end, 10); if (env != end) { display->modeinfo.xres = width; @@ -442,10 +443,10 @@ gdk_fb_set_mode(GdkFBDisplay *display) } } - env = getenv("GDK_DISPLAY_HEIGHT"); + env = getenv ("GDK_DISPLAY_HEIGHT"); if (env) { - height = strtol(env, &end, 10); + height = strtol (env, &end, 10); if (env != end) { display->modeinfo.yres = height; @@ -455,46 +456,50 @@ gdk_fb_set_mode(GdkFBDisplay *display) if (ioctl (display->fd, FBIOPUT_VSCREENINFO, &display->modeinfo) < 0) { - g_warning("Couldn't set specified mode\n"); + g_warning ("Couldn't set specified mode\n"); return -1; } if (ioctl (display->fd, FBIOGET_FSCREENINFO, &display->sinfo) < 0) { - g_warning("Error getting fixed screen info\n"); + g_warning ("Error getting fixed screen info\n"); return -1; } return 0; } static GdkFBDisplay * -gdk_fb_display_new(const char *filename) +gdk_fb_display_new (const char *filename) { int fd, n; GdkFBDisplay *retval; - fd = open(filename, O_RDWR); - if(fd < 0) + fd = open (filename, O_RDWR); + if (fd < 0) return NULL; - retval = g_new0(GdkFBDisplay, 1); + retval = g_new0 (GdkFBDisplay, 1); retval->fd = fd; - if (gdk_fb_set_mode(retval) < 0) + if (gdk_fb_set_mode (retval) < 0) { g_free (retval); return NULL; } - ioctl(retval->fd, FBIOBLANK, 0); + ioctl (retval->fd, FBIOBLANK, 0); /* We used to use sinfo.smem_len, but that seemed to be broken in many cases */ - retval->fbmem = mmap(NULL, retval->modeinfo.yres * retval->sinfo.line_length, - PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); - g_assert(retval->fbmem != MAP_FAILED); + retval->fbmem = mmap (NULL, + retval->modeinfo.yres * retval->sinfo.line_length, + PROT_READ|PROT_WRITE, + MAP_SHARED, + fd, + 0); + g_assert (retval->fbmem != MAP_FAILED); - if(retval->sinfo.visual == FB_VISUAL_PSEUDOCOLOR) + if (retval->sinfo.visual == FB_VISUAL_PSEUDOCOLOR) { guint16 red[256], green[256], blue[256]; struct fb_cmap cmap; @@ -503,10 +508,10 @@ gdk_fb_display_new(const char *filename) for(n = 16; n < 256; n++) red[n] = green[n] = blue[n] = n << 8; cmap.red = red; cmap.green = green; cmap.blue = blue; cmap.len = 256; cmap.start = 0; - ioctl(fd, FBIOPUTCMAP, &cmap); + ioctl (fd, FBIOPUTCMAP, &cmap); } - if(retval->sinfo.visual == FB_VISUAL_TRUECOLOR) + if (retval->sinfo.visual == FB_VISUAL_TRUECOLOR) { retval->red_byte = retval->modeinfo.red.offset >> 3; retval->green_byte = retval->modeinfo.green.offset >> 3; @@ -517,11 +522,11 @@ gdk_fb_display_new(const char *filename) } static void -gdk_fb_display_destroy(GdkFBDisplay *fbd) +gdk_fb_display_destroy (GdkFBDisplay *fbd) { - munmap(fbd->fbmem, fbd->modeinfo.yres * fbd->sinfo.line_length); - close(fbd->fd); - g_free(fbd); + munmap (fbd->fbmem, fbd->modeinfo.yres * fbd->sinfo.line_length); + close (fbd->fd); + g_free (fbd); } extern void keyboard_init(void); @@ -529,16 +534,16 @@ extern void keyboard_init(void); gboolean _gdk_windowing_init_check (int argc, char **argv) { - if(gdk_initialized) + if (gdk_initialized) return TRUE; - keyboard_init(); - gdk_display = gdk_fb_display_new("/dev/fb"); + keyboard_init (); + gdk_display = gdk_fb_display_new ("/dev/fb"); - if(!gdk_display) + if (!gdk_display) return FALSE; - gdk_fb_font_init(); + gdk_fb_font_init (); gdk_initialized = TRUE; @@ -592,34 +597,34 @@ gdk_fb_pointer_grab (GdkWindow * window, GdkEventMask event_mask, GdkWindow * confine_to, GdkCursor * cursor, - guint32 time, - gboolean implicit_grab) + guint32 time, + gboolean implicit_grab) { g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0); - if(_gdk_fb_pointer_grab_window) + if (_gdk_fb_pointer_grab_window) { - if(implicit_grab && !_gdk_fb_pointer_implicit_grab) + if (implicit_grab && !_gdk_fb_pointer_implicit_grab) return GDK_GRAB_ALREADY_GRABBED; - gdk_pointer_ungrab(time); + gdk_pointer_ungrab (time); } _gdk_fb_pointer_implicit_grab = implicit_grab; - _gdk_fb_pointer_grab_window = gdk_window_ref(window); - _gdk_fb_pointer_grab_window_events = owner_events?NULL:_gdk_fb_pointer_grab_window; + _gdk_fb_pointer_grab_window = gdk_window_ref (window); + _gdk_fb_pointer_grab_window_events = owner_events ? NULL : _gdk_fb_pointer_grab_window; - _gdk_fb_pointer_grab_confine = confine_to?gdk_window_ref(confine_to):NULL; + _gdk_fb_pointer_grab_confine = confine_to ? gdk_window_ref (confine_to) : NULL; _gdk_fb_pointer_grab_events = event_mask; - _gdk_fb_pointer_grab_cursor = cursor?gdk_cursor_ref(cursor):NULL; + _gdk_fb_pointer_grab_cursor = cursor ? gdk_cursor_ref (cursor) : NULL; - if(cursor) - gdk_fb_cursor_reset(); + if (cursor) + gdk_fb_cursor_reset (); - gdk_fb_window_visibility_crossing(window, TRUE, TRUE); + gdk_fb_window_visibility_crossing (window, TRUE, TRUE); return GDK_GRAB_SUCCESS; } @@ -642,7 +647,7 @@ gdk_fb_pointer_grab (GdkWindow * window, void gdk_pointer_ungrab (guint32 time) { - gdk_fb_pointer_ungrab(time, FALSE); + gdk_fb_pointer_ungrab (time, FALSE); } void @@ -650,27 +655,27 @@ gdk_fb_pointer_ungrab (guint32 time, gboolean implicit_grab) { gboolean have_grab_cursor = _gdk_fb_pointer_grab_cursor && 1; - if(!_gdk_fb_pointer_grab_window) + if (!_gdk_fb_pointer_grab_window) return; - if(implicit_grab && !_gdk_fb_pointer_implicit_grab) + if (implicit_grab && !_gdk_fb_pointer_implicit_grab) return; - if(_gdk_fb_pointer_grab_confine) - gdk_window_unref(_gdk_fb_pointer_grab_confine); + if (_gdk_fb_pointer_grab_confine) + gdk_window_unref (_gdk_fb_pointer_grab_confine); _gdk_fb_pointer_grab_confine = NULL; - if(_gdk_fb_pointer_grab_cursor) - gdk_cursor_unref(_gdk_fb_pointer_grab_cursor); + if (_gdk_fb_pointer_grab_cursor) + gdk_cursor_unref (_gdk_fb_pointer_grab_cursor); _gdk_fb_pointer_grab_cursor = NULL; - if(have_grab_cursor) - gdk_fb_cursor_reset(); + if (have_grab_cursor) + gdk_fb_cursor_reset (); - gdk_fb_window_visibility_crossing(_gdk_fb_pointer_grab_window, FALSE, TRUE); + gdk_fb_window_visibility_crossing (_gdk_fb_pointer_grab_window, FALSE, TRUE); - if(_gdk_fb_pointer_grab_window) - gdk_window_unref(_gdk_fb_pointer_grab_window); + if (_gdk_fb_pointer_grab_window) + gdk_window_unref (_gdk_fb_pointer_grab_window); _gdk_fb_pointer_grab_window = NULL; _gdk_fb_pointer_grab_window_events = NULL; @@ -726,11 +731,11 @@ gdk_keyboard_grab (GdkWindow * window, g_return_val_if_fail (window != NULL, 0); g_return_val_if_fail (GDK_IS_WINDOW (window), 0); - if(_gdk_fb_pointer_grab_window) - gdk_keyboard_ungrab(time); + if (_gdk_fb_pointer_grab_window) + gdk_keyboard_ungrab (time); - if(!owner_events) - _gdk_fb_keyboard_grab_window = gdk_window_ref(window); + if (!owner_events) + _gdk_fb_keyboard_grab_window = gdk_window_ref (window); return GDK_GRAB_SUCCESS; } @@ -753,8 +758,8 @@ gdk_keyboard_grab (GdkWindow * window, void gdk_keyboard_ungrab (guint32 time) { - if(_gdk_fb_keyboard_grab_window) - gdk_window_unref(_gdk_fb_keyboard_grab_window); + if (_gdk_fb_keyboard_grab_window) + gdk_window_unref (_gdk_fb_keyboard_grab_window); _gdk_fb_keyboard_grab_window = NULL; } @@ -885,11 +890,12 @@ extern void keyboard_shutdown(void); void gdk_windowing_exit (void) { - gdk_fb_display_destroy(gdk_display); gdk_display = NULL; + gdk_fb_display_destroy (gdk_display); + gdk_display = NULL; - gdk_fb_font_fini(); + gdk_fb_font_fini (); - keyboard_shutdown(); + keyboard_shutdown (); } gchar* @@ -907,12 +913,14 @@ gdk_keyval_from_name (const gchar *keyval_name) gchar * gdk_get_display(void) { - return g_strdup("/dev/fb0"); + return g_strdup ("/dev/fb0"); } /* utils */ GdkEvent * -gdk_event_make(GdkWindow *window, GdkEventType type, gboolean append_to_queue) +gdk_event_make (GdkWindow *window, + GdkEventType type, + gboolean append_to_queue) { static const guint type_masks[] = { GDK_SUBSTRUCTURE_MASK, /* GDK_DELETE = 0, */ @@ -953,46 +961,46 @@ gdk_event_make(GdkWindow *window, GdkEventType type, gboolean append_to_queue) evmask = GDK_WINDOW_IMPL_FBDATA(window)->event_mask; /* Bad hack to make sure that things work semi-properly with owner_events */ - if(_gdk_fb_pointer_grab_window) + if (_gdk_fb_pointer_grab_window) evmask |= _gdk_fb_pointer_grab_events; - if(_gdk_fb_keyboard_grab_window) + if (_gdk_fb_keyboard_grab_window) evmask |= _gdk_fb_keyboard_grab_events; - if(evmask & GDK_BUTTON_MOTION_MASK) + if (evmask & GDK_BUTTON_MOTION_MASK) { evmask |= GDK_BUTTON1_MOTION_MASK|GDK_BUTTON2_MOTION_MASK|GDK_BUTTON3_MOTION_MASK; } - if(evmask & (GDK_BUTTON1_MOTION_MASK|GDK_BUTTON2_MOTION_MASK|GDK_BUTTON3_MOTION_MASK)) + if (evmask & (GDK_BUTTON1_MOTION_MASK|GDK_BUTTON2_MOTION_MASK|GDK_BUTTON3_MOTION_MASK)) { gint x, y; GdkModifierType mask; - gdk_input_get_mouseinfo(&x, &y, &mask); + gdk_input_get_mouseinfo (&x, &y, &mask); - if(((mask & GDK_BUTTON1_MASK) && (evmask & GDK_BUTTON1_MOTION_MASK)) - || ((mask & GDK_BUTTON2_MASK) && (evmask & GDK_BUTTON2_MOTION_MASK)) - || ((mask & GDK_BUTTON3_MASK) && (evmask & GDK_BUTTON3_MOTION_MASK))) + if (((mask & GDK_BUTTON1_MASK) && (evmask & GDK_BUTTON1_MOTION_MASK)) || + ((mask & GDK_BUTTON2_MASK) && (evmask & GDK_BUTTON2_MOTION_MASK)) || + ((mask & GDK_BUTTON3_MASK) && (evmask & GDK_BUTTON3_MOTION_MASK))) evmask |= GDK_POINTER_MOTION_MASK; } - if(evmask & type_masks[type]) + if (evmask & type_masks[type]) { - GdkEvent *event = gdk_event_new(); + GdkEvent *event = gdk_event_new (); #if 0 guint32 the_time = g_latest_time.tv_sec * 1000 + g_latest_time.tv_usec / 1000; #else guint32 the_time; GTimeVal gcurtime; - g_get_current_time(&gcurtime); + g_get_current_time (&gcurtime); the_time = gcurtime.tv_sec * 1000 + gcurtime.tv_usec / 1000; #endif event->any.type = type; - event->any.window = gdk_window_ref(window); + event->any.window = gdk_window_ref (window); event->any.send_event = FALSE; - switch(type) + switch (type) { case GDK_MOTION_NOTIFY: event->motion.time = the_time; @@ -1051,8 +1059,8 @@ gdk_event_make(GdkWindow *window, GdkEventType type, gboolean append_to_queue) break; } - if(append_to_queue) - gdk_event_queue_append(event); + if (append_to_queue) + gdk_event_queue_append (event); return event; } @@ -1060,7 +1068,8 @@ gdk_event_make(GdkWindow *window, GdkEventType type, gboolean append_to_queue) return NULL; } -void CM(void) +/* Debug hack. Call to find malloc area overwrites: */ +void CM (void) { static gpointer mymem = NULL; gpointer arry[256]; @@ -1068,14 +1077,14 @@ void CM(void) return; - free(mymem); + free (mymem); for(i = 0; i < sizeof(arry)/sizeof(arry[0]); i++) - arry[i] = malloc(i+1); + arry[i] = malloc (i+1); for(i = 0; i < sizeof(arry)/sizeof(arry[0]); i++) - free(arry[i]); + free (arry[i]); - mymem = malloc(256); + mymem = malloc (256); } /* XXX badhack */ @@ -1089,12 +1098,12 @@ struct _GdkWindowPaint gint y_offset; }; -void RP(GdkDrawable *d) +void RP (GdkDrawable *d) { #if 0 - if(GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP) + if (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP) { - if(!GDK_PIXMAP_FBDATA(d)->no_free_mem) + if (!GDK_PIXMAP_FBDATA(d)->no_free_mem) { guchar *oldmem = GDK_DRAWABLE_FBDATA(d)->mem; guint len = ((GDK_DRAWABLE_IMPL_FBDATA(d)->width * GDK_DRAWABLE_IMPL_FBDATA(d)->depth + 7) / 8) * GDK_DRAWABLE_IMPL_FBDATA(d)->height; diff --git a/gdk/linux-fb/gdkpango-fb.c b/gdk/linux-fb/gdkpango-fb.c index 49fc3801a9..c86acf48f4 100644 --- a/gdk/linux-fb/gdkpango-fb.c +++ b/gdk/linux-fb/gdkpango-fb.c @@ -42,35 +42,35 @@ FT_Library gdk_fb_ft_lib = NULL; #define USE_FTGRAYS void -gdk_fb_font_init(void) +gdk_fb_font_init (void) { - FT_Init_FreeType(&gdk_fb_ft_lib); + FT_Init_FreeType (&gdk_fb_ft_lib); #ifdef USE_FTGRAYS - FT_Set_Raster(gdk_fb_ft_lib, &ft_grays_raster); /* If this is removed, also turn off USE_FTGRAYS define in gdkdrawable-fb2.c */ + FT_Set_Raster (gdk_fb_ft_lib, &ft_grays_raster); /* If this is removed, also turn off USE_FTGRAYS define in gdkdrawable-fb2.c */ #endif } void -gdk_fb_font_fini(void) +gdk_fb_font_fini (void) { - FT_Done_FreeType(gdk_fb_ft_lib); + FT_Done_FreeType (gdk_fb_ft_lib); } -void pango_fb_font_set_size(PangoFont *font); +void pango_fb_font_set_size (PangoFont *font); +static void pango_fb_font_map_init (PangoFBFontMap *fontmap); +static PangoFont *pango_fb_font_map_load_font (PangoFontMap *fontmap, + const PangoFontDescription *desc); +static void pango_fb_font_map_list_fonts (PangoFontMap *fontmap, + const gchar *family, + PangoFontDescription ***descs, + int *n_descs); +static void pango_fb_font_map_list_families (PangoFontMap *fontmap, + gchar ***families, + int *n_families); -static void pango_fb_font_map_init(PangoFBFontMap *fontmap); -static PangoFont *pango_fb_font_map_load_font(PangoFontMap *fontmap, - const PangoFontDescription *desc); -static void pango_fb_font_map_list_fonts(PangoFontMap *fontmap, - const gchar *family, - PangoFontDescription ***descs, - int *n_descs); -static void pango_fb_font_map_list_families(PangoFontMap *fontmap, - gchar ***families, - int *n_families); static void -pango_fb_font_map_class_init(PangoFBFontMapClass *class) +pango_fb_font_map_class_init (PangoFBFontMapClass *class) { class->parent_class.load_font = pango_fb_font_map_load_font; class->parent_class.list_fonts = pango_fb_font_map_list_fonts; @@ -78,7 +78,7 @@ pango_fb_font_map_class_init(PangoFBFontMapClass *class) } GType -pango_fb_font_map_get_type(void) +pango_fb_font_map_get_type (void) { static GType object_type = 0; @@ -107,8 +107,8 @@ pango_fb_font_map_get_type(void) } static PangoFont * -pango_fb_font_map_load_font(PangoFontMap *fontmap, - const PangoFontDescription *desc) +pango_fb_font_map_load_font (PangoFontMap *fontmap, + const PangoFontDescription *desc) { PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap; PangoFBFont *retval; @@ -117,68 +117,70 @@ pango_fb_font_map_load_font(PangoFontMap *fontmap, PangoFontDescription d2; /* XXX fixme badhack */ - if(!strcasecmp(desc->family_name, "sans")) + if (!strcasecmp (desc->family_name, "sans")) { d2 = *desc; d2.family_name = "Arial"; desc = &d2; } /* XXX fixme badhack */ - if(!strcasecmp(desc->family_name, "serif")) + if (!strcasecmp (desc->family_name, "serif")) { d2 = *desc; d2.family_name = "Times New Roman"; desc = &d2; } - retval = g_hash_table_lookup(fbfm->all_fonts, desc); + retval = g_hash_table_lookup (fbfm->all_fonts, desc); - if(retval) + if (retval) { - g_object_ref(G_OBJECT(retval)); + g_object_ref (G_OBJECT(retval)); goto out; } - for(i = 0; i < fbfm->all_descs->len; i++) + for (i = 0; i < fbfm->all_descs->len; i++) { - fl = g_ptr_array_index(fbfm->all_descs, i); + fl = g_ptr_array_index (fbfm->all_descs, i); /* Can't use pango_font_description_equal() because it checks ->size as well */ - if(!g_strcasecmp(desc->family_name, fl->desc.family_name) - && desc->style == fl->desc.style - && desc->weight == fl->desc.weight - && desc->stretch == fl->desc.stretch) + if (!g_strcasecmp (desc->family_name, fl->desc.family_name) && + desc->style == fl->desc.style && + desc->weight == fl->desc.weight && + desc->stretch == fl->desc.stretch) break; } - if(i >= fbfm->all_descs->len) + if (i >= fbfm->all_descs->len) return NULL; retval = (PangoFBFont *)g_object_new (PANGO_TYPE_FB_FONT, NULL); retval->desc = *desc; - retval->desc.family_name = g_strdup(desc->family_name); + retval->desc.family_name = g_strdup (desc->family_name); retval->ftf = fl->ftf; - g_hash_table_insert(fbfm->all_fonts, &retval->desc, retval); - g_object_ref(G_OBJECT(retval)); /* XXX FIXME: We have to keep the font in the cache forever because I'm too clueless to see - signals in gobject */ + g_hash_table_insert (fbfm->all_fonts, &retval->desc, retval); + g_object_ref (G_OBJECT (retval)); /* XXX FIXME: We have to keep the font in the cache forever because I'm too clueless to see + signals in gobject */ out: return (PangoFont *)retval; } static void -list_fonts(PangoFBFontMap *fm, const char *family, - GPtrArray *descs, const char *dir) +list_fonts (PangoFBFontMap *fm, + const char *family, + GPtrArray *descs, + const char *dir) { DIR *dirh; struct dirent *dent; - dirh = opendir(dir); - if(!dirh) + dirh = opendir (dir); + if (!dirh) return; - while((dent = readdir(dirh))) + while ((dent = readdir (dirh))) { PangoFBFontListing *pfd; char *ctmp; @@ -187,85 +189,85 @@ list_fonts(PangoFBFontMap *fm, const char *family, FT_Error ec; int i = 0, n = 1; - ctmp = strrchr(dent->d_name, '.'); - if(!ctmp - || (strcasecmp(ctmp, ".ttf") - && strcasecmp(ctmp, ".pfa") - && strcasecmp(ctmp, ".pfb"))) + ctmp = strrchr (dent->d_name, '.'); + if (!ctmp || + (strcasecmp (ctmp, ".ttf") && + strcasecmp (ctmp, ".pfa") && + strcasecmp (ctmp, ".pfb"))) continue; - g_snprintf(buf, sizeof(buf), "%s/%s", dir, dent->d_name); + g_snprintf (buf, sizeof(buf), "%s/%s", dir, dent->d_name); - while(i < n) + while (i < n) { - ec = FT_New_Face(gdk_fb_ft_lib, buf, i, &ftf); - if(ec) + ec = FT_New_Face (gdk_fb_ft_lib, buf, i, &ftf); + if (ec) break; /* error opening */ - FT_Select_Charmap(ftf, ft_encoding_unicode); + FT_Select_Charmap (ftf, ft_encoding_unicode); n = ftf->num_faces; - if(!ftf->family_name || !ftf->style_name) + if (!ftf->family_name || !ftf->style_name) { - g_warning("No family/style on %s", buf); - FT_Done_Face(ftf); + g_warning ("No family/style on %s", buf); + FT_Done_Face (ftf); break; } - pfd = g_new0(PangoFBFontListing, 1); + pfd = g_new0 (PangoFBFontListing, 1); /* Now add the item */ - if(ftf->family_name[0] == '/') - pfd->desc.family_name = g_strdup(ftf->family_name+1); + if (ftf->family_name[0] == '/') + pfd->desc.family_name = g_strdup (ftf->family_name+1); else - pfd->desc.family_name = g_strdup(ftf->family_name); + pfd->desc.family_name = g_strdup (ftf->family_name); pfd->desc.style = PANGO_STYLE_NORMAL; pfd->desc.variant = PANGO_VARIANT_NORMAL; pfd->desc.weight = PANGO_WEIGHT_NORMAL; pfd->desc.stretch = PANGO_STRETCH_NORMAL; - if(ftf->style_name) + if (ftf->style_name) { char lcstr[512]; - strcpy(lcstr, ftf->style_name); - g_strdown(lcstr); + strcpy (lcstr, ftf->style_name); + g_strdown (lcstr); - if(strstr(lcstr, "italic")) + if (strstr (lcstr, "italic")) pfd->desc.style = PANGO_STYLE_ITALIC; - else if(strstr(lcstr, "oblique")) + else if (strstr (lcstr, "oblique")) pfd->desc.style = PANGO_STYLE_OBLIQUE; - if(strstr(lcstr, "bold")) + if (strstr (lcstr, "bold")) pfd->desc.weight = PANGO_WEIGHT_BOLD; - if(strstr(lcstr, "condensed")) + if (strstr (lcstr, "condensed")) pfd->desc.stretch = PANGO_STRETCH_CONDENSED; - else if(strstr(lcstr, "expanded")) + else if (strstr (lcstr, "expanded")) pfd->desc.stretch = PANGO_STRETCH_EXPANDED; } pfd->ftf = ftf; - g_ptr_array_add(descs, pfd); + g_ptr_array_add (descs, pfd); i++; } } - closedir(dirh); + closedir (dirh); } static guint -pango_font_description_hash(gconstpointer a) +pango_font_description_hash (gconstpointer a) { const PangoFontDescription *fa = a; - return g_str_hash(fa->family_name) ^ (fa->style + fa->weight + fa->stretch + fa->variant + fa->size); + return g_str_hash (fa->family_name) ^ (fa->style + fa->weight + fa->stretch + fa->variant + fa->size); } static void -pango_fb_font_map_init(PangoFBFontMap *fontmap) +pango_fb_font_map_init (PangoFBFontMap *fontmap) { static const char *font_dirs[] = { "/usr/share/fonts/default/TrueType", @@ -276,35 +278,35 @@ pango_fb_font_map_init(PangoFBFontMap *fontmap) }; int i; - fontmap->all_fonts = g_hash_table_new(pango_font_description_hash, (GEqualFunc)pango_font_description_equal); - fontmap->all_descs = g_ptr_array_new(); - for(i = 0; font_dirs[i]; i++) - list_fonts(fontmap, NULL, fontmap->all_descs, font_dirs[i]); + fontmap->all_fonts = g_hash_table_new (pango_font_description_hash, (GEqualFunc)pango_font_description_equal); + fontmap->all_descs = g_ptr_array_new (); + for (i = 0; font_dirs[i]; i++) + list_fonts (fontmap, NULL, fontmap->all_descs, font_dirs[i]); } static void -pango_fb_font_map_list_fonts(PangoFontMap *fontmap, - const gchar *family, - PangoFontDescription ***descs, - int *n_descs) +pango_fb_font_map_list_fonts (PangoFontMap *fontmap, + const gchar *family, + PangoFontDescription ***descs, + int *n_descs) { PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap; int i, n; - *descs = g_new(PangoFontDescription *, fbfm->all_descs->len); + *descs = g_new (PangoFontDescription *, fbfm->all_descs->len); *n_descs = fbfm->all_descs->len; - for(i = n = 0; i < fbfm->all_descs->len; i++) + for (i = n = 0; i < fbfm->all_descs->len; i++) { - PangoFontDescription *pfd = g_ptr_array_index(fbfm->all_descs, i); + PangoFontDescription *pfd = g_ptr_array_index (fbfm->all_descs, i); - if(strcasecmp(family, pfd->family_name)) + if (strcasecmp (family, pfd->family_name)) continue; - (*descs)[n++] = pango_font_description_copy(pfd); + (*descs)[n++] = pango_font_description_copy (pfd); } *n_descs = n; - *descs = g_realloc(*descs, n * sizeof(PangoFontDescription *)); + *descs = g_realloc (*descs, n * sizeof(PangoFontDescription *)); } struct famlist { @@ -313,40 +315,40 @@ struct famlist { }; static void -add_entry(gpointer key, gpointer value, gpointer data) +add_entry (gpointer key, gpointer value, gpointer data) { struct famlist *fl = data; - fl->families[fl->last_added++] = g_strdup(key); + fl->families[fl->last_added++] = g_strdup (key); } static void -pango_fb_font_map_list_families(PangoFontMap *fontmap, - gchar ***families, - int *n_families) +pango_fb_font_map_list_families (PangoFontMap *fontmap, + gchar ***families, + int *n_families) { PangoFBFontMap *fbfm = (PangoFBFontMap *)fontmap; int i; - GHashTable *thash = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable *thash = g_hash_table_new (g_str_hash, g_str_equal); struct famlist stickittome; for(i = 0; i < fbfm->all_descs->len; i++) { - PangoFBFontListing *fl = g_ptr_array_index(fbfm->all_descs, i); - g_hash_table_insert(thash, fl->desc.family_name, fl); + PangoFBFontListing *fl = g_ptr_array_index (fbfm->all_descs, i); + g_hash_table_insert (thash, fl->desc.family_name, fl); } - *n_families = g_hash_table_size(thash); - *families = g_new(gchar *, *n_families); + *n_families = g_hash_table_size (thash); + *families = g_new (gchar *, *n_families); stickittome.families = *families; stickittome.last_added = 0; - g_hash_table_foreach(thash, add_entry, &stickittome); - g_hash_table_destroy(thash); + g_hash_table_foreach (thash, add_entry, &stickittome); + g_hash_table_destroy (thash); } static PangoFontMap * -pango_fb_font_map(void) +pango_fb_font_map (void) { - return g_object_new(pango_fb_font_map_get_type(), NULL); + return g_object_new (pango_fb_font_map_get_type (), NULL); } PangoMap * @@ -357,8 +359,8 @@ pango_fb_get_shaper_map (const char *lang) if (engine_type_id == 0) { - engine_type_id = g_quark_try_string(PANGO_ENGINE_TYPE_SHAPE); - render_type_id = g_quark_try_string(PANGO_RENDER_TYPE_FB); + engine_type_id = g_quark_try_string (PANGO_ENGINE_TYPE_SHAPE); + render_type_id = g_quark_try_string (PANGO_RENDER_TYPE_FB); } if (engine_type_id == 0) @@ -396,23 +398,23 @@ struct _PangoFBFontClass PangoFontClass parent_class; }; -static void pango_fb_font_class_init (PangoFBFontClass *class); -static void pango_fb_font_init (PangoFBFont *font); -static void pango_fb_font_finalize (GObject *object); +static void pango_fb_font_class_init (PangoFBFontClass *class); +static void pango_fb_font_init (PangoFBFont *font); +static void pango_fb_font_finalize (GObject *object); static PangoFontDescription *pango_fb_font_describe (PangoFont *font); static PangoCoverage * pango_fb_font_get_coverage (PangoFont *font, - const char *lang); + const char *lang); static PangoEngineShape * pango_fb_font_find_shaper (PangoFont *font, - const char *lang, - guint32 ch); + const char *lang, + guint32 ch); static void pango_fb_font_get_glyph_extents (PangoFont *font, - PangoGlyph glyph, - PangoRectangle *ink_rect, - PangoRectangle *logical_rect); + PangoGlyph glyph, + PangoRectangle *ink_rect, + PangoRectangle *logical_rect); static void pango_fb_font_get_metrics (PangoFont *font, - const gchar *lang, - PangoFontMetrics *metrics); + const gchar *lang, + PangoFontMetrics *metrics); GType pango_fb_font_get_type (void) @@ -447,29 +449,29 @@ static void pango_fb_font_init (PangoFBFont *font) { font->desc.size = -1; - font->glyph_info = g_hash_table_new(NULL, NULL); + font->glyph_info = g_hash_table_new (NULL, NULL); } static gboolean g_free_2(gpointer key, gpointer value, gpointer data) { PangoFBGlyphInfo *pgi = value; - g_free(pgi->fbd.drawable_data.mem); - g_free(value); + g_free (pgi->fbd.drawable_data.mem); + g_free (value); return TRUE; } static void pango_fb_font_clear_extent_cache(PangoFBFont *fbf) { - g_hash_table_foreach_remove(fbf->glyph_info, g_free_2, NULL); + g_hash_table_foreach_remove (fbf->glyph_info, g_free_2, NULL); } PangoFBGlyphInfo * -pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) +pango_fb_font_get_glyph_info (PangoFont *font, PangoGlyph glyph) { PangoFBGlyphInfo *pgi; - PangoFBFont *fbf = PANGO_FB_FONT(font); + PangoFBFont *fbf = PANGO_FB_FONT (font); FT_Bitmap *renderme; FT_GlyphSlot g; PangoRectangle *my_logical_rect, *my_ink_rect; @@ -478,19 +480,19 @@ pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) ftf = fbf->ftf; - pango_fb_font_set_size(font); + pango_fb_font_set_size (font); - pgi = g_hash_table_lookup(fbf->glyph_info, GUINT_TO_POINTER(glyph)); - if(pgi) + pgi = g_hash_table_lookup (fbf->glyph_info, GUINT_TO_POINTER (glyph)); + if (pgi) return pgi; - pgi = g_new0(PangoFBGlyphInfo, 1); + pgi = g_new0 (PangoFBGlyphInfo, 1); - FT_Load_Glyph(ftf, glyph, FT_LOAD_DEFAULT); + FT_Load_Glyph (ftf, glyph, FT_LOAD_DEFAULT); g = ftf->glyph; - if(g->format != ft_glyph_format_bitmap) + if (g->format != ft_glyph_format_bitmap) { FT_BitmapGlyph bgy; int bdepth; @@ -505,8 +507,8 @@ pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) bdepth = 0; #endif - if(FT_Get_Glyph_Bitmap(ftf, glyph, 0, bdepth, NULL, &bgy)) - g_error("Glyph render failed"); + if (FT_Get_Glyph_Bitmap(ftf, glyph, 0, bdepth, NULL, &bgy)) + g_error ("Glyph render failed"); renderme = &bgy->bitmap; free_buffer = TRUE; @@ -514,12 +516,12 @@ pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) else renderme = &g->bitmap; - pgi->fbd.drawable_data.mem = g_memdup(renderme->buffer, renderme->pitch * renderme->rows); + pgi->fbd.drawable_data.mem = g_memdup (renderme->buffer, renderme->pitch * renderme->rows); pgi->fbd.drawable_data.rowstride = renderme->pitch; pgi->fbd.drawable_data.width = pgi->fbd.drawable_data.lim_x = renderme->width; pgi->fbd.drawable_data.height = pgi->fbd.drawable_data.lim_y = renderme->rows; - switch(renderme->pixel_mode) + switch (renderme->pixel_mode) { case ft_pixel_mode_mono: pgi->fbd.drawable_data.depth = 1; @@ -532,7 +534,7 @@ pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) #endif break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } @@ -555,20 +557,20 @@ pango_fb_font_get_glyph_info(PangoFont *font, PangoGlyph glyph) pgi->hbearing = ((-g->metrics.horiBearingY) >> 6); - g_hash_table_insert(fbf->glyph_info, GUINT_TO_POINTER(glyph), pgi); + g_hash_table_insert (fbf->glyph_info, GUINT_TO_POINTER(glyph), pgi); return pgi; } -static void pango_fb_font_finalize (GObject *object) +static void pango_fb_font_finalize (GObject *object) { - PangoFBFont *fbf = PANGO_FB_FONT(object); + PangoFBFont *fbf = PANGO_FB_FONT (object); /* XXX FIXME g_hash_table_remove(ourfontmap, &fbf->desc); */ - pango_coverage_unref(fbf->coverage); - g_free(fbf->desc.family_name); - pango_fb_font_clear_extent_cache(fbf); - g_hash_table_destroy(fbf->glyph_info); + pango_coverage_unref (fbf->coverage); + g_free (fbf->desc.family_name); + pango_fb_font_clear_extent_cache (fbf); + g_hash_table_destroy (fbf->glyph_info); } static void @@ -586,9 +588,9 @@ pango_fb_font_class_init (PangoFBFontClass *class) } static PangoFontDescription * -pango_fb_font_describe(PangoFont *font) +pango_fb_font_describe (PangoFont *font) { - return pango_font_description_copy(&PANGO_FB_FONT(font)->desc); + return pango_font_description_copy (&PANGO_FB_FONT(font)->desc); } static void @@ -600,23 +602,23 @@ free_coverages_foreach (gpointer key, } static PangoCoverage * -pango_fb_font_get_coverage (PangoFont *font, - const char *lang) +pango_fb_font_get_coverage (PangoFont *font, + const char *lang) { int i, n; PangoCoverage *retval; PangoMap *shape_map; GHashTable *coverage_hash; - if(PANGO_FB_FONT(font)->coverage) - return pango_coverage_ref(PANGO_FB_FONT(font)->coverage); + if (PANGO_FB_FONT (font)->coverage) + return pango_coverage_ref (PANGO_FB_FONT (font)->coverage); - shape_map = pango_fb_get_shaper_map(lang); + shape_map = pango_fb_get_shaper_map (lang); coverage_hash = g_hash_table_new (g_str_hash, g_str_equal); - retval = pango_coverage_new(); - n = MIN(65536,PANGO_FB_FONT(font)->ftf->num_glyphs); + retval = pango_coverage_new (); + n = MIN( 65536, PANGO_FB_FONT (font)->ftf->num_glyphs); for(i = 0; i < n; i++) { PangoCoverageLevel font_level; @@ -648,15 +650,15 @@ pango_fb_font_get_coverage (PangoFont *font, g_hash_table_foreach (coverage_hash, free_coverages_foreach, NULL); g_hash_table_destroy (coverage_hash); - PANGO_FB_FONT(font)->coverage = pango_coverage_ref(retval); + PANGO_FB_FONT (font)->coverage = pango_coverage_ref (retval); return retval; } static PangoEngineShape * -pango_fb_font_find_shaper (PangoFont *font, - const char *lang, - guint32 ch) +pango_fb_font_find_shaper (PangoFont *font, + const char *lang, + guint32 ch) { PangoMap *shape_map = NULL; @@ -671,14 +673,14 @@ EXPORT_FUNC(FT_Error) FT_New_GlyphSlot( FT_Face face, #endif void -pango_fb_font_set_size(PangoFont *font) +pango_fb_font_set_size (PangoFont *font) { PangoFBFont *fbf = (PangoFBFont *)font; - if(PANGO_FB_FONT(font)->desc.size != GPOINTER_TO_UINT(fbf->ftf->generic.data)) + if (PANGO_FB_FONT (font)->desc.size != GPOINTER_TO_UINT (fbf->ftf->generic.data)) { - fbf->ftf->generic.data = GUINT_TO_POINTER(PANGO_FB_FONT(font)->desc.size); - FT_Set_Char_Size(fbf->ftf, 0, (PANGO_FB_FONT(font)->desc.size << 6)/PANGO_SCALE, 72, 72); + fbf->ftf->generic.data = GUINT_TO_POINTER (PANGO_FB_FONT (font)->desc.size); + FT_Set_Char_Size (fbf->ftf, 0, (PANGO_FB_FONT (font)->desc.size << 6)/PANGO_SCALE, 72, 72); } } @@ -692,30 +694,30 @@ pango_fb_font_get_glyph_extents (PangoFont *font, PangoRectangle *my_extents; PangoFBGlyphInfo *gi; - fbf = PANGO_FB_FONT(font); + fbf = PANGO_FB_FONT (font); - pango_fb_font_set_size(font); + pango_fb_font_set_size (font); - gi = pango_fb_font_get_glyph_info(font, glyph); + gi = pango_fb_font_get_glyph_info (font, glyph); my_extents = gi->extents; - if(ink_rect) + if (ink_rect) *ink_rect = my_extents[0]; - if(logical_rect) + if (logical_rect) *logical_rect = my_extents[1]; } static void -pango_fb_font_get_metrics (PangoFont *font, - const gchar *lang, - PangoFontMetrics *metrics) +pango_fb_font_get_metrics (PangoFont *font, + const gchar *lang, + PangoFontMetrics *metrics) { FT_Face ftf; - ftf = PANGO_FB_FONT(font)->ftf; + ftf = PANGO_FB_FONT (font)->ftf; - if(metrics) + if (metrics) { metrics->ascent = ftf->ascender * PANGO_SCALE >> 6; metrics->descent = ftf->descender * PANGO_SCALE >> 6; @@ -763,10 +765,10 @@ gdk_pango_context_get (void) PangoContext *retval; static PangoFontMap *font_map = NULL; - if(!font_map) + if (!font_map) font_map = pango_fb_font_map (); - retval = pango_context_new(); + retval = pango_context_new (); pango_context_add_font_map (retval, font_map); diff --git a/gdk/linux-fb/gdkpixmap-fb.c b/gdk/linux-fb/gdkpixmap-fb.c index 5f01a14815..4b9d3e4651 100644 --- a/gdk/linux-fb/gdkpixmap-fb.c +++ b/gdk/linux-fb/gdkpixmap-fb.c @@ -57,7 +57,7 @@ gdk_pixmap_impl_fb_init (GdkPixmapFBData *impl) GdkDrawableFBData *private = (GdkDrawableFBData *)impl; private->window_type = GDK_DRAWABLE_PIXMAP; - private->colormap = gdk_colormap_ref(gdk_colormap_get_system()); + private->colormap = gdk_colormap_ref (gdk_colormap_get_system()); private->mem = NULL; private->width = 1; private->height = 1; @@ -75,7 +75,7 @@ static void gdk_pixmap_impl_fb_class_init (GdkPixmapFBClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - // GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + /* GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); */ parent_class = g_type_class_peek_parent (klass); @@ -130,13 +130,12 @@ gdk_pixmap_new (GdkWindow *window, if (depth == -1) depth = gdk_drawable_get_visual (window)->depth; - pixmap = (GdkPixmap *)g_object_new (gdk_pixmap_get_type(), NULL); - private = GDK_DRAWABLE_IMPL_FBDATA(pixmap); - - GDK_DRAWABLE_IMPL_FBDATA(pixmap)->mem = g_malloc(((width * depth + 7) / 8) * height); - GDK_DRAWABLE_IMPL_FBDATA(pixmap)->rowstride = (width * depth + 7) / 8; /* Round up to nearest whole byte */ - GDK_DRAWABLE_IMPL_FBDATA(pixmap)->lim_x = width; - GDK_DRAWABLE_IMPL_FBDATA(pixmap)->lim_y = height; + pixmap = (GdkPixmap *)g_object_new (gdk_pixmap_get_type (), NULL); + private = GDK_DRAWABLE_IMPL_FBDATA (pixmap); + private->rowstride = (width * depth + 7) / 8; /* Round up to nearest whole byte */ + private->mem = g_malloc (private->rowstride * height); + private->lim_x = width; + private->lim_y = height; private->width = width; private->height = height; private->depth = ((GdkPixmapObject *)pixmap)->depth = depth; @@ -159,9 +158,9 @@ gdk_bitmap_create_from_data (GdkWindow *window, if (!window) window = gdk_parent_root; - pixmap = gdk_pixmap_new(window, width, height, 1); + pixmap = gdk_pixmap_new (window, width, height, 1); - memcpy(GDK_DRAWABLE_IMPL_FBDATA(pixmap)->mem, data, ((width + 7) / 8) * height); + memcpy (GDK_DRAWABLE_IMPL_FBDATA (pixmap)->mem, data, ((width + 7) / 8) * height); return pixmap; } @@ -190,9 +189,9 @@ gdk_pixmap_create_from_data (GdkWindow *window, if (depth == -1) depth = gdk_drawable_get_visual (window)->depth; - pixmap = gdk_pixmap_new(window, width, height, depth); + pixmap = gdk_pixmap_new (window, width, height, depth); - memcpy(GDK_DRAWABLE_IMPL_FBDATA(pixmap)->mem, data, height * GDK_DRAWABLE_IMPL_FBDATA(pixmap)->rowstride); + memcpy (GDK_DRAWABLE_IMPL_FBDATA (pixmap)->mem, data, height * GDK_DRAWABLE_IMPL_FBDATA (pixmap)->rowstride); return pixmap; } diff --git a/gdk/linux-fb/gdkprivate-fb.h b/gdk/linux-fb/gdkprivate-fb.h index 3eaa816732..76d029f6eb 100644 --- a/gdk/linux-fb/gdkprivate-fb.h +++ b/gdk/linux-fb/gdkprivate-fb.h @@ -39,10 +39,10 @@ #include #include -#define GDK_DRAWABLE_IMPL_FBDATA(win) ((GdkDrawableFBData *)((GdkWindowPrivate *)(win))->impl) -#define GDK_DRAWABLE_IMPL(win) ((GdkDrawable *)((GdkWindowPrivate *)(win))->impl) -#define GDK_WINDOW_IMPL_FBDATA(win) ((GdkWindowFBData *)((GdkWindowPrivate *)(win))->impl) -#define GDK_PIXMAP_IMPL_FBDATA(win) ((GdkPixmapFBData *)((GdkWindowPrivate *)(win))->impl) +#define GDK_DRAWABLE_IMPL_FBDATA(win) ((GdkDrawableFBData *)((GdkWindowObject *)(win))->impl) +#define GDK_DRAWABLE_IMPL(win) ((GdkDrawable *)((GdkWindowObject *)(win))->impl) +#define GDK_WINDOW_IMPL_FBDATA(win) ((GdkWindowFBData *)((GdkWindowObject *)(win))->impl) +#define GDK_PIXMAP_IMPL_FBDATA(win) ((GdkPixmapFBData *)((GdkWindowObject *)(win))->impl) #define GDK_DRAWABLE_FBDATA(win) ((GdkDrawableFBData *)(win)) #define GDK_PIXMAP_FBDATA(win) ((GdkPixmapFBData *)(win)) #define GDK_WINDOW_FBDATA(win) ((GdkWindowFBData *)(win)) @@ -57,7 +57,6 @@ typedef struct _GdkDrawableFBData GdkDrawableFBData; typedef struct _GdkWindowFBData GdkWindowFBData; typedef struct _GdkPixmapFBData GdkPixmapFBData; -typedef GdkWindowObject GdkWindowPrivate; #define GDK_DRAWABLE_PIXMAP (GDK_WINDOW_FOREIGN+1) struct _GdkDrawableFBData @@ -83,8 +82,6 @@ typedef struct { GdkDrawableClass base_class; } GdkDrawableFBClass; -#define GDK_DRAWABLE_P(x) ((GdkDrawableFBData *)(x)) - struct _GdkPixmapFBData { GdkDrawableFBData drawable_data; @@ -135,17 +132,11 @@ typedef struct { } GdkVisualPrivateFB; typedef struct { - GdkColormap base; - GHashTable *hash; GdkColorInfo *info; guint sync_tag; } GdkColormapPrivateFB; -typedef struct { - GdkColormapClass base_class; -} GdkColormapFBClass; - typedef struct { GdkCursor base; GdkPixmap *cursor, *mask; @@ -164,7 +155,7 @@ void gdk_fb_font_init(void); void gdk_fb_font_fini(void); typedef struct { - GdkImage base; + /* Empty */ } GdkImagePrivateFB; #define GDK_GC_FBDATA(x) ((GdkGCFBData *)(x)) diff --git a/gdk/linux-fb/gdkproperty-fb.c b/gdk/linux-fb/gdkproperty-fb.c index f32f78a93b..fd23186555 100644 --- a/gdk/linux-fb/gdkproperty-fb.c +++ b/gdk/linux-fb/gdkproperty-fb.c @@ -38,13 +38,13 @@ gdk_atom_intern (const gchar *atom_name, { g_return_val_if_fail (atom_name != NULL, GDK_NONE); - return g_quark_from_string(atom_name); + return g_quark_from_string (atom_name); } gchar* gdk_atom_name (GdkAtom atom) { - return g_quark_to_string(atom); + return g_quark_to_string (atom); } static void @@ -55,11 +55,11 @@ gdk_property_delete_2 (GdkWindow *window, GdkWindowFBData *fbd = GDK_WINDOW_IMPL_FBDATA(window); GdkEvent *event; - g_hash_table_remove(fbd->properties, GUINT_TO_POINTER(property)); - g_free(prop); + g_hash_table_remove (fbd->properties, GUINT_TO_POINTER (property)); + g_free (prop); - event = gdk_event_make(window, GDK_PROPERTY_NOTIFY, TRUE); - if(event) + event = gdk_event_make (window, GDK_PROPERTY_NOTIFY, TRUE); + if (event) { event->property.atom = property; event->property.state = GDK_PROPERTY_DELETE; @@ -70,20 +70,20 @@ void gdk_property_delete (GdkWindow *window, GdkAtom property) { - GdkWindowFBData *fbd = GDK_WINDOW_FBDATA(window); + GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window); GdkWindowProperty *prop; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if(!fbd->properties) + if (!fbd->properties) return; - prop = g_hash_table_lookup(fbd->properties, GUINT_TO_POINTER(property)); - if(!prop) + prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER(property)); + if (!prop) return; - gdk_property_delete_2(window, property, prop); + gdk_property_delete_2 (window, property, prop); } gint @@ -98,7 +98,7 @@ gdk_property_get (GdkWindow *window, gint *actual_length, guchar **data) { - GdkWindowFBData *fbd = GDK_WINDOW_FBDATA(window); + GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window); GdkWindowProperty *prop; int nbytes; @@ -107,19 +107,19 @@ gdk_property_get (GdkWindow *window, g_return_val_if_fail (actual_length != NULL, FALSE); g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE); - if(!fbd->properties) + if (!fbd->properties) return FALSE; - prop = g_hash_table_lookup(fbd->properties, GUINT_TO_POINTER(property)); - if(!prop) + prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER (property)); + if (!prop) return FALSE; nbytes = (offset + length * (prop->format >> 3)) - prop->length; - nbytes = MAX(nbytes, 0); - if(nbytes > 0) + nbytes = MAX (nbytes, 0); + if (nbytes > 0) { - *data = g_malloc(nbytes+1); - memcpy(data, prop->data + offset, nbytes); + *data = g_malloc (nbytes+1); + memcpy (data, prop->data + offset, nbytes); (*data)[nbytes] = 0; } else @@ -128,8 +128,8 @@ gdk_property_get (GdkWindow *window, *actual_property_type = prop->type; *actual_format_type = prop->format; - if(pdelete) - gdk_property_delete_2(window, property, prop); + if (pdelete) + gdk_property_delete_2 (window, property, prop); return TRUE; } @@ -143,7 +143,7 @@ gdk_property_change (GdkWindow *window, const guchar *data, gint nelements) { - GdkWindowFBData *fbd = GDK_WINDOW_FBDATA(window); + GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (window); GdkWindowProperty *prop, *new_prop; int new_size = 0; GdkEvent *event; @@ -151,10 +151,10 @@ gdk_property_change (GdkWindow *window, g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - if(!fbd->properties) - fbd->properties = g_hash_table_new(NULL, NULL); + if (!fbd->properties) + fbd->properties = g_hash_table_new (NULL, NULL); - prop = g_hash_table_lookup(fbd->properties, GUINT_TO_POINTER(property)); + prop = g_hash_table_lookup (fbd->properties, GUINT_TO_POINTER (property)); switch(mode) { @@ -164,39 +164,39 @@ gdk_property_change (GdkWindow *window, case GDK_PROP_MODE_PREPEND: case GDK_PROP_MODE_APPEND: new_size = nelements * (format >> 3); - if(prop) + if (prop) new_size += prop->length; default: break; } - new_prop = g_malloc(G_STRUCT_OFFSET(GdkWindowProperty, data) + new_size); + new_prop = g_malloc (G_STRUCT_OFFSET (GdkWindowProperty, data) + new_size); new_prop->length = new_size; new_prop->type = type; new_prop->format = format; - switch(mode) + switch (mode) { case GDK_PROP_MODE_REPLACE: - memcpy(new_prop->data, data, new_size); + memcpy (new_prop->data, data, new_size); break; case GDK_PROP_MODE_APPEND: - if(prop) - memcpy(new_prop->data, prop->data, prop->length); - memcpy(new_prop->data + prop->length, data, (nelements * (format >> 3))); + if (prop) + memcpy (new_prop->data, prop->data, prop->length); + memcpy (new_prop->data + prop->length, data, (nelements * (format >> 3))); break; case GDK_PROP_MODE_PREPEND: - memcpy(new_prop->data, data, (nelements * (format >> 3))); - if(prop) - memcpy(new_prop->data + (nelements * (format >> 3)), prop->data, prop->length); + memcpy (new_prop->data, data, (nelements * (format >> 3))); + if (prop) + memcpy (new_prop->data + (nelements * (format >> 3)), prop->data, prop->length); break; } - g_hash_table_insert(fbd->properties, GUINT_TO_POINTER(property), new_prop); - g_free(prop); + g_hash_table_insert (fbd->properties, GUINT_TO_POINTER (property), new_prop); + g_free (prop); - event = gdk_event_make(window, GDK_PROPERTY_NOTIFY, TRUE); - if(event) + event = gdk_event_make (window, GDK_PROPERTY_NOTIFY, TRUE); + if (event) { event->property.atom = property; event->property.state = GDK_PROPERTY_NEW_VALUE; diff --git a/gdk/linux-fb/gdkvisual-fb.c b/gdk/linux-fb/gdkvisual-fb.c index e3a8eb764a..ea410e0358 100644 --- a/gdk/linux-fb/gdkvisual-fb.c +++ b/gdk/linux-fb/gdkvisual-fb.c @@ -27,36 +27,19 @@ #include "gdkvisual.h" #include "gdkprivate-fb.h" #include "gdkinternals.h" -#include static GdkVisual *system_visual = NULL; -#ifdef G_ENABLE_DEBUG - -#if 0 -static const gchar* visual_names[] = -{ - "static gray", - "grayscale", - "static color", - "pseudo color", - "true color", - "direct color", -}; -#endif - -#endif /* G_ENABLE_DEBUG */ - void gdk_visual_init (void) { - system_visual = g_new0(GdkVisual, 1); + system_visual = g_new0 (GdkVisual, 1); system_visual->depth = system_visual->bits_per_rgb = gdk_display->modeinfo.bits_per_pixel; system_visual->byte_order = GDK_LSB_FIRST; system_visual->colormap_size = 0; - switch(gdk_display->sinfo.visual) + switch (gdk_display->sinfo.visual) { case FB_VISUAL_PSEUDOCOLOR: system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel; @@ -65,8 +48,9 @@ gdk_visual_init (void) case FB_VISUAL_DIRECTCOLOR: system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel; system_visual->type = GDK_VISUAL_DIRECT_COLOR; + /* Fall through */ case FB_VISUAL_TRUECOLOR: - if(gdk_display->sinfo.visual == FB_VISUAL_TRUECOLOR) + if (gdk_display->sinfo.visual == FB_VISUAL_TRUECOLOR) system_visual->type = GDK_VISUAL_TRUE_COLOR; system_visual->red_prec = gdk_display->modeinfo.red.length; @@ -86,7 +70,7 @@ gdk_visual_init (void) system_visual->colormap_size = 1 << gdk_display->modeinfo.bits_per_pixel; break; default: - g_assert_not_reached(); + g_assert_not_reached (); break; } } @@ -129,7 +113,7 @@ gdk_visual_get_best (void) GdkVisual* gdk_visual_get_best_with_depth (gint depth) { - if(system_visual->depth != depth) + if (system_visual->depth != depth) return NULL; return system_visual; @@ -138,7 +122,7 @@ gdk_visual_get_best_with_depth (gint depth) GdkVisual* gdk_visual_get_best_with_type (GdkVisualType visual_type) { - if(system_visual->type != visual_type) + if (system_visual->type != visual_type) return NULL; return system_visual; @@ -148,10 +132,10 @@ GdkVisual* gdk_visual_get_best_with_both (gint depth, GdkVisualType visual_type) { - if(system_visual->depth != depth) + if (system_visual->depth != depth) return NULL; - if(system_visual->type != visual_type) + if (system_visual->type != visual_type) return NULL; return system_visual; @@ -176,5 +160,5 @@ gdk_query_visual_types (GdkVisualType **visual_types, GList* gdk_list_visuals (void) { - return g_list_append(NULL, gdk_visual_get_system()); + return g_list_append (NULL, gdk_visual_get_system ()); } diff --git a/gdk/linux-fb/gdkwindow-fb.c b/gdk/linux-fb/gdkwindow-fb.c index f6eea8244c..dd0e86442a 100644 --- a/gdk/linux-fb/gdkwindow-fb.c +++ b/gdk/linux-fb/gdkwindow-fb.c @@ -36,29 +36,29 @@ static gpointer parent_class = NULL; -static void recompute_drawable(GdkDrawable *drawable); +static void recompute_drawable (GdkDrawable *drawable); static void -g_free_2nd(gpointer a, gpointer b, gpointer data) +g_free_2nd (gpointer a, gpointer b, gpointer data) { - g_free(b); + g_free (b); } static void gdk_window_impl_fb_finalize (GObject *object) { - GdkWindowFBData *fbd = GDK_WINDOW_FBDATA(object); + GdkWindowFBData *fbd = GDK_WINDOW_FBDATA (object); - if(GDK_WINDOW_P(fbd->drawable_data.wrapper)->mapped) - gdk_window_hide(fbd->drawable_data.wrapper); + if (GDK_WINDOW_P (fbd->drawable_data.wrapper)->mapped) + gdk_window_hide (fbd->drawable_data.wrapper); - if(fbd->cursor) - gdk_cursor_unref(fbd->cursor); + if (fbd->cursor) + gdk_cursor_unref (fbd->cursor); - if(fbd->properties) + if (fbd->properties) { - g_hash_table_foreach(fbd->properties, g_free_2nd, NULL); - g_hash_table_destroy(fbd->properties); + g_hash_table_foreach (fbd->properties, g_free_2nd, NULL); + g_hash_table_destroy (fbd->properties); } G_OBJECT_CLASS (parent_class)->finalize (object); @@ -68,7 +68,7 @@ static void gdk_window_impl_fb_class_init (GdkWindowFBClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - // GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); + /* GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); */ parent_class = g_type_class_peek_parent (klass); @@ -112,40 +112,30 @@ _gdk_window_impl_get_type (void) return object_type; } -#include "/usr/include/X11/bitmaps/left_ptr" -#include "/usr/include/X11/bitmaps/left_ptrmsk" - void _gdk_windowing_window_init (void) { GdkWindowAttr attr; - GdkBitmap *ptr, *mask; GdkCursor *cursor; - GdkWindowPrivate *private; + GdkWindowObject *private; - ptr = gdk_bitmap_create_from_data(gdk_parent_root, left_ptr_bits, left_ptr_width, left_ptr_height); - mask = gdk_bitmap_create_from_data(gdk_parent_root, left_ptrmsk_bits, left_ptrmsk_width, left_ptrmsk_height); -#if 1 - cursor = gdk_cursor_new_from_pixmap(ptr, mask, NULL, NULL, left_ptr_x_hot, left_ptr_y_hot); -#else - cursor = gdk_cursor_new(GDK_LEFT_PTR); -#endif + cursor = gdk_cursor_new (GDK_LEFT_PTR); - attr.width = gdk_screen_width(); - attr.height = gdk_screen_height(); + attr.width = gdk_screen_width (); + attr.height = gdk_screen_height (); attr.window_type = GDK_WINDOW_ROOT; attr.cursor = cursor; attr.event_mask = GDK_EXPOSURE_MASK; attr.wclass = GDK_INPUT_OUTPUT; - gdk_parent_root = gdk_window_new(NULL, &attr, GDK_WA_CURSOR); - private = (GdkWindowPrivate *)gdk_parent_root; + gdk_parent_root = gdk_window_new (NULL, &attr, GDK_WA_CURSOR); + private = (GdkWindowObject *)gdk_parent_root; private->mapped = TRUE; - GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->lim_x = attr.width; - GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->lim_y = attr.height; - gdk_fb_drawable_clear(gdk_parent_root); + GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->lim_x = attr.width; + GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->lim_y = attr.height; + gdk_fb_drawable_clear (gdk_parent_root); } GdkWindow* @@ -154,8 +144,8 @@ gdk_window_new (GdkWindow *parent, gint attributes_mask) { GdkWindow *window; - GdkWindowPrivate *private; - GdkWindowPrivate *parent_private; + GdkWindowObject *private; + GdkWindowObject *parent_private; GdkVisual *visual; GdkWindowFBData *impl; @@ -166,7 +156,7 @@ gdk_window_new (GdkWindow *parent, if (!parent || attributes->window_type != GDK_WINDOW_CHILD) parent = gdk_parent_root; - parent_private = (GdkWindowPrivate*) parent; + parent_private = (GdkWindowObject*) parent; window = (GdkWindow *)g_object_new (GDK_TYPE_WINDOW, NULL); private = (GdkWindowObject *)window; @@ -183,12 +173,12 @@ gdk_window_new (GdkWindow *parent, else y = 0; - gdk_window_set_events(window, attributes->event_mask); + gdk_window_set_events (window, attributes->event_mask); if (attributes_mask & GDK_WA_VISUAL) visual = attributes->visual; else - visual = gdk_visual_get_system(); + visual = gdk_visual_get_system (); impl = (GdkWindowFBData *)private->impl; impl->drawable_data.wrapper = window; @@ -209,11 +199,11 @@ gdk_window_new (GdkWindow *parent, private->input_only = FALSE; private->depth = impl->drawable_data.depth; - if ((attributes_mask & GDK_WA_COLORMAP) - && attributes->colormap) + if ((attributes_mask & GDK_WA_COLORMAP) && + attributes->colormap) impl->drawable_data.colormap = attributes->colormap; else - impl->drawable_data.colormap = gdk_colormap_get_system(); + impl->drawable_data.colormap = gdk_colormap_get_system (); switch (impl->drawable_data.window_type) { @@ -225,7 +215,7 @@ gdk_window_new (GdkWindow *parent, break; case GDK_WINDOW_ROOT: - if(gdk_parent_root) + if (gdk_parent_root) g_error ("cannot make windows of type GDK_WINDOW_ROOT"); break; case GDK_DRAWABLE_PIXMAP: @@ -252,9 +242,9 @@ gdk_window_new (GdkWindow *parent, if (parent_private) { - parent_private->children = g_list_prepend (parent_private->children, window); - if(parent_private->children->next) - impl->level = GDK_WINDOW_FBDATA(GDK_WINDOW_P(parent_private->children->next->data)->impl)->level + 1; + parent_private->children = g_list_prepend (parent_private->children, window); + if (parent_private->children->next) + impl->level = GDK_WINDOW_FBDATA (GDK_WINDOW_P (parent_private->children->next->data)->impl)->level + 1; } return window; @@ -267,13 +257,13 @@ gdk_window_new (GdkWindow *parent, * window. */ void -_gdk_windowing_window_destroy(GdkWindow *window, - gboolean recursing, - gboolean foreign_destroy) +_gdk_windowing_window_destroy (GdkWindow *window, + gboolean recursing, + gboolean foreign_destroy) { #if 0 - GdkWindowPrivate *private; - GdkWindowPrivate *temp_private; + GdkWindowObject *private; + GdkWindowObject *temp_private; GdkWindow *temp_window; GList *children; GList *tmp; @@ -281,7 +271,7 @@ _gdk_windowing_window_destroy(GdkWindow *window, g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; switch (private->window_type) { @@ -294,7 +284,7 @@ _gdk_windowing_window_destroy(GdkWindow *window, { if (private->parent) { - GdkWindowPrivate *parent_private = (GdkWindowPrivate *)private->parent; + GdkWindowObject *parent_private = (GdkWindowObject *)private->parent; if (parent_private->children) parent_private->children = g_list_remove (parent_private->children, window); } @@ -315,7 +305,7 @@ _gdk_windowing_window_destroy(GdkWindow *window, temp_window = tmp->data; tmp = tmp->next; - temp_private = (GdkWindowPrivate*) temp_window; + temp_private = (GdkWindowObject*) temp_window; if (temp_private) _gdk_windowing_window_destroy (temp_window, !FALSE, !our_destroy); @@ -379,12 +369,13 @@ _gdk_windowing_window_destroy(GdkWindow *window, /* This function is called when the XWindow is really gone. */ -static gboolean all_parents_shown(GdkWindowPrivate *private) +static gboolean +all_parents_shown (GdkWindowObject *private) { - while(private->mapped) + while (private->mapped) { - if(private->parent) - private = (GdkWindowPrivate *)private->parent; + if (private->parent) + private = (GdkWindowObject *)private->parent; else return TRUE; } @@ -393,83 +384,84 @@ static gboolean all_parents_shown(GdkWindowPrivate *private) } static void -send_map_events(GdkWindowPrivate *private, gboolean is_map) +send_map_events (GdkWindowObject *private, gboolean is_map) { GList *l; GdkWindow *parent = (GdkWindow *)private->parent; - g_assert(is_map); + g_assert (is_map); - if(!private->mapped) + if (!private->mapped) return; - if(is_map) - gdk_event_make((GdkWindow *)private, GDK_MAP, TRUE); + if (is_map) + gdk_event_make ((GdkWindow *)private, GDK_MAP, TRUE); - if(private->input_only) + if (private->input_only) return; - if(!parent) + if (!parent) parent = (GdkWindow *)private; - if(((GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x > GDK_DRAWABLE_IMPL_FBDATA(parent)->lim_x) - || (GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y > GDK_DRAWABLE_IMPL_FBDATA(parent)->lim_y) - || (GDK_DRAWABLE_IMPL_FBDATA(private)->lim_x < GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_x) - || (GDK_DRAWABLE_IMPL_FBDATA(private)->lim_y < GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_y))) + if (((GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x > GDK_DRAWABLE_IMPL_FBDATA (parent)->lim_x) || + (GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y > GDK_DRAWABLE_IMPL_FBDATA (parent)->lim_y) || + (GDK_DRAWABLE_IMPL_FBDATA (private)->lim_x < GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_x) || + (GDK_DRAWABLE_IMPL_FBDATA (private)->lim_y < GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_y))) return; - if(is_map) - gdk_window_clear((GdkWindow *)private); + if (is_map) + gdk_window_clear ((GdkWindow *)private); #if 0 - event = gdk_event_new(); + event = gdk_event_new (); event->expose.type = GDK_EXPOSE; - event->expose.window = gdk_window_ref((GdkWindow *)private); - if(GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x > GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_x) + event->expose.window = gdk_window_ref ((GdkWindow *)private); + if (GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x > GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_x) event->expose.area.x = 0; else - event->expose.area.x = GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_x - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x; + event->expose.area.x = GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_x - GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x; - if(GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y > GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_y) + if (GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y > GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_y) event->expose.area.y = 0; else - event->expose.area.y = GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_y - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y; + event->expose.area.y = GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_y - GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y; - event->expose.area.width = MIN(GDK_DRAWABLE_IMPL_FBDATA(private)->width, - GDK_DRAWABLE_IMPL_FBDATA(private)->lim_x - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x); - event->expose.area.height = MIN(GDK_DRAWABLE_IMPL_FBDATA(private)->height, - GDK_DRAWABLE_IMPL_FBDATA(private)->lim_y - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y); - if(event->expose.area.width > 0 - && event->expose.area.height > 0) + event->expose.area.width = MIN (GDK_DRAWABLE_IMPL_FBDATA (private)->width, + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_x - GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x); + event->expose.area.height = MIN (GDK_DRAWABLE_IMPL_FBDATA (private)->height, + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_y - GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y); + if (event->expose.area.width > 0 && + event->expose.area.height > 0) { - gdk_event_queue_append(event); + gdk_event_queue_append (event); } else - gdk_event_free(event); + gdk_event_free (event); #endif - for(l = private->children; l; l = l->next) - send_map_events(l->data, is_map); + for (l = private->children; l; l = l->next) + send_map_events (l->data, is_map); } /* Cut & paste versions of the stuff in gdkwindow.c, with the addition of clearing the newly exposed region. */ void -gdk_window_invalidate_region_clear(GdkWindow *window, GdkRegion *region) +gdk_window_invalidate_region_clear(GdkWindow *window, + GdkRegion *region) { int i; - GdkWindowPrivate *private = GDK_WINDOW_P(window); + GdkWindowObject *private = GDK_WINDOW_P (window); if (private->input_only || !private->mapped) return; - if(private->bg_pixmap != GDK_NO_BG) - for(i = 0; i < region->numRects; i++) - gdk_window_clear_area(window, - region->rects[i].x1, - region->rects[i].y1, - region->rects[i].x2 - region->rects[i].x1, - region->rects[i].y2 - region->rects[i].y1); + if (private->bg_pixmap != GDK_NO_BG) + for (i = 0; i < region->numRects; i++) + gdk_window_clear_area (window, + region->rects[i].x1, + region->rects[i].y1, + region->rects[i].x2 - region->rects[i].x1, + region->rects[i].y2 - region->rects[i].y1); - gdk_window_invalidate_region(window, region, FALSE); + gdk_window_invalidate_region (window, region, FALSE); { GList *tmp_list; @@ -510,16 +502,17 @@ gdk_window_invalidate_region_clear(GdkWindow *window, GdkRegion *region) } void -gdk_window_invalidate_rect_clear(GdkWindow *window, GdkRectangle *rect) +gdk_window_invalidate_rect_clear (GdkWindow *window, + GdkRectangle *rect) { - GdkWindowPrivate *private = GDK_WINDOW_P(window); + GdkWindowObject *private = GDK_WINDOW_P (window); if (private->input_only || !private->mapped) return; - if(GDK_WINDOW_P(window)->bg_pixmap != GDK_NO_BG) - gdk_window_clear_area(window, rect->x, rect->y, rect->width, rect->height); - gdk_window_invalidate_rect(window, rect, FALSE); + if (GDK_WINDOW_P (window)->bg_pixmap != GDK_NO_BG) + gdk_window_clear_area (window, rect->x, rect->y, rect->width, rect->height); + gdk_window_invalidate_rect (window, rect, FALSE); { GList *tmp_list; @@ -535,8 +528,8 @@ gdk_window_invalidate_rect_clear(GdkWindow *window, GdkRectangle *rect) { gint width, height; - width = GDK_DRAWABLE_IMPL_FBDATA(child)->width; - height = GDK_DRAWABLE_IMPL_FBDATA(child)->height; + width = GDK_DRAWABLE_IMPL_FBDATA (child)->width; + height = GDK_DRAWABLE_IMPL_FBDATA (child)->height; child_rect.x = child->x; child_rect.y = child->y; @@ -553,53 +546,52 @@ gdk_window_invalidate_rect_clear(GdkWindow *window, GdkRectangle *rect) } } } - } void -gdk_fb_redraw_all(void) +gdk_fb_redraw_all (void) { GdkRectangle r; r.x = r.y = 0; - r.width = GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->width; - r.height = GDK_DRAWABLE_IMPL_FBDATA(gdk_parent_root)->height; - gdk_window_invalidate_rect_clear(gdk_parent_root, &r); - gdk_window_process_all_updates(); + r.width = GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->width; + r.height = GDK_DRAWABLE_IMPL_FBDATA (gdk_parent_root)->height; + gdk_window_invalidate_rect_clear (gdk_parent_root, &r); + gdk_window_process_all_updates (); } void gdk_window_show (GdkWindow *window) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; if (!private->destroyed && !private->mapped) { private->mapped = TRUE; - if(all_parents_shown((GdkWindowPrivate *)private->parent)) + if (all_parents_shown ((GdkWindowObject *)private->parent)) { GdkRectangle rect; - recompute_drawable((GdkDrawable *)window); + recompute_drawable ((GdkDrawable *)window); - send_map_events(private, TRUE); + send_map_events (private, TRUE); private->mapped = FALSE; /* a hack, ayup, to make gdk_window_get_pointer get the other window */ - gdk_fb_window_visibility_crossing(window, TRUE, FALSE); + gdk_fb_window_visibility_crossing (window, TRUE, FALSE); private->mapped = TRUE; - if(private->input_only) + if (private->input_only) return; - rect.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - rect.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - rect.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - rect.x; - rect.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - rect.y; - gdk_window_invalidate_rect_clear(gdk_parent_root, &rect); + rect.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + rect.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + rect.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - rect.x; + rect.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - rect.y; + gdk_window_invalidate_rect_clear (gdk_parent_root, &rect); } } } @@ -607,11 +599,11 @@ gdk_window_show (GdkWindow *window) void gdk_window_hide (GdkWindow *window) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; if (!private->destroyed && private->mapped) { @@ -619,39 +611,39 @@ gdk_window_hide (GdkWindow *window) GdkRectangle r; gboolean do_hide; - event = gdk_event_make(window, GDK_UNMAP, TRUE); + event = gdk_event_make (window, GDK_UNMAP, TRUE); - r.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - r.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - r.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - r.x; - r.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - r.y; + r.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + r.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + r.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - r.x; + r.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - r.y; private->mapped = FALSE; - if(private->parent == GDK_WINDOW_P(gdk_parent_root)) + if (private->parent == GDK_WINDOW_P(gdk_parent_root)) gdk_fb_drawable_clear(gdk_parent_root); - if(all_parents_shown((GdkWindowPrivate *)private->parent)) - gdk_fb_window_visibility_crossing(window, FALSE, FALSE); + if (all_parents_shown ((GdkWindowObject *)private->parent)) + gdk_fb_window_visibility_crossing (window, FALSE, FALSE); - do_hide = gdk_fb_cursor_need_hide(&r); + do_hide = gdk_fb_cursor_need_hide (&r); - if(do_hide) - gdk_fb_cursor_hide(); - if(window == _gdk_fb_pointer_grab_window) - gdk_pointer_ungrab(GDK_CURRENT_TIME); - if(window == _gdk_fb_keyboard_grab_window) - gdk_keyboard_ungrab(GDK_CURRENT_TIME); - gdk_window_invalidate_rect_clear(gdk_parent_root, &r); - if(do_hide) - gdk_fb_cursor_unhide(); + if (do_hide) + gdk_fb_cursor_hide (); + if (window == _gdk_fb_pointer_grab_window) + gdk_pointer_ungrab (GDK_CURRENT_TIME); + if (window == _gdk_fb_keyboard_grab_window) + gdk_keyboard_ungrab (GDK_CURRENT_TIME); + gdk_window_invalidate_rect_clear (gdk_parent_root, &r); + if (do_hide) + gdk_fb_cursor_unhide (); } } void gdk_window_withdraw (GdkWindow *window) { - gdk_window_hide(window); + gdk_window_hide (window); } void @@ -659,13 +651,14 @@ gdk_window_move (GdkWindow *window, gint x, gint y) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); gdk_window_move_resize (window, x, y, - GDK_DRAWABLE_IMPL_FBDATA(private)->width, GDK_DRAWABLE_IMPL_FBDATA(private)->height); + GDK_DRAWABLE_IMPL_FBDATA (private)->width, + GDK_DRAWABLE_IMPL_FBDATA (private)->height); } void @@ -673,114 +666,116 @@ gdk_window_resize (GdkWindow *window, gint width, gint height) { - GdkWindowPrivate *private; + GdkWindowObject *private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; if (width < 1) width = 1; if (height < 1) height = 1; - gdk_window_move_resize(window, private->x, private->y, width, height); + gdk_window_move_resize (window, private->x, private->y, width, height); } static void -recompute_abs_positions(GdkDrawable *drawable, gint parent_x, gint parent_y, +recompute_abs_positions(GdkDrawable *drawable, + gint parent_x, gint parent_y, gint parent_llim_x, gint parent_llim_y, gint parent_lim_x, gint parent_lim_y) { GList *l; - if(GDK_IS_WINDOW(drawable)) + if (GDK_IS_WINDOW (drawable)) { - GdkWindowPrivate *private = GDK_WINDOW_P(drawable); + GdkWindowObject *private = GDK_WINDOW_P (drawable); int x, y; - if(!private->mapped) + if (!private->mapped) return; - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x = parent_x + private->x; - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y = parent_y + private->y; - x = MAX(parent_llim_x, GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x); - x = MIN(x, parent_lim_x); - GDK_DRAWABLE_IMPL_FBDATA(private)->llim_x = x; - y = MAX(parent_llim_y, GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y); - y = MIN(y, parent_lim_y); - GDK_DRAWABLE_IMPL_FBDATA(private)->llim_y = y; - x = MIN(parent_lim_x, - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x + GDK_DRAWABLE_IMPL_FBDATA(private)->width); - x = MAX(x, GDK_DRAWABLE_IMPL_FBDATA(private)->llim_x); - GDK_DRAWABLE_IMPL_FBDATA(private)->lim_x = x; - y = MIN(parent_lim_y, - GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y + GDK_DRAWABLE_IMPL_FBDATA(private)->height); - y = MAX(y, GDK_DRAWABLE_IMPL_FBDATA(private)->llim_y); - GDK_DRAWABLE_IMPL_FBDATA(private)->lim_y = y; + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x = parent_x + private->x; + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y = parent_y + private->y; + x = MAX (parent_llim_x, GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x); + x = MIN (x, parent_lim_x); + GDK_DRAWABLE_IMPL_FBDATA (private)->llim_x = x; + y = MAX (parent_llim_y, GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y); + y = MIN (y, parent_lim_y); + GDK_DRAWABLE_IMPL_FBDATA (private)->llim_y = y; + x = MIN (parent_lim_x, + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x + GDK_DRAWABLE_IMPL_FBDATA (private)->width); + x = MAX (x, GDK_DRAWABLE_IMPL_FBDATA (private)->llim_x); + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_x = x; + y = MIN (parent_lim_y, + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y + GDK_DRAWABLE_IMPL_FBDATA (private)->height); + y = MAX (y, GDK_DRAWABLE_IMPL_FBDATA (private)->llim_y); + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_y = y; - g_assert(GDK_DRAWABLE_IMPL_FBDATA(private)->llim_x <= GDK_DRAWABLE_IMPL_FBDATA(private)->lim_x); - g_assert(GDK_DRAWABLE_IMPL_FBDATA(private)->llim_y <= GDK_DRAWABLE_IMPL_FBDATA(private)->lim_y); + g_assert (GDK_DRAWABLE_IMPL_FBDATA (private)->llim_x <= GDK_DRAWABLE_IMPL_FBDATA (private)->lim_x); + g_assert (GDK_DRAWABLE_IMPL_FBDATA (private)->llim_y <= GDK_DRAWABLE_IMPL_FBDATA (private)->lim_y); - for(l = private->children; l; l = l->next) - recompute_abs_positions(l->data, GDK_DRAWABLE_IMPL_FBDATA(private)->abs_x, GDK_DRAWABLE_IMPL_FBDATA(private)->abs_y, - GDK_DRAWABLE_IMPL_FBDATA(private)->llim_x, GDK_DRAWABLE_IMPL_FBDATA(private)->llim_y, - GDK_DRAWABLE_IMPL_FBDATA(private)->lim_x, GDK_DRAWABLE_IMPL_FBDATA(private)->lim_y); + for (l = private->children; l; l = l->next) + recompute_abs_positions (l->data, + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_x, + GDK_DRAWABLE_IMPL_FBDATA (private)->abs_y, + GDK_DRAWABLE_IMPL_FBDATA (private)->llim_x, + GDK_DRAWABLE_IMPL_FBDATA (private)->llim_y, + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_x, + GDK_DRAWABLE_IMPL_FBDATA (private)->lim_y); } else { - GDK_DRAWABLE_IMPL_FBDATA(drawable)->abs_x = 0; - GDK_DRAWABLE_IMPL_FBDATA(drawable)->abs_y = 0; - GDK_DRAWABLE_IMPL_FBDATA(drawable)->llim_x = 0; - GDK_DRAWABLE_IMPL_FBDATA(drawable)->llim_y = 0; - GDK_DRAWABLE_IMPL_FBDATA(drawable)->lim_x = GDK_DRAWABLE_IMPL_FBDATA(drawable)->width; - GDK_DRAWABLE_IMPL_FBDATA(drawable)->lim_y = GDK_DRAWABLE_IMPL_FBDATA(drawable)->height; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->abs_x = 0; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->abs_y = 0; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->llim_x = 0; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->llim_y = 0; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->lim_x = GDK_DRAWABLE_IMPL_FBDATA (drawable)->width; + GDK_DRAWABLE_IMPL_FBDATA (drawable)->lim_y = GDK_DRAWABLE_IMPL_FBDATA (drawable)->height; } } static void -recompute_drawable(GdkDrawable *drawable) +recompute_drawable (GdkDrawable *drawable) { - if(GDK_IS_WINDOW(drawable)) + if (GDK_IS_WINDOW (drawable)) { - GdkWindowPrivate *private = GDK_WINDOW_P(drawable); + GdkWindowObject *private = GDK_WINDOW_P (drawable); GdkWindow *parent; parent = (GdkWindow *)private->parent; - if(!parent) + if (!parent) parent = gdk_parent_root; - recompute_abs_positions(drawable, GDK_DRAWABLE_IMPL_FBDATA(parent)->abs_x, - GDK_DRAWABLE_IMPL_FBDATA(parent)->abs_y, - GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_x, - GDK_DRAWABLE_IMPL_FBDATA(parent)->llim_y, - GDK_DRAWABLE_IMPL_FBDATA(parent)->lim_x, - GDK_DRAWABLE_IMPL_FBDATA(parent)->lim_y); + recompute_abs_positions (drawable, + GDK_DRAWABLE_IMPL_FBDATA (parent)->abs_x, + GDK_DRAWABLE_IMPL_FBDATA (parent)->abs_y, + GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_x, + GDK_DRAWABLE_IMPL_FBDATA (parent)->llim_y, + GDK_DRAWABLE_IMPL_FBDATA (parent)->lim_x, + GDK_DRAWABLE_IMPL_FBDATA (parent)->lim_y); } else - recompute_abs_positions(drawable, 0, 0, 0, 0, INT_MAX, INT_MAX); + recompute_abs_positions (drawable, 0, 0, 0, 0, INT_MAX, INT_MAX); } /* You can thank g_list_insert_sorted and GCompareFunc for these */ static gint static_dx_hack, static_dy_hack; static gint -compare_draw_rects(gconstpointer a, gconstpointer b) +compare_draw_rects (gconstpointer a, gconstpointer b) { const GdkRegionBox *ba = a, *bb = b; - if(static_dy_hack > 0 - && ba->y1 < bb->y1) + if (static_dy_hack > 0 && ba->y1 < bb->y1) return 1; - if(static_dy_hack < 0 - && ba->y1 > bb->y1) + if (static_dy_hack < 0 && ba->y1 > bb->y1) return 1; - if(static_dx_hack > 0 - && ba->x1 < bb->x1) + if (static_dx_hack > 0 && ba->x1 < bb->x1) return 1; - if(static_dx_hack < 0 - && ba->x1 > bb->x1) + if (static_dx_hack < 0 && ba->x1 > bb->x1) return 1; return -1; @@ -794,7 +789,7 @@ gdk_fb_window_move_resize (GdkWindow *window, gint height, gboolean send_expose_events) { - GdkWindowPrivate *private; + GdkWindowObject *private; gint dx, dy, dw, dh; g_return_if_fail (window != NULL); @@ -805,94 +800,94 @@ gdk_fb_window_move_resize (GdkWindow *window, if (height < 1) height = 1; - private = (GdkWindowPrivate*) window; + private = (GdkWindowObject*) window; if (!private->destroyed) { GdkRegion *old_region = NULL; - if(private->input_only) + if (private->input_only) send_expose_events = FALSE; - if(private->mapped && send_expose_events) - old_region = gdk_fb_clip_region(GDK_DRAWABLE_IMPL(window), NULL, TRUE, FALSE); + if (private->mapped && send_expose_events) + old_region = gdk_fb_clip_region (GDK_DRAWABLE_IMPL(window), NULL, TRUE, FALSE); dx = x - private->x; dy = y - private->y; - dw = width - GDK_DRAWABLE_IMPL_FBDATA(private)->width; - dh = height - GDK_DRAWABLE_IMPL_FBDATA(private)->height; + dw = width - GDK_DRAWABLE_IMPL_FBDATA (private)->width; + dh = height - GDK_DRAWABLE_IMPL_FBDATA (private)->height; private->x = x; private->y = y; - GDK_DRAWABLE_IMPL_FBDATA(private)->width = width; - GDK_DRAWABLE_IMPL_FBDATA(private)->height = height; + GDK_DRAWABLE_IMPL_FBDATA (private)->width = width; + GDK_DRAWABLE_IMPL_FBDATA (private)->height = height; - if(private->mapped) + if (private->mapped) { - recompute_drawable((GdkDrawable *)window); + recompute_drawable ((GdkDrawable *)window); - if(send_expose_events) + if (send_expose_events) { GdkRegion *new_region, *region; int i; gboolean handle_cursor = FALSE; GList *rects, *ltmp, *next; - new_region = gdk_fb_clip_region(GDK_DRAWABLE_IMPL(window), NULL, TRUE, FALSE); + new_region = gdk_fb_clip_region (GDK_DRAWABLE_IMPL (window), NULL, TRUE, FALSE); - region = gdk_region_copy(old_region); - gdk_region_offset(region, dx, dy); - gdk_region_intersect(region, new_region); + region = gdk_region_copy (old_region); + gdk_region_offset (region, dx, dy); + gdk_region_intersect (region, new_region); - if(region->numRects) + if (region->numRects) { GdkFBDrawingContext fbdc; - if(gdk_fb_cursor_region_need_hide(region)) + if (gdk_fb_cursor_region_need_hide (region)) { - gdk_fb_cursor_hide(); + gdk_fb_cursor_hide (); handle_cursor = TRUE; } - gdk_fb_drawing_context_init(&fbdc, GDK_DRAWABLE_IMPL(gdk_parent_root), NULL, FALSE, FALSE); - g_print("[%p] %ld rect +[%d, %d] move [%d, %d] from [%d, %d] to [%d, %d]\n", - window, - region->numRects, - region->rects[0].x2 - region->rects[0].x1, - region->rects[0].y2 - region->rects[0].y1, - dx, dy, - region->rects[0].x1 - dx, - region->rects[0].y1 - dy, - region->rects[0].x1, - region->rects[0].y1); - + gdk_fb_drawing_context_init (&fbdc, GDK_DRAWABLE_IMPL (gdk_parent_root), NULL, FALSE, FALSE); + g_print ("[%p] %ld rect +[%d, %d] move [%d, %d] from [%d, %d] to [%d, %d]\n", + window, + region->numRects, + region->rects[0].x2 - region->rects[0].x1, + region->rects[0].y2 - region->rects[0].y1, + dx, dy, + region->rects[0].x1 - dx, + region->rects[0].y1 - dy, + region->rects[0].x1, + region->rects[0].y1); + static_dx_hack = dx; static_dy_hack = dy; - for(rects = NULL, i = 0; i < region->numRects; i++) - rects = g_list_insert_sorted(rects, ®ion->rects[i], compare_draw_rects); + for (rects = NULL, i = 0; i < region->numRects; i++) + rects = g_list_insert_sorted (rects, ®ion->rects[i], compare_draw_rects); - for(ltmp = rects; ltmp; ltmp = next) + for (ltmp = rects; ltmp; ltmp = next) { GdkRegionBox *reg = ltmp->data; - gdk_fb_draw_drawable_3(GDK_DRAWABLE_IMPL(gdk_parent_root), NULL, GDK_DRAWABLE_IMPL(gdk_parent_root), - &fbdc, - (reg->x1 - dx), - (reg->y1 - dy), - (reg->x1), - (reg->y1), - (reg->x2 - reg->x1), - (reg->y2 - reg->y1)); + gdk_fb_draw_drawable_3 (GDK_DRAWABLE_IMPL(gdk_parent_root), NULL, GDK_DRAWABLE_IMPL(gdk_parent_root), + &fbdc, + (reg->x1 - dx), + (reg->y1 - dy), + (reg->x1), + (reg->y1), + (reg->x2 - reg->x1), + (reg->y2 - reg->y1)); next = ltmp->next; - g_list_free_1(ltmp); + g_list_free_1 (ltmp); } - gdk_fb_drawing_context_finalize(&fbdc); + gdk_fb_drawing_context_finalize (&fbdc); } - gdk_region_union(new_region, old_region); - gdk_region_subtract(new_region, region); - gdk_region_destroy(region); + gdk_region_union (new_region, old_region); + gdk_region_subtract (new_region, region); + gdk_region_destroy (region); #if 0 g_print("Redraw region enclosed by [%d, %d] +[%d, %d]\n", @@ -900,12 +895,13 @@ gdk_fb_window_move_resize (GdkWindow *window, new_region->extents.x2 - new_region->extents.x1, new_region->extents.y2 - new_region->extents.y1); #endif - gdk_window_invalidate_region_clear(gdk_parent_root, new_region); - if(handle_cursor) - gdk_fb_cursor_unhide(); + + gdk_window_invalidate_region_clear (gdk_parent_root, new_region); + if (handle_cursor) + gdk_fb_cursor_unhide (); - gdk_region_destroy(old_region); - gdk_region_destroy(new_region); + gdk_region_destroy (old_region); + gdk_region_destroy (new_region); } } } @@ -918,7 +914,7 @@ gdk_window_move_resize (GdkWindow *window, gint width, gint height) { - gdk_fb_window_move_resize(window, x, y, width, height, TRUE); + gdk_fb_window_move_resize (window, x, y, width, height, TRUE); } void @@ -927,9 +923,9 @@ gdk_window_reparent (GdkWindow *window, gint x, gint y) { - GdkWindowPrivate *window_private; - GdkWindowPrivate *parent_private; - GdkWindowPrivate *old_parent_private; + GdkWindowObject *window_private; + GdkWindowObject *parent_private; + GdkWindowObject *old_parent_private; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -939,39 +935,39 @@ gdk_window_reparent (GdkWindow *window, if (!new_parent) new_parent = gdk_parent_root; - window_private = (GdkWindowPrivate*) window; - old_parent_private = (GdkWindowPrivate*)window_private->parent; - parent_private = (GdkWindowPrivate*) new_parent; + window_private = (GdkWindowObject*) window; + old_parent_private = (GdkWindowObject*)window_private->parent; + parent_private = (GdkWindowObject*) new_parent; - g_assert(GDK_DRAWABLE_IMPL_FBDATA(window_private)->colormap); + g_assert(GDK_DRAWABLE_IMPL_FBDATA (window_private)->colormap); - window_private->parent = (GdkWindowPrivate *)new_parent; + window_private->parent = (GdkWindowObject *)new_parent; if (old_parent_private) old_parent_private->children = g_list_remove (old_parent_private->children, window); parent_private->children = g_list_prepend (parent_private->children, window); - if(window_private->mapped) + if (window_private->mapped) { GdkRectangle r; GdkRegion *region; - r.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - r.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - r.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - r.x; - r.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - r.y; - region = gdk_region_rectangle(&r); + r.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + r.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + r.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - r.x; + r.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - r.y; + region = gdk_region_rectangle (&r); - recompute_drawable((GdkDrawable *)window); - r.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - r.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - r.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - r.x; - r.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - r.y; - gdk_region_union_with_rect(region, &r); + recompute_drawable ((GdkDrawable *)window); + r.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + r.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + r.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - r.x; + r.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - r.y; + gdk_region_union_with_rect (region, &r); - gdk_window_invalidate_region_clear(gdk_parent_root, region); - gdk_region_destroy(region); + gdk_window_invalidate_region_clear (gdk_parent_root, region); + gdk_region_destroy (region); } } @@ -986,17 +982,17 @@ _gdk_windowing_window_clear_area (GdkWindow *window, GdkPixmap *bgpm; GdkWindow *relto; - if(GDK_WINDOW_P(window)->input_only) + if (GDK_WINDOW_P (window)->input_only) return; - bgpm = GDK_WINDOW_P(window)->bg_pixmap; + bgpm = GDK_WINDOW_P (window)->bg_pixmap; #if 0 - for(relto = window; bgpm == GDK_PARENT_RELATIVE_BG && relto; relto = (GdkWindow *)GDK_WINDOW_P(relto)->parent) - bgpm = GDK_WINDOW_P(relto)->bg_pixmap; + for (relto = window; bgpm == GDK_PARENT_RELATIVE_BG && relto; relto = (GdkWindow *)GDK_WINDOW_P(relto)->parent) + bgpm = GDK_WINDOW_P (relto)->bg_pixmap; #endif - if(bgpm && bgpm != GDK_NO_BG) + if (bgpm && bgpm != GDK_NO_BG) { int curx, cury; int xtrans, ytrans; @@ -1006,32 +1002,35 @@ _gdk_windowing_window_clear_area (GdkWindow *window, return; /* Don't bother doing this - gtk+ will do it itself using GC tiles. If removing this line, then also remove the #if 0 stuff */ - gdk_fb_drawing_context_init(&fbdc, window, NULL, FALSE, TRUE); + gdk_fb_drawing_context_init (&fbdc, window, NULL, FALSE, TRUE); - xtrans = GDK_DRAWABLE_IMPL_FBDATA(relto)->abs_x - GDK_DRAWABLE_IMPL_FBDATA(window)->abs_x; - ytrans = GDK_DRAWABLE_IMPL_FBDATA(relto)->abs_y - GDK_DRAWABLE_IMPL_FBDATA(window)->abs_y; + xtrans = GDK_DRAWABLE_IMPL_FBDATA (relto)->abs_x - GDK_DRAWABLE_IMPL_FBDATA (window)->abs_x; + ytrans = GDK_DRAWABLE_IMPL_FBDATA (relto)->abs_y - GDK_DRAWABLE_IMPL_FBDATA (window)->abs_y; - for(cury = y - ytrans; cury < (y - ytrans + height); cury += ystep) + for (cury = y - ytrans; cury < (y - ytrans + height); cury += ystep) { - int drawh = cury % GDK_DRAWABLE_P(bgpm)->height; - ystep = GDK_DRAWABLE_P(bgpm)->height - drawh; + int drawh = cury % GDK_DRAWABLE_FBDATA (bgpm)->height; + ystep = GDK_DRAWABLE_FBDATA (bgpm)->height - drawh; for(curx = x - xtrans; curx < (x - xtrans + width); curx += xstep) { - int draww = curx % GDK_DRAWABLE_IMPL_FBDATA(bgpm)->width; - xstep = GDK_DRAWABLE_IMPL_FBDATA(bgpm)->width - draww; + int draww = curx % GDK_DRAWABLE_IMPL_FBDATA (bgpm)->width; + xstep = GDK_DRAWABLE_IMPL_FBDATA (bgpm)->width - draww; - gdk_fb_draw_drawable_3(GDK_DRAWABLE_IMPL(window), NULL, GDK_DRAWABLE_IMPL(bgpm), - &fbdc, - draww, drawh, curx + xtrans, cury + ytrans, - xstep, ystep); + gdk_fb_draw_drawable_3 (GDK_DRAWABLE_IMPL (window), + NULL, + GDK_DRAWABLE_IMPL (bgpm), + &fbdc, + draww, drawh, + curx + xtrans, cury + ytrans, + xstep, ystep); } } - gdk_fb_drawing_context_finalize(&fbdc); + gdk_fb_drawing_context_finalize (&fbdc); } - else if(!bgpm) - gdk_fb_draw_rectangle(GDK_DRAWABLE_IMPL(window), NULL, TRUE, x, y, width, height); + else if (!bgpm) + gdk_fb_draw_rectangle (GDK_DRAWABLE_IMPL (window), NULL, TRUE, x, y, width, height); } /* What's the diff? */ @@ -1042,27 +1041,27 @@ _gdk_windowing_window_clear_area_e (GdkWindow *window, gint width, gint height) { - _gdk_windowing_window_clear_area(window, x, y, width, height); + _gdk_windowing_window_clear_area (window, x, y, width, height); } static gint -compare_window_levels(gconstpointer a, gconstpointer b) +compare_window_levels (gconstpointer a, gconstpointer b) { - return (GDK_WINDOW_IMPL_FBDATA(b)->level - GDK_WINDOW_IMPL_FBDATA(a)->level); + return (GDK_WINDOW_IMPL_FBDATA (b)->level - GDK_WINDOW_IMPL_FBDATA (a)->level); } /* Child list is sorted bottom-to-top */ static void -gdk_window_resort_children(GdkWindow *win) +gdk_window_resort_children (GdkWindow *win) { - GdkWindowPrivate *private = GDK_WINDOW_P(win); + GdkWindowObject *private = GDK_WINDOW_P(win); - private->children = g_list_sort(private->children, compare_window_levels); + private->children = g_list_sort (private->children, compare_window_levels); /* Now the fun part - redraw */ - if(GDK_WINDOW_P(win)->parent) + if (GDK_WINDOW_P (win)->parent) { - gdk_window_invalidate_rect(win, NULL, TRUE); + gdk_window_invalidate_rect (win, NULL, TRUE); } } @@ -1072,10 +1071,10 @@ gdk_window_raise (GdkWindow *window) g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - GDK_WINDOW_IMPL_FBDATA(window)->level++; + GDK_WINDOW_IMPL_FBDATA (window)->level++; - if(GDK_WINDOW_P(window)->parent) - gdk_window_resort_children((GdkWindow *)GDK_WINDOW_P(window)->parent); + if (GDK_WINDOW_P (window)->parent) + gdk_window_resort_children ((GdkWindow *)GDK_WINDOW_P (window)->parent); } void @@ -1084,10 +1083,10 @@ gdk_window_lower (GdkWindow *window) g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); - GDK_WINDOW_IMPL_FBDATA(window)->level--; + GDK_WINDOW_IMPL_FBDATA (window)->level--; - if(GDK_WINDOW_P(window)->parent) - gdk_window_resort_children((GdkWindow *)GDK_WINDOW_P(window)->parent); + if (GDK_WINDOW_P(window)->parent) + gdk_window_resort_children ((GdkWindow *)GDK_WINDOW_P (window)->parent); } void @@ -1125,14 +1124,14 @@ void gdk_window_set_transient_for (GdkWindow *window, GdkWindow *parent) { - GDK_WINDOW_IMPL_FBDATA(window)->level = GDK_WINDOW_IMPL_FBDATA(parent)->level + 1; + GDK_WINDOW_IMPL_FBDATA (window)->level = GDK_WINDOW_IMPL_FBDATA (parent)->level + 1; } void gdk_window_set_background (GdkWindow *window, GdkColor *color) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1153,7 +1152,7 @@ gdk_window_set_back_pixmap (GdkWindow *window, GdkPixmap *pixmap, gboolean parent_relative) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; GdkPixmap *old_pixmap; g_return_if_fail (window != NULL); @@ -1192,19 +1191,17 @@ gdk_window_set_cursor (GdkWindow *window, GdkCursor *old_cursor = GDK_WINDOW_IMPL_FBDATA(window)->cursor; GdkRectangle window_reg; - GDK_WINDOW_IMPL_FBDATA(window)->cursor = cursor?gdk_cursor_ref(cursor):NULL; + GDK_WINDOW_IMPL_FBDATA (window)->cursor = cursor ? gdk_cursor_ref (cursor) : NULL; - if(old_cursor) - gdk_cursor_unref(old_cursor); + if (old_cursor) + gdk_cursor_unref (old_cursor); - window_reg.x = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_x; - window_reg.y = GDK_DRAWABLE_IMPL_FBDATA(window)->llim_y; - window_reg.width = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_x - window_reg.x; - window_reg.height = GDK_DRAWABLE_IMPL_FBDATA(window)->lim_y - window_reg.y; - if(gdk_fb_cursor_need_hide(&window_reg)) - { - gdk_fb_cursor_reset(); - } + window_reg.x = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_x; + window_reg.y = GDK_DRAWABLE_IMPL_FBDATA (window)->llim_y; + window_reg.width = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_x - window_reg.x; + window_reg.height = GDK_DRAWABLE_IMPL_FBDATA (window)->lim_y - window_reg.y; + if (gdk_fb_cursor_need_hide (&window_reg)) + gdk_fb_cursor_reset (); } void @@ -1215,7 +1212,7 @@ gdk_window_get_geometry (GdkWindow *window, gint *height, gint *depth) { - GdkWindowPrivate *private = (GdkWindowPrivate *)window; + GdkWindowObject *private = (GdkWindowObject *)window; g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); @@ -1230,9 +1227,9 @@ gdk_window_get_geometry (GdkWindow *window, if (y) *y = private->y; if (width) - *width = GDK_DRAWABLE_IMPL_FBDATA(window)->width; + *width = GDK_DRAWABLE_IMPL_FBDATA (window)->width; if (height) - *height = GDK_DRAWABLE_IMPL_FBDATA(window)->height; + *height = GDK_DRAWABLE_IMPL_FBDATA (window)->height; if (depth) *depth = gdk_display->modeinfo.bits_per_pixel; } @@ -1246,9 +1243,9 @@ gdk_window_get_origin (GdkWindow *window, g_return_val_if_fail (window != NULL, 0); if (x) - *x = GDK_DRAWABLE_IMPL_FBDATA(window)->abs_x; + *x = GDK_DRAWABLE_IMPL_FBDATA (window)->abs_x; if (y) - *y = GDK_DRAWABLE_IMPL_FBDATA(window)->abs_y; + *y = GDK_DRAWABLE_IMPL_FBDATA (window)->abs_y; return TRUE; } @@ -1266,8 +1263,8 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, if (!GDK_WINDOW_DESTROYED (window)) { - tx = GDK_DRAWABLE_IMPL_FBDATA(window)->abs_x; - ty = GDK_DRAWABLE_IMPL_FBDATA(window)->abs_y; + tx = GDK_DRAWABLE_IMPL_FBDATA (window)->abs_x; + ty = GDK_DRAWABLE_IMPL_FBDATA (window)->abs_y; return_val = TRUE; } @@ -1287,7 +1284,7 @@ gdk_window_get_root_origin (GdkWindow *window, gint *x, gint *y) { - gdk_window_get_deskrelative_origin(window, x, y); + gdk_window_get_deskrelative_origin (window, x, y); } GdkWindow* @@ -1307,8 +1304,8 @@ gdk_window_get_pointer (GdkWindow *window, if (!window) window = gdk_parent_root; - gdk_window_get_root_origin(window, &x_int, &y_int); - gdk_input_get_mouseinfo(&winx, &winy, &my_mask); + gdk_window_get_root_origin (window, &x_int, &y_int); + gdk_input_get_mouseinfo (&winx, &winy, &my_mask); winx -= x_int; winy -= y_int; @@ -1322,28 +1319,28 @@ gdk_window_get_pointer (GdkWindow *window, return_val = NULL; - if((winx >= 0) && (winx < GDK_DRAWABLE_IMPL_FBDATA(window)->width) - && (winy >= 0) && (winy < GDK_DRAWABLE_IMPL_FBDATA(window)->height)) + if ((winx >= 0) && (winx < GDK_DRAWABLE_IMPL_FBDATA (window)->width) && + (winy >= 0) && (winy < GDK_DRAWABLE_IMPL_FBDATA (window)->height)) { - GdkWindowPrivate *private; - GdkWindowPrivate *sub; + GdkWindowObject *private; + GdkWindowObject *sub; int subx = winx, suby = winy; - for(private = sub = (GdkWindowPrivate *)window; sub; private = sub) + for (private = sub = (GdkWindowObject *)window; sub; private = sub) { GList *ltmp; - for(ltmp = private->children; ltmp; ltmp = ltmp->next) + for (ltmp = private->children; ltmp; ltmp = ltmp->next) { sub = ltmp->data; - if(!sub->mapped) + if (!sub->mapped) continue; - if(subx >= sub->x - && (subx < (GDK_DRAWABLE_IMPL_FBDATA(sub)->width + sub->x)) - && (suby >= sub->y) - && (suby < (GDK_DRAWABLE_IMPL_FBDATA(sub)->height + sub->y))) + if (subx >= sub->x && + (subx < (GDK_DRAWABLE_IMPL_FBDATA (sub)->width + sub->x)) && + (suby >= sub->y) && + (suby < (GDK_DRAWABLE_IMPL_FBDATA (sub)->height + sub->y))) { subx -= sub->x; suby -= sub->y; @@ -1351,7 +1348,7 @@ gdk_window_get_pointer (GdkWindow *window, } } - if(!ltmp) + if (!ltmp) { sub = NULL; break; @@ -1361,7 +1358,7 @@ gdk_window_get_pointer (GdkWindow *window, return_val = (GdkWindow *)private; } - if(!return_val) + if (!return_val) return_val = gdk_parent_root; return return_val; @@ -1372,14 +1369,14 @@ gdk_window_at_pointer (gint *win_x, gint *win_y) { gint rx, ry; - GdkWindow *retval = gdk_window_get_pointer(NULL, win_x, win_y, NULL); + GdkWindow *retval = gdk_window_get_pointer (NULL, win_x, win_y, NULL); - if(retval) + if (retval) { - gdk_window_get_origin(retval, &ry, &rx); - if(win_x) + gdk_window_get_origin (retval, &ry, &rx); + if (win_x) (*win_x) -= rx; - if(win_y) + if (win_y) (*win_y) -= ry; } @@ -1395,7 +1392,7 @@ gdk_window_get_events (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return 0; else - return GDK_WINDOW_IMPL_FBDATA(window)->event_mask; + return GDK_WINDOW_IMPL_FBDATA (window)->event_mask; } void @@ -1407,7 +1404,7 @@ gdk_window_set_events (GdkWindow *window, g_return_if_fail (GDK_IS_WINDOW (window)); if (!GDK_WINDOW_DESTROYED (window)) - GDK_WINDOW_IMPL_FBDATA(window)->event_mask = event_mask; + GDK_WINDOW_IMPL_FBDATA (window)->event_mask = event_mask; } void diff --git a/gdk/linux-fb/mitypes.h b/gdk/linux-fb/mitypes.h index 997ec8aa07..e975d364e4 100644 --- a/gdk/linux-fb/mitypes.h +++ b/gdk/linux-fb/mitypes.h @@ -23,45 +23,6 @@ typedef struct _miDash *miDashPtr; #define CT_YXSORTED 14 #define CT_YXBANDED 18 -struct _GdkGCFuncs { - void (* ValidateGC)( - GdkGC* /*pGC*/, - unsigned long /*stateChanges*/, - GdkDrawable* /*pDrawable*/ - ); - - void (* ChangeGC)( - GdkGC* /*pGC*/, - unsigned long /*mask*/ - ); - - void (* CopyGC)( - GdkGC* /*pGCSrc*/, - unsigned long /*mask*/, - GdkGC* /*pGCDst*/ - ); - - void (* DestroyGC)( - GdkGC* /*pGC*/ - ); - - void (* ChangeClip)( - GdkGC* /*pGC*/, - int /*type*/, - gpointer /*pvalue*/, - int /*nrects*/ - ); - void (* DestroyClip)( - GdkGC* /*pGC*/ - ); - - void (* CopyClip)( - GdkGC* /*pgcDst*/, - GdkGC* /*pgcSrc*/ - ); - -}; - typedef union { guint32 val; gpointer ptr; @@ -70,223 +31,6 @@ typedef union { #define PixmapBytePad(w, d) (w) #define BitmapBytePad(w) (w) -#if 0 -typedef struct _PaddingInfo { - int padRoundUp; /* pixels per pad unit - 1 */ - int padPixelsLog2; /* log 2 (pixels per pad unit) */ - int padBytesLog2; /* log 2 (bytes per pad unit) */ - int notPower2; /* bitsPerPixel not a power of 2 */ - int bytesPerPixel; /* only set when notPower2 is TRUE */ -} PaddingInfo; -extern PaddingInfo PixmapWidthPaddingInfo[]; - -#define PixmapWidthInPadUnits(w, d) \ - (PixmapWidthPaddingInfo[d].notPower2 ? \ - (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \ - PixmapWidthPaddingInfo[d].bytesPerPixel) >> \ - PixmapWidthPaddingInfo[d].padBytesLog2) : \ - ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \ - PixmapWidthPaddingInfo[d].padPixelsLog2)) - -#define PixmapBytePad(w, d) \ - (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) - -#define BitmapBytePad(w) \ - (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) - -typedef struct _GdkDrawable GdkPixmap, *GdkPixmap*; -typedef struct _GdkDrawable GdkDrawable, *GdkDrawable*; -typedef struct _GdkGCOps GdkGCOps; -typedef struct _Region Region, *GdkRegion*; - -#define EVEN_DASH 0 -#define ODD_DASH ~0 - -typedef struct _GdkPoint { - gint16 x, y; -} GdkPoint, *GdkPoint*; - -typedef struct _GdkGC { - unsigned char depth; - unsigned char alu; - unsigned short line_width; - unsigned short dashOffset; - unsigned short numInDashList; - unsigned char *dash; - unsigned int lineStyle : 2; - unsigned int capStyle : 2; - unsigned int joinStyle : 2; - unsigned int fillStyle : 2; - unsigned int fillRule : 1; - unsigned int arcMode : 1; - unsigned int subWindowMode : 1; - unsigned int graphicsExposures : 1; - unsigned int clientClipType : 2; /* CT_ */ - unsigned int miTranslate:1; /* should mi things translate? */ - unsigned int tileIsPixel:1; /* tile is solid pixel */ - unsigned int fExpose:1; /* Call exposure handling */ - unsigned int freeCompClip:1; /* Free composite clip */ - unsigned int unused:14; /* see comment above */ - unsigned long planemask; - unsigned long fgPixel; - unsigned long bgPixel; - /* - * alas -- both tile and stipple must be here as they - * are independently specifiable - */ - /* PixUnion tile; - GdkPixmap* stipple;*/ - GdkPoint patOrg; /* origin for (tile, stipple) */ - struct _Font *font; - GdkPoint clipOrg; - GdkPoint lastWinOrg; /* position of window last validated */ - gpointer clientClip; - unsigned long stateChanges; /* masked with GC_ */ - unsigned long serialNumber; - /* GCFuncs *funcs; */ - GdkGCOps *ops; -} GdkGC, *GdkGC*; - -struct _GdkDrawable { - unsigned char type; /* DRAWABLE_ */ - unsigned char depth; - unsigned char bitsPerPixel; - short x; /* window: screen absolute, pixmap: 0 */ - short y; /* window: screen absolute, pixmap: 0 */ - unsigned short width; - unsigned short height; - unsigned long serialNumber; - - guchar *buffer; - int rowStride; -}; - -typedef struct _GdkSegment { - gint16 x1, y1, x2, y2; -} GdkSegment; - -typedef struct _GdkRectangle { - gint16 x, y; - guint16 width, height; -} GdkRectangle, *GdkRectangle*; - -typedef struct _Box { - short x1, y1, x2, y2; -} BoxRec, *BoxPtr; - -/* - * graphics operations invoked through a GC - */ - -/* graphics functions, as in GC.alu */ - -#define GDK_CLEAR 0x0 /* 0 */ -#define GDK_AND 0x1 /* src AND dst */ -#define GDK_AND_REVERSE 0x2 /* src AND NOT dst */ -#define GDK_COPY 0x3 /* src */ -#define GDK_AND_INVERT 0x4 /* NOT src AND dst */ -#define GDK_NOOP 0x5 /* dst */ -#define GDK_XOR 0x6 /* src XOR dst */ -#define GDK_OR 0x7 /* src OR dst */ -#define GDK_NOR 0x8 /* NOT src AND NOT dst */ -#define GDK_EQUIV 0x9 /* NOT src XOR dst */ -#define GDK_INVERT 0xa /* NOT dst */ -#define GDK_OR_REVERSE 0xb /* src OR NOT dst */ -#define GDK_COPY_INVERT 0xc /* NOT src */ -#define GDK_OR_INVERT 0xd /* NOT src OR dst */ -#define GDK_NAND 0xe /* NOT src OR NOT dst */ -#define GDK_SET 0xf /* 1 */ - -/* CoordinateMode for drawing routines */ - -#define CoordModeOrigin 0 /* relative to the origin */ -#define CoordModePrevious 1 /* relative to previous point */ - -/* Polygon shapes */ - -#define Complex 0 /* paths may intersect */ -#define Nonconvex 1 /* no paths intersect, but not convex */ -#define Convex 2 /* wholly convex */ - -/* LineStyle */ - -#define GDK_LINE_SOLID 0 -#define GDK_LINE_ON_OFF_DASH 1 -#define GDK_LINE_DOUBLE_DASH 2 - -/* capStyle */ - -#define GDK_CAP_NOT_LAST 0 -#define GDK_CAP_BUTT 1 -#define GDK_CAP_ROUND 2 -#define GDK_CAP_PROJECTING 3 - -/* joinStyle */ - -#define GDK_JOIN_MITER 0 -#define GDK_JOIN_ROUND 1 -#define GDK_JOIN_BEVEL 2 - -/* Arc modes for PolyFillArc */ - -#define ArcChord 0 /* join endpoints of arc */ -#define ArcPieSlice 1 /* join endpoints to center of arc */ - -/* fillRule */ - -#define EvenOddRule 0 -#define WindingRule 1 - -/* fillStyle */ - -#define GDK_SOLID 0 -#define GDK_TILED 1 -#define GDK_STIPPLED 2 -#define GDK_OPAQUE_STIPPLED 3 - -typedef enum { Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit } FontEncoding; - -#define MININT G_MININT -#define MAXINT G_MAXINT -#define MINSHORT G_MINSHORT -#define MAXSHORT G_MAXSHORT - -/* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into - GC.stateChanges */ - -#define GDK_GC_FUNCTION (1L<<0) -#define GCPlaneMask (1L<<1) -#define GDK_GC_FOREGROUND (1L<<2) -#define GDK_GC_BACKGROUND (1L<<3) -#define GDK_GC_LINE_WIDTH (1L<<4) -#define GCLineStyle (1L<<5) -#define GDK_GC_CAP_STYLE (1L<<6) -#define GDK_GC_JOIN_STYLE (1L<<7) -#define GDK_GC_FILL_STYLE (1L<<8) -#define GCFillRule (1L<<9) -#define GCTile (1L<<10) -#define GDK_GC_STIPPLE (1L<<11) -#define GDK_GC_TS_X_ORIGIN (1L<<12) -#define GDK_GC_TS_Y_ORIGIN (1L<<13) -#define GCFont (1L<<14) -#define GCSubwindowMode (1L<<15) -#define GCGraphicsExposures (1L<<16) -#define GCClipXOrigin (1L<<17) -#define GCClipYOrigin (1L<<18) -#define GCClipMask (1L<<19) -#define GCDashOffset (1L<<20) -#define GCDashList (1L<<21) -#define GCArcMode (1L<<22) - -/* types for Drawable */ - -#define GDK_WINDOW_CHILD 0 -#define GDK_DRAWABLE_PIXMAP 1 -#define GDK_WINDOW_FOREIGN 2 -#define GDK_WINDOW_TEMP 3 - -#endif - typedef GdkSegment BoxRec, *BoxPtr; typedef struct _miArc { @@ -295,192 +39,6 @@ typedef struct _miArc { gint16 angle1, angle2; } miArc; -struct _GdkGCOps { - void (* FillSpans)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*nInit*/, - GdkPoint* /*pptInit*/, - int * /*pwidthInit*/, - int /*fSorted*/ -); - - void (* SetSpans)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - char * /*psrc*/, - GdkPoint* /*ppt*/, - int * /*pwidth*/, - int /*nspans*/, - int /*fSorted*/ -); - - void (* PutImage)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*depth*/, - int /*x*/, - int /*y*/, - int /*w*/, - int /*h*/, - int /*leftPad*/, - int /*format*/, - char * /*pBits*/ -); - - GdkRegion* (* CopyArea)( - GdkDrawable* /*pSrc*/, - GdkDrawable* /*pDst*/, - GdkGC* /*pGC*/, - int /*srcx*/, - int /*srcy*/, - int /*w*/, - int /*h*/, - int /*dstx*/, - int /*dsty*/ -); - - GdkRegion* (* CopyPlane)( - GdkDrawable* /*pSrcDrawable*/, - GdkDrawable* /*pDstDrawable*/, - GdkGC* /*pGC*/, - int /*srcx*/, - int /*srcy*/, - int /*width*/, - int /*height*/, - int /*dstx*/, - int /*dsty*/, - unsigned long /*bitPlane*/ -); - void (* PolyPoint)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*mode*/, - int /*npt*/, - GdkPoint* /*pptInit*/ -); - - void (* Polylines)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*mode*/, - int /*npt*/, - GdkPoint* /*pptInit*/ -); - - void (* PolySegment)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*nseg*/, - GdkSegment * /*pSegs*/ -); - - void (* PolyRectangle)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*nrects*/, - GdkRectangle * /*pRects*/ -); - - void (* PolyArc)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*narcs*/, - miArc * /*parcs*/ -); - - void (* FillPolygon)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*shape*/, - int /*mode*/, - int /*count*/, - GdkPoint* /*pPts*/ -); - - void (* PolyFillRect)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*nrectFill*/, - GdkRectangle * /*prectInit*/ -); - - void (* PolyFillArc)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*narcs*/, - miArc * /*parcs*/ -); - -#if 0 - int (* PolyText8)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/ -); - - int (* PolyText16)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - unsigned short * /*chars*/ -); - - void (* ImageText8)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - char * /*chars*/ -); - - void (* ImageText16)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - int /*count*/, - unsigned short * /*chars*/ -); - - void (* ImageGlyphBlt)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - unsigned int /*nglyph*/, - CharInfoPtr * /*ppci*/, - pointer /*pglyphBase*/ -); - - void (* PolyGlyphBlt)( - GdkDrawable* /*pDrawable*/, - GdkGC* /*pGC*/, - int /*x*/, - int /*y*/, - unsigned int /*nglyph*/, - CharInfoPtr * /*ppci*/, - pointer /*pglyphBase*/ -); -#endif - - void (* PushPixels)( - GdkGC* /*pGC*/, - GdkPixmap* /*pBitMap*/, - GdkDrawable* /*pDst*/, - int /*w*/, - int /*h*/, - int /*x*/, - int /*y*/ -); -}; - #define SCRRIGHT(x, n) ((x)>>(n)) #endif /* MITYPES_H */ diff --git a/modules/linux-fb/basic.c b/modules/linux-fb/basic.c index 6e03d3b570..38c6841dec 100644 --- a/modules/linux-fb/basic.c +++ b/modules/linux-fb/basic.c @@ -23,8 +23,8 @@ #include #include +#include #include "gdkprivate-fb.h" -#include PangoGlyph pango_fb_get_unknown_glyph(PangoFont *font) @@ -325,7 +325,7 @@ basic_engine_shape (PangoFont *font, for (i=0; i < n_chars; i++) { gunichar wc; - FriBidiChar mirrored_ch; + gunichar mirrored_ch; PangoGlyph index; char buf[6]; const char *input; @@ -334,7 +334,7 @@ basic_engine_shape (PangoFont *font, input = p; if (analysis->level % 2) - if (fribidi_get_mirror_char (wc, &mirrored_ch)) + if (pango_get_mirror_char (wc, &mirrored_ch)) { wc = mirrored_ch;