xwm: split weston_wm_window_draw_decoration()
Split the function into two: - weston_wm_window_draw_decoration() that only draws the decorations with Cairo, and - weston_wm_window_set_pending_state() which sets up the surface state to be latches into use on the next commit from Xwayland. The new weston_wm_window_do_repaint() is the equivalent of the old weston_wm_window_draw_decorations(), everything still happens the same way as it was. Just some debug messages have been reworded. weston_wm_window_read_properties() is moved into weston_wm_window_do_repaint() because it is not strictly a part of drawing decorations. The same with resetting repaint_source. draw_decorations does not need the child position nor xwayland interface. Also some convenience variables have been eliminated. set_pending_state code has been un-indented by one level, so the change is best viewed with whitespace changes ignored. This patch makes the code more readable, and prepares for calling the draw_decorations and set_pending_state from different places. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
+67
-52
@@ -1119,25 +1119,14 @@ weston_wm_handle_unmap_notify(struct weston_wm *wm, xcb_generic_event_t *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
weston_wm_window_draw_decoration(void *data)
|
weston_wm_window_draw_decoration(struct weston_wm_window *window)
|
||||||
{
|
{
|
||||||
struct weston_wm_window *window = data;
|
|
||||||
struct weston_wm *wm = window->wm;
|
|
||||||
struct theme *t = wm->theme;
|
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
int x, y, width, height;
|
int width, height;
|
||||||
int32_t input_x, input_y, input_w, input_h;
|
|
||||||
const struct weston_desktop_xwayland_interface *xwayland_interface =
|
|
||||||
wm->server->compositor->xwayland_interface;
|
|
||||||
|
|
||||||
wm_log("XWM: start draw decoration, win %d\n", window->id);
|
wm_log("XWM: draw decoration, win %d\n", window->id);
|
||||||
|
|
||||||
weston_wm_window_read_properties(window);
|
|
||||||
|
|
||||||
window->repaint_source = NULL;
|
|
||||||
|
|
||||||
weston_wm_window_get_frame_size(window, &width, &height);
|
weston_wm_window_get_frame_size(window, &width, &height);
|
||||||
weston_wm_window_get_child_position(window, &x, &y);
|
|
||||||
|
|
||||||
cairo_xcb_surface_set_size(window->cairo_surface, width, height);
|
cairo_xcb_surface_set_size(window->cairo_surface, width, height);
|
||||||
cr = cairo_create(window->cairo_surface);
|
cr = cairo_create(window->cairo_surface);
|
||||||
@@ -1152,52 +1141,79 @@ weston_wm_window_draw_decoration(void *data)
|
|||||||
cairo_set_source_rgba(cr, 0, 0, 0, 0);
|
cairo_set_source_rgba(cr, 0, 0, 0, 0);
|
||||||
cairo_paint(cr);
|
cairo_paint(cr);
|
||||||
|
|
||||||
render_shadow(cr, t->shadow, 2, 2, width + 8, height + 8, 64, 64);
|
render_shadow(cr, window->wm->theme->shadow,
|
||||||
|
2, 2, width + 8, height + 8, 64, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_destroy(cr);
|
cairo_destroy(cr);
|
||||||
cairo_surface_flush(window->cairo_surface);
|
cairo_surface_flush(window->cairo_surface);
|
||||||
xcb_flush(window->wm->conn);
|
xcb_flush(window->wm->conn);
|
||||||
|
}
|
||||||
|
|
||||||
if (window->surface) {
|
static void
|
||||||
pixman_region32_fini(&window->surface->pending.opaque);
|
weston_wm_window_set_pending_state(struct weston_wm_window *window)
|
||||||
if (window->has_alpha) {
|
{
|
||||||
pixman_region32_init(&window->surface->pending.opaque);
|
int x, y, width, height;
|
||||||
} else {
|
int32_t input_x, input_y, input_w, input_h;
|
||||||
/* We leave an extra pixel around the X window area to
|
const struct weston_desktop_xwayland_interface *xwayland_interface =
|
||||||
* make sure we don't sample from the undefined alpha
|
window->wm->server->compositor->xwayland_interface;
|
||||||
* channel when filtering. */
|
|
||||||
pixman_region32_init_rect(&window->surface->pending.opaque,
|
|
||||||
x - 1, y - 1,
|
|
||||||
window->width + 2,
|
|
||||||
window->height + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
pixman_region32_fini(&window->surface->pending.input);
|
if (!window->surface)
|
||||||
|
return;
|
||||||
|
|
||||||
if (window->decorate && !window->fullscreen) {
|
weston_wm_window_get_frame_size(window, &width, &height);
|
||||||
frame_input_rect(window->frame, &input_x, &input_y,
|
weston_wm_window_get_child_position(window, &x, &y);
|
||||||
&input_w, &input_h);
|
|
||||||
} else {
|
|
||||||
input_x = x;
|
|
||||||
input_y = y;
|
|
||||||
input_w = width;
|
|
||||||
input_h = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
pixman_region32_init_rect(&window->surface->pending.input,
|
pixman_region32_fini(&window->surface->pending.opaque);
|
||||||
input_x, input_y, input_w, input_h);
|
if (window->has_alpha) {
|
||||||
|
pixman_region32_init(&window->surface->pending.opaque);
|
||||||
wm_log("XWM: draw decoration, win %d geometry: %d,%d %dx%d\n",
|
} else {
|
||||||
window->id, input_x, input_y, input_w, input_h);
|
/* We leave an extra pixel around the X window area to
|
||||||
|
* make sure we don't sample from the undefined alpha
|
||||||
xwayland_interface->set_window_geometry(window->shsurf,
|
* channel when filtering. */
|
||||||
input_x, input_y, input_w, input_h);
|
pixman_region32_init_rect(&window->surface->pending.opaque,
|
||||||
if (window->name)
|
x - 1, y - 1,
|
||||||
xwayland_interface->set_title(window->shsurf, window->name);
|
window->width + 2,
|
||||||
if (window->pid > 0)
|
window->height + 2);
|
||||||
xwayland_interface->set_pid(window->shsurf, window->pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pixman_region32_fini(&window->surface->pending.input);
|
||||||
|
|
||||||
|
if (window->decorate && !window->fullscreen) {
|
||||||
|
frame_input_rect(window->frame, &input_x, &input_y,
|
||||||
|
&input_w, &input_h);
|
||||||
|
} else {
|
||||||
|
input_x = x;
|
||||||
|
input_y = y;
|
||||||
|
input_w = width;
|
||||||
|
input_h = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
wm_log("XWM: win %d geometry: %d,%d %dx%d\n",
|
||||||
|
window->id, input_x, input_y, input_w, input_h);
|
||||||
|
|
||||||
|
pixman_region32_init_rect(&window->surface->pending.input,
|
||||||
|
input_x, input_y, input_w, input_h);
|
||||||
|
|
||||||
|
xwayland_interface->set_window_geometry(window->shsurf,
|
||||||
|
input_x, input_y, input_w, input_h);
|
||||||
|
if (window->name)
|
||||||
|
xwayland_interface->set_title(window->shsurf, window->name);
|
||||||
|
if (window->pid > 0)
|
||||||
|
xwayland_interface->set_pid(window->shsurf, window->pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
weston_wm_window_do_repaint(void *data)
|
||||||
|
{
|
||||||
|
struct weston_wm_window *window = data;
|
||||||
|
|
||||||
|
window->repaint_source = NULL;
|
||||||
|
|
||||||
|
weston_wm_window_read_properties(window);
|
||||||
|
|
||||||
|
weston_wm_window_draw_decoration(window);
|
||||||
|
weston_wm_window_set_pending_state(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1232,8 +1248,7 @@ weston_wm_window_schedule_repaint(struct weston_wm_window *window)
|
|||||||
|
|
||||||
window->repaint_source =
|
window->repaint_source =
|
||||||
wl_event_loop_add_idle(wm->server->loop,
|
wl_event_loop_add_idle(wm->server->loop,
|
||||||
weston_wm_window_draw_decoration,
|
weston_wm_window_do_repaint, window);
|
||||||
window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
Reference in New Issue
Block a user