[PATCH weston 11/16] clients: xwm: Fix frame repaint

Tiago Vignatti tiago.vignatti at intel.com
Wed Dec 19 11:32:21 PST 2012


It brings back a feature we removed previously:

  #4 drawing scheduling and window activation

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 clients/xwm.c                 |   42 +++++++++++++++++++++++++++++++++++------
 src/xwayland/window-manager.c |   10 +---------
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/clients/xwm.c b/clients/xwm.c
index 7993a30..7185434 100644
--- a/clients/xwm.c
+++ b/clients/xwm.c
@@ -49,10 +49,15 @@ struct xwm {
 struct xwm_window {
 	struct xwm_wm *wm;
 	xcb_window_t id;
-	xcb_window_t frame_id;
 	struct wm_xwin *xwin;
+
+	/* frame border decoration */
+	xcb_window_t frame_id;
 	struct wm_xwin *xwin_frame;
 	cairo_surface_t *cairo_surface;
+	struct task paint_task;
+	int repaint_scheduled;
+
 	int properties_dirty;
 	int pid;
 	char *machine;
@@ -119,6 +124,29 @@ struct motif_wm_hints {
 static void
 xwm_window_draw_decoration(struct xwm_window *window);
 
+static void
+xwm_schedule_task(struct task *task, uint32_t events)
+{
+	struct xwm_window *window =
+		container_of(task, struct xwm_window, paint_task);
+
+	xwm_window_draw_decoration(window);
+	window->repaint_scheduled = 0;
+}
+
+static void
+xwm_window_schedule_repaint(struct xwm_window *window)
+{
+	struct xwm_wm *wm = window->wm;
+
+	if (window->repaint_scheduled)
+		return;
+
+	window->paint_task.run = xwm_schedule_task;
+	display_defer(wm->xwm->display, &window->paint_task);
+	window->repaint_scheduled = 1;
+}
+
 const char *
 get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
 {
@@ -456,7 +484,7 @@ xwm_handle_configure_request(struct xwm_wm *wm, xcb_generic_event_t *event)
 	mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
 	xcb_configure_window(wm->conn, window->frame_id, mask, values);
 
-	xwm_window_draw_decoration(window);
+	xwm_window_schedule_repaint(window);
 }
 
 static void
@@ -557,7 +585,7 @@ handle_configure(void *data, struct wm_xwin *xwin, uint32_t edges,
 			     values);
 	xcb_flush(wm->conn);
 
-	xwm_window_draw_decoration(window);
+	xwm_window_schedule_repaint(window);
 }
 
 static void
@@ -588,10 +616,10 @@ set_state_activate(struct xwm *xwm, struct xwm_window *window)
 	}
 
 	if (wm->focus_window)
-		xwm_window_draw_decoration(wm->focus_window);
+		xwm_window_schedule_repaint(wm->focus_window);
 	wm->focus_window = window;
 	if (wm->focus_window)
-		xwm_window_draw_decoration(wm->focus_window);
+		xwm_window_schedule_repaint(wm->focus_window);
 }
 
 static void
@@ -804,6 +832,7 @@ xwm_window_draw_decoration(struct xwm_window *window)
 		cairo_set_source_rgba(cr, 0, 0, 0, 0.45);
 		tile_mask(cr, t->shadow, 2, 2, width + 8, height + 8, 64, 64);
 	}
+	xcb_flush(window->wm->conn);
 
 	cairo_destroy(cr);
 #if 0
@@ -851,7 +880,7 @@ xwm_handle_property_notify(struct xwm_wm *wm, xcb_generic_event_t *event)
 
 	if (property_notify->atom == wm->atom.net_wm_name ||
 	    property_notify->atom == XCB_ATOM_WM_NAME)
-		xwm_window_draw_decoration(window);
+		xwm_window_schedule_repaint(window);
 }
 
 static void
@@ -873,6 +902,7 @@ xwm_window_create(struct xwm_wm *wm,
 	memset(window, 0, sizeof *window);
 	window->wm = wm;
 	window->id = id;
+	window->repaint_scheduled = 0;
 	window->properties_dirty = 1;
 	window->override_redirect = override;
 	window->width = width;
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index fe62ea5..97765a0 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -107,21 +107,15 @@ xserver_handle_window_surface(struct wl_client *client,
 			break;
 
 	if (window == NULL) {
-		fprintf(stderr, "set_window_id for unknown window %d\n", xid);
+		weston_log("unknown window %d\n", xid);
 		return;
 	}
 
-	fprintf(stderr, "set_window_id %d for surface %p\n", xid, surface);
-
-//	weston_wm_window_read_properties(window);
-
 	window->surface = surface;
 	window->surface_destroy_listener.notify = surface_destroy;
 	wl_signal_add(&surface->resource.destroy_signal,
 		      &window->surface_destroy_listener);
 
-//	weston_wm_window_draw_decoration(window);
-
 	window->shsurf =
 		shell_interface->create_shell_surface(shell_interface->shell,
 						      weston_surface,
@@ -141,7 +135,6 @@ wm_xwin_handle_set_window(struct wl_client *client,
 {
 	struct xserver_window *window = resource->data;
 
-	fprintf(stderr, "%s: %d\n", __func__, window->xid);
 	window->x = x;
 	window->y = y;
 	window->width = width;
@@ -255,7 +248,6 @@ wm_handle_create_xwindow(struct wl_client *client,
 	struct weston_xserver *wxs = resource->data;
 	struct xserver_window *window;
 
-	fprintf(stderr, "%s: xid: %d\n", __func__, xid);
 	window = malloc(sizeof *window);
 	if (!window) {
 		wl_resource_post_no_memory(resource);
-- 
1.7.9.5



More information about the wayland-devel mailing list