199 lines
5.9 KiB
Diff
199 lines
5.9 KiB
Diff
? gnome-session-speedup.patch
|
|
? stamp-h1
|
|
Index: gnome-session/logout.c
|
|
===================================================================
|
|
RCS file: /cvs/gnome/gnome-session/gnome-session/logout.c,v
|
|
retrieving revision 1.60
|
|
diff -u -p -r1.60 logout.c
|
|
--- gnome-session/logout.c 26 Apr 2005 10:56:50 -0000 1.60
|
|
+++ gnome-session/logout.c 17 Aug 2005 16:37:52 -0000
|
|
@@ -61,10 +61,12 @@ typedef struct {
|
|
int rowstride;
|
|
GdkWindow *root_window;
|
|
GdkWindow *draw_window;
|
|
- GdkPixbuf *start_pb, *end_pb, *frame;
|
|
- guchar *start_p, *end_p, *frame_p;
|
|
+ GdkPixmap *draw_pixmap;
|
|
+ GdkPixbuf *start_pb, *frame;
|
|
+ guchar *start_p, *frame_p;
|
|
GTimeVal start_time;
|
|
GdkGC *gc;
|
|
+ int callback_id;
|
|
} FadeoutData;
|
|
|
|
static GList *fadeout_windows = NULL;
|
|
@@ -76,8 +78,10 @@ static void
|
|
get_current_frame (FadeoutData *fadeout,
|
|
double sat)
|
|
{
|
|
- guchar *sp, *ep, *fp;
|
|
+ guchar *sp, *fp;
|
|
int i, j, width, offset;
|
|
+ const int FIXED = 8;
|
|
+ int fixed_mult = (0.5 + (sat / 2)) * (1 << 8);
|
|
|
|
width = fadeout->area.width * 3;
|
|
offset = 0;
|
|
@@ -85,44 +89,17 @@ get_current_frame (FadeoutData *fadeout,
|
|
for (i = 0; i < fadeout->area.height; i++)
|
|
{
|
|
sp = fadeout->start_p + offset;
|
|
- ep = fadeout->end_p + offset;
|
|
fp = fadeout->frame_p + offset;
|
|
|
|
- for (j = 0; j < width; j += 3)
|
|
+ for (j = 0; j < width; j ++)
|
|
{
|
|
- guchar r = abs (*(sp++) - ep[0]);
|
|
- guchar g = abs (*(sp++) - ep[1]);
|
|
- guchar b = abs (*(sp++) - ep[2]);
|
|
-
|
|
- *(fp++) = *(ep++) + r * sat;
|
|
- *(fp++) = *(ep++) + g * sat;
|
|
- *(fp++) = *(ep++) + b * sat;
|
|
+ *(fp++) = (*(sp++) * fixed_mult) >> FIXED;
|
|
}
|
|
|
|
offset += fadeout->rowstride;
|
|
}
|
|
}
|
|
|
|
-static void
|
|
-darken_pixbuf (GdkPixbuf *pb)
|
|
-{
|
|
- int width, height, rowstride;
|
|
- int i, j;
|
|
- guchar *p, *pixels;
|
|
-
|
|
- width = gdk_pixbuf_get_width (pb) * 3;
|
|
- height = gdk_pixbuf_get_height (pb);
|
|
- rowstride = gdk_pixbuf_get_rowstride (pb);
|
|
- pixels = gdk_pixbuf_get_pixels (pb);
|
|
-
|
|
- for (i = 0; i < height; i++)
|
|
- {
|
|
- p = pixels + (i * rowstride);
|
|
- for (j = 0; j < width; j++)
|
|
- p [j] >>= 1;
|
|
- }
|
|
-}
|
|
-
|
|
static gboolean
|
|
fadeout_callback (FadeoutData *fadeout)
|
|
{
|
|
@@ -141,30 +118,26 @@ fadeout_callback (FadeoutData *fadeout)
|
|
|
|
if (elapsed > FADE_DURATION)
|
|
{
|
|
- gdk_draw_pixbuf (fadeout->draw_window,
|
|
+ get_current_frame (fadeout, 0.0);
|
|
+ gdk_draw_pixbuf (fadeout->draw_pixmap,
|
|
fadeout->gc,
|
|
- fadeout->end_pb,
|
|
+ fadeout->frame,
|
|
0, 0,
|
|
0, 0,
|
|
fadeout->area.width,
|
|
fadeout->area.height,
|
|
GDK_RGB_DITHER_NONE,
|
|
0, 0);
|
|
+ gdk_window_clear (fadeout->draw_window);
|
|
|
|
- g_object_unref (fadeout->gc);
|
|
- g_object_unref (fadeout->start_pb);
|
|
- g_object_unref (fadeout->end_pb);
|
|
- g_object_unref (fadeout->frame);
|
|
-
|
|
- g_free (fadeout);
|
|
-
|
|
+ fadeout->callback_id = 0;
|
|
return FALSE;
|
|
}
|
|
|
|
percent = elapsed / FADE_DURATION;
|
|
|
|
get_current_frame (fadeout, 1.0 - percent);
|
|
- gdk_draw_pixbuf (fadeout->draw_window,
|
|
+ gdk_draw_pixbuf (fadeout->draw_pixmap,
|
|
fadeout->gc,
|
|
fadeout->frame,
|
|
0, 0,
|
|
@@ -173,6 +146,7 @@ fadeout_callback (FadeoutData *fadeout)
|
|
fadeout->area.height,
|
|
GDK_RGB_DITHER_NONE,
|
|
0, 0);
|
|
+ gdk_window_clear (fadeout->draw_window);
|
|
|
|
gdk_flush ();
|
|
|
|
@@ -211,7 +185,8 @@ fadeout_screen (GdkScreen *screen,
|
|
attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR;
|
|
|
|
fadeout->draw_window = gdk_window_new (fadeout->root_window, &attr, attr_mask);
|
|
- fadeout_windows = g_list_prepend (fadeout_windows, fadeout->draw_window);
|
|
+ fadeout->draw_pixmap = gdk_pixmap_new (fadeout->draw_window, fadeout->area.width, fadeout->area.height, gdk_drawable_get_depth (fadeout->draw_window));
|
|
+ fadeout_windows = g_list_prepend (fadeout_windows, fadeout);
|
|
|
|
fadeout->start_pb = gdk_pixbuf_get_from_drawable (NULL,
|
|
fadeout->root_window,
|
|
@@ -222,14 +197,10 @@ fadeout_screen (GdkScreen *screen,
|
|
fadeout->area.width,
|
|
fadeout->area.height);
|
|
|
|
- fadeout->end_pb = gdk_pixbuf_copy (fadeout->start_pb);
|
|
- darken_pixbuf (fadeout->end_pb);
|
|
-
|
|
fadeout->frame = gdk_pixbuf_copy (fadeout->start_pb);
|
|
fadeout->rowstride = gdk_pixbuf_get_rowstride (fadeout->start_pb);
|
|
|
|
fadeout->start_p = gdk_pixbuf_get_pixels (fadeout->start_pb);
|
|
- fadeout->end_p = gdk_pixbuf_get_pixels (fadeout->end_pb);
|
|
fadeout->frame_p = gdk_pixbuf_get_pixels (fadeout->frame);
|
|
|
|
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
|
|
@@ -238,7 +209,7 @@ fadeout_screen (GdkScreen *screen,
|
|
|
|
gdk_window_set_back_pixmap (fadeout->draw_window, NULL, FALSE);
|
|
gdk_window_show (fadeout->draw_window);
|
|
- gdk_draw_pixbuf (fadeout->draw_window,
|
|
+ gdk_draw_pixbuf (fadeout->draw_pixmap,
|
|
fadeout->gc,
|
|
fadeout->frame,
|
|
0, 0,
|
|
@@ -247,9 +218,11 @@ fadeout_screen (GdkScreen *screen,
|
|
fadeout->area.height,
|
|
GDK_RGB_DITHER_NONE,
|
|
0, 0);
|
|
+ gdk_window_set_back_pixmap (fadeout->draw_window, fadeout->draw_pixmap, FALSE);
|
|
+ gdk_window_clear (fadeout->draw_window);
|
|
|
|
g_get_current_time (&fadeout->start_time);
|
|
- g_idle_add ((GSourceFunc) fadeout_callback, fadeout);
|
|
+ fadeout->callback_id = g_idle_add ((GSourceFunc) fadeout_callback, fadeout);
|
|
}
|
|
|
|
static void
|
|
@@ -259,8 +232,20 @@ hide_fadeout_windows (void)
|
|
|
|
for (l = fadeout_windows; l; l = l->next)
|
|
{
|
|
- gdk_window_hide (GDK_WINDOW (l->data));
|
|
- g_object_unref (l->data);
|
|
+ FadeoutData *fadeout = l->data;
|
|
+ gdk_window_hide (fadeout->draw_window);
|
|
+
|
|
+ if (fadeout->callback_id)
|
|
+ g_source_remove (fadeout->callback_id);
|
|
+
|
|
+ g_object_unref (fadeout->gc);
|
|
+ g_object_unref (fadeout->start_pb);
|
|
+ g_object_unref (fadeout->frame);
|
|
+
|
|
+ g_object_unref (fadeout->draw_window);
|
|
+ g_object_unref (fadeout->draw_pixmap);
|
|
+
|
|
+ g_free (fadeout);
|
|
}
|
|
|
|
g_list_free (fadeout_windows);
|