rpms/eel2/devel eel2-2.10.0-desktop-memory-saver.patch, NONE, 1.1 eel2-2.10.0-user-desktop-file.patch, NONE, 1.1 eel2.spec, 1.22, 1.23
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Sun Apr 3 19:17:05 UTC 2005
Update of /cvs/dist/rpms/eel2/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv29812
Modified Files:
eel2.spec
Added Files:
eel2-2.10.0-desktop-memory-saver.patch
eel2-2.10.0-user-desktop-file.patch
Log Message:
* Sun Apr 3 2005 David Zeuthen <davidz at redhat.com> 2.10.0-2
- Include patches for desktop background memory saving (GNOME bug #169347)
- Patch for making sure user added desktop files dont conflict with global ones
eel2-2.10.0-desktop-memory-saver.patch:
eel-background.c | 348 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
eel-background.h | 6
2 files changed, 336 insertions(+), 18 deletions(-)
--- NEW FILE eel2-2.10.0-desktop-memory-saver.patch ---
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-background.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- eel/eel-background.c 2003/02/05 18:30:31 1.45
+++ eel/eel-background.c 2005/03/16 08:29:15 1.46
@@ -44,6 +44,12 @@
#include <math.h>
#include <stdio.h>
+/* To work with desktop background */
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <gdk/gdkx.h>
+
+
/* FIXME: This could really be eliminated now */
typedef struct {
/* 24-bit RGB buffer for rendering */
@@ -82,6 +88,11 @@
static void eel_background_draw_aa (EelBackground *background,
EelCanvasBuf *buffer);
+static gboolean eel_background_swap_timeout (gpointer data);
+static void eel_background_cancel_swap (EelBackground *background);
+static void eel_background_start_swap (EelBackground *background);
+static void eel_background_ensure_image_nonswapped (EelBackground *background);
+
EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT)
@@ -139,6 +150,15 @@
gboolean background_changes_with_size;
gboolean use_base;
+
+ /* Is this background attached to desktop window */
+ gboolean is_desktop;
+ /* Desktop background swap */
+ gulong swap_timeout;
+ /* Desktop screen size watcher */
+ gulong screen_size_handler;
+ /* Can we use common pixmap for root window and desktop window */
+ gboolean use_common_pixmap;
};
static void
@@ -231,6 +251,7 @@
g_object_unref (background->details->image);
background->details->image = NULL;
}
+ eel_background_cancel_swap (background);
}
static void
@@ -545,6 +566,55 @@
}
}
+static gboolean
+eel_background_swap_timeout (gpointer data)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (data);
+
+ eel_background_remove_current_image (background);
+ background->details->swap_timeout = 0;
+
+ return FALSE;
+}
+
+static void
+eel_background_cancel_swap (EelBackground *background)
+{
+ if (background->details->swap_timeout > 0) {
+ g_source_remove (background->details->swap_timeout);
+ background->details->swap_timeout = 0;
+ }
+}
+
+static void
+eel_background_start_swap (EelBackground *background)
+{
+ if (!background->details->is_desktop) {
+ return;
+ }
+ if (background->details->image_uri == NULL || background->details->image == NULL) {
+ return;
+ }
+ if (background->details->swap_timeout > 0) {
+ g_source_remove (background->details->swap_timeout);
+ }
+ background->details->swap_timeout = g_timeout_add (30000, eel_background_swap_timeout, background);
+}
+
+static void
+eel_background_ensure_image_nonswapped (EelBackground *background)
+{
+ if (!background->details->is_desktop) {
+ return;
+ }
+ if (background->details->image_uri != NULL && background->details->image == NULL) {
+ eel_background_start_loading_image (background, FALSE, FALSE);
+ }
+ eel_background_start_swap (background);
+}
+
static void
eel_background_ensure_image_scaled (EelBackground *background, int dest_width, int dest_height)
{
@@ -646,8 +716,20 @@
if (background->details->image == NULL) {
if (background->details->is_solid_color) {
- *changes_with_size = FALSE;
- return FALSE;
+ if (!background->details->is_desktop) {
+ *changes_with_size = FALSE;
+ return FALSE;
+ } else {
+ /* We should create small pixmap in this
+ * case too since most transparent programs
+ * like terminal or panel requires background
+ * pixmap and can't handle just color
+ */
+ *pixmap_width = 1;
+ *pixmap_height = 1;
+ *changes_with_size = FALSE;
+ return TRUE;
+ }
}
if (background->details->gradient_is_horizontal) {
*pixmap_width = entire_width;
@@ -709,6 +791,114 @@
background->details->background_entire_height = 0;
}
+/*
+ * Create a persistent pixmap. We create a separate display
+ * and set the closedown mode on it to RetainPermanent.
+ */
+static GdkPixmap *
+make_root_pixmap (GdkScreen *screen, gint width, gint height)
+{
+ Display *display;
+ const char *display_name;
+ Pixmap result;
+ GdkPixmap *gdk_pixmap;
+ int screen_num;
+
+ screen_num = gdk_screen_get_number (screen);
+
+ gdk_flush ();
+
+ display_name = gdk_display_get_name (gdk_screen_get_display (screen));
+ display = XOpenDisplay (display_name);
+
+ if (display == NULL) {
+ g_warning ("Unable to open display '%s' when setting background pixmap\n",
+ (display_name) ? display_name : "NULL");
+ return NULL;
+ }
+
+ /* Desktop background pixmap should be created from
+ * dummy X client since most applications will try to
+ * kill it with XKillClient later when changing pixmap
+ */
+
+ XSetCloseDownMode (display, RetainPermanent);
+
+ result = XCreatePixmap (display,
+ RootWindow (display, screen_num),
+ width, height,
+ DefaultDepth (display, screen_num));
+
+ XCloseDisplay (display);
+
+ gdk_pixmap = gdk_pixmap_foreign_new (result);
+ gdk_drawable_set_colormap (GDK_DRAWABLE (gdk_pixmap),
+ gdk_drawable_get_colormap (gdk_screen_get_root_window (screen)));
+
+ return gdk_pixmap;
+}
+
+/* Set the root pixmap, and properties pointing to it. We
+ * do this atomically with XGrabServer to make sure that
+ * we won't leak the pixmap if somebody else it setting
+ * it at the same time. (This assumes that they follow the
+ * same conventions we do)
+ */
+static void
+set_root_pixmap (GdkPixmap *pixmap, GdkScreen *screen)
+{
+ int result;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ guchar *data_esetroot;
+ Pixmap pixmap_id;
+ Atom type;
+ Display *display;
+ int screen_num;
+
+ screen_num = gdk_screen_get_number (screen);
+
+ data_esetroot = NULL;
+ display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
+
+ XGrabServer (display);
+
+ result = XGetWindowProperty (display, RootWindow (display, screen_num),
+ gdk_x11_get_xatom_by_name ("ESETROOT_PMAP_ID"),
+ 0L, 1L, False, XA_PIXMAP,
+ &type, &format, &nitems, &bytes_after,
+ &data_esetroot);
+
+ if (data_esetroot != NULL) {
+ if (result == Success && type == XA_PIXMAP && format == 32 && nitems == 1) {
+ gdk_error_trap_push ();
+ XKillClient (display, *(Pixmap *)data_esetroot);
+ gdk_flush ();
+ gdk_error_trap_pop ();
+ }
+ XFree (data_esetroot);
+ }
+
+ pixmap_id = GDK_WINDOW_XWINDOW (pixmap);
+
+ XChangeProperty (display, RootWindow (display, screen_num),
+ gdk_x11_get_xatom_by_name ("ESETROOT_PMAP_ID"), XA_PIXMAP,
+ 32, PropModeReplace,
+ (guchar *) &pixmap_id, 1);
+ XChangeProperty (display, RootWindow (display, screen_num),
+ gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"), XA_PIXMAP,
+ 32, PropModeReplace,
+ (guchar *) &pixmap_id, 1);
+
+ XSetWindowBackgroundPixmap (display, RootWindow (display, screen_num), pixmap_id);
+ XClearWindow (display, RootWindow (display, screen_num));
+
+ XUngrabServer (display);
+
+ XFlush (display);
+}
+
static gboolean
eel_background_ensure_realized (EelBackground *background, GdkWindow *window,
int entire_width, int entire_height)
@@ -724,6 +914,8 @@
/* Try to parse the color spec. If we fail, default to the style's color */
+ eel_background_ensure_image_nonswapped (background);
+
start_color_spec = eel_gradient_get_start_color_spec (background->details->color);
if (start_color_spec && eel_gdk_color_parse (start_color_spec, &color))
@@ -731,14 +923,13 @@
else {
/* Get the widget to which the window belongs and its style as well */
gdk_window_get_user_data (window, (void **) &widget);
- g_assert (widget != NULL);
-
- style = gtk_widget_get_style (widget);
-
- if (background->details->use_base) {
- background->details->background_color = style->base[GTK_STATE_NORMAL];
- } else {
- background->details->background_color = style->bg[GTK_STATE_NORMAL];
+ if (widget != NULL) {
+ style = gtk_widget_get_style (widget);
+ if (background->details->use_base) {
+ background->details->background_color = style->base[GTK_STATE_NORMAL];
+ } else {
+ background->details->background_color = style->bg[GTK_STATE_NORMAL];
+ }
}
}
@@ -766,7 +957,13 @@
changed = FALSE;
if (get_pixmap_size (background, entire_width, entire_height,
&pixmap_width, &pixmap_height, &background->details->background_changes_with_size)) {
- pixmap = gdk_pixmap_new (window, pixmap_width, pixmap_height, -1);
+
+ if (background->details->is_desktop && background->details->use_common_pixmap) {
+ pixmap = make_root_pixmap (gdk_drawable_get_screen(window), pixmap_width, pixmap_height);
+ } else {
+ pixmap = gdk_pixmap_new (window, pixmap_width, pixmap_height, -1);
+ }
+
gc = gdk_gc_new (pixmap);
eel_background_pre_draw (background, entire_width, entire_height);
eel_background_draw (background, pixmap, gc,
@@ -780,6 +977,8 @@
background->details->background_entire_width = entire_width;
background->details->background_entire_height = entire_height;
+ eel_background_start_swap (background);
+
return changed;
}
@@ -1491,10 +1690,16 @@
eel_background_set_up_widget (EelBackground *background, GtkWidget *widget)
{
GtkStyle *style;
+ GdkGC *gc;
GdkPixmap *pixmap;
+ GdkPixmap *root_pixmap;
GdkColor color;
+
int window_width;
int window_height;
+ int pixmap_width;
+ int pixmap_height;
+
GdkWindow *window;
GdkScreen *screen;
gboolean changes_with_size;
@@ -1505,16 +1710,15 @@
gdk_drawable_get_size (widget->window, &window_width, &window_height);
- /* HACK HACK HACK HACK
- * Hack to work around the fact that bonoboplug/socket first realizes
- * the child at the wrong size. This allows us to avoid re-reading the
- * image when we later get the right size */
- if (g_object_get_data (G_OBJECT (background), "is_desktop") != 0) {
+ /*
+ * Screen resultion resizing makes root drawable have incorrect size.
+ */
+ if (background->details->is_desktop) {
screen = gtk_widget_get_screen (widget);
window_width = gdk_screen_get_width (screen);
window_height = gdk_screen_get_height (screen);
}
-
+
pixmap = eel_background_get_pixmap_and_color (background,
widget->window,
window_width,
@@ -1535,9 +1739,40 @@
if (pixmap && !changes_with_size) {
gdk_window_set_back_pixmap (window, pixmap, FALSE);
} else {
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
gdk_window_set_background (window, &color);
}
+
+
+ if (background->details->is_desktop) {
+
+ root_pixmap = NULL;
+
+ if (background->details->use_common_pixmap) {
+ if (pixmap != NULL) {
+ root_pixmap = g_object_ref(pixmap);
+ }
+ } else {
+ if (get_pixmap_size (background, window_width, window_height,
+ &pixmap_width, &pixmap_height, &background->details->background_changes_with_size)) {
+ root_pixmap = make_root_pixmap (gdk_drawable_get_screen(window), pixmap_width, pixmap_height);
+
+ gc = gdk_gc_new (root_pixmap);
+ eel_background_pre_draw (background, window_width, window_height);
+ eel_background_draw (background, root_pixmap, gc,
+ 0, 0, 0, 0,
+ pixmap_width, pixmap_height);
+ g_object_unref (gc);
+ }
+ }
+
+ if (root_pixmap != NULL) {
+ set_root_pixmap (root_pixmap, gdk_drawable_get_screen (window));
+ g_object_unref (root_pixmap);
+ }
+ }
+
if (pixmap) {
g_object_unref (pixmap);
}
@@ -1566,15 +1801,88 @@
}
static void
-widget_realize_cb (GtkWidget *widget, gpointer data)
+screen_size_changed (GdkScreen *screen, EelBackground *background)
+{
+ g_signal_emit (background, signals[APPEARANCE_CHANGED], 0);
+}
+
+
+static void
+widget_realized_setup (GtkWidget *widget, gpointer data)
{
EelBackground *background;
background = EEL_BACKGROUND (data);
+ if (background->details->is_desktop) {
+ GdkWindow *root_window;
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (widget);
+
+ if (background->details->screen_size_handler > 0) {
+ g_signal_handler_disconnect (screen,
+ background->details->screen_size_handler);
+ }
+
+ background->details->screen_size_handler =
+ g_signal_connect (screen, "size_changed",
+ G_CALLBACK (screen_size_changed), background);
+
+ root_window = gdk_screen_get_root_window(screen);
+
+ if (gdk_drawable_get_visual (root_window) == gtk_widget_get_visual (widget)) {
+ background->details->use_common_pixmap = TRUE;
+ } else {
+ background->details->use_common_pixmap = FALSE;
+ }
+ }
+}
+
+static void
+widget_realize_cb (GtkWidget *widget, gpointer data)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (data);
+
+ widget_realized_setup (widget, data);
+
eel_background_set_up_widget (background, widget);
}
+static void
+widget_unrealize_cb (GtkWidget *widget, gpointer data)
+{
+ EelBackground *background;
+
+ background = EEL_BACKGROUND (data);
+
+ if (background->details->screen_size_handler > 0) {
+ g_signal_handler_disconnect (gtk_widget_get_screen (GTK_WIDGET (widget)),
+ background->details->screen_size_handler);
+ background->details->screen_size_handler = 0;
+ }
+ background->details->use_common_pixmap = FALSE;
+}
+
+void
+eel_background_set_desktop (EelBackground *background, GtkWidget *widget, gboolean is_desktop)
+{
+ background->details->is_desktop = is_desktop;
+
+ if (GTK_WIDGET_REALIZED(widget) && background->details->is_desktop) {
+ widget_realized_setup (widget, background);
+ }
+
+}
+
+gboolean
+eel_background_is_desktop (EelBackground *background)
+{
+ return background->details->is_desktop;
+}
+
/* Gets the background attached to a widget.
If the widget doesn't already have a EelBackground object,
@@ -1624,6 +1932,10 @@
G_CALLBACK (widget_realize_cb),
background,
0);
+ g_signal_connect_object (widget, "unrealize",
+ G_CALLBACK (widget_unrealize_cb),
+ background,
+ 0);
return background;
}
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-background.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- eel/eel-background.h 2002/11/21 15:49:36 1.15
+++ eel/eel-background.h 2005/03/16 08:29:16 1.16
@@ -188,6 +188,12 @@
/* Find the background ancestor for the widget. */
GtkWidget * eel_gtk_widget_find_background_ancestor (GtkWidget *widget);
+/* Should be TRUE for desktop background */
+void eel_background_set_desktop (EelBackground *background,
+ GtkWidget *widget,
+ gboolean is_desktop);
+gboolean eel_background_is_desktop (EelBackground *background);
+
typedef struct EelBackgroundDetails EelBackgroundDetails;
struct EelBackground
eel2-2.10.0-user-desktop-file.patch:
eel-mime-extensions.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
--- NEW FILE eel2-2.10.0-user-desktop-file.patch ---
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-mime-extensions.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- eel/eel-mime-extensions.c 2005/01/21 09:59:23 1.9
+++ eel/eel-mime-extensions.c 2005/03/07 13:34:12 1.10
@@ -231,7 +231,7 @@
application_dir = get_user_dir ("applications");
/* Get a filename */
- basename = g_strdup_printf ("%s.desktop", name);
+ basename = g_strdup_printf ("%s-usercreated.desktop", name);
filename = g_build_filename (application_dir, basename, NULL);
i = 1;
@@ -239,7 +239,7 @@
g_free (basename);
g_free (filename);
- basename = g_strdup_printf ("%s%d.desktop", name, i);
+ basename = g_strdup_printf ("%s-usercreated-%d.desktop", name, i);
filename = g_build_filename (application_dir, basename, NULL);
i++;
Index: eel2.spec
===================================================================
RCS file: /cvs/dist/rpms/eel2/devel/eel2.spec,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- eel2.spec 18 Mar 2005 16:05:39 -0000 1.22
+++ eel2.spec 3 Apr 2005 19:17:03 -0000 1.23
@@ -16,13 +16,16 @@
Name: eel2
Summary: Eazel Extensions Library.
Version: 2.10.0
-Release: 1
+Release: 2
License: GPL
Group: System Environment/Libraries
Source: eel-%{version}.tar.bz2
URL: http://www.gnome.org/projects/nautilus/
BuildRoot: /var/tmp/%{name}-%{version}-root
+Patch0: eel2-2.10.0-desktop-memory-saver.patch
+Patch1: eel2-2.10.0-user-desktop-file.patch
+
Requires: pango >= %{pango_version}
Requires: gtk2 >= %{gtk2_version}
Requires: libgnomeui >= %{libgnomeui_version}
@@ -71,6 +74,9 @@
%prep
%setup -q -n eel-%{version}
+%patch0 -p0 -b .desktop-memory-saver
+%patch1 -p0 -b .user-desktop-file
+
%build
%configure
export tagname=CC
@@ -105,6 +111,10 @@
%{_includedir}/eel-2
%changelog
+* Sun Apr 3 2005 David Zeuthen <davidz at redhat.com> 2.10.0-2
+- Include patches for desktop background memory saving (GNOME bug #169347)
+- Patch for making sure user added desktop files dont conflict with global ones
+
* Fri Mar 18 2005 David Zeuthen <davidz at redhat.com> 2.10.0-1
- New upstream version
More information about the fedora-cvs-commits
mailing list