summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@l3000.localdomain>2011-12-08 01:41:54 -0500
committerSøren Sandmann Pedersen <ssp@l3000.localdomain>2011-12-08 01:41:54 -0500
commit4ca2ad5eb73c1ca0c5641e11f78f54421b2fa537 (patch)
tree6f5e91a0d496745d83adac55fd779faf0a810533
parent99e9fbf0cc673538728901bd48e7d6c101826d7a (diff)
Make it work with argb windows
-rw-r--r--main.c4
-rw-r--r--window.c30
2 files changed, 21 insertions, 13 deletions
diff --git a/main.c b/main.c
index 364147e..7840510 100644
--- a/main.c
+++ b/main.c
@@ -26,17 +26,17 @@ main ()
image = pixman_image_create_solid_fill (&color);
ws_window_copy_from_image (window, image, 0, 0, 0, 0, 200, 200);
ws_window_finish (&window, 1);
+ ws_process (ws);
while (1)
{
- pixman_color_t color = { 0xffff, 0xabcd, 0x7777, 0x7777 };
+ pixman_color_t color = { 0xffff, 0xabcd, 0x7777, 0xaaaa };
int fd = ws_get_fd (ws);
FD_ZERO (&set);
FD_SET (fd, &set);
select (fd + 1, &set, NULL, NULL, NULL);
-
ws_process (ws);
color.red = rand();
diff --git a/window.c b/window.c
index 4cfcc80..73b9987 100644
--- a/window.c
+++ b/window.c
@@ -8,12 +8,14 @@
struct ws_t
{
Display * display;
+ int depth;
Visual * visual;
pixman_format_code_t format;
pixman_bool_t composited;
pixman_bool_t has_alpha;
int byte_order;
int fd;
+ Colormap colormap;
list_t windows;
};
@@ -133,7 +135,6 @@ ws_open (void)
{
ws_t *ws;
Display *display;
- int depth;
int x;
if (!(display = XOpenDisplay (NULL)))
@@ -144,7 +145,7 @@ ws_open (void)
ws->composited = is_composited (display);
/* Use the default visual ... */
- depth = DefaultDepth (ws->display, 0);
+ ws->depth = DefaultDepth (ws->display, 0);
ws->visual = DefaultVisual (ws->display, 0);
ws->has_alpha = FALSE;
@@ -169,7 +170,7 @@ ws_open (void)
visinfo->green_mask == 0x0000ff00 &&
visinfo->blue_mask == 0x000000ff))
{
- depth = 32;
+ ws->depth = 32;
ws->visual = visinfo->visual;
ws->has_alpha = TRUE;
break;
@@ -177,7 +178,10 @@ ws_open (void)
}
}
- if (!visual_to_format (ws->visual, depth, &ws->format))
+ ws->colormap = XCreateColormap (
+ ws->display, RootWindow (ws->display, 0), ws->visual, AllocNone);
+
+ if (!visual_to_format (ws->visual, ws->depth, &ws->format))
return NULL;
x = 1;
@@ -217,15 +221,13 @@ find_window (ws_t *ws, XID xid)
static void
process_configure_notify (ws_t *ws, XEvent *event)
{
- window_t *window = find_window (ws, event->xconfigure.window);
-
-
}
static void
process_expose (ws_t *ws, const XEvent *event)
{
- printf ("expose\n");
+ window_t *window = find_window (ws, event->xexpose.window);
+ printf ("expose %x\n", window->xid);
}
void
@@ -262,15 +264,21 @@ ws_create_window (ws_t *ws,
int height)
{
window_t *window = malloc (sizeof *window);
- Window root = DefaultRootWindow (ws->display);
+ Window root = RootWindow (ws->display, 0);
XSetWindowAttributes attr;
attr.background_pixmap = None;
+ attr.colormap = ws->colormap;
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+#if 0
+ printf ("%d %x %x %x %x %x\n", ws->depth, ws->visual->red_mask, ws->visual->green_mask, ws->visual->blue_mask, ws->visual->visualid, ws->colormap);
+#endif
window->xid = XCreateWindow (
ws->display, root, x, y, width, height, 0,
- DefaultDepth (ws->display, 0), InputOutput,
- DefaultVisual (ws->display, 0), CWBackPixmap, &attr);
+ ws->depth, InputOutput, ws->visual,
+ CWBackPixel | CWBorderPixel | CWBackPixmap | CWColormap, &attr);
window->ref_count = 1;
window->backing_store =