Commit aabf43d0 authored by Pekka Paalanen's avatar Pekka Paalanen

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's avatarPekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
parent 77a6d95a
......@@ -1119,25 +1119,14 @@ weston_wm_handle_unmap_notify(struct weston_wm *wm, xcb_generic_event_t *event)
}
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;
int x, y, 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);
weston_wm_window_read_properties(window);
int width, height;
window->repaint_source = NULL;
wm_log("XWM: draw decoration, win %d\n", window->id);
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);
cr = cairo_create(window->cairo_surface);
......@@ -1152,14 +1141,29 @@ weston_wm_window_draw_decoration(void *data)
cairo_set_source_rgba(cr, 0, 0, 0, 0);
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_surface_flush(window->cairo_surface);
xcb_flush(window->wm->conn);
}
static void
weston_wm_window_set_pending_state(struct weston_wm_window *window)
{
int x, y, width, height;
int32_t input_x, input_y, input_w, input_h;
const struct weston_desktop_xwayland_interface *xwayland_interface =
window->wm->server->compositor->xwayland_interface;
if (!window->surface)
return;
weston_wm_window_get_frame_size(window, &width, &height);
weston_wm_window_get_child_position(window, &x, &y);
if (window->surface) {
pixman_region32_fini(&window->surface->pending.opaque);
if (window->has_alpha) {
pixman_region32_init(&window->surface->pending.opaque);
......@@ -1185,19 +1189,31 @@ weston_wm_window_draw_decoration(void *data)
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);
wm_log("XWM: draw decoration, win %d geometry: %d,%d %dx%d\n",
window->id, 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
......@@ -1232,8 +1248,7 @@ weston_wm_window_schedule_repaint(struct weston_wm_window *window)
window->repaint_source =
wl_event_loop_add_idle(wm->server->loop,
weston_wm_window_draw_decoration,
window);
weston_wm_window_do_repaint, window);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment