xwayland: replace opaque_rect, fix an alpha problem
authorPekka Paalanen <ppaalanen@gmail.com>
Mon, 3 Sep 2012 13:48:41 +0000 (16:48 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 4 Sep 2012 20:14:29 +0000 (16:14 -0400)
Remove weston_surface::opaque_rect completely.

Instead, set the opaque region in xwayland.

Before this patch, black text in xterm was transparent. Now it is not.

However, this patch fixes only a part of the alpha problem. If you apply
full-surface alpha with super+alt+wheel, the problem reappears. This
problem is still due to bad alpha channel contents on xwayland windows.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
src/compositor.c
src/compositor.h
src/xwayland/window-manager.c

index 9ce44d4..5e9a0c2 100644 (file)
@@ -243,10 +243,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
        surface->compositor = compositor;
        surface->alpha = 1.0;
-       surface->opaque_rect[0] = 0.0;
-       surface->opaque_rect[1] = 0.0;
-       surface->opaque_rect[2] = 0.0;
-       surface->opaque_rect[3] = 0.0;
        surface->pitch = 1;
 
        surface->num_textures = 0;
index 96a0477..38c2657 100644 (file)
@@ -399,7 +399,6 @@ struct weston_surface {
        struct wl_list layer_link;
        struct weston_shader *shader;
        GLfloat color[4];
-       GLfloat opaque_rect[4];
        GLfloat alpha;
        struct weston_plane *plane;
 
index e705fec..65eb11a 100644 (file)
@@ -717,17 +717,19 @@ weston_wm_window_draw_decoration(void *data)
        cairo_destroy(cr);
 
        if (window->surface) {
+               pixman_region32_fini(&window->surface->opaque);
+               pixman_region32_init_rect(&window->surface->opaque, 0, 0,
+                                         width, height);
+
                /* We leave an extra pixel around the X window area to
                 * make sure we don't sample from the undefined alpha
                 * channel when filtering. */
-               window->surface->opaque_rect[0] =
-                       (double) (x - 1) / width;
-               window->surface->opaque_rect[1] =
-                       (double) (x + window->width + 1) / width;
-               window->surface->opaque_rect[2] =
-                       (double) (y - 1) / height;
-               window->surface->opaque_rect[3] =
-                       (double) (y + window->height + 1) / height;
+               pixman_region32_intersect_rect(&window->surface->opaque,
+                                              &window->surface->opaque,
+                                              x - 1, y - 1,
+                                              window->width + 2,
+                                              window->height + 2);
+               window->surface->geometry.dirty = 1;
 
                pixman_region32_init_rect(&window->surface->input,
                                          t->margin, t->margin,
@@ -740,13 +742,15 @@ static void
 weston_wm_window_schedule_repaint(struct weston_wm_window *window)
 {
        struct weston_wm *wm = window->wm;
+       int width, height;
 
        if (window->frame_id == XCB_WINDOW_NONE) {
                if (window->surface != NULL) {
-                       window->surface->opaque_rect[0] = 0.0;
-                       window->surface->opaque_rect[1] = 1.0;
-                       window->surface->opaque_rect[2] = 0.0;
-                       window->surface->opaque_rect[3] = 1.0;
+                       weston_wm_window_get_frame_size(window, &width, &height);
+                       pixman_region32_fini(&window->surface->opaque);
+                       pixman_region32_init_rect(&window->surface->opaque, 0, 0,
+                                                 width, height);
+                       window->surface->geometry.dirty = 1;
                }
                return;
        }