Hello Adam,
An updated patch is attached. Thanks for responding so fast :) Bye,
Thomas
On 02/09/05 06:42, Adam Kopacz adam.kopacz-at-klografx.de |bugs-debian| wrote:
i need this patch for http://www.klografx.net/qiv/devel/qiv-2.1-pre7.tgz
diff -Naur qiv-2.1_vanilla/image.c qiv-2.1/image.c --- qiv-2.1_vanilla/image.c 2005-01-01 12:43:47.000000000 +0100 +++ qiv-2.1/image.c 2005-02-09 09:28:44.000000000 +0100 @@ -197,9 +197,16 @@ { GdkWindow *root_win = GDK_ROOT_PARENT(); GdkVisual *gvis = gdk_window_get_visual(root_win); - GdkPixmap *temp; + GdkPixmap *pixmap; GdkPixmap *m = NULL; gchar *buffer; + unsigned char *data_root, *data_esetroot; + Display *display=GDK_DISPLAY(); + Atom prop_root=XInternAtom(display, "_XROOTPMAP_ID", False), + prop_esetroot=XInternAtom(display, "ESETROOT_PMAP_ID", False), + xa_pixmap=XInternAtom(display, "PIXMAP", True), prop_type; + int prop_format; + unsigned long prop_length, after; gint root_w = screen_x, root_h = screen_y; gint root_x = 0, root_y = 0; @@ -231,25 +238,71 @@ } if (to_root_t) { - gdk_window_set_back_pixmap(root_win, q->p, FALSE); + pixmap=q->p; + q->p=0; } else { GdkGC *rootGC; buffer = calloc(1, screen_x * screen_y); rootGC = gdk_gc_new(root_win); - temp = gdk_pixmap_create_from_data(root_win, buffer, screen_x, - screen_y, gvis->depth, &image_bg, &image_bg); - gdk_draw_pixmap(temp, rootGC, q->p, 0, 0, root_x, root_y, root_w, root_h); - gdk_window_set_back_pixmap(root_win, temp, FALSE); - gdk_imlib_free_pixmap(temp); + pixmap = gdk_pixmap_create_from_data(root_win, buffer, screen_x, + screen_y, gvis->depth, &image_bg, &image_bg); + gdk_draw_pixmap(pixmap, rootGC, q->p, 0, 0, + root_x, root_y, root_w, root_h); gdk_gc_destroy(rootGC); } + /* Send the pixmap to the server so that it can be referenced by the + atoms later on. */ + gdk_window_set_back_pixmap(root_win, pixmap, FALSE); + + /* set the appropriate properties on the root window to allow other apps to + find the pixmap */ + if (prop_root!=None && prop_esetroot!=None) { + /* NB: There once was a GDK/Imlib version of this code. It liked to + segfault other apps; there is obviously a discrepancy between what + GDK_WINDOW_XWINDOW spits out and what gdk_property_change expects. We + don't need GDK anyway for this code snippet since it will not get much + simpler with it. Give it a try again once this app has been ported to + Gdk/Pixbuf. */ + Pixmap pixmap_id=GDK_WINDOW_XWINDOW(pixmap); + Window xwin=RootWindow(display, DefaultScreen(display)); + + /* test whether an existing client should be killed */ + XGetWindowProperty(display, xwin, + prop_root, 0, 1, False, AnyPropertyType, + &prop_type, &prop_format, &prop_length, &after, + &data_root); + if (prop_type==xa_pixmap) { + XGetWindowProperty(display, xwin, + prop_esetroot, 0, 1, False, AnyPropertyType, + &prop_type, &prop_format, &prop_length, &after, + &data_esetroot); + /* If data structures match the client can be safely killed. In case of + data structure mismatch just ignore the client since it possibly could + be the window manager. Memory should not be reclaimed in this case. */ + if (data_root&&data_esetroot&&prop_type==xa_pixmap&& + *((Pixmap*)data_root)==*((Pixmap*)data_esetroot)) + /* Do NOT kill any clients. It seems that GDK is already taking care + of killing the pixmap if set with gdk_window_set_back_pixmap. + XKillClient(display, *((Pixmap*)data_root)) */; + } + + /* really change the property now */ + XChangeProperty(display, xwin, prop_root, xa_pixmap, 32, + PropModeReplace, (unsigned char*)&pixmap_id, 1); + XChangeProperty(display, xwin, prop_esetroot, xa_pixmap, 32, + PropModeReplace, (unsigned char*)&pixmap_id, 1); + XSetCloseDownMode(display, RetainPermanent); + } + + gdk_window_clear(root_win); + gdk_flush(); if(q->p) { gdk_imlib_free_pixmap(q->p); q->p = NULL; } - gdk_window_clear(root_win); - gdk_flush(); + gdk_imlib_free_pixmap(pixmap); + pixmap=0; } void zoom_in(qiv_image *q)