summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-06-01 19:12:01 +0000
committerKeith Packard <keithp@keithp.com>2004-06-01 19:12:01 +0000
commit521828a128b58a3c3984975e7cb6f9ca2a4611d2 (patch)
tree30e640b2ac591834d926719496284833179825f8
parent537a71fa230d2c5fafdc3af1cb33f979dc9545bb (diff)
Prefix all exposed (but not public) APIs with _xlightpipe_. Don't use
Composite on root windows
-rw-r--r--ChangeLog24
-rw-r--r--lightpipe.c9
-rw-r--r--lpapi.c22
-rw-r--r--lpdamage.c16
-rw-r--r--lpdisplay.c6
-rw-r--r--lpevent.c28
-rw-r--r--lpimage.c6
-rw-r--r--lpinit.c29
-rw-r--r--lpint.h32
-rw-r--r--lptable.c24
10 files changed, 117 insertions, 79 deletions
diff --git a/ChangeLog b/ChangeLog
index b1bab25..fdb8c92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2004-06-01 Keith Packard <keithp@keithp.com>
+
+ reviewed by: <delete if not using a buddy>
+
+ * lightpipe.c: (main):
+ * lpapi.c: (XLightPipeAttendWindow), (XLightPipeIgnoreWindow),
+ (XLightPipeCheckWindow), (XLightPipeCheckAny), (XLightPipeRelease):
+ * lpdamage.c: (add_damage), (remove_damage),
+ (_xlightpipe_damage_window), (_xlightpipe_update_window),
+ (_xlightpipe_undamage_window), (_xlightpipe_find_damaged):
+ * lpdisplay.c: (_xlightpipe_find_display):
+ * lpevent.c: (process_destroy_notify), (process_configure_notify),
+ (process_damage_notify), (process_event),
+ (_xlightpipe_await_event), (_xlightpipe_process_events):
+ * lpimage.c: (_xlightpipe_create_window_image),
+ (_xlightpipe_destroy_window_image), (_xlightpipe_update_region):
+ * lpinit.c: (is_root), (_xlightpipe_init_window),
+ (_xlightpipe_fini_window):
+ * lpint.h:
+ * lptable.c: (_xlightpipe_lp_context), (_xlightpipe_find_window),
+ (_xlightpipe_add_window), (_xlightpipe_remove_window):
+ Prefix all exposed (but not public) APIs with _xlightpipe_.
+ Don't use Composite on root windows
+
2004-05-07 Keith Packard <keithp@keithp.com>
* Makefile.am:
diff --git a/lightpipe.c b/lightpipe.c
index 38b8190..3dfc74c 100644
--- a/lightpipe.c
+++ b/lightpipe.c
@@ -33,12 +33,12 @@ int
main (int argc, char **argv)
{
Display *display;
- Display *new_display;
+ Display *new_display = 0;
Window window;
Window new = 0;
- int new_width, new_height;
+ int new_width = 0, new_height = 0;
XLightPipeWindow *lpw;
- GC new_gc;
+ GC new_gc = 0;
if (argc != 4)
{
@@ -99,8 +99,6 @@ main (int argc, char **argv)
new_height = lpw->geometry.height;
XResizeWindow (new_display, new, new_width, new_height);
}
- printf ("%dx%d+%d+%d\n",
- lpw->damage.width, lpw->damage.height, lpw->damage.x, lpw->damage.y);
XPutImage (new_display, new, new_gc, lpw->image,
lpw->damage.x, lpw->damage.y,
lpw->damage.x, lpw->damage.y,
@@ -108,6 +106,7 @@ main (int argc, char **argv)
lpw->damage.height);
XFlush (new_display);
XLightPipeRelease (display, lpw);
+ XFlush (display);
}
return 0;
}
diff --git a/lpapi.c b/lpapi.c
index 5579093..5878cfb 100644
--- a/lpapi.c
+++ b/lpapi.c
@@ -40,7 +40,7 @@ XLightPipeInit (void)
Bool
XLightPipeAttendWindow (Display *display, Window window)
{
- return add_window (display, window) ? True : False;
+ return _xlightpipe_add_window (display, window) ? True : False;
}
/*
@@ -62,7 +62,7 @@ XLightPipeAttendSubwindows (Display *display, Window window)
void
XLightPipeIgnoreWindow (Display *display, Window window)
{
- remove_window (display, window);
+ _xlightpipe_remove_window (display, window);
}
/*
@@ -78,16 +78,16 @@ XLightPipeCheckWindow (Display *display, Window window, Bool block)
light_pipe_window *lpw;
do {
- process_events (display);
- for (lpw = find_damaged (display); lpw; lpw = lpw->next_damaged)
+ _xlightpipe_process_events (display);
+ for (lpw = _xlightpipe_find_damaged (display); lpw; lpw = lpw->next_damaged)
{
if (lpw->window == window)
{
- update_window (lpw);
+ _xlightpipe_update_window (lpw);
return &lpw->public;
}
}
- } while (!block || await_event (display));
+ } while (block && _xlightpipe_await_event (display));
return 0;
}
@@ -100,14 +100,14 @@ XLightPipeCheckAny (Display *display, Bool block)
light_pipe_window *lpw;
do {
- process_events (display);
- lpw = find_damaged (display);
+ _xlightpipe_process_events (display);
+ lpw = _xlightpipe_find_damaged (display);
if (lpw)
{
- update_window (lpw);
+ _xlightpipe_update_window (lpw);
return &lpw->public;
}
- } while (!block || await_event (display));
+ } while (block && _xlightpipe_await_event (display));
return 0;
}
@@ -121,5 +121,5 @@ XLightPipeRelease (Display *display, XLightPipeWindow *xlpw)
{
light_pipe_window *lpw = (light_pipe_window *) xlpw;
- undamage_window (lpw);
+ _xlightpipe_undamage_window (lpw);
}
diff --git a/lpdamage.c b/lpdamage.c
index d87c66a..8d4922a 100644
--- a/lpdamage.c
+++ b/lpdamage.c
@@ -27,7 +27,7 @@
static void
add_damage (light_pipe_window *lpw)
{
- light_pipe_display *lpd = find_display (lpw->display);
+ light_pipe_display *lpd = _xlightpipe_find_display (lpw->display);
light_pipe_window **prev;
if (!lpd)
@@ -42,7 +42,7 @@ add_damage (light_pipe_window *lpw)
static void
remove_damage (light_pipe_window *lpw)
{
- light_pipe_display *lpd = find_display (lpw->display);
+ light_pipe_display *lpd = _xlightpipe_find_display (lpw->display);
light_pipe_window **prev;
if (!lpd)
@@ -56,7 +56,7 @@ remove_damage (light_pipe_window *lpw)
}
void
-damage_window (light_pipe_window *lpw, int x, int y, int width, int height)
+_xlightpipe_damage_window (light_pipe_window *lpw, int x, int y, int width, int height)
{
add_damage (lpw);
if (lpw->public.damage.width == 0)
@@ -87,7 +87,7 @@ damage_window (light_pipe_window *lpw, int x, int y, int width, int height)
}
void
-update_window (light_pipe_window *lpw)
+_xlightpipe_update_window (light_pipe_window *lpw)
{
if (lpw->public.damage.width && lpw->public.damage.height)
{
@@ -99,7 +99,7 @@ update_window (light_pipe_window *lpw)
lpw->damage,
lpw->repair,
None);
- update_region (lpw,
+ _xlightpipe_update_region (lpw,
lpw->public.damage.x,
lpw->public.damage.y,
lpw->public.damage.width,
@@ -109,7 +109,7 @@ update_window (light_pipe_window *lpw)
}
void
-undamage_window (light_pipe_window *lpw)
+_xlightpipe_undamage_window (light_pipe_window *lpw)
{
remove_damage (lpw);
lpw->public.damage.x = lpw->public.damage.y = 0;
@@ -117,10 +117,10 @@ undamage_window (light_pipe_window *lpw)
}
light_pipe_window *
-find_damaged (Display *display)
+_xlightpipe_find_damaged (Display *display)
{
light_pipe_display *lpd;
- lpd = find_display (display);
+ lpd = _xlightpipe_find_display (display);
return lpd->damaged;
}
diff --git a/lpdisplay.c b/lpdisplay.c
index cd666ec..31b6ae1 100644
--- a/lpdisplay.c
+++ b/lpdisplay.c
@@ -43,11 +43,11 @@ init_display (light_pipe_display *lpd)
}
light_pipe_display *
-find_display (Display *display)
+_xlightpipe_find_display (Display *display)
{
light_pipe_display *lpd;
- if (XFindContext (display, 0, lp_context (), (XPointer *) &lpd) == 0)
+ if (XFindContext (display, 0, _xlightpipe_lp_context (), (XPointer *) &lpd) == 0)
return lpd;
lpd = malloc (sizeof (light_pipe_display));
if (!lpd)
@@ -59,7 +59,7 @@ find_display (Display *display)
free (lpd);
return 0;
}
- if (XSaveContext (display, 0, lp_context (), (char *) lpd) != 0)
+ if (XSaveContext (display, 0, _xlightpipe_lp_context (), (char *) lpd) != 0)
{
free (lpd);
return 0;
diff --git a/lpevent.c b/lpevent.c
index 334fe98..4fca280 100644
--- a/lpevent.c
+++ b/lpevent.c
@@ -27,13 +27,13 @@
static void
process_destroy_notify (XDestroyWindowEvent *event)
{
- remove_window (event->display, event->window);
+ _xlightpipe_remove_window (event->display, event->window);
}
static void
process_configure_notify (XConfigureEvent *event)
{
- light_pipe_window *lpw = find_window (event->display, event->window);
+ light_pipe_window *lpw = _xlightpipe_find_window (event->display, event->window);
if (!lpw)
return;
@@ -42,9 +42,9 @@ process_configure_notify (XConfigureEvent *event)
{
lpw->public.geometry.width = event->width;
lpw->public.geometry.height = event->height;
- destroy_window_image (lpw);
- create_window_image (lpw);
- damage_window (lpw, 0, 0, event->width, event->height);
+ _xlightpipe_destroy_window_image (lpw);
+ _xlightpipe_create_window_image (lpw);
+ _xlightpipe_damage_window (lpw, 0, 0, event->width, event->height);
}
lpw->public.geometry.x = event->x;
lpw->public.geometry.y = event->y;
@@ -54,22 +54,22 @@ process_configure_notify (XConfigureEvent *event)
static void
process_damage_notify (XDamageNotifyEvent *event)
{
- light_pipe_window *lpw = find_window (event->display, event->drawable);
+ light_pipe_window *lpw = _xlightpipe_find_window (event->display, event->drawable);
if (!lpw)
return;
- damage_window (lpw,
- event->area.x,
- event->area.y,
- event->area.width,
- event->area.height);
+ _xlightpipe_damage_window (lpw,
+ event->area.x,
+ event->area.y,
+ event->area.width,
+ event->area.height);
}
static void
process_event (XEvent *event)
{
Display *display = event->xany.display;
- light_pipe_display *lpd = find_display (display);
+ light_pipe_display *lpd = _xlightpipe_find_display (display);
if (!lpd)
return;
@@ -93,7 +93,7 @@ process_event (XEvent *event)
}
Bool
-await_event (Display *display)
+_xlightpipe_await_event (Display *display)
{
XEvent event;
@@ -102,7 +102,7 @@ await_event (Display *display)
}
void
-process_events (Display *display)
+_xlightpipe_process_events (Display *display)
{
while (XPending (display))
{
diff --git a/lpimage.c b/lpimage.c
index b4936e0..852e33a 100644
--- a/lpimage.c
+++ b/lpimage.c
@@ -25,7 +25,7 @@
#include "lpint.h"
Bool
-create_window_image (light_pipe_window *lpw)
+_xlightpipe_create_window_image (light_pipe_window *lpw)
{
int image_size;
XGCValues gcv;
@@ -85,7 +85,7 @@ create_window_image (light_pipe_window *lpw)
}
void
-destroy_window_image (light_pipe_window *lpw)
+_xlightpipe_destroy_window_image (light_pipe_window *lpw)
{
if (lpw->public.image)
{
@@ -103,7 +103,7 @@ destroy_window_image (light_pipe_window *lpw)
}
void
-update_region (light_pipe_window *lpw, int x, int y, int width, int height)
+_xlightpipe_update_region (light_pipe_window *lpw, int x, int y, int width, int height)
{
XCopyArea (lpw->display,
lpw->window,
diff --git a/lpinit.c b/lpinit.c
index 4c3aa87..32c788b 100644
--- a/lpinit.c
+++ b/lpinit.c
@@ -24,8 +24,19 @@
#include "lpint.h"
+static Bool
+is_root (Display *dpy, Window window)
+{
+ int s;
+
+ for (s = 0; s < ScreenCount (dpy); s++)
+ if (window == RootWindow (dpy, s))
+ return True;
+ return False;
+}
+
Bool
-init_window (Display *display, Window window, light_pipe_window *lpw)
+_xlightpipe_init_window (Display *display, Window window, light_pipe_window *lpw)
{
XWindowAttributes attr;
@@ -57,27 +68,31 @@ init_window (Display *display, Window window, light_pipe_window *lpw)
lpw->repair = XFixesCreateRegion (display, 0, 0);
- XCompositeRedirectWindow (display, window, CompositeRedirectAutomatic);
+ /*
+ * Ensure that the window contents are available even when occluded
+ */
+ if (!is_root (display, window))
+ XCompositeRedirectWindow (display, window, CompositeRedirectAutomatic);
lpw->next_damaged = 0;
- if (!create_window_image (lpw))
+ if (!_xlightpipe_create_window_image (lpw))
{
XSelectInput (display, window, 0);
return False;
}
if (attr.map_state == IsViewable)
- damage_window (lpw, 0, 0, attr.width, attr.height);
+ _xlightpipe_damage_window (lpw, 0, 0, attr.width, attr.height);
return True;
}
void
-fini_window (Display *display, Window window, light_pipe_window *lpw)
+_xlightpipe_fini_window (Display *display, Window window, light_pipe_window *lpw)
{
XSelectInput (display, window, 0);
- undamage_window (lpw);
+ _xlightpipe_undamage_window (lpw);
XCompositeUnredirectWindow (display, window, CompositeRedirectAutomatic);
XDamageDestroy (display, lpw->damage);
- destroy_window_image (lpw);
+ _xlightpipe_destroy_window_image (lpw);
}
diff --git a/lpint.h b/lpint.h
index 7386bd3..db85c62 100644
--- a/lpint.h
+++ b/lpint.h
@@ -66,62 +66,62 @@ typedef struct _light_pipe_display {
/* mark area as damaged */
void
-damage_window (light_pipe_window *lpw, int x, int y, int width, int height);
+_xlightpipe_damage_window (light_pipe_window *lpw, int x, int y, int width, int height);
/* synchronize local copy of window with remote */
void
-update_window (light_pipe_window *lpw);
+_xlightpipe_update_window (light_pipe_window *lpw);
/* mark window as entirely undamaged */
void
-undamage_window (light_pipe_window *lpw);
+_xlightpipe_undamage_window (light_pipe_window *lpw);
light_pipe_window *
-find_damaged (Display *display);
+_xlightpipe_find_damaged (Display *display);
/* lpdisplay.c */
light_pipe_display *
-find_display (Display *display);
+_xlightpipe_find_display (Display *display);
/* lpevent.c */
Bool
-await_event (Display *display);
+_xlightpipe_await_event (Display *display);
void
-process_events (Display *display);
+_xlightpipe_process_events (Display *display);
/* lptable.c */
int
-lp_context (void);
+_xlightpipe_lp_context (void);
light_pipe_window *
-find_window (Display *display, Window window);
+_xlightpipe_find_window (Display *display, Window window);
light_pipe_window *
-add_window (Display *display, Window window);
+_xlightpipe_add_window (Display *display, Window window);
void
-remove_window (Display *display, Window window);
+_xlightpipe_remove_window (Display *display, Window window);
/* lpimage.c */
Bool
-create_window_image (light_pipe_window *lpw);
+_xlightpipe_create_window_image (light_pipe_window *lpw);
void
-destroy_window_image (light_pipe_window *lpw);
+_xlightpipe_destroy_window_image (light_pipe_window *lpw);
void
-update_region (light_pipe_window *lpw, int x, int y, int width, int height);
+_xlightpipe_update_region (light_pipe_window *lpw, int x, int y, int width, int height);
/* lpinit.c */
Bool
-init_window (Display *display, Window window, light_pipe_window *lpw);
+_xlightpipe_init_window (Display *display, Window window, light_pipe_window *lpw);
void
-fini_window (Display *display, Window window, light_pipe_window *lpw);
+_xlightpipe_fini_window (Display *display, Window window, light_pipe_window *lpw);
diff --git a/lptable.c b/lptable.c
index 12aad9b..30382d6 100644
--- a/lptable.c
+++ b/lptable.c
@@ -25,7 +25,7 @@
#include "lpint.h"
int
-lp_context (void)
+_xlightpipe_lp_context (void)
{
static int context;
@@ -35,33 +35,33 @@ lp_context (void)
}
light_pipe_window *
-find_window (Display *display, Window window)
+_xlightpipe_find_window (Display *display, Window window)
{
light_pipe_window *lpw;
- if (XFindContext (display, window, lp_context (), (XPointer *) &lpw) != 0)
+ if (XFindContext (display, window, _xlightpipe_lp_context (), (XPointer *) &lpw) != 0)
return 0;
return lpw;
}
light_pipe_window *
-add_window (Display *display, Window window)
+_xlightpipe_add_window (Display *display, Window window)
{
light_pipe_window *lpw;
- if (XFindContext (display, window, lp_context (), (XPointer *) &lpw) == 0)
+ if (XFindContext (display, window, _xlightpipe_lp_context (), (XPointer *) &lpw) == 0)
return 0;
lpw = malloc (sizeof (light_pipe_window));
if (!lpw)
return 0;
- if (XSaveContext (display, window, lp_context (), (char *) lpw) != 0)
+ if (XSaveContext (display, window, _xlightpipe_lp_context (), (char *) lpw) != 0)
{
free (lpw);
return 0;
}
- if (!init_window (display, window, lpw))
+ if (!_xlightpipe_init_window (display, window, lpw))
{
- XDeleteContext (display, window, lp_context());
+ XDeleteContext (display, window, _xlightpipe_lp_context());
free (lpw);
return 0;
}
@@ -69,13 +69,13 @@ add_window (Display *display, Window window)
}
void
-remove_window (Display *display, Window window)
+_xlightpipe_remove_window (Display *display, Window window)
{
light_pipe_window *lpw;
- if (!XFindContext (display, window, lp_context (), (XPointer *) &lpw))
+ if (!XFindContext (display, window, _xlightpipe_lp_context (), (XPointer *) &lpw))
return;
- (void) XDeleteContext (display, window, lp_context ());
- fini_window (display, window, lpw);
+ (void) XDeleteContext (display, window, _xlightpipe_lp_context ());
+ _xlightpipe_fini_window (display, window, lpw);
free (lpw);
}