summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-03-11 00:05:28 -0800
committerJess VanDerwalker <washu@sonic.net>2012-03-11 00:05:28 -0800
commited5b88f64ecec95d967a42babc86a12a35d77fea (patch)
treee1eb230b12c7135c24908d072d59b619c8019408
parent627bd6d14b4d3eb0587bb14a87adffbf99055b4f (diff)
Changes to settings of the contexts damaged area to get redrawing when window is enlarged and shrunk correct.
-rw-r--r--src/libcompositewm/event_loop.c62
-rw-r--r--src/libcompositewm/window.c13
-rw-r--r--src/libcompositewm/xtoq.c34
-rw-r--r--src/libcompositewm/xtoq.h7
-rw-r--r--src/xtoq/XtoqView.m11
5 files changed, 90 insertions, 37 deletions
diff --git a/src/libcompositewm/event_loop.c b/src/libcompositewm/event_loop.c
index ee20637..516ed21 100644
--- a/src/libcompositewm/event_loop.c
+++ b/src/libcompositewm/event_loop.c
@@ -117,9 +117,10 @@ void *run_event_loop (void *thread_arg_struct)
while ((evt = xcb_wait_for_event(event_conn))) {
if ((evt->response_type & ~0x80) == _damage_event) {
xcb_damage_notify_event_t *dmgevnt = (xcb_damage_notify_event_t *)evt;
- xcb_void_cookie_t cookie;
- xcb_xfixes_region_t region = xcb_generate_id(root_context->conn);
- xcb_rectangle_t rect;
+ int old_x;
+ int old_y;
+ int old_height;
+ int old_width;
return_evt = malloc(sizeof(xtoq_event_t));
return_evt->event_type = XTOQ_DAMAGE;
@@ -130,45 +131,46 @@ void *run_event_loop (void *thread_arg_struct)
continue;
}
- rect.x = dmgevnt->area.x;
- rect.y = dmgevnt->area.y;
- rect.width = dmgevnt->area.width;
- rect.height = dmgevnt->area.height;
-
/* Increase the damaged area if new damage is outside the
* area already marked - this should be set back to 0 by 0
* when area is actually redrawn. This is likely to be
* done in another thread that handles window redraws */
xtoq_get_event_thread_lock();
- if (return_evt->context->damaged_x > dmgevnt->area.x) {
+
+ old_x = return_evt->context->damaged_x;
+ old_y = return_evt->context->damaged_y;
+ old_width = return_evt->context->damaged_width;
+ old_height = return_evt->context->damaged_height;
+
+ if (return_evt->context->damaged_width == 0) {
+ /* We know something is damaged */
return_evt->context->damaged_x = dmgevnt->area.x;
- }
- if (return_evt->context->damaged_y > dmgevnt->area.y) {
return_evt->context->damaged_y = dmgevnt->area.y;
- }
- if (return_evt->context->damaged_width < dmgevnt->area.width) {
return_evt->context->damaged_width = dmgevnt->area.width;
- }
- if (return_evt->context->damaged_height = dmgevnt->area.height) {
return_evt->context->damaged_height = dmgevnt->area.height;
+ } else {
+ /* Is the new damage bigger than the old */
+ if (old_x > dmgevnt->area.x) {
+ return_evt->context->damaged_x = dmgevnt->area.x;
+ }
+ if ( old_y > dmgevnt->area.y) {
+ return_evt->context->damaged_y = dmgevnt->area.y;
+ }
+ if ( old_width < dmgevnt->area.width) {
+ return_evt->context->damaged_width = dmgevnt->area.width;
+ }
+ if ( old_height < dmgevnt->area.height) {
+ return_evt->context->damaged_height = dmgevnt->area.height;
+ }
}
xtoq_release_event_thread_lock();
- xcb_xfixes_create_region(root_context->conn,
- region,
- 1,
- &rect);
-
- cookie = xcb_damage_subtract_checked (return_evt->context->conn,
- return_evt->context->damage,
- region,
- 0);
-
- if ((_xtoq_request_check(root_context->conn,
- cookie,
- "Failed to subtract damage"))) {
- free(return_evt);
- } else {
+ if (((old_x > dmgevnt->area.x) || (old_y > dmgevnt->area.y))
+ || ((old_width < dmgevnt->area.width)
+ || (old_height < dmgevnt->area.height))) {
+ /* We should only reach here if this damage event
+ * actually increases that area of the window marked
+ * for damage. */
callback_ptr(return_evt);
}
} else {
diff --git a/src/libcompositewm/window.c b/src/libcompositewm/window.c
index dbe01a4..d4304f4 100644
--- a/src/libcompositewm/window.c
+++ b/src/libcompositewm/window.c
@@ -149,7 +149,12 @@ xtoq_configure_window(xtoq_context_t *context, int x, int y, int height, int wid
uint32_t values[] = {(uint32_t)x, (uint32_t)y, (uint32_t)width, (uint32_t)height };
xcb_configure_window (context->conn, context->window, XCB_CONFIG_WINDOW_X
- | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+ | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
+
+ /* Set the damage area to the new window size so its redrawn properly */
+ context->damaged_width = width;
+ context->damaged_height = height;
+
xcb_flush(context->conn);
return;
}
@@ -318,6 +323,12 @@ init_damage_on_window (xtoq_context_t *context)
}
/* Assign this damage object to the roots window's context */
context->damage = damage_id;
+
+ /* Set the damage area in the context to zero */
+ context->damaged_x = 0;
+ context->damaged_y = 0;
+ context->damaged_width = 0;
+ context->damaged_height = 0;
}
diff --git a/src/libcompositewm/xtoq.c b/src/libcompositewm/xtoq.c
index f634f7f..8635c55 100644
--- a/src/libcompositewm/xtoq.c
+++ b/src/libcompositewm/xtoq.c
@@ -202,7 +202,41 @@ xtoq_image_destroy(xtoq_image_t * xtoq_image){
}
+void
+xtoq_remove_context_damage(xtoq_context_t *context)
+{
+ xcb_xfixes_region_t region = xcb_generate_id(context->conn);
+ xcb_rectangle_t rect;
+ xcb_void_cookie_t cookie;
+
+ if (!context) {
+ return;
+ }
+ rect.x = context->damaged_x;
+ rect.y = context->damaged_y;
+ rect.width = context->damaged_width;
+ rect.height = context->damaged_height;
+
+ xcb_xfixes_create_region(root_context->conn,
+ region,
+ 1,
+ &rect);
+
+ cookie = xcb_damage_subtract_checked (context->conn,
+ context->damage,
+ region,
+ 0);
+
+ if (!(_xtoq_request_check(context->conn, cookie,
+ "Failed to subtract damage"))) {
+ context->damaged_x = 0;
+ context->damaged_y = 0;
+ context->damaged_width = 0;
+ context->damaged_height = 0;
+ }
+ return;
+}
/* Close all windows, the connection, as well as the event loop */
void xtoq_close(void) {
diff --git a/src/libcompositewm/xtoq.h b/src/libcompositewm/xtoq.h
index aa550f1..02a4095 100644
--- a/src/libcompositewm/xtoq.h
+++ b/src/libcompositewm/xtoq.h
@@ -140,6 +140,13 @@ int
xtoq_release_event_thread_lock(void);
/**
+ * Remove the damage from the given context.
+ * @param context The context to remove the damage from
+ */
+void
+xtoq_remove_context_damage(xtoq_context_t *context);
+
+/**
* Closes the windows open on the X Server, the connection, and the event
* loop.
*/
diff --git a/src/xtoq/XtoqView.m b/src/xtoq/XtoqView.m
index 6b29063..50da5fc 100644
--- a/src/xtoq/XtoqView.m
+++ b/src/xtoq/XtoqView.m
@@ -52,7 +52,8 @@ initWithFrame:(NSRect)frame {
viewContext = context;
}
-// Overridden by subclasses to draw the receiver’s image within the passed-in rectangle.
+// Overridden by subclasses to draw the receiver’s image within the
+// passed-in rectangle.
-(void)
drawRect:(NSRect)dirtyRect {
xtoq_image_t *imageT;
@@ -71,12 +72,10 @@ drawRect:(NSRect)dirtyRect {
y:y_transformed];
[imageNew draw];
[imageNew destroy];
+
+ // Remove the damage
+ xtoq_remove_context_damage(viewContext);
}
- // Set the damage for the context back to 0
- viewContext->damaged_x = 0;
- viewContext->damaged_y = 0;
- viewContext->damaged_width = 0;
- viewContext->damaged_height = 0;
xtoq_release_event_thread_lock();
}