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

Tiago Vignatti tiago.vignatti at intel.com
Wed Dec 12 07:26:23 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                 |   40 +++++++++++++++++++++++++++++++++++-----
 src/xwayland/window-manager.c |   12 +-----------
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/clients/xwm.c b/clients/xwm.c
index 0e59f7c..fca6098 100644
--- a/clients/xwm.c
+++ b/clients/xwm.c
@@ -99,8 +99,13 @@ struct motif_wm_hints {
 struct xwm_window {
 	struct xwm_wm *wm;
 	xcb_window_t id;
+
+	/* frame border */
 	xcb_window_t frame_id;
 	cairo_surface_t *cairo_surface;
+	struct task paint_task;
+	int repaint_scheduled;
+
 	int properties_dirty;
 	int pid;
 	char *machine;
@@ -118,6 +123,29 @@ struct xwm_window {
 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)
 {
@@ -454,7 +482,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
@@ -517,10 +545,10 @@ set_state_activate(struct xwm *xwm, uint32_t id)
 	}
 
 	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
@@ -767,6 +795,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
@@ -814,7 +843,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
@@ -836,6 +865,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;
@@ -1534,7 +1564,7 @@ get_configure(void *data, struct wm *w, uint32_t id, uint32_t edges,
 			     values);
 	xcb_flush(wm->conn);
 
-	xwm_window_draw_decoration(window);
+	xwm_window_schedule_repaint(window);
 }
 
 static void
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index 0b582a5..48f81d3 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -97,17 +97,11 @@ xserver_get_window_surface(struct wl_client *client,
 		return;
 	}
 
-	fprintf(stderr, "set_window_id %d for surface %p\n", id, 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,
@@ -127,8 +121,6 @@ wm_get_window(struct wl_client *client, struct wl_resource *resource,
 	struct weston_xserver *wxs = resource->data;
 	struct xserver_window *w;
 
-	fprintf(stderr, "%s: ", __func__);
-
 	w = hash_table_lookup(wxs->window_hash, id);
 	if (!w) {
 		w = malloc(sizeof *w);
@@ -140,9 +132,7 @@ wm_get_window(struct wl_client *client, struct wl_resource *resource,
 		w->shsurf = NULL;
 		w->wxs = wxs;
 		w->id = id;
-		fprintf(stderr, "insert: %d, flags: %d\n", id, flags);
-	} else
-		fprintf(stderr, "found: %d, flags: %d\n", id, flags);
+	}
 
 	w->x = x;
 	w->y = y;
-- 
1.7.9.5



More information about the wayland-devel mailing list