summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2007-02-08 00:50:41 -0800
committerKeith Packard <keithp@neko.keithp.com>2007-02-08 00:50:41 -0800
commitb54d8d406e8dc3d062ec18efb155d136401d4717 (patch)
treed8181f8e089e682a5f5f5ca6b5b647ed2de7e751
parent7c3bd23a9276882ed2ef83a293ac1796a6a374fe (diff)
Add optional app-visible region to lp API.HEADmaster
-rw-r--r--Makefile.am14
-rw-r--r--lightpipe.c2
-rw-r--r--lightpipe.h21
-rw-r--r--lpapi.c6
-rw-r--r--lpdamage.c18
-rw-r--r--lpinit.c10
-rw-r--r--lpint.h2
-rw-r--r--lptable.c8
8 files changed, 70 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am
index 77b0a2d..69adcbc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
#
# $Id$
#
-# Copyright © 2004 @AUTHORS@
+# Copyright © 2004 Keith Packard
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
@@ -44,7 +44,19 @@ liblightpipe_la_SOURCES = \
lpint.h \
lptable.c
+#
+# Library version info. Check the libtool docs for
+# instructions on when and how to change this value
+#
+# bump when the ABI changes
+LIGHTPIPE_CURRENT=1
+# bump for non-ABI changes, reset to zero when CURRENT changes
+LIGHTPIPE_REVISION=0
+# bump when the ABI changes in backward-compatible fashion
+LIGHTPIPE_AGE=0
+
liblightpipe_la_LIBADD = $(LIGHTPIPE_LIBS)
+liblightpipe_la_LDFLAGS = -version-info ${LIGHTPIPE_CURRENT}:${LIGHTPIPE_REVISION}:${LIGHTPIPE_AGE} -no-undefined
liblightpipeincludedir = $(includedir)/X11/extensions
liblightpipeinclude_HEADERS = lightpipe.h
diff --git a/lightpipe.c b/lightpipe.c
index d7ad270..8215e3b 100644
--- a/lightpipe.c
+++ b/lightpipe.c
@@ -64,7 +64,7 @@ main (int argc, char **argv)
else
window = strtol (argv[2], 0, 0);
XLightPipeInit ();
- XLightPipeAttendWindow (display, window);
+ XLightPipeAttendWindow (display, window, False);
for (;;)
{
if (new && XPending (new_display))
diff --git a/lightpipe.h b/lightpipe.h
index de12b42..8ea4095 100644
--- a/lightpipe.h
+++ b/lightpipe.h
@@ -23,12 +23,29 @@
*/
#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+/*
+ * This definition comes from region.h which is not installed by
+ * the monolithic Xlib build system
+ */
+typedef struct {
+ short x1, x2, y1, y2;
+} Box, BOX, BoxRec, *BoxPtr;
+
+typedef struct _XRegion {
+ long size;
+ long numRects;
+ BOX *rects;
+ BOX extents;
+} REGION;
typedef struct {
XRectangle geometry; /* in screen space, read-only */
int border_width; /* read-only */
XRectangle damage; /* in window space, client may modify */
XImage *image; /* read-only */
+ Region damage_region; /* in window space, client may modify */
} XLightPipeWindow;
/*
@@ -43,7 +60,7 @@ XLightPipeInit (void);
*/
Bool
-XLightPipeAttendWindow (Display *display, Window window);
+XLightPipeAttendWindow (Display *display, Window window, Bool provide_region);
/*
* Start monitoring all sub windows; create/destroy handled
@@ -51,7 +68,7 @@ XLightPipeAttendWindow (Display *display, Window window);
*/
Bool
-XLightPipeAttendSubwindows (Display *display, Window window);
+XLightPipeAttendSubwindows (Display *display, Window window, Bool provide_region);
/*
* Stop monitoring window. Note that monitoring is automatically
diff --git a/lpapi.c b/lpapi.c
index 5878cfb..2676962 100644
--- a/lpapi.c
+++ b/lpapi.c
@@ -38,9 +38,9 @@ XLightPipeInit (void)
*/
Bool
-XLightPipeAttendWindow (Display *display, Window window)
+XLightPipeAttendWindow (Display *display, Window window, Bool provide_region)
{
- return _xlightpipe_add_window (display, window) ? True : False;
+ return _xlightpipe_add_window (display, window, provide_region) ? True : False;
}
/*
@@ -49,7 +49,7 @@ XLightPipeAttendWindow (Display *display, Window window)
*/
Bool
-XLightPipeAttendSubwindows (Display *display, Window window)
+XLightPipeAttendSubwindows (Display *display, Window window, Bool provide_region)
{
return False;
}
diff --git a/lpdamage.c b/lpdamage.c
index 8d4922a..066748f 100644
--- a/lpdamage.c
+++ b/lpdamage.c
@@ -84,6 +84,17 @@ _xlightpipe_damage_window (light_pipe_window *lpw, int x, int y, int width, int
old_y2 = new_y2;
lpw->public.damage.height = old_y2 - lpw->public.damage.y;
}
+ if (lpw->public.damage_region)
+ {
+ XRectangle r;
+
+ r.x = x;
+ r.y = y;
+ r.width = width;
+ r.height = height;
+ XUnionRectWithRegion (&r, lpw->public.damage_region,
+ lpw->public.damage_region);
+ }
}
void
@@ -114,6 +125,13 @@ _xlightpipe_undamage_window (light_pipe_window *lpw)
remove_damage (lpw);
lpw->public.damage.x = lpw->public.damage.y = 0;
lpw->public.damage.width = lpw->public.damage.height = 0;
+ if (lpw->public.damage_region)
+ {
+ Region empty = XCreateRegion ();
+ XIntersectRegion (lpw->public.damage_region, empty,
+ lpw->public.damage_region);
+ XDestroyRegion (empty);
+ }
}
light_pipe_window *
diff --git a/lpinit.c b/lpinit.c
index 5c55b88..fdd3268 100644
--- a/lpinit.c
+++ b/lpinit.c
@@ -40,6 +40,7 @@ _xlightpipe_init_window (Display *display, Window window, light_pipe_window *lpw
{
XWindowAttributes attr;
light_pipe_display *lpd = _xlightpipe_find_display (display);
+ int level;
if (!lpd)
return False;
@@ -68,7 +69,11 @@ _xlightpipe_init_window (Display *display, Window window, light_pipe_window *lpw
lpw->visual = attr.visual;
lpw->depth = attr.depth;
- lpw->damage = XDamageCreate (display, window, XDamageReportBoundingBox);
+ if (lpw->public.damage_region)
+ level = XDamageReportDeltaRectangles;
+ else
+ level = XDamageReportBoundingBox;
+ lpw->damage = XDamageCreate (display, window, level);
lpw->repair = XFixesCreateRegion (display, 0, 0);
@@ -96,7 +101,8 @@ _xlightpipe_fini_window (Display *display, Window window, light_pipe_window *lpw
{
XSelectInput (display, window, 0);
_xlightpipe_undamage_window (lpw);
- XCompositeUnredirectWindow (display, window, CompositeRedirectAutomatic);
+ if (!is_root (display, window))
+ XCompositeUnredirectWindow (display, window, CompositeRedirectAutomatic);
XDamageDestroy (display, lpw->damage);
_xlightpipe_destroy_window_image (lpw);
}
diff --git a/lpint.h b/lpint.h
index e08f273..b2d4e4e 100644
--- a/lpint.h
+++ b/lpint.h
@@ -102,7 +102,7 @@ light_pipe_window *
_xlightpipe_find_window (Display *display, Window window);
light_pipe_window *
-_xlightpipe_add_window (Display *display, Window window);
+_xlightpipe_add_window (Display *display, Window window, Bool provide_region);
void
_xlightpipe_remove_window (Display *display, Window window);
diff --git a/lptable.c b/lptable.c
index 30382d6..ed8430b 100644
--- a/lptable.c
+++ b/lptable.c
@@ -45,7 +45,7 @@ _xlightpipe_find_window (Display *display, Window window)
}
light_pipe_window *
-_xlightpipe_add_window (Display *display, Window window)
+_xlightpipe_add_window (Display *display, Window window, Bool provide_region)
{
light_pipe_window *lpw;
@@ -59,6 +59,10 @@ _xlightpipe_add_window (Display *display, Window window)
free (lpw);
return 0;
}
+ if (provide_region)
+ lpw->public.damage_region = XCreateRegion ();
+ else
+ lpw->public.damage_region = NULL;
if (!_xlightpipe_init_window (display, window, lpw))
{
XDeleteContext (display, window, _xlightpipe_lp_context());
@@ -77,5 +81,7 @@ _xlightpipe_remove_window (Display *display, Window window)
return;
(void) XDeleteContext (display, window, _xlightpipe_lp_context ());
_xlightpipe_fini_window (display, window, lpw);
+ if (lpw->public.damage_region)
+ XDestroyRegion (lpw->public.damage_region);
free (lpw);
}