summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2007-11-20 20:31:15 +0000
committerIain Holmes <iain@src.gnome.org>2007-11-20 20:31:15 +0000
commit065a1f90a26d231c8d5f7267d43016afc512a89c (patch)
treef6c72d146aebcb22af2734cb3ac2e02da5631743
parent06fd56f3591b9b54a2d2a7187194bc15a2dacd4e (diff)
downloadmetacity-065a1f90a26d231c8d5f7267d43016afc512a89c.tar.gz
Fix some XID leaks. Shuffle code around to make it slightly neater Write
Fix some XID leaks. Shuffle code around to make it slightly neater Write the Pixmap->Pixbuf code better svn path=/branches/iains-blingtastic-bucket-o-bling/; revision=3422
-rw-r--r--src/compositor.c113
-rw-r--r--src/screen.c3
-rw-r--r--src/ui.c15
-rw-r--r--src/ui.h4
4 files changed, 72 insertions, 63 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 8027c060..1ea4598f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -587,7 +587,7 @@ root_tile (MetaScreen *screen)
if ((picture != None) && (fill))
{
XRenderColor c;
-
+
/* Background default to just plain ugly grey */
c.red = 0x8080;
c.green = 0x8080;
@@ -633,7 +633,8 @@ create_root_buffer (MetaScreen *screen)
}
static void
-paint_root (MetaScreen *screen)
+paint_root (MetaScreen *screen,
+ Picture root_buffer)
{
MetaDisplay *display = screen->display;
MetaCompScreen *info = screen->compositor_data;
@@ -647,7 +648,7 @@ paint_root (MetaScreen *screen)
}
XRenderComposite (display->xdisplay, PictOpSrc,
- info->root_tile, None, info->root_buffer,
+ info->root_tile, None, root_buffer,
0, 0, 0, 0, 0, 0,
screen->rect.width, screen->rect.height);
}
@@ -671,7 +672,7 @@ win_extents (MetaCompWindow *cw)
/*
We apply a shadow to the window if:
- * the window is ARGB and override redirected.
+ * the window is ARGB and not override redirected.
*/
if (! (cw->mode == WINDOW_ARGB && cw->attrs.override_redirect))
@@ -793,8 +794,10 @@ get_window_picture (MetaCompWindow *cw)
}
static void
-paint_all (MetaScreen *screen,
- XserverRegion region)
+paint_windows (MetaScreen *screen,
+ GList *windows,
+ Picture root_buffer,
+ XserverRegion region)
{
MetaDisplay *display = screen->display;
MetaCompScreen *info = screen->compositor_data;
@@ -803,16 +806,13 @@ paint_all (MetaScreen *screen,
int screen_width, screen_height, screen_number;
Window xroot;
MetaCompWindow *cw;
+ XserverRegion paint_region;
screen_width = screen->rect.width;
screen_height = screen->rect.height;
screen_number = screen->number;
xroot = screen->xroot;
- /* Create root buffer if not done yet */
- if (info->root_buffer == None)
- info->root_buffer = create_root_buffer (screen);
-
if (region == None)
{
XRectangle r;
@@ -820,20 +820,21 @@ paint_all (MetaScreen *screen,
r.y = 0;
r.width = screen_width;
r.height = screen_height;
- region = XFixesCreateRegion (xdisplay, &r, 1);
+ paint_region = XFixesCreateRegion (xdisplay, &r, 1);
+ }
+ else
+ {
+ paint_region = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, paint_region, region);
}
- /* Set clipping to the given region */
- XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region);
-
/*
* Painting from top to bottom, reducing the clipping area at
* each iteration. Only the opaque windows are painted 1st.
*/
- for (index = info->windows; index; index = index->next)
+ for (index = windows; index; index = index->next)
{
cw = (MetaCompWindow *) index->data;
-
if (!cw->damaged)
{
/* Not damaged */
@@ -890,50 +891,52 @@ paint_all (MetaScreen *screen,
hei = cw->attrs.height;
#endif
- XFixesSetPictureClipRegion (xdisplay, info->root_buffer,
- 0, 0, region);
+ XFixesSetPictureClipRegion (xdisplay, root_buffer,
+ 0, 0, paint_region);
XRenderComposite (xdisplay, PictOpSrc, cw->picture,
- None, info->root_buffer, 0, 0, 0, 0,
+ None, root_buffer, 0, 0, 0, 0,
x, y, wid, hei);
- XFixesSubtractRegion (xdisplay, region, region, cw->border_size);
+ XFixesSubtractRegion (xdisplay, paint_region,
+ paint_region, cw->border_size);
}
if (!cw->border_clip)
{
cw->border_clip = XFixesCreateRegion (xdisplay, 0, 0);
- XFixesCopyRegion (xdisplay, cw->border_clip, region);
+ XFixesCopyRegion (xdisplay, cw->border_clip, paint_region);
}
}
- XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, region);
- paint_root (screen);
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, paint_region);
+ paint_root (screen, root_buffer);
/*
* Painting from bottom to top, translucent windows and shadows are painted
*/
- for (index = g_list_last (info->windows); index; index = index->prev)
- {
- XserverRegion shadow_clip;
-
+ for (index = g_list_last (windows); index; index = index->prev)
+ {
cw = (MetaCompWindow *) index->data;
- shadow_clip = None;
if (cw->picture)
{
if (cw->shadow)
{
+ XserverRegion shadow_clip;
+
shadow_clip = XFixesCreateRegion (xdisplay, NULL, 0);
XFixesSubtractRegion (xdisplay, shadow_clip, cw->border_clip,
cw->border_size);
- XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0,
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0,
shadow_clip);
XRenderComposite (xdisplay, PictOpOver, info->black_picture,
- cw->shadow, info->root_buffer,
+ cw->shadow, root_buffer,
0, 0, 0, 0,
cw->attrs.x + cw->shadow_dx,
cw->attrs.y + cw->shadow_dy,
cw->shadow_width, cw->shadow_height);
+ if (shadow_clip)
+ XFixesDestroyRegion (xdisplay, shadow_clip);
}
if ((cw->opacity != (int) OPAQUE) && !(cw->alpha_pict))
@@ -945,7 +948,7 @@ paint_all (MetaScreen *screen,
XFixesIntersectRegion (xdisplay, cw->border_clip, cw->border_clip,
cw->border_size);
- XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0,
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0,
cw->border_clip);
if (cw->mode == WINDOW_TRANS || cw->mode == WINDOW_ARGB)
@@ -964,18 +967,9 @@ paint_all (MetaScreen *screen,
#endif
XRenderComposite (xdisplay, PictOpOver, cw->picture,
- cw->alpha_pict, info->root_buffer, 0, 0, 0, 0,
+ cw->alpha_pict, root_buffer, 0, 0, 0, 0,
x, y, wid, hei);
}
-
- if (shadow_clip)
- XFixesDestroyRegion (xdisplay, shadow_clip);
-
- if (cw->border_clip)
- {
- XFixesDestroyRegion (xdisplay, cw->border_clip);
- cw->border_clip = None;
- }
}
if (cw->border_clip)
@@ -984,16 +978,35 @@ paint_all (MetaScreen *screen,
cw->border_clip = None;
}
}
+
+ XFixesDestroyRegion (xdisplay, paint_region);
+}
+
+static void
+paint_all (MetaScreen *screen,
+ XserverRegion region)
+{
+ MetaCompScreen *info = screen->compositor_data;
+ Display *xdisplay = screen->display->xdisplay;
+ int screen_width, screen_height;
+
+ /* Set clipping to the given region */
+ XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region);
- if (info->root_picture != info->root_buffer)
- {
- XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, None);
- XRenderComposite (xdisplay, PictOpSrc, info->root_buffer, None,
- info->root_picture, 0, 0, 0, 0, 0, 0,
- screen_width, screen_height);
- }
+ if (info->root_buffer == None)
+ info->root_buffer = create_root_buffer (screen);
+
+ paint_windows (screen, info->windows, info->root_buffer, region);
+
+ screen_width = screen->rect.width;
+ screen_height = screen->rect.height;
+
+ XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, None);
+ XRenderComposite (xdisplay, PictOpSrc, info->root_buffer, None,
+ info->root_picture, 0, 0, 0, 0, 0, 0,
+ screen_width, screen_height);
}
-
+
static void
repair_screen (MetaScreen *screen)
{
@@ -2016,7 +2029,7 @@ meta_compositor_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
- MetaCompWindow *cw;
+ MetaCompWindow *cw = NULL;
if (window->frame)
{
diff --git a/src/screen.c b/src/screen.c
index d0033ecb..be57fdb3 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1245,8 +1245,7 @@ get_window_pixbuf (MetaWindow *window)
if (pmap == None)
return NULL;
- pixbuf = meta_ui_get_pixbuf_from_pixmap (window->display->xdisplay,
- window->screen->number, pmap);
+ pixbuf = meta_ui_get_pixbuf_from_pixmap (pmap);
if (pixbuf == NULL)
return NULL;
diff --git a/src/ui.c b/src/ui.c
index 03103bfb..5d35febb 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -963,26 +963,25 @@ meta_ui_get_direction (void)
}
GdkPixbuf *
-meta_ui_get_pixbuf_from_pixmap (Display *xdisplay,
- int screen_no,
- Pixmap pmap)
+meta_ui_get_pixbuf_from_pixmap (Pixmap pmap)
{
- GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
- GdkScreen *screen = gdk_display_get_screen (display, screen_no);
- GdkPixbuf *pixbuf;
GdkPixmap *gpmap;
+ GdkScreen *screen;
+ GdkPixbuf *pixbuf;
GdkColormap *cmap;
int width, height, depth;
gpmap = gdk_pixmap_foreign_new (pmap);
- gdk_drawable_get_size (GDK_DRAWABLE (gpmap), &width, &height);
+ screen = gdk_drawable_get_screen (gpmap);
+ gdk_drawable_get_size (GDK_DRAWABLE (gpmap), &width, &height);
+
depth = gdk_drawable_get_depth (GDK_DRAWABLE (gpmap));
if (depth <= 24)
cmap = gdk_screen_get_rgb_colormap (screen);
else
cmap = gdk_screen_get_rgba_colormap (screen);
-
+
pixbuf = gdk_pixbuf_get_from_drawable (NULL, gpmap, cmap, 0, 0, 0, 0,
width, height);
diff --git a/src/ui.h b/src/ui.h
index a42de1f8..a4d7fea7 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -202,9 +202,7 @@ int meta_ui_get_drag_threshold (MetaUI *ui);
MetaUIDirection meta_ui_get_direction (void);
-GdkPixbuf *meta_ui_get_pixbuf_from_pixmap (Display *xdisplay,
- int screen_no,
- Pixmap pmap);
+GdkPixbuf *meta_ui_get_pixbuf_from_pixmap (Pixmap pmap);
#include "tabpopup.h"